summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2018-07-10 10:35:07 +0800
committerAdrian Thurston <thurston@colm.net>2018-07-10 10:35:07 +0800
commit8a81f855d5a11e4af0abdcfa42c9ac996730f8a4 (patch)
tree00d9b441c53984c6441e589a1a5a528eae2a4298
parentbe90eb6ea7bc94d49ce1b7e9ad5f170c1fc0a1b2 (diff)
downloadcolm-8a81f855d5a11e4af0abdcfa42c9ac996730f8a4.tar.gz
improvements to free bytecodes, bytecode def cleanup
-rw-r--r--free-bytecodes.sh12
-rw-r--r--free-codes.sh13
-rw-r--r--src/bytecode.c16
-rw-r--r--src/bytecode.h25
-rw-r--r--src/declare.cc16
-rw-r--r--src/synthesis.cc2
6 files changed, 36 insertions, 48 deletions
diff --git a/free-bytecodes.sh b/free-bytecodes.sh
deleted file mode 100644
index 1f7e931e..00000000
--- a/free-bytecodes.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-#
-
-IN=$1
-
-diff -U0 \
-<(
- for i in `seq 0 255`; do
- printf "0x%02x\\n" $i
- done
-) \
-<(sed -n '/^ *$/d; s/#define [A-Z0-9_]* *//; p' $IN | sort | uniq)
diff --git a/free-codes.sh b/free-codes.sh
new file mode 100644
index 00000000..1ef8f324
--- /dev/null
+++ b/free-codes.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+#
+
+TYPE="$1"
+FN="$2"
+
+diff -u <(
+ for I in `seq 0 255`; do
+ printf "0x%02x\\n" $I
+ done
+) <(
+ sed -n "/#define ${TYPE}_/s/#define ${TYPE}_[A-Z0-9_]* *//p" $FN | sort
+) | sed -n '/^[\+\-]0/s/^.//p'
diff --git a/src/bytecode.c b/src/bytecode.c
index 4d2d07ba..5a1df5bf 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -3674,8 +3674,8 @@ again:
read_half( constValId );
switch ( constValId ) {
- case IN_CONST_STDIN: {
- debug( prg, REALM_BYTECODE, "IN_CONST_STDIN\n" );
+ case CONST_STDIN: {
+ debug( prg, REALM_BYTECODE, "CONST_STDIN\n" );
/* Pop the root object. */
vm_pop_tree();
@@ -3685,8 +3685,8 @@ again:
vm_push_stream( prg->stdin_val );
break;
}
- case IN_CONST_STDOUT: {
- debug( prg, REALM_BYTECODE, "IN_CONST_STDOUT\n" );
+ case CONST_STDOUT: {
+ debug( prg, REALM_BYTECODE, "CONST_STDOUT\n" );
/* Pop the root object. */
vm_pop_tree();
@@ -3695,8 +3695,8 @@ again:
vm_push_stream( prg->stdout_val );
break;
}
- case IN_CONST_STDERR: {
- debug( prg, REALM_BYTECODE, "IN_CONST_STDERR\n" );
+ case CONST_STDERR: {
+ debug( prg, REALM_BYTECODE, "CONST_STDERR\n" );
/* Pop the root object. */
vm_pop_tree();
@@ -3706,11 +3706,11 @@ again:
vm_push_stream( prg->stderr_val );
break;
}
- case IN_CONST_ARG: {
+ case CONST_ARG: {
word_t offset;
read_word( offset );
- debug( prg, REALM_BYTECODE, "IN_CONST_ARG %d\n", offset );
+ debug( prg, REALM_BYTECODE, "CONST_ARG %d\n", offset );
/* Pop the root object. */
vm_pop_tree();
diff --git a/src/bytecode.h b/src/bytecode.h
index 2d5f4c71..5a37fdea 100644
--- a/src/bytecode.h
+++ b/src/bytecode.h
@@ -38,6 +38,7 @@ extern "C" {
typedef unsigned long ulong;
typedef unsigned char uchar;
+#define IN_NONE 0x00
#define IN_LOAD_INT 0x01
#define IN_LOAD_STR 0x02
#define IN_LOAD_NIL 0x03
@@ -221,14 +222,6 @@ typedef unsigned char uchar;
#define IN_GET_MAP_MEM_WC 0x7e
#define IN_GET_MAP_MEM_BKT 0x7f
-#define IN_VECTOR_LENGTH 0x80
-#define IN_VECTOR_APPEND_WV 0x81
-#define IN_VECTOR_APPEND_WC 0x82
-#define IN_VECTOR_APPEND_BKT 0x83
-#define IN_VECTOR_INSERT_WV 0x84
-#define IN_VECTOR_INSERT_WC 0x85
-#define IN_VECTOR_INSERT_BKT 0x86
-
#define IN_TREE_TO_STR_XML 0x6e
#define IN_TREE_TO_STR_XML_AC 0x6f
#define IN_TREE_TO_STR_POSTFIX 0xb6
@@ -310,7 +303,6 @@ typedef unsigned char uchar;
#define IN_SET_PARSER_CONTEXT 0xd0
#define IN_SET_PARSER_INPUT 0x96
-
#define IN_GET_RHS_VAL_R 0xd7
#define IN_GET_RHS_VAL_WC 0xd8
#define IN_GET_RHS_VAL_WV 0xd9
@@ -320,12 +312,6 @@ typedef unsigned char uchar;
#define IN_SET_RHS_VAL_BKT 0xdd
#define IN_GET_PARSER_MEM_R 0x5b
-#define IN_GET_PARSER_MEM_WC 0x00
-#define IN_GET_PARSER_MEM_WV 0x00
-#define IN_GET_PARSER_MEM_BKT 0x00
-#define IN_SET_PARSER_MEM_WC 0x00
-#define IN_SET_PARSER_MEM_WV 0x00
-#define IN_SET_PARSER_MEM_BKT 0x00
#define IN_GET_STREAM_MEM_R 0xb7
@@ -358,10 +344,10 @@ typedef unsigned char uchar;
/*
* Const things to get.
*/
-#define IN_CONST_STDIN 0x10
-#define IN_CONST_STDOUT 0x11
-#define IN_CONST_STDERR 0x12
-#define IN_CONST_ARG 0x13
+#define CONST_STDIN 0x10
+#define CONST_STDOUT 0x11
+#define CONST_STDERR 0x12
+#define CONST_ARG 0x13
@@ -370,6 +356,7 @@ typedef unsigned char uchar;
*/
#define IN_FN 0xff
+#define FN_NONE 0x00
#define FN_STOP 0x0a
#define FN_STR_ATOI 0x1d
diff --git a/src/declare.cc b/src/declare.cc
index cbabb663..6e92bdf0 100644
--- a/src/declare.cc
+++ b/src/declare.cc
@@ -1095,7 +1095,7 @@ void Compiler::addStdin()
el->inGetValWV = IN_GET_CONST;
el->isConstVal = true;
- el->constValId = IN_CONST_STDIN;
+ el->constValId = CONST_STDIN;
rootNamespace->rootScope->insertField( el->name, el );
}
@@ -1118,7 +1118,7 @@ void Compiler::addStdout()
el->inGetValWV = IN_GET_CONST;
el->isConstVal = true;
- el->constValId = IN_CONST_STDOUT;
+ el->constValId = CONST_STDOUT;
rootNamespace->rootScope->insertField( el->name, el );
}
@@ -1141,7 +1141,7 @@ void Compiler::addStderr()
el->inGetValWV = IN_GET_CONST;
el->isConstVal = true;
- el->constValId = IN_CONST_STDERR;
+ el->constValId = CONST_STDERR;
rootNamespace->rootScope->insertField( el->name, el );
}
@@ -1206,7 +1206,7 @@ void Compiler::addDefineArgs()
el->inGetValWV = IN_GET_CONST;
el->isConstVal = true;
- el->constValId = IN_CONST_ARG;
+ el->constValId = CONST_ARG;
el->constValArg = d->value;
rootNamespace->rootScope->insertField( el->name, el );
@@ -1463,10 +1463,10 @@ void Compiler::initParserField( GenericType *gen, const char *name,
ObjectField::InbuiltOffType, typeRef, name );
el->inGetR = IN_GET_PARSER_MEM_R;
- el->inGetWC = IN_GET_PARSER_MEM_WC;
- el->inGetWV = IN_GET_PARSER_MEM_WV;
- el->inSetWC = IN_SET_PARSER_MEM_WC;
- el->inSetWV = IN_SET_PARSER_MEM_WV;
+ // el->inGetWC = IN_GET_PARSER_MEM_WC;
+ // el->inGetWV = IN_GET_PARSER_MEM_WV;
+ // el->inSetWC = IN_SET_PARSER_MEM_WC;
+ // el->inSetWV = IN_SET_PARSER_MEM_WV;
gen->objDef->rootScope->insertField( el->name, el );
diff --git a/src/synthesis.cc b/src/synthesis.cc
index 43c805f5..5a47d56e 100644
--- a/src/synthesis.cc
+++ b/src/synthesis.cc
@@ -442,7 +442,7 @@ UniqueType *LangVarRef::loadField( Compiler *pd, CodeVect &code,
if ( el->isConstVal ) {
code.appendHalf( el->constValId );
- if ( el->constValId == IN_CONST_ARG ) {
+ if ( el->constValId == CONST_ARG ) {
/* Make sure we have this string. */
StringMapEl *mapEl = 0;
if ( pd->literalStrings.insert( el->constValArg, &mapEl ) )