summaryrefslogtreecommitdiff
path: root/src/bytecode.c
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2018-07-04 13:23:21 +0700
committerAdrian Thurston <thurston@colm.net>2018-07-04 13:23:21 +0700
commit00b1dd7777079036321afb8b3dcff0a229815517 (patch)
tree74f4d3acf8c043b03b1182e0453659cd8dca4f8a /src/bytecode.c
parente87efd2f55958dc4f915890091ecf436d33d8c4f (diff)
downloadcolm-00b1dd7777079036321afb8b3dcff0a229815517.tar.gz
reusing stream impls when parsing from 'input'
To detect parsing from a top level input and to avoid appending it to a parser's top level (thus creating a tree), added a new type for input so we can replace the parser's top level. This change forces us to a two level structure where stream seq is at the top and stream data underneath. Requires us to hack the destructor so that we don't multiple delete the stream impl.
Diffstat (limited to 'src/bytecode.c')
-rw-r--r--src/bytecode.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/bytecode.c b/src/bytecode.c
index 4e8d8e61..d79231f5 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -2453,6 +2453,22 @@ again:
break;
}
+ case IN_REPLACE_STREAM: {
+ debug( prg, REALM_BYTECODE, "IN_REPLACE_STREAM\n" );
+
+ stream_t *to_replace_with = vm_pop_stream();
+ stream_t *stream = vm_pop_stream();
+
+ stream->impl = to_replace_with->impl;
+ stream->not_owner = true;
+
+ vm_push_stream( stream );
+
+ exec->steps = stream->parser->pda_run->steps;
+ exec->pcr = PCR_START;
+
+ break;
+ }
case IN_SEND_STREAM_W: {
debug( prg, REALM_BYTECODE, "IN_SEND_STREAM_W\n" );