summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2018-05-15 17:36:30 -0400
committerAdrian Thurston <thurston@colm.net>2018-05-15 17:36:30 -0400
commit44f8ba6d73a3de862d05c5606fda32a3141018aa (patch)
tree5cc799c662eebfeda0382795303ca020a31ca7f9
parentc6868422f732147146fd4cf58252187df1afb438 (diff)
downloadcolm-44f8ba6d73a3de862d05c5606fda32a3141018aa.tar.gz
merged the EXIT instructions into PARSE_FRAG
-rw-r--r--src/bytecode.c62
-rw-r--r--src/bytecode.h3
-rw-r--r--src/synthesis.cc1
3 files changed, 20 insertions, 46 deletions
diff --git a/src/bytecode.c b/src/bytecode.c
index 523eb7aa..ae57763a 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -2346,8 +2346,7 @@ again:
vm_push_stream( stream );
- //instr += SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE;
- instr += SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE;
+ instr += SIZEOF_CODE + SIZEOF_CODE;
}
else {
stream_append_text( prg, sp, stream, input );
@@ -2374,8 +2373,7 @@ again:
vm_push_stream( stream );
- //instr += SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE;
- instr += SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE;
+ instr += SIZEOF_CODE + SIZEOF_CODE;
}
else {
parser_t *parser = stream->parser;
@@ -2427,8 +2425,7 @@ again:
vm_push_stream( stream );
- //instr += SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE;
- instr += SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE;
+ instr += SIZEOF_CODE + SIZEOF_CODE;
}
else {
parser_t *parser = stream->parser;
@@ -2457,8 +2454,7 @@ again:
vm_push_stream( stream );
- //instr += SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE;
- instr += SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE;
+ instr += SIZEOF_CODE + SIZEOF_CODE;
}
else {
parser_t *parser = stream->parser;
@@ -2558,8 +2554,7 @@ again:
}
if ( stream->parser == 0 )
- //instr += SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE;
- instr += SIZEOF_CODE + SIZEOF_CODE + SIZEOF_CODE;
+ instr += SIZEOF_CODE + SIZEOF_CODE;
break;
}
@@ -2700,29 +2695,20 @@ again:
* through to call some code, then jump back here. */
if ( exec->pcr != PCR_DONE )
instr = pcr_call( prg, exec, &sp, instr, stream );
- break;
- }
-
- case IN_PARSE_FRAG_EXIT_W: {
- debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_EXIT_W \n" );
-
- stream_t *stream = vm_pop_stream();
- vm_push_stream( stream );
-
- if ( exec->WV ) {
- rcode_unit_start( exec );
+ else {
+ if ( exec->WV ) {
+ rcode_unit_start( exec );
+
+ rcode_code( exec, IN_PARSE_INIT_BKT );
+ rcode_word( exec, (word_t)stream );
+ rcode_word( exec, (word_t)exec->steps );
+ rcode_code( exec, IN_PARSE_FRAG_BKT );
+ rcode_unit_term( exec );
+ }
- rcode_code( exec, IN_PARSE_INIT_BKT );
- rcode_word( exec, (word_t)stream );
- rcode_word( exec, (word_t)exec->steps );
- rcode_code( exec, IN_PARSE_FRAG_BKT );
- rcode_code( exec, IN_PARSE_FRAG_EXIT_BKT );
- rcode_unit_term( exec );
+ if ( prg->induce_exit )
+ goto out;
}
-
- if ( prg->induce_exit )
- goto out;
-
break;
}
@@ -2737,13 +2723,9 @@ again:
if ( exec->pcr != PCR_DONE )
instr = pcr_call( prg, exec, &sp, instr, stream );
- break;
- }
-
- case IN_PARSE_FRAG_EXIT_BKT: {
- debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_EXIT_BKT\n" );
-
- vm_pop_stream();
+ else {
+ vm_pop_stream();
+ }
break;
}
@@ -4721,10 +4703,6 @@ again:
debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_BKT\n" );
break;
}
- case IN_PARSE_FRAG_EXIT_BKT: {
- debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_EXIT_BKT\n" );
- break;
- }
case IN_PCR_RET: {
debug( prg, REALM_BYTECODE, "IN_PCR_RET\n" );
return;
diff --git a/src/bytecode.h b/src/bytecode.h
index 336fbb0f..114bafc5 100644
--- a/src/bytecode.h
+++ b/src/bytecode.h
@@ -261,10 +261,7 @@ typedef unsigned char uchar;
#define IN_PARSE_INIT_BKT 0xa1
#define IN_PARSE_FRAG_W 0xa2
-#define IN_PARSE_FRAG_EXIT_W 0xa3
-
#define IN_PARSE_FRAG_BKT 0xa6
-#define IN_PARSE_FRAG_EXIT_BKT 0xa7
#define IN_SEND_TREE_WC 0xa8
#define IN_SEND_TREE_WV 0xa9
diff --git a/src/synthesis.cc b/src/synthesis.cc
index c351c50f..f2526d49 100644
--- a/src/synthesis.cc
+++ b/src/synthesis.cc
@@ -1422,7 +1422,6 @@ void LangTerm::parseFrag( Compiler *pd, CodeVect &code, int stopId )
{
code.append( IN_PARSE_LOAD );
code.append( IN_PARSE_FRAG_W );
- code.append( IN_PARSE_FRAG_EXIT_W );
}
UniqueType *LangTerm::evaluateReadReduce( Compiler *pd, CodeVect &code ) const