summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2012-01-21 20:06:35 +0000
committerAdrian Thurston <thurston@complang.org>2012-01-21 20:06:35 +0000
commit34667452fbf9d645c2894b7a860a006d29c708f2 (patch)
tree78b8dc0681da220f7f0150265789435d310cb2ed
parent434a7749954c6dd5d63935298ea0856ee0e1a88b (diff)
downloadcolm-34667452fbf9d645c2894b7a860a006d29c708f2.tar.gz
The stream operations are now depreciated by the input operations. Streams are
sources of data, pushing popping, pulling happens on the input object.
-rw-r--r--colm/bytecode.c101
-rw-r--r--colm/bytecode.h31
-rw-r--r--colm/compile.cc9
3 files changed, 15 insertions, 126 deletions
diff --git a/colm/bytecode.c b/colm/bytecode.c
index 3fbb750c..5e36096e 100644
--- a/colm/bytecode.c
+++ b/colm/bytecode.c
@@ -576,22 +576,6 @@ again:
debug( REALM_BYTECODE, "IN_PCR_END_DECK\n" );
return;
}
- case IN_STREAM_PULL_BKT: {
- Tree *string;
- read_tree( string );
-
- debug( REALM_BYTECODE, "IN_STREAM_PULL_BKT\n" );
-
- treeDownref( prg, sp, string );
- break;
- }
- case IN_STREAM_PUSH_BKT: {
- Word len;
- read_word( len );
-
- debug( REALM_BYTECODE, "IN_STREAM_PUSH_BKT\n" );
- break;
- }
case IN_INPUT_APPEND_BKT: {
Tree *parser;
Tree *input;
@@ -2467,89 +2451,8 @@ again:
break;
}
- case IN_STREAM_PULL: {
- debug( REALM_BYTECODE, "IN_STREAM_PULL\n" );
-
- Tree *parser = vm_pop();
- Tree *len = vm_pop();
- Tree *string = streamPullBc( prg, exec->fsmRun, ((Parser*)parser)->input->in, len );
- treeUpref( string );
- vm_push( string );
-
- /* Single unit. */
- treeUpref( string );
- append( &exec->pdaRun->rcodeCollect, IN_STREAM_PULL_BKT );
- appendWord( &exec->pdaRun->rcodeCollect, (Word) string );
- exec->rcodeUnitLen += SIZEOF_CODE + SIZEOF_WORD;
- append( &exec->pdaRun->rcodeCollect, exec->rcodeUnitLen );
-
- treeDownref( prg, sp, parser );
- treeDownref( prg, sp, len );
- break;
- }
- case IN_STREAM_PULL_BKT: {
- Tree *string;
- read_tree( string );
-
- Tree *parser = vm_pop();
-
- debug( REALM_BYTECODE, "IN_STREAM_PULL_BKT\n" );
-
- //undoPull( prg, ((Parser*)parser)->fsmRun, ((Parser*)parser)->in, string );
- treeDownref( prg, sp, parser );
- treeDownref( prg, sp, string );
- break;
- }
- case IN_STREAM_PUSH_WV: {
- debug( REALM_BYTECODE, "IN_STREAM_PUSH_WV\n" );
-
- Tree *parser = vm_pop();
- Tree *tree = vm_pop();
- int len = streamPush( prg, sp, ((Parser*)parser)->fsmRun, ((Parser*)parser)->input->in, tree, false );
- vm_push( 0 );
-
- /* Single unit. */
- append( &exec->pdaRun->rcodeCollect, IN_STREAM_PUSH_BKT );
- appendWord( &exec->pdaRun->rcodeCollect, len );
- exec->rcodeUnitLen += SIZEOF_CODE + SIZEOF_WORD;
- append( &exec->pdaRun->rcodeCollect, exec->rcodeUnitLen );
-
- treeDownref( prg, sp, parser );
- treeDownref( prg, sp, tree );
- break;
- }
- case IN_STREAM_PUSH_IGNORE_WV: {
- debug( REALM_BYTECODE, "IN_STREAM_PUSH_IGNORE_WV\n" );
-
- Tree *parser = vm_pop();
- Tree *tree = vm_pop();
- long len = streamPush( prg, sp, ((Parser*)parser)->fsmRun, ((Parser*)parser)->input->in, tree, true );
- vm_push( 0 );
-
- /* Single unit. */
- append( &exec->pdaRun->rcodeCollect, IN_STREAM_PUSH_BKT );
- appendWord( &exec->pdaRun->rcodeCollect, len );
- exec->rcodeUnitLen += SIZEOF_CODE + SIZEOF_WORD;
- append( &exec->pdaRun->rcodeCollect, exec->rcodeUnitLen );
-
- treeDownref( prg, sp, parser );
- treeDownref( prg, sp, tree );
- break;
- }
- case IN_STREAM_PUSH_BKT: {
- Word len;
- read_word( len );
-
- Tree *parser = vm_pop();
-
- debug( REALM_BYTECODE, "IN_STREAM_PUSH_BKT\n" );
-
- undoStreamPush( prg, sp, ((Parser*)parser)->fsmRun, ((Parser*)parser)->input->in, len );
- treeDownref( prg, sp, parser );
- break;
- }
- case IN_INPUT_PULL: {
- debug( REALM_BYTECODE, "IN_INPUT_PULL\n" );
+ case IN_INPUT_PULL_WV: {
+ debug( REALM_BYTECODE, "IN_INPUT_PULL_WV\n" );
Input *accumStream = (Input*)vm_pop();
Tree *len = vm_pop();
diff --git a/colm/bytecode.h b/colm/bytecode.h
index 6a9706c7..72cf8f95 100644
--- a/colm/bytecode.h
+++ b/colm/bytecode.h
@@ -218,11 +218,8 @@ typedef unsigned char uchar;
#define IN_MAKE_TREE 0x8f
#define IN_CONSTRUCT_TERM 0x90
-#define IN_STREAM_PULL 0x94
-#define IN_STREAM_PULL_BKT 0x95
-
-#define IN_INPUT_PULL 0xf7
-#define IN_INPUT_PULL_BKT 0xf8
+#define IN_INPUT_PULL_WV 0xf7
+#define IN_INPUT_PULL_BKT 0xf8
#define IN_PARSE_LOAD_START 0xf2
#define IN_PARSE_SAVE_STEPS 0xf3
@@ -235,9 +232,9 @@ typedef unsigned char uchar;
#define IN_PARSE_FRAG_BKT 0xc2
#define IN_PARSE_FRAG_BKT3 0xe6
-#define IN_INPUT_APPEND_WC 0x91
-#define IN_INPUT_APPEND_WV 0x92
-#define IN_INPUT_APPEND_BKT 0x93
+#define IN_INPUT_APPEND_WC 0x91
+#define IN_INPUT_APPEND_WV 0x92
+#define IN_INPUT_APPEND_BKT 0x93
#define IN_PARSE_FINISH_WC 0x9d
#define IN_PARSE_FINISH_WC3 0xea
@@ -264,23 +261,19 @@ typedef unsigned char uchar;
#define IN_EXIT 0xa5
#define IN_ERROR 0xa6
-#define IN_STREAM_PUSH_WV 0x96
-#define IN_STREAM_PUSH_BKT 0x97
-#define IN_STREAM_PUSH_IGNORE_WV 0xbb
-
#define IN_LOAD_ACCUM_R 0xa8
#define IN_LOAD_ACCUM_WV 0xa9
#define IN_LOAD_ACCUM_WC 0xaa
#define IN_LOAD_ACCUM_BKT 0xab
-#define IN_LOAD_INPUT_R 0x98
-#define IN_LOAD_INPUT_WV 0x99
-#define IN_LOAD_INPUT_WC 0x9a
-#define IN_LOAD_INPUT_BKT 0x9b
+#define IN_LOAD_INPUT_R 0x98
+#define IN_LOAD_INPUT_WV 0x99
+#define IN_LOAD_INPUT_WC 0x9a
+#define IN_LOAD_INPUT_BKT 0x9b
-#define IN_INPUT_PUSH_WV 0xf9
-#define IN_INPUT_PUSH_BKT 0xfa
-#define IN_INPUT_PUSH_IGNORE_WV 0xfb
+#define IN_INPUT_PUSH_WV 0xf9
+#define IN_INPUT_PUSH_BKT 0xfa
+#define IN_INPUT_PUSH_IGNORE_WV 0xfb
#define IN_LOAD_CONTEXT_R 0xac
#define IN_LOAD_CONTEXT_WV 0xad
diff --git a/colm/compile.cc b/colm/compile.cc
index d7da1059..11de46b7 100644
--- a/colm/compile.cc
+++ b/colm/compile.cc
@@ -2420,13 +2420,6 @@ void ParseData::initStreamObject( )
streamObj = new ObjectDef( ObjectDef::BuiltinType,
"stream", nextObjectId++ );
streamLangEl->objectDef = streamObj;
-
- initFunction( uniqueTypeStr, streamObj, "pull",
- IN_STREAM_PULL, IN_STREAM_PULL, uniqueTypeInt, false );
- initFunction( uniqueTypeStr, streamObj, "push",
- IN_STREAM_PUSH_WV, IN_STREAM_PUSH_WV, uniqueTypeAny, false );
- initFunction( uniqueTypeStr, streamObj, "push_ignore",
- IN_STREAM_PUSH_IGNORE_WV, IN_STREAM_PUSH_IGNORE_WV, uniqueTypeAny, false );
}
void ParseData::initInputObject( )
@@ -2436,7 +2429,7 @@ void ParseData::initInputObject( )
inputLangEl->objectDef = inputObj;
initFunction( uniqueTypeStr, inputObj, "pull",
- IN_INPUT_PULL, IN_INPUT_PULL, uniqueTypeInt, false );
+ IN_INPUT_PULL_WV, IN_INPUT_PULL_WV, uniqueTypeInt, false );
initFunction( uniqueTypeStr, inputObj, "push",
IN_INPUT_PUSH_WV, IN_INPUT_PUSH_WV, uniqueTypeAny, false );
initFunction( uniqueTypeStr, inputObj, "push_ignore",