diff options
-rw-r--r-- | src/bytecode.c | 140 | ||||
-rw-r--r-- | src/bytecode.h | 19 | ||||
-rw-r--r-- | src/synthesis.cc | 48 |
3 files changed, 58 insertions, 149 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index 967181a3..2e56f7e8 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -2330,8 +2330,8 @@ again: break; } - case IN_SEND_TEXT_WC: { - debug( prg, REALM_BYTECODE, "IN_SEND_TEXT_WC\n" ); + case IN_SEND_TEXT_W: { + debug( prg, REALM_BYTECODE, "IN_SEND_TEXT_W\n" ); tree_t *input = vm_pop_tree(); stream_t *stream = vm_pop_stream(); @@ -2347,54 +2347,29 @@ again: vm_push_stream( stream ); instr += SIZEOF_CODE; - } - else { - stream_append_text( prg, sp, stream, input ); - vm_push_stream( stream ); - exec->steps = stream->parser->pda_run->steps; - exec->pcr = PCR_START; - } - - colm_tree_downref( prg, sp, input ); - break; - } - - case IN_SEND_TEXT_WV: { - debug( prg, REALM_BYTECODE, "IN_SEND_TEXT_WV\n" ); - - tree_t *input = vm_pop_tree(); - stream_t *stream = vm_pop_stream(); - - if ( stream->parser == 0 ) { - struct stream_impl *si = stream_to_impl( stream ); - - if ( si->file != 0 ) - colm_print_tree_file( prg, sp, si, input, false ); - else if ( si->collect != 0 ) - colm_print_tree_collect( prg, sp, si->collect, input, false ); - - vm_push_stream( stream ); - - instr += SIZEOF_CODE; + colm_tree_downref( prg, sp, input ); } else { - parser_t *parser = stream->parser; - - word_t len = stream_append_text( prg, sp, parser->input, input ); + word_t len = stream_append_text( prg, sp, stream, input ); vm_push_stream( stream ); - rcode_unit_start( exec ); - rcode_code( exec, IN_SEND_TEXT_BKT ); - rcode_word( exec, (word_t) stream ); - rcode_word( exec, (word_t) input ); - rcode_word( exec, (word_t) len ); - rcode_unit_term( exec ); + if ( !exec->WV ) + colm_tree_downref( prg, sp, input ); + else { + rcode_unit_start( exec ); + rcode_code( exec, IN_SEND_TEXT_BKT ); + rcode_word( exec, (word_t) stream ); + rcode_word( exec, (word_t) input ); + rcode_word( exec, (word_t) len ); + rcode_unit_term( exec ); + } exec->steps = stream->parser->pda_run->steps; exec->pcr = PCR_START; } + break; } @@ -2415,8 +2390,8 @@ again: break; } - case IN_SEND_TREE_WC: { - debug( prg, REALM_BYTECODE, "IN_SEND_TREE_WC\n" ); + case IN_SEND_TREE_W: { + debug( prg, REALM_BYTECODE, "IN_SEND_TREE_W\n" ); tree_t *input = vm_pop_tree(); stream_t *stream = vm_pop_stream(); @@ -2431,37 +2406,7 @@ again: vm_push_stream( stream ); - instr += SIZEOF_CODE; - } - else { - parser_t *parser = stream->parser; - - stream_append_tree( prg, sp, parser->input, input ); - vm_push_stream( stream ); - - exec->steps = stream->parser->pda_run->steps; - exec->pcr = PCR_START; - } - - colm_tree_downref( prg, sp, input ); - break; - } - - case IN_SEND_TREE_WV: { - debug( prg, REALM_BYTECODE, "IN_SEND_TREE_WV\n" ); - - tree_t *input = vm_pop_tree(); - stream_t *stream = vm_pop_stream(); - - if ( stream->parser == 0 ) { - struct stream_impl *si = stream_to_impl( stream ); - - if ( si->file != 0 ) - colm_print_tree_file( prg, sp, si, input, false ); - else if ( si->collect != 0 ) - colm_print_tree_collect( prg, sp, si->collect, input, false ); - - vm_push_stream( stream ); + colm_tree_downref( prg, sp, input ); instr += SIZEOF_CODE; } @@ -2472,12 +2417,16 @@ again: vm_push_stream( stream ); - rcode_unit_start( exec ); - rcode_code( exec, IN_SEND_TREE_BKT ); - rcode_word( exec, (word_t) stream ); - rcode_word( exec, (word_t) input ); - rcode_word( exec, (word_t) len ); - rcode_unit_term( exec ); + if ( !exec->WV ) + colm_tree_downref( prg, sp, input ); + else { + rcode_unit_start( exec ); + rcode_code( exec, IN_SEND_TREE_BKT ); + rcode_word( exec, (word_t) stream ); + rcode_word( exec, (word_t) input ); + rcode_word( exec, (word_t) len ); + rcode_unit_term( exec ); + } exec->steps = stream->parser->pda_run->steps; exec->pcr = PCR_START; @@ -2502,23 +2451,8 @@ again: break; } - case IN_SEND_STREAM_WC: { - debug( prg, REALM_BYTECODE, "IN_SEND_STREAM_WC\n" ); - - tree_t *input = vm_pop_tree(); - stream_t *stream = vm_pop_stream(); - - vm_push_stream( stream ); - - stream_append_stream( prg, sp, stream->parser->input, input ); - - exec->steps = stream->parser->pda_run->steps; - exec->pcr = PCR_START; - - break; - } - case IN_SEND_STREAM_WV: { - debug( prg, REALM_BYTECODE, "IN_SEND_STREAM_WV\n" ); + case IN_SEND_STREAM_W: { + debug( prg, REALM_BYTECODE, "IN_SEND_STREAM_W\n" ); tree_t *input = vm_pop_tree(); stream_t *stream = vm_pop_stream(); @@ -2527,12 +2461,14 @@ again: vm_push_stream( stream ); - rcode_unit_start( exec ); - rcode_code( exec, IN_SEND_STREAM_BKT ); - rcode_word( exec, (word_t) stream ); - rcode_word( exec, (word_t) input ); - rcode_word( exec, (word_t) len ); - rcode_unit_term( exec ); + if ( exec->WV ) { + rcode_unit_start( exec ); + rcode_code( exec, IN_SEND_STREAM_BKT ); + rcode_word( exec, (word_t) stream ); + rcode_word( exec, (word_t) input ); + rcode_word( exec, (word_t) len ); + rcode_unit_term( exec ); + } exec->steps = stream->parser->pda_run->steps; exec->pcr = PCR_START; diff --git a/src/bytecode.h b/src/bytecode.h index 0ebbdd29..e303e675 100644 --- a/src/bytecode.h +++ b/src/bytecode.h @@ -261,20 +261,17 @@ typedef unsigned char uchar; #define IN_PARSE_INIT_BKT 0xa1 #define IN_PARSE_FRAG_BKT 0xa6 -#define IN_SEND_TREE_WC 0xa8 -#define IN_SEND_TREE_WV 0xa9 -#define IN_SEND_TREE_BKT 0xaa +#define IN_SEND_TEXT_W 0x89 +#define IN_SEND_TEXT_BKT 0x8a -#define IN_SEND_TEXT_WC 0x88 -#define IN_SEND_TEXT_WV 0x89 -#define IN_SEND_TEXT_BKT 0x8a +#define IN_SEND_TREE_W 0xa9 +#define IN_SEND_TREE_BKT 0xaa -#define IN_SEND_STREAM_WC 0x96 -#define IN_SEND_STREAM_WV 0x90 -#define IN_SEND_STREAM_BKT 0x1c +#define IN_SEND_STREAM_W 0x90 +#define IN_SEND_STREAM_BKT 0x1c -#define IN_SEND_EOF_W 0x87 -#define IN_SEND_EOF_BKT 0xa4 +#define IN_SEND_EOF_W 0x87 +#define IN_SEND_EOF_BKT 0xa4 #define IN_REDUCE_COMMIT 0xa5 diff --git a/src/synthesis.cc b/src/synthesis.cc index 08f120dc..5af50863 100644 --- a/src/synthesis.cc +++ b/src/synthesis.cc @@ -1565,24 +1565,12 @@ UniqueType *LangTerm::evaluateParse( Compiler *pd, CodeVect &code, break; }} - if ( isStream ) { - if ( pd->revertOn ) - code.append( IN_SEND_STREAM_WV ); - else - code.append( IN_SEND_STREAM_WC ); - } - else if ( tree ) { - if ( pd->revertOn ) - code.append( IN_SEND_TREE_WV ); - else - code.append( IN_SEND_TREE_WC ); - } - else { - if ( pd->revertOn ) - code.append( IN_SEND_TEXT_WV ); - else - code.append( IN_SEND_TEXT_WC ); - } + if ( isStream ) + code.append( IN_SEND_STREAM_W ); + else if ( tree ) + code.append( IN_SEND_TREE_W ); + else + code.append( IN_SEND_TEXT_W ); /* Parse instruction, dependent on whether or not we are producing * revert or commit code. */ @@ -1678,24 +1666,12 @@ void LangTerm::evaluateSendParser( Compiler *pd, CodeVect &code, bool strings ) break; } - if ( isStream ) { - if ( pd->revertOn ) - code.append( IN_SEND_STREAM_WV ); - else - code.append( IN_SEND_STREAM_WC ); - } - else if ( !strings ) { - if ( pd->revertOn ) - code.append( IN_SEND_TREE_WV ); - else - code.append( IN_SEND_TREE_WC ); - } - else { - if ( pd->revertOn ) - code.append( IN_SEND_TEXT_WV ); - else - code.append( IN_SEND_TEXT_WC ); - } + if ( isStream ) + code.append( IN_SEND_STREAM_W ); + else if ( !strings ) + code.append( IN_SEND_TREE_W ); + else + code.append( IN_SEND_TEXT_W ); parseFrag( pd, code, 0 ); } |