summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2013-03-29 12:05:16 -0400
committerAdrian Thurston <thurston@complang.org>2013-03-29 12:05:16 -0400
commit3d7fcac0a8ec6cfa6ea34ea12014f43980f546ec (patch)
tree65df51e905ad415f1e09b45007859a871ca34a5a
parentdcca0ae4634e030cc7c0289cbd282c958a4b928f (diff)
downloadcolm-3d7fcac0a8ec6cfa6ea34ea12014f43980f546ec.tar.gz
active realm is now stored in Program
No longer using a global var for the active realms. Downside is that we need to have prg available.
-rw-r--r--colm/bytecode.c464
-rw-r--r--colm/codegen.cc6
-rw-r--r--colm/colm.h4
-rw-r--r--colm/compiler.cc6
-rw-r--r--colm/conscolm.cc4
-rw-r--r--colm/conscolm.h2
-rw-r--r--colm/consinit.cc2
-rw-r--r--colm/consinit.h2
-rw-r--r--colm/ctinput.cc2
-rw-r--r--colm/debug.c8
-rw-r--r--colm/debug.h11
-rw-r--r--colm/fsmcodegen.h2
-rw-r--r--colm/input.c40
-rw-r--r--colm/load.cc8
-rw-r--r--colm/load.h3
-rw-r--r--colm/main.cc25
-rw-r--r--colm/parsedata.h2
-rw-r--r--colm/parser.h2
-rw-r--r--colm/pdarun.c150
-rw-r--r--colm/pool.c2
-rw-r--r--colm/program.c7
-rw-r--r--colm/program.h2
-rw-r--r--colm/tree.c28
23 files changed, 391 insertions, 391 deletions
diff --git a/colm/bytecode.c b/colm/bytecode.c
index 291c662d..6fa56eb8 100644
--- a/colm/bytecode.c
+++ b/colm/bytecode.c
@@ -261,7 +261,7 @@ long undoParseFrag( Program *prg, Tree **sp, Parser *parser, long steps, long en
StreamImpl *is = parser->input->in;
PdaRun *pdaRun = parser->pdaRun;
- debug( REALM_PARSE, "undo parse frag, target steps: %ld, pdarun steps: %ld\n", steps, pdaRun->steps );
+ debug( prg, REALM_PARSE, "undo parse frag, target steps: %ld, pdarun steps: %ld\n", steps, pdaRun->steps );
resetToken( pdaRun );
@@ -363,7 +363,7 @@ void downrefLocalTrees( Program *prg, Tree **sp, Tree **frame, char *trees, long
{
long i;
for ( i = 0; i < treesLen; i++ ) {
- debug( REALM_BYTECODE, "local tree downref: %ld\n", (long)trees[i] );
+ debug( prg, REALM_BYTECODE, "local tree downref: %ld\n", (long)trees[i] );
treeDownref( prg, sp, frame[((long)trees[i])] );
}
@@ -470,7 +470,7 @@ void rcodeDownref( Program *prg, Tree **sp, Code *instr )
again:
switch ( *instr++ ) {
case IN_PARSE_SAVE_STEPS: {
- debug( REALM_BYTECODE, "IN_PARSE_SAVE_STEPS\n" );
+ debug( prg, REALM_BYTECODE, "IN_PARSE_SAVE_STEPS\n" );
break;
}
case IN_PARSE_INIT_BKT: {
@@ -478,7 +478,7 @@ again:
Word pcr;
Word steps;
- debug( REALM_BYTECODE, "IN_PARSE_INIT_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_PARSE_INIT_BKT\n" );
read_tree( parser );
read_word( pcr );
@@ -491,20 +491,20 @@ again:
case IN_LOAD_TREE: {
Word w;
read_word( w );
- debug( REALM_BYTECODE, "IN_LOAD_TREE %p\n", (Tree*)w );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_TREE %p\n", (Tree*)w );
treeDownref( prg, sp, (Tree*)w );
break;
}
case IN_LOAD_WORD: {
Word w;
read_word( w );
- debug( REALM_BYTECODE, "IN_LOAD_WORD\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_WORD\n" );
break;
}
case IN_RESTORE_LHS: {
Tree *restore;
read_tree( restore );
- debug( REALM_BYTECODE, "IN_RESTORE_LHS\n" );
+ debug( prg, REALM_BYTECODE, "IN_RESTORE_LHS\n" );
treeDownref( prg, sp, restore );
break;
}
@@ -512,33 +512,33 @@ again:
case IN_PARSE_FRAG_BKT: {
Half stopId;
read_half( stopId );
- debug( REALM_BYTECODE, "IN_PARSE_FRAG_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_BKT\n" );
break;
}
case IN_PARSE_FRAG_EXIT_BKT: {
- debug( REALM_BYTECODE, "IN_PARSE_FRAG_EXIT_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_EXIT_BKT\n" );
break;
}
case IN_PARSE_FINISH_BKT: {
Half stopId;
read_half( stopId );
- debug( REALM_BYTECODE, "IN_PARSE_FINISH_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_PARSE_FINISH_BKT\n" );
break;
}
case IN_PARSE_FINISH_EXIT_BKT: {
- debug( REALM_BYTECODE, "IN_PARSE_FINISH_EXIT_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_PARSE_FINISH_EXIT_BKT\n" );
break;
}
case IN_PCR_CALL: {
- debug( REALM_BYTECODE, "IN_PCR_CALL\n" );
+ debug( prg, REALM_BYTECODE, "IN_PCR_CALL\n" );
break;
}
case IN_PCR_RET: {
- debug( REALM_BYTECODE, "IN_PCR_RET\n" );
+ debug( prg, REALM_BYTECODE, "IN_PCR_RET\n" );
return;
}
case IN_PCR_END_DECK: {
- debug( REALM_BYTECODE, "IN_PCR_END_DECK\n" );
+ debug( prg, REALM_BYTECODE, "IN_PCR_END_DECK\n" );
return;
}
case IN_INPUT_APPEND_BKT: {
@@ -549,7 +549,7 @@ again:
read_tree( input );
read_word( len );
- debug( REALM_BYTECODE, "IN_INPUT_APPEND_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_INPUT_APPEND_BKT\n" );
treeDownref( prg, sp, parser );
treeDownref( prg, sp, input );
@@ -559,7 +559,7 @@ again:
Tree *string;
read_tree( string );
- debug( REALM_BYTECODE, "IN_INPUT_PULL_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_INPUT_PULL_BKT\n" );
treeDownref( prg, sp, string );
break;
@@ -568,34 +568,34 @@ again:
Word len;
read_word( len );
- debug( REALM_BYTECODE, "IN_INPUT_PUSH_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_INPUT_PUSH_BKT\n" );
break;
}
case IN_LOAD_GLOBAL_BKT: {
- debug( REALM_BYTECODE, "IN_LOAD_GLOBAL_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_GLOBAL_BKT\n" );
break;
}
case IN_LOAD_CONTEXT_BKT: {
- debug( REALM_BYTECODE, "IN_LOAD_CONTEXT_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_CONTEXT_BKT\n" );
break;
}
case IN_LOAD_PARSER_BKT: {
/* Tree *parser; */
consume_word();
- debug( REALM_BYTECODE, "IN_LOAD_PARSER_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_PARSER_BKT\n" );
break;
}
case IN_LOAD_INPUT_BKT: {
/* Tree *input; */
consume_word();
- debug( REALM_BYTECODE, "IN_LOAD_INPUT_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_INPUT_BKT\n" );
break;
}
case IN_GET_FIELD_BKT: {
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_GET_FIELD_BKT %hd\n", field );
+ debug( prg, REALM_BYTECODE, "IN_GET_FIELD_BKT %hd\n", field );
break;
}
case IN_SET_FIELD_BKT: {
@@ -604,7 +604,7 @@ again:
read_half( field );
read_tree( val );
- debug( REALM_BYTECODE, "IN_SET_FIELD_BKT %hd\n", field );
+ debug( prg, REALM_BYTECODE, "IN_SET_FIELD_BKT %hd\n", field );
treeDownref( prg, sp, val );
break;
@@ -613,7 +613,7 @@ again:
Tree *ptr;
read_tree( ptr );
- debug( REALM_BYTECODE, "IN_PTR_DEREF_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_PTR_DEREF_BKT\n" );
treeDownref( prg, sp, ptr );
break;
@@ -622,21 +622,21 @@ again:
Word oldval;
read_word( oldval );
- debug( REALM_BYTECODE, "IN_SET_TOKEN_DATA_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_SET_TOKEN_DATA_BKT\n" );
Head *head = (Head*)oldval;
stringFree( prg, head );
break;
}
case IN_LIST_APPEND_BKT: {
- debug( REALM_BYTECODE, "IN_LIST_APPEND_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_LIST_APPEND_BKT\n" );
break;
}
case IN_LIST_REMOVE_END_BKT: {
Tree *val;
read_tree( val );
- debug( REALM_BYTECODE, "IN_LIST_REMOVE_END_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_LIST_REMOVE_END_BKT\n" );
treeDownref( prg, sp, val );
break;
@@ -645,7 +645,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_GET_LIST_MEM_BKT %hd\n", field );
+ debug( prg, REALM_BYTECODE, "IN_GET_LIST_MEM_BKT %hd\n", field );
break;
}
case IN_SET_LIST_MEM_BKT: {
@@ -654,7 +654,7 @@ again:
read_half( field );
read_tree( val );
- debug( REALM_BYTECODE, "IN_SET_LIST_MEM_BKT %hd\n", field );
+ debug( prg, REALM_BYTECODE, "IN_SET_LIST_MEM_BKT %hd\n", field );
treeDownref( prg, sp, val );
break;
@@ -665,7 +665,7 @@ again:
consume_byte();
read_tree( key );
- debug( REALM_BYTECODE, "IN_MAP_INSERT_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_MAP_INSERT_BKT\n" );
treeDownref( prg, sp, key );
break;
@@ -675,7 +675,7 @@ again:
read_tree( key );
read_tree( val );
- debug( REALM_BYTECODE,"IN_MAP_STORE_BKT\n" );
+ debug( prg, REALM_BYTECODE,"IN_MAP_STORE_BKT\n" );
treeDownref( prg, sp, key );
treeDownref( prg, sp, val );
@@ -686,7 +686,7 @@ again:
read_tree( key );
read_tree( val );
- debug( REALM_BYTECODE, "IN_MAP_REMOVE_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_MAP_REMOVE_BKT\n" );
treeDownref( prg, sp, key );
treeDownref( prg, sp, val );
@@ -778,7 +778,7 @@ int makeReverseCode( PdaRun *pdaRun )
void transferReverseCode( PdaRun *pdaRun, ParseTree *parseTree )
{
if ( pdaRun->rcBlockCount > 0 ) {
- debug( REALM_PARSE, "attaching reverse code to token\n" );
+ //debug( REALM_PARSE, "attaching reverse code to token\n" );
parseTree->flags |= PF_HAS_RCODE;
pdaRun->rcBlockCount = 0;
}
@@ -845,13 +845,13 @@ again:
Tree *restore;
read_tree( restore );
- debug( REALM_BYTECODE, "IN_RESTORE_LHS\n" );
+ debug( prg, REALM_BYTECODE, "IN_RESTORE_LHS\n" );
treeDownref( prg, sp, exec->parser->pdaRun->parseInput->shadow->tree );
exec->parser->pdaRun->parseInput->shadow->tree = restore;
break;
}
case IN_LOAD_NIL: {
- debug( REALM_BYTECODE, "IN_LOAD_NIL\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_NIL\n" );
vm_push( 0 );
break;
}
@@ -859,24 +859,24 @@ again:
Tree *tree;
read_tree( tree );
vm_push( tree );
- debug( REALM_BYTECODE, "IN_LOAD_TREE %p id: %d refs: %d\n", tree, tree->id, tree->refs );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_TREE %p id: %d refs: %d\n", tree, tree->id, tree->refs );
break;
}
case IN_LOAD_WORD: {
- debug( REALM_BYTECODE, "IN_LOAD_WORD\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_WORD\n" );
Word w;
read_word( w );
vm_push( (SW)w );
break;
}
case IN_LOAD_TRUE: {
- debug( REALM_BYTECODE, "IN_LOAD_TRUE\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_TRUE\n" );
treeUpref( prg->trueVal );
vm_push( prg->trueVal );
break;
}
case IN_LOAD_FALSE: {
- debug( REALM_BYTECODE, "IN_LOAD_FALSE\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_FALSE\n" );
treeUpref( prg->falseVal );
vm_push( prg->falseVal );
break;
@@ -885,7 +885,7 @@ again:
Word i;
read_word( i );
- debug( REALM_BYTECODE, "IN_LOAD_INT %d\n", i );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_INT %d\n", i );
Tree *tree = constructInteger( prg, i );
treeUpref( tree );
@@ -896,7 +896,7 @@ again:
Word offset;
read_word( offset );
- debug( REALM_BYTECODE, "IN_LOAD_STR %d\n", offset );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_STR %d\n", offset );
Head *lit = makeLiteral( prg, offset );
Tree *tree = constructString( prg, lit );
@@ -907,7 +907,7 @@ again:
case IN_PRINT: {
int n;
read_byte( n );
- debug( REALM_BYTECODE, "IN_PRINT %d\n", n );
+ debug( prg, REALM_BYTECODE, "IN_PRINT %d\n", n );
while ( n-- > 0 ) {
Tree *tree = vm_pop();
@@ -920,7 +920,7 @@ again:
int n;
read_byte( n );
- debug( REALM_BYTECODE, "IN_PRINT_XML_AC %d\n", n );
+ debug( prg, REALM_BYTECODE, "IN_PRINT_XML_AC %d\n", n );
while ( n-- > 0 ) {
Tree *tree = vm_pop();
@@ -932,7 +932,7 @@ again:
case IN_PRINT_XML: {
int n;
read_byte( n );
- debug( REALM_BYTECODE, "IN_PRINT_XML %d", n );
+ debug( prg, REALM_BYTECODE, "IN_PRINT_XML %d", n );
while ( n-- > 0 ) {
Tree *tree = vm_pop();
@@ -944,7 +944,7 @@ again:
case IN_PRINT_STREAM: {
int n;
read_byte( n );
- debug( REALM_BYTECODE, "IN_PRINT_STREAM\n" );
+ debug( prg, REALM_BYTECODE, "IN_PRINT_STREAM\n" );
Stream *stream = (Stream*)vm_pop();
while ( n-- > 0 ) {
@@ -959,14 +959,14 @@ again:
break;
}
case IN_LOAD_CONTEXT_R: {
- debug( REALM_BYTECODE, "IN_LOAD_CONTEXT_R\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_CONTEXT_R\n" );
treeUpref( exec->parser->pdaRun->context );
vm_push( exec->parser->pdaRun->context );
break;
}
case IN_LOAD_CONTEXT_WV: {
- debug( REALM_BYTECODE, "IN_LOAD_CONTEXT_WV\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_CONTEXT_WV\n" );
treeUpref( exec->parser->pdaRun->context );
vm_push( exec->parser->pdaRun->context );
@@ -977,7 +977,7 @@ again:
break;
}
case IN_LOAD_CONTEXT_WC: {
- debug( REALM_BYTECODE, "IN_LOAD_CONTEXT_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_CONTEXT_WC\n" );
/* This is identical to the _R version, but using it for writing
* would be confusing. */
@@ -986,21 +986,21 @@ again:
break;
}
case IN_LOAD_CONTEXT_BKT: {
- debug( REALM_BYTECODE, "IN_LOAD_CONTEXT_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_CONTEXT_BKT\n" );
treeUpref( exec->parser->pdaRun->context );
vm_push( exec->parser->pdaRun->context );
break;
}
case IN_LOAD_GLOBAL_R: {
- debug( REALM_BYTECODE, "IN_LOAD_GLOBAL_R\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_GLOBAL_R\n" );
treeUpref( prg->global );
vm_push( prg->global );
break;
}
case IN_LOAD_GLOBAL_WV: {
- debug( REALM_BYTECODE, "IN_LOAD_GLOBAL_WV\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_GLOBAL_WV\n" );
treeUpref( prg->global );
vm_push( prg->global );
@@ -1011,7 +1011,7 @@ again:
break;
}
case IN_LOAD_GLOBAL_WC: {
- debug( REALM_BYTECODE, "IN_LOAD_GLOBAL_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_GLOBAL_WC\n" );
/* This is identical to the _R version, but using it for writing
* would be confusing. */
@@ -1020,14 +1020,14 @@ again:
break;
}
case IN_LOAD_GLOBAL_BKT: {
- debug( REALM_BYTECODE, "IN_LOAD_GLOBAL_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_GLOBAL_BKT\n" );
treeUpref( prg->global );
vm_push( prg->global );
break;
}
case IN_LOAD_PARSER_R: {
- debug( REALM_BYTECODE, "IN_LOAD_PARSER_R\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_PARSER_R\n" );
treeUpref( (Tree*)exec->parser );
vm_push( (Tree*)exec->parser );
@@ -1035,7 +1035,7 @@ again:
break;
}
case IN_LOAD_PARSER_WV: {
- debug( REALM_BYTECODE, "IN_LOAD_PARSER_WV\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_PARSER_WV\n" );
treeUpref( (Tree*)exec->parser );
vm_push( (Tree*)exec->parser );
@@ -1048,7 +1048,7 @@ again:
break;
}
case IN_LOAD_PARSER_WC: {
- debug( REALM_BYTECODE, "IN_LOAD_PARSER_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_PARSER_WC\n" );
/* This is identical to the _R version, but using it for writing
* would be confusing. */
@@ -1061,14 +1061,14 @@ again:
Tree *parser;
read_tree( parser );
- debug( REALM_BYTECODE, "IN_LOAD_PARSER_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_PARSER_BKT\n" );
treeUpref( parser );
vm_push( parser );
break;
}
case IN_LOAD_INPUT_R: {
- debug( REALM_BYTECODE, "IN_LOAD_INPUT_R\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_INPUT_R\n" );
assert( exec->parser != 0 );
treeUpref( (Tree*)exec->parser->input );
@@ -1076,7 +1076,7 @@ again:
break;
}
case IN_LOAD_INPUT_WV: {
- debug( REALM_BYTECODE, "IN_LOAD_INPUT_WV\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_INPUT_WV\n" );
assert( exec->parser != 0 );
treeUpref( (Tree*)exec->parser->input );
@@ -1089,7 +1089,7 @@ again:
break;
}
case IN_LOAD_INPUT_WC: {
- debug( REALM_BYTECODE, "IN_LOAD_INPUT_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_INPUT_WC\n" );
/* This is identical to the _R version, but using it for writing
* would be confusing. */
@@ -1102,21 +1102,21 @@ again:
Tree *accumStream;
read_tree( accumStream );
- debug( REALM_BYTECODE, "IN_LOAD_INPUT_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_INPUT_BKT\n" );
treeUpref( accumStream );
vm_push( accumStream );
break;
}
case IN_LOAD_CTX_R: {
- debug( REALM_BYTECODE, "IN_LOAD_CTX_R\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_CTX_R\n" );
treeUpref( exec->parser->pdaRun->context );
vm_push( exec->parser->pdaRun->context );
break;
}
case IN_LOAD_CTX_WV: {
- debug( REALM_BYTECODE, "IN_LOAD_CTX_WV\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_CTX_WV\n" );
treeUpref( exec->parser->pdaRun->context );
vm_push( exec->parser->pdaRun->context );
@@ -1128,7 +1128,7 @@ again:
break;
}
case IN_LOAD_CTX_WC: {
- debug( REALM_BYTECODE, "IN_LOAD_CTX_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_CTX_WC\n" );
/* This is identical to the _R version, but using it for writing
* would be confusing. */
@@ -1137,7 +1137,7 @@ again:
break;
}
case IN_LOAD_CTX_BKT: {
- debug( REALM_BYTECODE, "IN_LOAD_CTX_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_CTX_BKT\n" );
treeUpref( exec->parser->pdaRun->context );
vm_push( exec->parser->pdaRun->context );
@@ -1147,7 +1147,7 @@ again:
/* uchar ncaps; */
consume_byte();
- debug( REALM_BYTECODE, "IN_INIT_CAPTURES\n" );
+ debug( prg, REALM_BYTECODE, "IN_INIT_CAPTURES\n" );
/* If there are captures (this is a translate block) then copy them into
* the local frame now. */
@@ -1171,7 +1171,7 @@ again:
read_half( position );
read_half( field );
- debug( REALM_BYTECODE, "IN_INIT_RHS_EL %hd\n", field );
+ debug( prg, REALM_BYTECODE, "IN_INIT_RHS_EL %hd\n", field );
Tree *val = getRhsEl( prg, exec->parser->pdaRun->redLel->shadow->tree, position );
treeUpref( val );
@@ -1183,7 +1183,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_INIT_LHS_EL %hd\n", field );
+ debug( prg, REALM_BYTECODE, "IN_INIT_LHS_EL %hd\n", field );
/* We transfer it to to the local field. Possibly take a copy. */
Tree *val = exec->parser->pdaRun->redLel->shadow->tree;
@@ -1200,7 +1200,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_STORE_LHS_EL %hd\n", field );
+ debug( prg, REALM_BYTECODE, "IN_STORE_LHS_EL %hd\n", field );
Tree *val = vm_local(field);
vm_local(field) = 0;
@@ -1211,7 +1211,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_UITER_ADVANCE\n" );
+ debug( prg, REALM_BYTECODE, "IN_UITER_ADVANCE\n" );
/* Get the iterator. */
UserIter *uiter = (UserIter*) vm_local(field);
@@ -1231,7 +1231,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_UITER_GET_CUR_R\n" );
+ debug( prg, REALM_BYTECODE, "IN_UITER_GET_CUR_R\n" );
UserIter *uiter = (UserIter*) vm_local(field);
Tree *val = uiter->ref.kid->tree;
@@ -1243,7 +1243,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_UITER_GET_CUR_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_UITER_GET_CUR_WC\n" );
UserIter *uiter = (UserIter*) vm_local(field);
splitRef( prg, &sp, &uiter->ref );
@@ -1256,7 +1256,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_UITER_SET_CUR_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_UITER_SET_CUR_WC\n" );
Tree *t = vm_pop();
UserIter *uiter = (UserIter*) vm_local(field);
@@ -1270,7 +1270,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_GET_LOCAL_R %hd\n", field );
+ debug( prg, REALM_BYTECODE, "IN_GET_LOCAL_R %hd\n", field );
Tree *val = vm_local(field);
treeUpref( val );
@@ -1281,7 +1281,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_GET_LOCAL_WC %hd\n", field );
+ debug( prg, REALM_BYTECODE, "IN_GET_LOCAL_WC %hd\n", field );
Tree *split = getLocalSplit( prg, exec->framePtr, field );
treeUpref( split );
@@ -1292,7 +1292,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_SET_LOCAL_WC %hd\n", field );
+ debug( prg, REALM_BYTECODE, "IN_SET_LOCAL_WC %hd\n", field );
Tree *val = vm_pop();
treeDownref( prg, sp, vm_local(field) );
@@ -1300,7 +1300,7 @@ again:
break;
}
case IN_SAVE_RET: {
- debug( REALM_BYTECODE, "IN_SAVE_RET\n" );
+ debug( prg, REALM_BYTECODE, "IN_SAVE_RET\n" );
Tree *val = vm_pop();
vm_local(FR_RV) = val;
@@ -1310,7 +1310,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_GET_LOCAL_REF_R\n" );
+ debug( prg, REALM_BYTECODE, "IN_GET_LOCAL_REF_R\n" );
Ref *ref = (Ref*) vm_plocal(field);
Tree *val = ref->kid->tree;
@@ -1322,7 +1322,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_GET_LOCAL_REF_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_GET_LOCAL_REF_WC\n" );
Ref *ref = (Ref*) vm_plocal(field);
splitRef( prg, &sp, ref );
@@ -1335,7 +1335,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_SET_LOCAL_REF_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_SET_LOCAL_REF_WC\n" );
Tree *val = vm_pop();
Ref *ref = (Ref*) vm_plocal(field);
@@ -1347,7 +1347,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_GET_FIELD_R %d\n", field );
+ debug( prg, REALM_BYTECODE, "IN_GET_FIELD_R %d\n", field );
Tree *obj = vm_pop();
treeDownref( prg, sp, obj );
@@ -1361,7 +1361,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_GET_FIELD_WC %d\n", field );
+ debug( prg, REALM_BYTECODE, "IN_GET_FIELD_WC %d\n", field );
Tree *obj = vm_pop();
treeDownref( prg, sp, obj );
@@ -1375,7 +1375,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_GET_FIELD_WV\n" );
+ debug( prg, REALM_BYTECODE, "IN_GET_FIELD_WV\n" );
Tree *obj = vm_pop();
treeDownref( prg, sp, obj );
@@ -1393,7 +1393,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_GET_FIELD_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_GET_FIELD_BKT\n" );
Tree *obj = vm_pop();
treeDownref( prg, sp, obj );
@@ -1407,7 +1407,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_SET_FIELD_WC %d\n", field );
+ debug( prg, REALM_BYTECODE, "IN_SET_FIELD_WC %d\n", field );
Tree *obj = vm_pop();
Tree *val = vm_pop();
@@ -1424,7 +1424,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_SET_FIELD_WV %d\n", field );
+ debug( prg, REALM_BYTECODE, "IN_SET_FIELD_WV %d\n", field );
Tree *obj = vm_pop();
Tree *val = vm_pop();
@@ -1447,7 +1447,7 @@ again:
read_half( field );
read_tree( val );
- debug( REALM_BYTECODE, "IN_SET_FIELD_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_SET_FIELD_BKT\n" );
Tree *obj = vm_pop();
treeDownref( prg, sp, obj );
@@ -1463,7 +1463,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_SET_FIELD_LEAVE_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_SET_FIELD_LEAVE_WC\n" );
/* Note that we don't downref the object here because we are
* leaving it on the stack. */
@@ -1482,7 +1482,7 @@ again:
break;
}
case IN_GET_RHS_VAL_R: {
- debug( REALM_BYTECODE, "IN_GET_RHS_VAL_R\n" );
+ debug( prg, REALM_BYTECODE, "IN_GET_RHS_VAL_R\n" );
int i, done = 0;
uchar len;
@@ -1505,7 +1505,7 @@ again:
break;
}
case IN_POP: {
- debug( REALM_BYTECODE, "IN_POP\n" );
+ debug( prg, REALM_BYTECODE, "IN_POP\n" );
Tree *val = vm_pop();
treeDownref( prg, sp, val );
@@ -1515,13 +1515,13 @@ again:
short n;
read_half( n );
- debug( REALM_BYTECODE, "IN_POP_N_WORDS\n" );
+ debug( prg, REALM_BYTECODE, "IN_POP_N_WORDS\n" );
vm_popn( n );
break;
}
case IN_SPRINTF: {
- debug( REALM_BYTECODE, "IN_SPRINTF\n" );
+ debug( prg, REALM_BYTECODE, "IN_SPRINTF\n" );
Tree *f = vm_pop();
f++;
@@ -1536,7 +1536,7 @@ again:
break;
}
case IN_STR_ATOI: {
- debug( REALM_BYTECODE, "IN_STR_ATOI\n" );
+ debug( prg, REALM_BYTECODE, "IN_STR_ATOI\n" );
Str *str = (Str*)vm_pop();
Word res = strAtoi( str->value );
@@ -1547,7 +1547,7 @@ again:
break;
}
case IN_INT_TO_STR: {
- debug( REALM_BYTECODE, "IN_INT_TO_STR\n" );
+ debug( prg, REALM_BYTECODE, "IN_INT_TO_STR\n" );
Int *i = (Int*)vm_pop();
Head *res = intToStr( prg, i->value );
@@ -1558,7 +1558,7 @@ again:
break;
}
case IN_TREE_TO_STR: {
- debug( REALM_BYTECODE, "IN_TREE_TO_STR\n" );
+ debug( prg, REALM_BYTECODE, "IN_TREE_TO_STR\n" );
Tree *tree = vm_pop();
Head *res = treeToStr( prg, sp, tree, true );
@@ -1569,7 +1569,7 @@ again:
break;
}
case IN_TREE_TO_STR_NOTRIM: {
- debug( REALM_BYTECODE, "IN_TREE_TO_STR_NOTRIM\n" );
+ debug( prg, REALM_BYTECODE, "IN_TREE_TO_STR_NOTRIM\n" );
Tree *tree = vm_pop();
Head *res = treeToStr( prg, sp, tree, false );
@@ -1580,7 +1580,7 @@ again:
break;
}
case IN_TREE_TRIM: {
- debug( REALM_BYTECODE, "IN_TREE_TRIM\n" );
+ debug( prg, REALM_BYTECODE, "IN_TREE_TRIM\n" );
Tree *tree = vm_pop();
Tree *trimmed = treeTrim( prg, sp, tree );
@@ -1588,7 +1588,7 @@ again:
break;
}
case IN_CONCAT_STR: {
- debug( REALM_BYTECODE, "IN_CONCAT_STR\n" );
+ debug( prg, REALM_BYTECODE, "IN_CONCAT_STR\n" );
Str *s2 = (Str*)vm_pop();
Str *s1 = (Str*)vm_pop();
@@ -1601,7 +1601,7 @@ again:
break;
}
case IN_STR_UORD8: {
- debug( REALM_BYTECODE, "IN_STR_UORD8\n" );
+ debug( prg, REALM_BYTECODE, "IN_STR_UORD8\n" );
Str *str = (Str*)vm_pop();
Word res = strUord8( str->value );
@@ -1612,7 +1612,7 @@ again:
break;
}
case IN_STR_UORD16: {
- debug( REALM_BYTECODE, "IN_STR_UORD16\n" );
+ debug( prg, REALM_BYTECODE, "IN_STR_UORD16\n" );
Str *str = (Str*)vm_pop();
Word res = strUord16( str->value );
@@ -1624,7 +1624,7 @@ again:
}
case IN_STR_LENGTH: {
- debug( REALM_BYTECODE, "IN_STR_LENGTH\n" );
+ debug( prg, REALM_BYTECODE, "IN_STR_LENGTH\n" );
Str *str = (Str*)vm_pop();
long len = stringLength( str->value );
@@ -1638,7 +1638,7 @@ again:
short dist;
read_half( dist );
- debug( REALM_BYTECODE, "IN_JMP_FALSE %d\n", dist );
+ debug( prg, REALM_BYTECODE, "IN_JMP_FALSE %d\n", dist );
Tree *tree = vm_pop();
if ( testFalse( prg, tree ) )
@@ -1650,7 +1650,7 @@ again:
short dist;
read_half( dist );
- debug( REALM_BYTECODE, "IN_JMP_TRUE %d\n", dist );
+ debug( prg, REALM_BYTECODE, "IN_JMP_TRUE %d\n", dist );
Tree *tree = vm_pop();
if ( !testFalse( prg, tree ) )
@@ -1662,13 +1662,13 @@ again:
short dist;
read_half( dist );
- debug( REALM_BYTECODE, "IN_JMP\n" );
+ debug( prg, REALM_BYTECODE, "IN_JMP\n" );
instr += dist;
break;
}
case IN_REJECT: {
- debug( REALM_BYTECODE, "IN_REJECT\n" );
+ debug( prg, REALM_BYTECODE, "IN_REJECT\n" );
exec->parser->pdaRun->reject = true;
break;
}
@@ -1677,7 +1677,7 @@ again:
* Binary comparison operators.
*/
case IN_TST_EQL: {
- debug( REALM_BYTECODE, "IN_TST_EQL\n" );
+ debug( prg, REALM_BYTECODE, "IN_TST_EQL\n" );
Tree *o2 = vm_pop();
Tree *o1 = vm_pop();
@@ -1690,7 +1690,7 @@ again:
break;
}
case IN_TST_NOT_EQL: {
- debug( REALM_BYTECODE, "IN_TST_NOT_EQL\n" );
+ debug( prg, REALM_BYTECODE, "IN_TST_NOT_EQL\n" );
Tree *o2 = vm_pop();
Tree *o1 = vm_pop();
@@ -1703,7 +1703,7 @@ again:
break;
}
case IN_TST_LESS: {
- debug( REALM_BYTECODE, "IN_TST_LESS\n" );
+ debug( prg, REALM_BYTECODE, "IN_TST_LESS\n" );
Tree *o2 = vm_pop();
Tree *o1 = vm_pop();
@@ -1716,7 +1716,7 @@ again:
break;
}
case IN_TST_LESS_EQL: {
- debug( REALM_BYTECODE, "IN_TST_LESS_EQL\n" );
+ debug( prg, REALM_BYTECODE, "IN_TST_LESS_EQL\n" );
Tree *o2 = vm_pop();
Tree *o1 = vm_pop();
@@ -1728,7 +1728,7 @@ again:
treeDownref( prg, sp, o2 );
}
case IN_TST_GRTR: {
- debug( REALM_BYTECODE, "IN_TST_GRTR\n" );
+ debug( prg, REALM_BYTECODE, "IN_TST_GRTR\n" );
Tree *o2 = vm_pop();
Tree *o1 = vm_pop();
@@ -1741,7 +1741,7 @@ again:
break;
}
case IN_TST_GRTR_EQL: {
- debug( REALM_BYTECODE, "IN_TST_GRTR_EQL\n" );
+ debug( prg, REALM_BYTECODE, "IN_TST_GRTR_EQL\n" );
Tree *o2 = (Tree*)vm_pop();
Tree *o1 = (Tree*)vm_pop();
@@ -1754,7 +1754,7 @@ again:
break;
}
case IN_TST_LOGICAL_AND: {
- debug( REALM_BYTECODE, "IN_TST_LOGICAL_AND\n" );
+ debug( prg, REALM_BYTECODE, "IN_TST_LOGICAL_AND\n" );
Tree *o2 = vm_pop();
Tree *o1 = vm_pop();
@@ -1769,7 +1769,7 @@ again:
break;
}
case IN_TST_LOGICAL_OR: {
- debug( REALM_BYTECODE, "IN_TST_LOGICAL_OR\n" );
+ debug( prg, REALM_BYTECODE, "IN_TST_LOGICAL_OR\n" );
Tree *o2 = vm_pop();
Tree *o1 = vm_pop();
@@ -1784,7 +1784,7 @@ again:
break;
}
case IN_NOT: {
- debug( REALM_BYTECODE, "IN_NOT\n" );
+ debug( prg, REALM_BYTECODE, "IN_NOT\n" );
Tree *tree = (Tree*)vm_pop();
long r = testFalse( prg, tree );
@@ -1796,7 +1796,7 @@ again:
}
case IN_ADD_INT: {
- debug( REALM_BYTECODE, "IN_ADD_INT\n" );
+ debug( prg, REALM_BYTECODE, "IN_ADD_INT\n" );
Int *o2 = (Int*)vm_pop();
Int *o1 = (Int*)vm_pop();
@@ -1809,7 +1809,7 @@ again:
break;
}
case IN_MULT_INT: {
- debug( REALM_BYTECODE, "IN_MULT_INT\n" );
+ debug( prg, REALM_BYTECODE, "IN_MULT_INT\n" );
Int *o2 = (Int*)vm_pop();
Int *o1 = (Int*)vm_pop();
@@ -1822,7 +1822,7 @@ again:
break;
}
case IN_DIV_INT: {
- debug( REALM_BYTECODE, "IN_DIV_INT\n" );
+ debug( prg, REALM_BYTECODE, "IN_DIV_INT\n" );
Int *o2 = (Int*)vm_pop();
Int *o1 = (Int*)vm_pop();
@@ -1835,7 +1835,7 @@ again:
break;
}
case IN_SUB_INT: {
- debug( REALM_BYTECODE, "IN_SUB_INT\n" );
+ debug( prg, REALM_BYTECODE, "IN_SUB_INT\n" );
Int *o2 = (Int*)vm_pop();
Int *o1 = (Int*)vm_pop();
@@ -1848,7 +1848,7 @@ again:
break;
}
case IN_TOP_SWAP: {
- debug( REALM_BYTECODE, "IN_TOP_SWAP\n" );
+ debug( prg, REALM_BYTECODE, "IN_TOP_SWAP\n" );
Tree *v1 = vm_pop();
Tree *v2 = vm_pop();
@@ -1857,7 +1857,7 @@ again:
break;
}
case IN_DUP_TOP: {
- debug( REALM_BYTECODE, "IN_DUP_TOP\n" );
+ debug( prg, REALM_BYTECODE, "IN_DUP_TOP\n" );
Tree *val = vm_top();
treeUpref( val );
@@ -1870,7 +1870,7 @@ again:
read_half( field );
read_half( searchTypeId );
- debug( REALM_BYTECODE, "IN_TRITER_FROM_REF\n" );
+ debug( prg, REALM_BYTECODE, "IN_TRITER_FROM_REF\n" );
Ref rootRef;
rootRef.kid = (Kid*)vm_pop();
@@ -1887,7 +1887,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_TRITER_DESTROY\n" );
+ debug( prg, REALM_BYTECODE, "IN_TRITER_DESTROY\n" );
TreeIter *iter = (TreeIter*) vm_plocal(field);
treeIterDestroy( prg, &sp, iter );
@@ -1899,7 +1899,7 @@ again:
read_half( field );
read_half( searchTypeId );
- debug( REALM_BYTECODE, "IN_REV_TRITER_FROM_REF\n" );
+ debug( prg, REALM_BYTECODE, "IN_REV_TRITER_FROM_REF\n" );
Ref rootRef;
rootRef.kid = (Kid*)vm_pop();
@@ -1924,7 +1924,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_REV_TRITER_DESTROY\n" );
+ debug( prg, REALM_BYTECODE, "IN_REV_TRITER_DESTROY\n" );
RevTreeIter *iter = (RevTreeIter*) vm_plocal(field);
long curStackSize = vm_ssize() - iter->rootSize;
@@ -1936,7 +1936,7 @@ again:
Word id;
read_word( id );
- debug( REALM_BYTECODE, "IN_TREE_SEARCH\n" );
+ debug( prg, REALM_BYTECODE, "IN_TREE_SEARCH\n" );
Tree *tree = vm_pop();
Tree *res = treeSearch( prg, tree, id );
@@ -1949,7 +1949,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_TRITER_ADVANCE\n" );
+ debug( prg, REALM_BYTECODE, "IN_TRITER_ADVANCE\n" );
TreeIter *iter = (TreeIter*) vm_plocal(field);
Tree *res = treeIterAdvance( prg, &sp, iter );
@@ -1961,7 +1961,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_TRITER_NEXT_CHILD\n" );
+ debug( prg, REALM_BYTECODE, "IN_TRITER_NEXT_CHILD\n" );
TreeIter *iter = (TreeIter*) vm_plocal(field);
Tree *res = treeIterNextChild( prg, &sp, iter );
@@ -1973,7 +1973,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_REV_TRITER_PREV_CHILD\n" );
+ debug( prg, REALM_BYTECODE, "IN_REV_TRITER_PREV_CHILD\n" );
RevTreeIter *iter = (RevTreeIter*) vm_plocal(field);
Tree *res = treeRevIterPrevChild( prg, &sp, iter );
@@ -1985,7 +1985,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_TRITER_NEXT_REPEAT\n" );
+ debug( prg, REALM_BYTECODE, "IN_TRITER_NEXT_REPEAT\n" );
TreeIter *iter = (TreeIter*) vm_plocal(field);
Tree *res = treeIterNextRepeat( prg, &sp, iter );
@@ -1997,7 +1997,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_TRITER_PREV_REPEAT\n" );
+ debug( prg, REALM_BYTECODE, "IN_TRITER_PREV_REPEAT\n" );
TreeIter *iter = (TreeIter*) vm_plocal(field);
Tree *res = treeIterPrevRepeat( prg, &sp, iter );
@@ -2009,7 +2009,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_TRITER_GET_CUR_R\n" );
+ debug( prg, REALM_BYTECODE, "IN_TRITER_GET_CUR_R\n" );
TreeIter *iter = (TreeIter*) vm_plocal(field);
Tree *tree = treeIterDerefCur( iter );
@@ -2021,7 +2021,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_TRITER_GET_CUR_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_TRITER_GET_CUR_WC\n" );
TreeIter *iter = (TreeIter*) vm_plocal(field);
splitIterCur( prg, &sp, iter );
@@ -2034,7 +2034,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_TRITER_SET_CUR_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_TRITER_SET_CUR_WC\n" );
Tree *tree = vm_pop();
TreeIter *iter = (TreeIter*) vm_plocal(field);
@@ -2048,7 +2048,7 @@ again:
Half patternId;
read_half( patternId );
- debug( REALM_BYTECODE, "IN_MATCH\n" );
+ debug( prg, REALM_BYTECODE, "IN_MATCH\n" );
Tree *tree = vm_pop();
@@ -2089,7 +2089,7 @@ again:
}
case IN_GET_PARSER_CTX_R: {
- debug( REALM_BYTECODE, "IN_GET_PARSER_CTX_R\n" );
+ debug( prg, REALM_BYTECODE, "IN_GET_PARSER_CTX_R\n" );
Tree *obj = vm_pop();
Tree *ctx = ((Parser*)obj)->pdaRun->context;
@@ -2100,7 +2100,7 @@ again:
}
case IN_SET_PARSER_CTX_WC: {
- debug( REALM_BYTECODE, "IN_SET_PARSER_CTX_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_SET_PARSER_CTX_WC\n" );
Tree *parser = vm_pop();
Tree *val = vm_pop();
@@ -2116,7 +2116,7 @@ again:
// break;
case IN_INPUT_APPEND_WC: {
- debug( REALM_BYTECODE, "IN_INPUT_APPEND_WC \n" );
+ debug( prg, REALM_BYTECODE, "IN_INPUT_APPEND_WC \n" );
Stream *accumStream = (Stream*)vm_pop();
Tree *input = vm_pop();
@@ -2127,7 +2127,7 @@ again:
break;
}
case IN_INPUT_APPEND_WV: {
- debug( REALM_BYTECODE, "IN_INPUT_APPEND_WV \n" );
+ debug( prg, REALM_BYTECODE, "IN_INPUT_APPEND_WV \n" );
Stream *accumStream = (Stream*)vm_pop();
Tree *input = vm_pop();
@@ -2153,7 +2153,7 @@ again:
read_tree( input );
read_word( len );
- debug( REALM_BYTECODE, "IN_INPUT_APPEND_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_INPUT_APPEND_BKT\n" );
undoStreamAppend( prg, sp, ((Stream*)accumStream)->in, input, len );
treeDownref( prg, sp, accumStream );
@@ -2162,7 +2162,7 @@ again:
}
case IN_PARSE_SAVE_STEPS: {
- debug( REALM_BYTECODE, "IN_PARSE_SAVE_STEPS\n" );
+ debug( prg, REALM_BYTECODE, "IN_PARSE_SAVE_STEPS\n" );
Parser *parser = (Parser*)vm_pop();
long steps = parser->pdaRun->steps;
@@ -2178,7 +2178,7 @@ again:
}
case IN_PARSE_INIT_BKT: {
- debug( REALM_BYTECODE, "IN_PARSE_INIT_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_PARSE_INIT_BKT\n" );
Tree *parser;
Word pcr;
@@ -2199,7 +2199,7 @@ again:
}
case IN_PCR_CALL: {
- debug( REALM_BYTECODE, "IN_PCR_CALL\n" );
+ debug( prg, REALM_BYTECODE, "IN_PCR_CALL\n" );
FrameInfo *fi = &prg->rtd->frameInfo[exec->parser->pdaRun->frameId];
long stretch = fi->argSize + 4 + fi->frameSize;
@@ -2224,11 +2224,11 @@ again:
}
case IN_PCR_RET: {
- debug( REALM_BYTECODE, "IN_PCR_RET\n" );
+ debug( prg, REALM_BYTECODE, "IN_PCR_RET\n" );
FrameInfo *fi = &prg->rtd->frameInfo[exec->frameId];
downrefLocalTrees( prg, sp, exec->framePtr, fi->trees, fi->treesLen );
- debug( REALM_BYTECODE, "RET: %d\n", fi->frameSize );
+ debug( prg, REALM_BYTECODE, "RET: %d\n", fi->frameSize );
vm_popn( fi->frameSize );
instr = (Code*) vm_pop();
@@ -2244,7 +2244,7 @@ again:
}
case IN_PCR_END_DECK: {
- debug( REALM_BYTECODE, "IN_PCR_END_DECK\n" );
+ debug( prg, REALM_BYTECODE, "IN_PCR_END_DECK\n" );
exec->parser->pdaRun->onDeck = false;
break;
}
@@ -2253,7 +2253,7 @@ again:
Half stopId;
read_half( stopId );
- debug( REALM_BYTECODE, "IN_PARSE_FRAG_WC %hd\n", stopId );
+ debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_WC %hd\n", stopId );
exec->pcr = parseFrag( prg, sp, exec->parser, stopId, exec->pcr );
@@ -2265,7 +2265,7 @@ again:
}
case IN_PARSE_FRAG_EXIT_WC: {
- debug( REALM_BYTECODE, "IN_PARSE_FRAG_EXIT_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_EXIT_WC\n" );
Parser *parser = exec->parser;
@@ -2285,7 +2285,7 @@ again:
Half stopId;
read_half( stopId );
- debug( REALM_BYTECODE, "IN_PARSE_FRAG_WV %hd\n", stopId );
+ debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_WV %hd\n", stopId );
exec->pcr = parseFrag( prg, sp, exec->parser, stopId, exec->pcr );
@@ -2297,7 +2297,7 @@ again:
}
case IN_PARSE_FRAG_EXIT_WV: {
- debug( REALM_BYTECODE, "IN_PARSE_FRAG_EXIT_WV \n" );
+ debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_EXIT_WV \n" );
Parser *parser = exec->parser;
long steps = exec->steps;
@@ -2326,7 +2326,7 @@ again:
Half stopId;
read_half( stopId );
- debug( REALM_BYTECODE, "IN_PARSE_FRAG_BKT %hd\n", stopId );
+ debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_BKT %hd\n", stopId );
exec->pcr = undoParseFrag( prg, sp, exec->parser, exec->steps, exec->pcr );
@@ -2336,7 +2336,7 @@ again:
}
case IN_PARSE_FRAG_EXIT_BKT: {
- debug( REALM_BYTECODE, "IN_PARSE_FRAG_EXIT_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_PARSE_FRAG_EXIT_BKT\n" );
Parser *parser = exec->parser;
@@ -2352,7 +2352,7 @@ again:
Half stopId;
read_half( stopId );
- debug( REALM_BYTECODE, "IN_PARSE_FINISH_WC %hd\n", stopId );
+ debug( prg, REALM_BYTECODE, "IN_PARSE_FINISH_WC %hd\n", stopId );
exec->parser->result = 0;
exec->pcr = parseFinish( &exec->parser->result, prg, sp, exec->parser, false, exec->pcr );
@@ -2365,7 +2365,7 @@ again:
}
case IN_PARSE_FINISH_EXIT_WC: {
- debug( REALM_BYTECODE, "IN_PARSE_FINISH_EXIT_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_PARSE_FINISH_EXIT_WC\n" );
Parser *parser = exec->parser;
@@ -2385,7 +2385,7 @@ again:
Half stopId;
read_half( stopId );
- debug( REALM_BYTECODE, "IN_PARSE_FINISH_WV %hd\n", stopId );
+ debug( prg, REALM_BYTECODE, "IN_PARSE_FINISH_WV %hd\n", stopId );
exec->parser->result = 0;
exec->pcr = parseFinish( &exec->parser->result, prg, sp, exec->parser, true, exec->pcr );
@@ -2396,7 +2396,7 @@ again:
}
case IN_PARSE_FINISH_EXIT_WV: {
- debug( REALM_BYTECODE, "IN_PARSE_FINISH_EXIT_WV\n" );
+ debug( prg, REALM_BYTECODE, "IN_PARSE_FINISH_EXIT_WV\n" );
Parser *parser = exec->parser;
long steps = exec->steps;
@@ -2428,7 +2428,7 @@ again:
Half stopId;
read_half( stopId );
- debug( REALM_BYTECODE, "IN_PARSE_FINISH_BKT %hd\n", stopId );
+ debug( prg, REALM_BYTECODE, "IN_PARSE_FINISH_BKT %hd\n", stopId );
exec->pcr = undoParseFrag( prg, sp, exec->parser, exec->steps, exec->pcr );
@@ -2438,7 +2438,7 @@ again:
}
case IN_PARSE_FINISH_EXIT_BKT: {
- debug( REALM_BYTECODE, "IN_PARSE_FINISH_EXIT_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_PARSE_FINISH_EXIT_BKT\n" );
Parser *parser = exec->parser;
@@ -2452,7 +2452,7 @@ again:
}
case IN_INPUT_PULL_WV: {
- debug( REALM_BYTECODE, "IN_INPUT_PULL_WV\n" );
+ debug( prg, REALM_BYTECODE, "IN_INPUT_PULL_WV\n" );
Stream *accumStream = (Stream*)vm_pop();
Tree *len = vm_pop();
@@ -2473,7 +2473,7 @@ again:
}
case IN_INPUT_PULL_WC: {
- debug( REALM_BYTECODE, "IN_INPUT_PULL_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_INPUT_PULL_WC\n" );
Stream *accumStream = (Stream*)vm_pop();
Tree *len = vm_pop();
@@ -2492,7 +2492,7 @@ again:
Tree *accumStream = vm_pop();
- debug( REALM_BYTECODE, "IN_INPUT_PULL_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_INPUT_PULL_BKT\n" );
undoPull( prg, ((Stream*)accumStream)->in, string );
treeDownref( prg, sp, accumStream );
@@ -2500,7 +2500,7 @@ again:
break;
}
case IN_INPUT_PUSH_WV: {
- debug( REALM_BYTECODE, "IN_INPUT_PUSH_WV\n" );
+ debug( prg, REALM_BYTECODE, "IN_INPUT_PUSH_WV\n" );
Stream *input = (Stream*)vm_pop();
Tree *tree = vm_pop();
@@ -2517,7 +2517,7 @@ again:
break;
}
case IN_INPUT_PUSH_IGNORE_WV: {
- debug( REALM_BYTECODE, "IN_INPUT_PUSH_IGNORE_WV\n" );
+ debug( prg, REALM_BYTECODE, "IN_INPUT_PUSH_IGNORE_WV\n" );
Stream *input = (Stream*)vm_pop();
Tree *tree = vm_pop();
@@ -2539,7 +2539,7 @@ again:
Stream *input = (Stream*)vm_pop();
- debug( REALM_BYTECODE, "IN_INPUT_PUSH_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_INPUT_PUSH_BKT\n" );
undoStreamPush( prg, sp, input->in, len );
treeDownref( prg, sp, (Tree*)input );
@@ -2549,7 +2549,7 @@ again:
Half patternId;
read_half( patternId );
- debug( REALM_BYTECODE, "IN_CONSTRUCT\n" );
+ debug( prg, REALM_BYTECODE, "IN_CONSTRUCT\n" );
int rootNode = prg->rtd->patReplInfo[patternId].offset;
@@ -2580,7 +2580,7 @@ again:
break;
}
case IN_CONSTRUCT_INPUT: {
- debug( REALM_BYTECODE, "IN_CONSTRUCT_INPUT\n" );
+ debug( prg, REALM_BYTECODE, "IN_CONSTRUCT_INPUT\n" );
Tree *input = constructStream( prg );
treeUpref( input );
@@ -2588,7 +2588,7 @@ again:
break;
}
case IN_GET_INPUT: {
- debug( REALM_BYTECODE, "IN_GET_INPUT\n" );
+ debug( prg, REALM_BYTECODE, "IN_GET_INPUT\n" );
Parser *parser = (Parser*)vm_pop();
treeUpref( (Tree*)parser->input );
@@ -2597,7 +2597,7 @@ again:
break;
}
case IN_SET_INPUT: {
- debug( REALM_BYTECODE, "IN_SET_INPUT\n" );
+ debug( prg, REALM_BYTECODE, "IN_SET_INPUT\n" );
Parser *parser = (Parser*)vm_pop();
Stream *accumStream = (Stream*)vm_pop();
@@ -2611,7 +2611,7 @@ again:
Half tokenId;
read_half( tokenId );
- debug( REALM_BYTECODE, "IN_CONSTRUCT_TERM\n" );
+ debug( prg, REALM_BYTECODE, "IN_CONSTRUCT_TERM\n" );
/* Pop the string we are constructing the token from. */
Str *str = (Str*)vm_pop();
@@ -2624,7 +2624,7 @@ again:
uchar nargs;
read_byte( nargs );
- debug( REALM_BYTECODE, "IN_MAKE_TOKEN\n" );
+ debug( prg, REALM_BYTECODE, "IN_MAKE_TOKEN\n" );
Tree *result = constructToken( prg, sp, nargs );
long i;
@@ -2639,7 +2639,7 @@ again:
uchar nargs;
read_byte( nargs );
- debug( REALM_BYTECODE, "IN_MAKE_TREE\n" );
+ debug( prg, REALM_BYTECODE, "IN_MAKE_TREE\n" );
Tree *result = makeTree( prg, sp, nargs );
long i;
@@ -2651,7 +2651,7 @@ again:
break;
}
case IN_TREE_NEW: {
- debug( REALM_BYTECODE, "IN_TREE_NEW \n" );
+ debug( prg, REALM_BYTECODE, "IN_TREE_NEW \n" );
Tree *tree = vm_pop();
Tree *res = constructPointer( prg, tree );
@@ -2660,7 +2660,7 @@ again:
break;
}
case IN_PTR_DEREF_R: {
- debug( REALM_BYTECODE, "IN_PTR_DEREF_R\n" );
+ debug( prg, REALM_BYTECODE, "IN_PTR_DEREF_R\n" );
Pointer *ptr = (Pointer*)vm_pop();
treeDownref( prg, sp, (Tree*)ptr );
@@ -2671,7 +2671,7 @@ again:
break;
}
case IN_PTR_DEREF_WC: {
- debug( REALM_BYTECODE, "IN_PTR_DEREF_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_PTR_DEREF_WC\n" );
Pointer *ptr = (Pointer*)vm_pop();
treeDownref( prg, sp, (Tree*)ptr );
@@ -2682,7 +2682,7 @@ again:
break;
}
case IN_PTR_DEREF_WV: {
- debug( REALM_BYTECODE, "IN_PTR_DEREF_WV\n" );
+ debug( prg, REALM_BYTECODE, "IN_PTR_DEREF_WV\n" );
Pointer *ptr = (Pointer*)vm_pop();
/* Don't downref the pointer since it is going into the reverse
@@ -2702,7 +2702,7 @@ again:
Word p;
read_word( p );
- debug( REALM_BYTECODE, "IN_PTR_DEREF_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_PTR_DEREF_BKT\n" );
Pointer *ptr = (Pointer*)p;
@@ -2717,7 +2717,7 @@ again:
short int field;
read_half( field );
- debug( REALM_BYTECODE, "IN_REF_FROM_LOCAL\n" );
+ debug( prg, REALM_BYTECODE, "IN_REF_FROM_LOCAL\n" );
/* First push the null next pointer, then the kid pointer. */
Tree **ptr = vm_plocal(field);
@@ -2730,7 +2730,7 @@ again:
short int field;
read_half( field );
- debug( REALM_BYTECODE, "IN_REF_FROM_REF\n" );
+ debug( prg, REALM_BYTECODE, "IN_REF_FROM_REF\n" );
Ref *ref = (Ref*)vm_plocal(field);
vm_contiguous( 2 );
@@ -2744,7 +2744,7 @@ again:
read_half( back );
read_half( field );
- debug( REALM_BYTECODE, "IN_REF_FROM_QUAL_REF\n" );
+ debug( prg, REALM_BYTECODE, "IN_REF_FROM_QUAL_REF\n" );
Ref *ref = (Ref*)(sp + back);
@@ -2760,7 +2760,7 @@ again:
short int field;
read_half( field );
- debug( REALM_BYTECODE, "IN_TRITER_REF_FROM_CUR\n" );
+ debug( prg, REALM_BYTECODE, "IN_TRITER_REF_FROM_CUR\n" );
/* Push the next pointer first, then the kid. */
TreeIter *iter = (TreeIter*) vm_plocal(field);
@@ -2774,7 +2774,7 @@ again:
short int field;
read_half( field );
- debug( REALM_BYTECODE, "IN_UITER_REF_FROM_CUR\n" );
+ debug( prg, REALM_BYTECODE, "IN_UITER_REF_FROM_CUR\n" );
/* Push the next pointer first, then the kid. */
UserIter *uiter = (UserIter*) vm_local(field);
@@ -2784,7 +2784,7 @@ again:
break;
}
case IN_GET_TOKEN_DATA_R: {
- debug( REALM_BYTECODE, "IN_GET_TOKEN_DATA_R\n" );
+ debug( prg, REALM_BYTECODE, "IN_GET_TOKEN_DATA_R\n" );
Tree *tree = (Tree*) vm_pop();
Head *data = stringCopy( prg, tree->tokdata );
@@ -2795,7 +2795,7 @@ again:
break;
}
case IN_SET_TOKEN_DATA_WC: {
- debug( REALM_BYTECODE, "IN_SET_TOKEN_DATA_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_SET_TOKEN_DATA_WC\n" );
Tree *tree = vm_pop();
Tree *val = vm_pop();
@@ -2808,7 +2808,7 @@ again:
break;
}
case IN_SET_TOKEN_DATA_WV: {
- debug( REALM_BYTECODE, "IN_SET_TOKEN_DATA_WV\n" );
+ debug( prg, REALM_BYTECODE, "IN_SET_TOKEN_DATA_WV\n" );
Tree *tree = vm_pop();
Tree *val = vm_pop();
@@ -2827,7 +2827,7 @@ again:
break;
}
case IN_SET_TOKEN_DATA_BKT: {
- debug( REALM_BYTECODE, "IN_SET_TOKEN_DATA_BKT \n" );
+ debug( prg, REALM_BYTECODE, "IN_SET_TOKEN_DATA_BKT \n" );
Word oldval;
read_word( oldval );
@@ -2840,7 +2840,7 @@ again:
break;
}
case IN_GET_TOKEN_POS_R: {
- debug( REALM_BYTECODE, "IN_GET_TOKEN_POS_R\n" );
+ debug( prg, REALM_BYTECODE, "IN_GET_TOKEN_POS_R\n" );
Tree *tree = (Tree*) vm_pop();
Tree *integer = 0;
@@ -2853,7 +2853,7 @@ again:
break;
}
case IN_GET_TOKEN_LINE_R: {
- debug( REALM_BYTECODE, "IN_GET_TOKEN_LINE_R\n" );
+ debug( prg, REALM_BYTECODE, "IN_GET_TOKEN_LINE_R\n" );
Tree *tree = (Tree*) vm_pop();
Tree *integer = 0;
@@ -2866,7 +2866,7 @@ again:
break;
}
case IN_GET_MATCH_LENGTH_R: {
- debug( REALM_BYTECODE, "IN_GET_MATCH_LENGTH_R\n" );
+ debug( prg, REALM_BYTECODE, "IN_GET_MATCH_LENGTH_R\n" );
Tree *integer = constructInteger( prg, stringLength(exec->parser->pdaRun->tokdata) );
treeUpref( integer );
@@ -2874,7 +2874,7 @@ again:
break;
}
case IN_GET_MATCH_TEXT_R: {
- debug( REALM_BYTECODE, "IN_GET_MATCH_TEXT_R\n" );
+ debug( prg, REALM_BYTECODE, "IN_GET_MATCH_TEXT_R\n" );
Head *s = stringCopy( prg, exec->parser->pdaRun->tokdata );
Tree *tree = constructString( prg, s );
@@ -2883,7 +2883,7 @@ again:
break;
}
case IN_LIST_LENGTH: {
- debug( REALM_BYTECODE, "IN_LIST_LENGTH\n" );
+ debug( prg, REALM_BYTECODE, "IN_LIST_LENGTH\n" );
List *list = (List*) vm_pop();
long len = listLength( list );
@@ -2894,7 +2894,7 @@ again:
break;
}
case IN_LIST_APPEND_WV: {
- debug( REALM_BYTECODE, "IN_LIST_APPEND_WV\n" );
+ debug( prg, REALM_BYTECODE, "IN_LIST_APPEND_WV\n" );
Tree *obj = vm_pop();
Tree *val = vm_pop();
@@ -2911,7 +2911,7 @@ again:
break;
}
case IN_LIST_APPEND_WC: {
- debug( REALM_BYTECODE, "IN_LIST_APPEND_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_LIST_APPEND_WC\n" );
Tree *obj = vm_pop();
Tree *val = vm_pop();
@@ -2924,7 +2924,7 @@ again:
break;
}
case IN_LIST_APPEND_BKT: {
- debug( REALM_BYTECODE, "IN_LIST_APPEND_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_LIST_APPEND_BKT\n" );
Tree *obj = vm_pop();
treeDownref( prg, sp, obj );
@@ -2934,7 +2934,7 @@ again:
break;
}
case IN_LIST_REMOVE_END_WC: {
- debug( REALM_BYTECODE, "IN_LIST_REMOVE_END_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_LIST_REMOVE_END_WC\n" );
Tree *obj = vm_pop();
treeDownref( prg, sp, obj );
@@ -2944,7 +2944,7 @@ again:
break;
}
case IN_LIST_REMOVE_END_WV: {
- debug( REALM_BYTECODE, "IN_LIST_REMOVE_END_WV\n" );
+ debug( prg, REALM_BYTECODE, "IN_LIST_REMOVE_END_WV\n" );
Tree *obj = vm_pop();
treeDownref( prg, sp, obj );
@@ -2961,7 +2961,7 @@ again:
break;
}
case IN_LIST_REMOVE_END_BKT: {
- debug( REALM_BYTECODE, "IN_LIST_REMOVE_END_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_LIST_REMOVE_END_BKT\n" );
Tree *val;
read_tree( val );
@@ -2976,7 +2976,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_GET_LIST_MEM_R\n" );
+ debug( prg, REALM_BYTECODE, "IN_GET_LIST_MEM_R\n" );
Tree *obj = vm_pop();
treeDownref( prg, sp, obj );
@@ -2990,7 +2990,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_GET_LIST_MEM_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_GET_LIST_MEM_WC\n" );
Tree *obj = vm_pop();
treeDownref( prg, sp, obj );
@@ -3004,7 +3004,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_GET_LIST_MEM_WV\n" );
+ debug( prg, REALM_BYTECODE, "IN_GET_LIST_MEM_WV\n" );
Tree *obj = vm_pop();
treeDownref( prg, sp, obj );
@@ -3022,7 +3022,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_GET_LIST_MEM_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_GET_LIST_MEM_BKT\n" );
Tree *obj = vm_pop();
treeDownref( prg, sp, obj );
@@ -3036,7 +3036,7 @@ again:
Half field;
read_half( field );
- debug( REALM_BYTECODE, "IN_SET_LIST_MEM_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_SET_LIST_MEM_WC\n" );
Tree *obj = vm_pop();
treeDownref( prg, sp, obj );
@@ -3050,7 +3050,7 @@ again:
Half field;
read_half( field );
- debug( REALM_BYTECODE, "IN_SET_LIST_MEM_WV\n" );
+ debug( prg, REALM_BYTECODE, "IN_SET_LIST_MEM_WV\n" );
Tree *obj = vm_pop();
treeDownref( prg, sp, obj );
@@ -3071,7 +3071,7 @@ again:
read_half( field );
read_tree( val );
- debug( REALM_BYTECODE, "IN_SET_LIST_MEM_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_SET_LIST_MEM_BKT\n" );
Tree *obj = vm_pop();
treeDownref( prg, sp, obj );
@@ -3084,7 +3084,7 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_GET_PARSER_MEM_R %hd\n", field );
+ debug( prg, REALM_BYTECODE, "IN_GET_PARSER_MEM_R %hd\n", field );
Tree *obj = vm_pop();
Tree *val = getParserMem( (Parser*)obj, field );
@@ -3097,7 +3097,7 @@ again:
break;
}
case IN_MAP_INSERT_WV: {
- debug( REALM_BYTECODE, "IN_MAP_INSERT_WV\n" );
+ debug( prg, REALM_BYTECODE, "IN_MAP_INSERT_WV\n" );
Tree *obj = vm_pop();
Tree *val = vm_pop();
@@ -3128,7 +3128,7 @@ again:
break;
}
case IN_MAP_INSERT_WC: {
- debug( REALM_BYTECODE, "IN_MAP_INSERT_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_MAP_INSERT_WC\n" );
Tree *obj = vm_pop();
Tree *val = vm_pop();
@@ -3153,7 +3153,7 @@ again:
read_byte( inserted );
read_tree( key );
- debug( REALM_BYTECODE, "IN_MAP_INSERT_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_MAP_INSERT_BKT\n" );
Tree *obj = vm_pop();
if ( inserted ) {
@@ -3167,7 +3167,7 @@ again:
break;
}
case IN_MAP_STORE_WC: {
- debug( REALM_BYTECODE, "IN_MAP_STORE_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_MAP_STORE_WC\n" );
Tree *obj = vm_pop();
Tree *element = vm_pop();
@@ -3186,7 +3186,7 @@ again:
break;
}
case IN_MAP_STORE_WV: {
- debug( REALM_BYTECODE, "IN_MAP_STORE_WV\n" );
+ debug( prg, REALM_BYTECODE, "IN_MAP_STORE_WV\n" );
Tree *obj = vm_pop();
Tree *element = vm_pop();
@@ -3217,7 +3217,7 @@ again:
read_tree( key );
read_tree( val );
- debug( REALM_BYTECODE, "IN_MAP_STORE_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_MAP_STORE_BKT\n" );
Tree *obj = vm_pop();
Tree *stored = mapUnstore( prg, (Map*)obj, key, val );
@@ -3231,7 +3231,7 @@ again:
break;
}
case IN_MAP_REMOVE_WC: {
- debug( REALM_BYTECODE, "IN_MAP_REMOVE_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_MAP_REMOVE_WC\n" );
Tree *obj = vm_pop();
Tree *key = vm_pop();
@@ -3245,7 +3245,7 @@ again:
break;
}
case IN_MAP_REMOVE_WV: {
- debug( REALM_BYTECODE, "IN_MAP_REMOVE_WV\n" );
+ debug( prg, REALM_BYTECODE, "IN_MAP_REMOVE_WV\n" );
Tree *obj = vm_pop();
Tree *key = vm_pop();
@@ -3269,7 +3269,7 @@ again:
read_tree( key );
read_tree( val );
- debug( REALM_BYTECODE, "IN_MAP_REMOVE_BKT\n" );
+ debug( prg, REALM_BYTECODE, "IN_MAP_REMOVE_BKT\n" );
/* Either both or neither. */
assert( ( key == 0 ) ^ ( val != 0 ) );
@@ -3282,7 +3282,7 @@ again:
break;
}
case IN_MAP_LENGTH: {
- debug( REALM_BYTECODE, "IN_MAP_LENGTH\n" );
+ debug( prg, REALM_BYTECODE, "IN_MAP_LENGTH\n" );
Tree *obj = vm_pop();
long len = mapLength( (Map*)obj );
@@ -3294,7 +3294,7 @@ again:
break;
}
case IN_MAP_FIND: {
- debug( REALM_BYTECODE, "IN_MAP_FIND\n" );
+ debug( prg, REALM_BYTECODE, "IN_MAP_FIND\n" );
Tree *obj = vm_pop();
Tree *key = vm_pop();
@@ -3309,7 +3309,7 @@ again:
case IN_CONTIGUOUS: {
Half size;
read_half( size );
- debug( REALM_BYTECODE, "IN_CONTIGUOUS %hd\n", size );
+ debug( prg, REALM_BYTECODE, "IN_CONTIGUOUS %hd\n", size );
vm_contiguous( size );
break;
}
@@ -3317,7 +3317,7 @@ again:
Half size;
read_half( size );
- debug( REALM_BYTECODE, "IN_INIT_LOCALS %hd\n", size );
+ debug( prg, REALM_BYTECODE, "IN_INIT_LOCALS %hd\n", size );
exec->framePtr = vm_ptop();
vm_pushn( size );
@@ -3330,7 +3330,7 @@ again:
FunctionInfo *fi = &prg->rtd->functionInfo[funcId];
- debug( REALM_BYTECODE, "IN_CALL_WV %ld\n", fi->name );
+ debug( prg, REALM_BYTECODE, "IN_CALL_WV %ld\n", fi->name );
vm_push( 0 ); /* Return value. */
vm_push( (SW)instr );
@@ -3348,7 +3348,7 @@ again:
FunctionInfo *fi = &prg->rtd->functionInfo[funcId];
- debug( REALM_BYTECODE, "IN_CALL_WC %ld\n", fi->name );
+ debug( prg, REALM_BYTECODE, "IN_CALL_WC %ld\n", fi->name );
vm_push( 0 ); /* Return value. */
vm_push( (SW)instr );
@@ -3361,7 +3361,7 @@ again:
break;
}
case IN_YIELD: {
- debug( REALM_BYTECODE, "IN_YIELD\n" );
+ debug( prg, REALM_BYTECODE, "IN_YIELD\n" );
Kid *kid = (Kid*)vm_pop();
Ref *next = (Ref*)vm_pop();
@@ -3397,7 +3397,7 @@ again:
read_half( funcId );
read_half( searchId );
- debug( REALM_BYTECODE, "IN_UITER_CREATE_WV\n" );
+ debug( prg, REALM_BYTECODE, "IN_UITER_CREATE_WV\n" );
FunctionInfo *fi = prg->rtd->functionInfo + funcId;
UserIter *uiter = uiterCreate( prg, &sp, fi, searchId );
@@ -3422,7 +3422,7 @@ again:
read_half( funcId );
read_half( searchId );
- debug( REALM_BYTECODE, "IN_UITER_CREATE_WC\n" );
+ debug( prg, REALM_BYTECODE, "IN_UITER_CREATE_WC\n" );
FunctionInfo *fi = prg->rtd->functionInfo + funcId;
UserIter *uiter = uiterCreate( prg, &sp, fi, searchId );
@@ -3444,14 +3444,14 @@ again:
short field;
read_half( field );
- debug( REALM_BYTECODE, "IN_UITER_DESTROY\n" );
+ debug( prg, REALM_BYTECODE, "IN_UITER_DESTROY\n" );
UserIter *uiter = (UserIter*) vm_local(field);
userIterDestroy( prg, &sp, uiter );
break;
}
case IN_RET: {
- debug( REALM_BYTECODE, "IN_RET\n" );
+ debug( prg, REALM_BYTECODE, "IN_RET\n" );
FrameInfo *fi = &prg->rtd->frameInfo[exec->frameId];
downrefLocalTrees( prg, sp, exec->framePtr, fi->trees, fi->treesLen );
@@ -3466,7 +3466,7 @@ again:
break;
}
case IN_TO_UPPER: {
- debug( REALM_BYTECODE, "IN_TO_UPPER\n" );
+ debug( prg, REALM_BYTECODE, "IN_TO_UPPER\n" );
Tree *in = vm_pop();
Head *head = stringToUpper( in->tokdata );
@@ -3477,7 +3477,7 @@ again:
break;
}
case IN_TO_LOWER: {
- debug( REALM_BYTECODE, "IN_TO_LOWER\n" );
+ debug( prg, REALM_BYTECODE, "IN_TO_LOWER\n" );
Tree *in = vm_pop();
Head *head = stringToLower( in->tokdata );
@@ -3488,7 +3488,7 @@ again:
break;
}
case IN_OPEN_FILE: {
- debug( REALM_BYTECODE, "IN_OPEN_FILE\n" );
+ debug( prg, REALM_BYTECODE, "IN_OPEN_FILE\n" );
Tree *mode = vm_pop();
Tree *name = vm_pop();
@@ -3500,7 +3500,7 @@ again:
break;
}
case IN_GET_STDIN: {
- debug( REALM_BYTECODE, "IN_GET_STDIN\n" );
+ debug( prg, REALM_BYTECODE, "IN_GET_STDIN\n" );
/* Pop the root object. */
Tree *obj = vm_pop();
@@ -3515,7 +3515,7 @@ again:
break;
}
case IN_GET_STDOUT: {
- debug( REALM_BYTECODE, "IN_GET_STDOUT\n" );
+ debug( prg, REALM_BYTECODE, "IN_GET_STDOUT\n" );
/* Pop the root object. */
Tree *obj = vm_pop();
@@ -3530,7 +3530,7 @@ again:
break;
}
case IN_GET_STDERR: {
- debug( REALM_BYTECODE, "IN_GET_STDERR\n" );
+ debug( prg, REALM_BYTECODE, "IN_GET_STDERR\n" );
/* Pop the root object. */
Tree *obj = vm_pop();
@@ -3547,7 +3547,7 @@ again:
case IN_LOAD_ARGV: {
Half field;
read_half( field );
- debug( REALM_BYTECODE, "IN_LOAD_ARGV %lu\n", field );
+ debug( prg, REALM_BYTECODE, "IN_LOAD_ARGV %lu\n", field );
/* Tree comes back upreffed. */
Tree *tree = constructArgv( prg, prg->argc, prg->argv );
@@ -3556,7 +3556,7 @@ again:
}
case IN_EXIT: {
- debug( REALM_BYTECODE, "IN_EXIT\n" );
+ debug( prg, REALM_BYTECODE, "IN_EXIT\n" );
Tree *global = vm_pop();
Int *status = (Int*)vm_pop();
@@ -3592,7 +3592,7 @@ again:
}
case IN_STOP: {
- debug( REALM_BYTECODE, "IN_STOP\n" );
+ debug( prg, REALM_BYTECODE, "IN_STOP\n" );
FrameInfo *fi = &prg->rtd->frameInfo[exec->frameId];
downrefLocalTrees( prg, sp, exec->framePtr, fi->trees, fi->treesLen );
diff --git a/colm/codegen.cc b/colm/codegen.cc
index 653d8d51..05fdb46c 100644
--- a/colm/codegen.cc
+++ b/colm/codegen.cc
@@ -28,15 +28,15 @@
#include <string>
-void FsmCodeGen::writeMain()
+void FsmCodeGen::writeMain( long activeRealm )
{
out <<
"int main( int argc, const char **argv )\n"
"{\n"
" struct ColmProgram *prg;\n"
" int exitStatus;\n"
- " colmInit( " << colmActiveRealm << " );\n"
- " prg = colmNewProgram( &main_runtimeData );\n"
+ " colmInit( 0 );\n"
+ " prg = colmNewProgram( &main_runtimeData, " << activeRealm << " );\n"
" colmRunProgram( prg, argc, argv );\n"
" exitStatus = colmDeleteProgram( prg );\n"
" return exitStatus;\n"
diff --git a/colm/colm.h b/colm/colm.h
index 07309a91..d069403d 100644
--- a/colm/colm.h
+++ b/colm/colm.h
@@ -11,8 +11,8 @@ struct ColmProgram;
struct ColmRuntimeData;
struct ColmTree;
-void colmInit( long debugRealm );
-struct ColmProgram *colmNewProgram( struct ColmRuntimeData *rtd );
+void colmInit( long );
+struct ColmProgram *colmNewProgram( struct ColmRuntimeData *rtd, long debugRealm );
void colmRunProgram( struct ColmProgram *prg, int argc, const char **argv );
int colmDeleteProgram( struct ColmProgram *prg );
diff --git a/colm/compiler.cc b/colm/compiler.cc
index c524c47e..6344608c 100644
--- a/colm/compiler.cc
+++ b/colm/compiler.cc
@@ -1043,7 +1043,7 @@ PdaRun *Compiler::parsePattern( Program *prg, Tree **sp, const InputLoc &loc,
void Compiler::parsePatterns()
{
- Program *prg = colmNewProgram( runtimeData );
+ Program *prg = colmNewProgram( runtimeData, 0 );
/* Turn off context-dependent parsing. */
prg->ctxDepParsing = 0;
@@ -1099,7 +1099,7 @@ void Compiler::collectParserEls( BstSet<LangEl*> &parserEls )
}
-void Compiler::generateOutput()
+void Compiler::generateOutput( long activeRealm )
{
FsmCodeGen *fsmGen = new FsmCodeGen( *outStream, redFsm, fsmTables );
@@ -1116,7 +1116,7 @@ void Compiler::generateOutput()
pdaGen->writeRuntimeData( runtimeData, pdaTables );
if ( !gblLibrary )
- fsmGen->writeMain();
+ fsmGen->writeMain( activeRealm );
outStream->flush();
}
diff --git a/colm/conscolm.cc b/colm/conscolm.cc
index 2d4ab2b6..2dba86ba 100644
--- a/colm/conscolm.cc
+++ b/colm/conscolm.cc
@@ -330,7 +330,7 @@ void LoadColm::consExportError( StmtList *stmtList )
stmtList->append( programExport );
}
-void LoadColm::go()
+void LoadColm::go( long activeRealm )
{
LoadColm::init();
@@ -341,7 +341,7 @@ void LoadColm::go()
argv[1] = 0;
colmInit( 0 );
- ColmProgram *program = colmNewProgram( &main_runtimeData );
+ ColmProgram *program = colmNewProgram( &main_runtimeData, 0 );
colmRunProgram( program, 1, argv );
/* Extract the parse tree. */
diff --git a/colm/conscolm.h b/colm/conscolm.h
index 2494900b..6cf774db 100644
--- a/colm/conscolm.h
+++ b/colm/conscolm.h
@@ -64,5 +64,5 @@ struct LoadColm
void consExportTree( StmtList *stmtList );
void consExportError( StmtList *stmtList );
- void go();
+ virtual void go( long activeRealm );
};
diff --git a/colm/consinit.cc b/colm/consinit.cc
index 4c6f4fa0..0893e9c4 100644
--- a/colm/consinit.cc
+++ b/colm/consinit.cc
@@ -777,7 +777,7 @@ void ConsInit::exportTree( StmtList *stmtList )
stmtList->append( programExport );
}
-void ConsInit::go()
+void ConsInit::go( long activeRealm )
{
ConsInit::init();
diff --git a/colm/consinit.h b/colm/consinit.h
index b92115a5..27cb0a77 100644
--- a/colm/consinit.h
+++ b/colm/consinit.h
@@ -96,7 +96,7 @@ struct ConsInit
void parseInput( StmtList *stmtList );
void exportTree( StmtList *stmtList );
- void go();
+ virtual void go( long activeRealm );
};
diff --git a/colm/ctinput.cc b/colm/ctinput.cc
index bed408eb..0bee62cc 100644
--- a/colm/ctinput.cc
+++ b/colm/ctinput.cc
@@ -180,7 +180,7 @@ void inputStreamPatternUndoConsumeLangEl( StreamImpl *ss )
int inputStreamPatternConsumeData( StreamImpl *ss, int length )
{
- debug( REALM_INPUT, "consuming %ld bytes\n", length );
+ //debug( REALM_INPUT, "consuming %ld bytes\n", length );
int consumed = 0;
diff --git a/colm/debug.c b/colm/debug.c
index 6d9689e0..2dc8328b 100644
--- a/colm/debug.c
+++ b/colm/debug.c
@@ -20,12 +20,12 @@
*/
#include <colm/debug.h>
+#include <colm/program.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
-long colmActiveRealm = 0;
-const char *colmRealmNames[REALMS] =
+const char *const colmRealmNames[REALMS] =
{
"BYTECODE",
"PARSE",
@@ -37,10 +37,10 @@ const char *colmRealmNames[REALMS] =
"SCAN",
};
-int _debug( long realm, const char *fmt, ... )
+int _debug( struct ColmProgram *prg, long realm, const char *fmt, ... )
{
int result = 0;
- if ( colmActiveRealm & realm ) {
+ if ( prg->activeRealm & realm ) {
/* Compute the index by shifting. */
int ind = 0;
while ( (realm & 0x1) != 0x1 ) {
diff --git a/colm/debug.h b/colm/debug.h
index 3fd9bb8e..aa5656ff 100644
--- a/colm/debug.h
+++ b/colm/debug.h
@@ -28,14 +28,16 @@ extern "C" {
void fatal( const char *fmt, ... );
#ifdef DEBUG
-#define debug( realm, ... ) _debug( realm, __VA_ARGS__ )
+#define debug( prg, realm, ... ) _debug( prg, realm, __VA_ARGS__ )
#define check_realm( realm ) _check_realm( realm )
#else
-#define debug( realm, ... )
+#define debug( prg, realm, ... )
#define check_realm( realm )
#endif
-int _debug( long realm, const char *fmt, ... );
+struct ColmProgram;
+
+int _debug( struct ColmProgram *prg, long realm, const char *fmt, ... );
void message( const char *fmt, ... );
@@ -50,8 +52,7 @@ void message( const char *fmt, ... );
#define REALMS 32
-extern long colmActiveRealm;
-extern const char *colmRealmNames[REALMS];
+extern const char *const colmRealmNames[REALMS];
#ifdef __cplusplus
}
diff --git a/colm/fsmcodegen.h b/colm/fsmcodegen.h
index 3bf28787..7c88dc84 100644
--- a/colm/fsmcodegen.h
+++ b/colm/fsmcodegen.h
@@ -188,7 +188,7 @@ public:
void writeInit();
void writeExec();
void writeCode();
- void writeMain();
+ void writeMain( long activeRealm );
protected:
bool useAgainLabel();
diff --git a/colm/input.c b/colm/input.c
index 0db59567..8c496e40 100644
--- a/colm/input.c
+++ b/colm/input.c
@@ -229,7 +229,7 @@ int fdGetData( StreamImpl *ss, char *dest, int length )
}
if ( length == 0 ) {
- debug( REALM_INPUT, "exiting get data\n", length );
+ //debug( REALM_INPUT, "exiting get data\n", length );
break;
}
@@ -241,7 +241,7 @@ int fdGetData( StreamImpl *ss, char *dest, int length )
int fdConsumeData( StreamImpl *ss, int length )
{
- debug( REALM_INPUT, "source consuming %ld bytes\n", length );
+ //debug( REALM_INPUT, "source consuming %ld bytes\n", length );
int consumed = 0;
@@ -262,7 +262,7 @@ int fdConsumeData( StreamImpl *ss, int length )
if ( avail > 0 ) {
/* The source data from the current buffer. */
int slen = avail <= length ? avail : length;
- debug( REALM_INPUT, "consumed: %.*s\n", slen, buf->data + buf->offset );
+ //debug( REALM_INPUT, "consumed: %.*s\n", slen, buf->data + buf->offset );
consumed += slen;
length -= slen;
buf->offset += slen;
@@ -281,7 +281,7 @@ int fdConsumeData( StreamImpl *ss, int length )
int fdUndoConsumeData( StreamImpl *ss, const char *data, int length )
{
- debug( REALM_INPUT, "undoing consume of %ld bytes\n", length );
+ //debug( REALM_INPUT, "undoing consume of %ld bytes\n", length );
RunBuf *newBuf = newRunBuf();
newBuf->length = length;
@@ -297,7 +297,7 @@ int fdUndoConsumeData( StreamImpl *ss, const char *data, int length )
int fileGetDataSource( StreamImpl *ss, char *dest, int length )
{
- debug( REALM_INPUT, "inputStreamFileGetDataSource length = %ld\n", length );
+ //debug( REALM_INPUT, "inputStreamFileGetDataSource length = %ld\n", length );
size_t res = fread( dest, 1, length, ss->file );
return res;
}
@@ -420,7 +420,7 @@ static int isSourceStream( StreamImpl *is )
static void _setEof( StreamImpl *is )
{
- debug( REALM_INPUT, "setting EOF in input stream\n" );
+ //debug( REALM_INPUT, "setting EOF in input stream\n" );
is->eof = true;
}
@@ -460,7 +460,7 @@ static int _getParseBlock( StreamImpl *is, int skip, char **pdp, int *copied )
// }
if ( type == INPUT_EOD || type == INPUT_EOF ) {
- debug( REALM_INPUT, "skipping over input\n" );
+ //debug( REALM_INPUT, "skipping over input\n" );
buf = buf->next;
continue;
}
@@ -511,22 +511,22 @@ static int _getParseBlock( StreamImpl *is, int skip, char **pdp, int *copied )
#if DEBUG
switch ( ret ) {
case INPUT_DATA:
- debug( REALM_INPUT, "get parse block: DATA: %d\n", *copied );
+ //debug( REALM_INPUT, "get parse block: DATA: %d\n", *copied );
break;
case INPUT_EOD:
- debug( REALM_INPUT, "get parse block: EOD\n" );
+ //debug( REALM_INPUT, "get parse block: EOD\n" );
break;
case INPUT_EOF:
- debug( REALM_INPUT, "get parse block: EOF\n" );
+ //debug( REALM_INPUT, "get parse block: EOF\n" );
break;
case INPUT_TREE:
- debug( REALM_INPUT, "get parse block: TREE\n" );
+ //debug( REALM_INPUT, "get parse block: TREE\n" );
break;
case INPUT_IGNORE:
- debug( REALM_INPUT, "get parse block: IGNORE\n" );
+ //debug( REALM_INPUT, "get parse block: IGNORE\n" );
break;
case INPUT_LANG_EL:
- debug( REALM_INPUT, "get parse block: LANG_EL\n" );
+ //debug( REALM_INPUT, "get parse block: LANG_EL\n" );
break;
}
#endif
@@ -551,7 +551,7 @@ static int _getData( StreamImpl *is, char *dest, int length )
int glen = stream->in->funcs->getData( stream->in, dest+copied, length );
if ( glen == 0 ) {
- debug( REALM_INPUT, "skipping over input\n" );
+ //debug( REALM_INPUT, "skipping over input\n" );
buf = buf->next;
continue;
}
@@ -580,7 +580,7 @@ static int _getData( StreamImpl *is, char *dest, int length )
}
if ( length == 0 ) {
- debug( REALM_INPUT, "exiting get data\n", length );
+ //debug( REALM_INPUT, "exiting get data\n", length );
break;
}
@@ -592,7 +592,7 @@ static int _getData( StreamImpl *is, char *dest, int length )
static int _consumeData( StreamImpl *is, int length )
{
- debug( REALM_INPUT, "consuming %d bytes\n", length );
+ //debug( REALM_INPUT, "consuming %d bytes\n", length );
int consumed = 0;
@@ -606,7 +606,7 @@ static int _consumeData( StreamImpl *is, int length )
if ( buf->type == RunBufSourceType ) {
Stream *stream = (Stream*)buf->tree;
int slen = stream->in->funcs->consumeData( stream->in, length );
- debug( REALM_INPUT, " got %d bytes from source\n", slen );
+ //debug( REALM_INPUT, " got %d bytes from source\n", slen );
consumed += slen;
length -= slen;
@@ -628,7 +628,7 @@ static int _consumeData( StreamImpl *is, int length )
}
if ( length == 0 ) {
- debug( REALM_INPUT, "exiting consume\n", length );
+ //debug( REALM_INPUT, "exiting consume\n", length );
break;
}
@@ -641,7 +641,7 @@ static int _consumeData( StreamImpl *is, int length )
static int _undoConsumeData( StreamImpl *is, const char *data, int length )
{
- debug( REALM_INPUT, "undoing consume of %ld bytes\n", length );
+ //debug( REALM_INPUT, "undoing consume of %ld bytes\n", length );
if ( isSourceStream( is ) ) {
Stream *stream = (Stream*)is->queue->tree;
@@ -756,7 +756,7 @@ static void _prependStream( StreamImpl *in, struct ColmTree *tree )
static int _undoPrependData( StreamImpl *is, int length )
{
- debug( REALM_INPUT, "consuming %d bytes\n", length );
+ //debug( REALM_INPUT, "consuming %d bytes\n", length );
int consumed = 0;
diff --git a/colm/load.cc b/colm/load.cc
index 95d3c084..10f42e3c 100644
--- a/colm/load.cc
+++ b/colm/load.cc
@@ -636,7 +636,7 @@ struct LoadSource
argv[0] = file.data;
argv[1] = 0;
- ColmProgram *program = colmNewProgram( &main_runtimeData );
+ ColmProgram *program = colmNewProgram( &main_runtimeData, 0 );
colmRunProgram( program, 1, argv );
/* Extract the parse tree. */
@@ -1881,10 +1881,10 @@ struct LoadSource
return stmtList;
}
- virtual void go();
+ virtual void go( long activeRealm );
};
-void LoadSource::go()
+void LoadSource::go( long activeRealm )
{
LoadSource::init();
@@ -1893,7 +1893,7 @@ void LoadSource::go()
argv[1] = 0;
colmInit( 0 );
- ColmProgram *program = colmNewProgram( &main_runtimeData );
+ ColmProgram *program = colmNewProgram( &main_runtimeData, activeRealm );
colmRunProgram( program, 1, argv );
/* Extract the parse tree. */
diff --git a/colm/load.h b/colm/load.h
index fab559e9..ebfc8307 100644
--- a/colm/load.h
+++ b/colm/load.h
@@ -19,9 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <iostream>
-#include "avltree.h"
-#include "parsedata.h"
#include "parser.h"
BaseParser *consLoadSource( Compiler *pd, const char *inputFileName );
diff --git a/colm/main.cc b/colm/main.cc
index ed12a716..1a084555 100644
--- a/colm/main.cc
+++ b/colm/main.cc
@@ -89,6 +89,7 @@ bool logging = false;
bool branchPointInfo = false;
bool addUniqueEmptyProductions = false;
bool gblLibrary = false;
+long gblActiveRealm = 0;
ArgsVector includePaths;
@@ -253,7 +254,7 @@ void openOutput( )
}
}
- debug( REALM_PARSE, "opening output file: %s\n", outputFileName );
+ //debug( REALM_PARSE, "opening output file: %s\n", outputFileName );
/* Make sure we are not writing to the same file as the input file. */
if ( outputFileName != 0 && inputFileName != 0 &&
@@ -491,21 +492,21 @@ void processArgs( int argc, const char **argv )
case 'D':
#if DEBUG
if ( strcmp( pc.parameterArg, "BYTECODE" ) == 0 )
- colmActiveRealm |= REALM_BYTECODE;
+ gblActiveRealm |= REALM_BYTECODE;
else if ( strcmp( pc.parameterArg, "PARSE" ) == 0 )
- colmActiveRealm |= REALM_PARSE;
+ gblActiveRealm |= REALM_PARSE;
else if ( strcmp( pc.parameterArg, "MATCH" ) == 0 )
- colmActiveRealm |= REALM_MATCH;
+ gblActiveRealm |= REALM_MATCH;
else if ( strcmp( pc.parameterArg, "COMPILE" ) == 0 )
- colmActiveRealm |= REALM_COMPILE;
+ gblActiveRealm |= REALM_COMPILE;
else if ( strcmp( pc.parameterArg, "POOL" ) == 0 )
- colmActiveRealm |= REALM_POOL;
+ gblActiveRealm |= REALM_POOL;
else if ( strcmp( pc.parameterArg, "PRINT" ) == 0 )
- colmActiveRealm |= REALM_PRINT;
+ gblActiveRealm |= REALM_PRINT;
else if ( strcmp( pc.parameterArg, "INPUT" ) == 0 )
- colmActiveRealm |= REALM_INPUT;
+ gblActiveRealm |= REALM_INPUT;
else if ( strcmp( pc.parameterArg, "SCAN" ) == 0 )
- colmActiveRealm |= REALM_SCAN;
+ gblActiveRealm |= REALM_SCAN;
else
fatal( "unknown argument to -D %s\n", pc.parameterArg );
#else
@@ -540,7 +541,7 @@ int main(int argc, const char **argv)
processArgs( argc, argv );
if ( verbose )
- colmActiveRealm = 0xffffffff;
+ gblActiveRealm = 0xffffffff;
/* Bail on above errors. */
if ( gblErrorCount > 0 )
@@ -583,7 +584,7 @@ int main(int argc, const char **argv)
BaseParser *parser = consLoadSource( pd, inputFileName );
#endif
- parser->go();
+ parser->go( gblActiveRealm );
/* Parsing complete, check for errors.. */
if ( gblErrorCount > 0 )
@@ -601,7 +602,7 @@ int main(int argc, const char **argv)
}
else {
openOutput();
- pd->generateOutput();
+ pd->generateOutput( gblActiveRealm );
if ( outStream != 0 )
delete outStream;
diff --git a/colm/parsedata.h b/colm/parsedata.h
index 7c179a2a..d46fca8e 100644
--- a/colm/parsedata.h
+++ b/colm/parsedata.h
@@ -806,7 +806,7 @@ struct Compiler
void resolveUses();
void createDefaultScanner();
- void generateOutput();
+ void generateOutput( long activeRealm );
void compile();
void openNameSpace( ostream &out, Namespace *nspace );
diff --git a/colm/parser.h b/colm/parser.h
index 0ac8d612..497a968a 100644
--- a/colm/parser.h
+++ b/colm/parser.h
@@ -136,7 +136,7 @@ struct BaseParser
void pushScope();
void popScope();
- virtual void go() = 0;
+ virtual void go( long activeRealm ) = 0;
};
#endif
diff --git a/colm/pdarun.c b/colm/pdarun.c
index 8aba0443..915da819 100644
--- a/colm/pdarun.c
+++ b/colm/pdarun.c
@@ -114,20 +114,20 @@ void undoPosition( StreamImpl *is, const char *data, long length )
void incrementSteps( PdaRun *pdaRun )
{
pdaRun->steps += 1;
- debug( REALM_PARSE, "steps up to %ld\n", pdaRun->steps );
+ //debug( prg, REALM_PARSE, "steps up to %ld\n", pdaRun->steps );
}
void decrementSteps( PdaRun *pdaRun )
{
pdaRun->steps -= 1;
- debug( REALM_PARSE, "steps down to %ld\n", pdaRun->steps );
+ //debug( prg, REALM_PARSE, "steps down to %ld\n", pdaRun->steps );
}
Head *extractMatch( Program *prg, FsmRun *fsmRun, StreamImpl *is )
{
long length = fsmRun->toklen;
- debug( REALM_PARSE, "extracting token of length: %ld\n", length );
+ //debug( prg, REALM_PARSE, "extracting token of length: %ld\n", length );
RunBuf *runBuf = fsmRun->consumeBuf;
if ( runBuf == 0 || length > ( FSM_BUFSIZE - runBuf->length ) ) {
@@ -154,7 +154,7 @@ Head *extractMatch( Program *prg, FsmRun *fsmRun, StreamImpl *is )
head->location->column = is->column;
head->location->byte = is->byte;
- debug( REALM_PARSE, "location byte: %d\n", is->byte );
+ debug( prg, REALM_PARSE, "location byte: %d\n", is->byte );
return head;
}
@@ -184,7 +184,7 @@ Head *peekMatch( Program *prg, FsmRun *fsmRun, StreamImpl *is )
head->location->column = is->column;
head->location->byte = is->byte;
- debug( REALM_PARSE, "location byte: %d\n", is->byte );
+ debug( prg, REALM_PARSE, "location byte: %d\n", is->byte );
return head;
}
@@ -229,7 +229,7 @@ Head *streamPull( Program *prg, PdaRun *pdaRun, StreamImpl *is, long length )
void undoStreamPull( StreamImpl *is, const char *data, long length )
{
- debug( REALM_PARSE, "undoing stream pull\n" );
+ //debug( REALM_PARSE, "undoing stream pull\n" );
is->funcs->prependData( is, data, length );
}
@@ -277,13 +277,13 @@ void undoStreamAppend( Program *prg, Tree **sp, StreamImpl *is, Tree *input, lon
* a previous buffer and slide back data. */
static void sendBackText( FsmRun *fsmRun, StreamImpl *is, const char *data, long length )
{
- debug( REALM_PARSE, "push back of %ld characters\n", length );
+ //debug( REALM_PARSE, "push back of %ld characters\n", length );
if ( length == 0 )
return;
- debug( REALM_PARSE, "sending back text: %.*s\n",
- (int)length, data );
+ //debug( REALM_PARSE, "sending back text: %.*s\n",
+ // (int)length, data );
is->funcs->undoConsumeData( is, data, length );
undoPosition( is, data, length );
@@ -303,7 +303,7 @@ static void sendBackIgnore( Program *prg, Tree **sp, PdaRun *pdaRun, FsmRun *fsm
{
#ifdef DEBUG
LangElInfo *lelInfo = prg->rtd->lelInfo;
- debug( REALM_PARSE, "sending back: %s%s\n",
+ debug( prg, REALM_PARSE, "sending back: %s%s\n",
lelInfo[parseTree->shadow->tree->id].name,
parseTree->flags & PF_ARTIFICIAL ? " (artificial)" : "" );
#endif
@@ -323,7 +323,7 @@ static void sendBackIgnore( Program *prg, Tree **sp, PdaRun *pdaRun, FsmRun *fsm
}
if ( pdaRun->steps == pdaRun->targetSteps ) {
- debug( REALM_PARSE, "trigger parse stop, steps = target = %d\n", pdaRun->targetSteps );
+ debug( prg, REALM_PARSE, "trigger parse stop, steps = target = %d\n", pdaRun->targetSteps );
pdaRun->stop = true;
}
}
@@ -361,7 +361,7 @@ void resetToken( PdaRun *pdaRun )
static void sendBack( Program *prg, Tree **sp, PdaRun *pdaRun, FsmRun *fsmRun,
StreamImpl *is, ParseTree *parseTree )
{
- debug( REALM_PARSE, "sending back: %s\n", prg->rtd->lelInfo[parseTree->id].name );
+ debug( prg, REALM_PARSE, "sending back: %s\n", prg->rtd->lelInfo[parseTree->id].name );
if ( parseTree->flags & PF_NAMED ) {
///* Send back anything in the buffer that has not been parsed. */
@@ -379,7 +379,7 @@ static void sendBack( Program *prg, Tree **sp, PdaRun *pdaRun, FsmRun *fsmRun,
if ( parseTree->flags & PF_ARTIFICIAL ) {
/* Check for reverse code. */
if ( parseTree->flags & PF_HAS_RCODE ) {
- debug( REALM_PARSE, "tree has rcode, setting on deck\n" );
+ debug( prg, REALM_PARSE, "tree has rcode, setting on deck\n" );
pdaRun->onDeck = true;
parseTree->flags &= ~PF_HAS_RCODE;
}
@@ -391,7 +391,7 @@ static void sendBack( Program *prg, Tree **sp, PdaRun *pdaRun, FsmRun *fsmRun,
else {
/* Check for reverse code. */
if ( parseTree->flags & PF_HAS_RCODE ) {
- debug( REALM_PARSE, "tree has rcode, setting on deck\n" );
+ debug( prg, REALM_PARSE, "tree has rcode, setting on deck\n" );
pdaRun->onDeck = true;
parseTree->flags &= ~PF_HAS_RCODE;
}
@@ -409,7 +409,7 @@ static void sendBack( Program *prg, Tree **sp, PdaRun *pdaRun, FsmRun *fsmRun,
}
if ( pdaRun->steps == pdaRun->targetSteps ) {
- debug( REALM_PARSE, "trigger parse stop, steps = target = %d\n", pdaRun->targetSteps );
+ debug( prg, REALM_PARSE, "trigger parse stop, steps = target = %d\n", pdaRun->targetSteps );
pdaRun->stop = true;
}
@@ -480,7 +480,7 @@ Kid *makeTokenWithData( Program *prg, PdaRun *pdaRun, FsmRun *fsmRun,
input = kidAllocate( prg );
input->tree = treeAllocate( prg );
- debug( REALM_PARSE, "made token %p\n", input->tree );
+ debug( prg, REALM_PARSE, "made token %p\n", input->tree );
input->tree->refs = 1;
input->tree->id = id;
@@ -535,7 +535,7 @@ static void reportParseError( Program *prg, Tree **sp, PdaRun *pdaRun )
if ( deepest == 0 )
errorHead = stringAllocFull( prg, "PARSE ERROR at 1:1", 18 );
else {
- debug( REALM_PARSE, "deepest location byte: %d\n", deepest->location->byte );
+ debug( prg, REALM_PARSE, "deepest location byte: %d\n", deepest->location->byte );
long line = deepest->location->line;
long i, column = deepest->location->column;
@@ -567,7 +567,7 @@ static void attachRightIgnore( Program *prg, Tree **sp, PdaRun *pdaRun, ParseTre
if ( pdaRun->stackTop->id > 0 && pdaRun->stackTop->id < prg->rtd->firstNonTermId ) {
/* OK, do it */
- debug( REALM_PARSE, "attaching right ignore\n" );
+ debug( prg, REALM_PARSE, "attaching right ignore\n" );
/* Reset. */
assert( ! ( parseTree->flags & PF_RIGHT_IL_ATTACHED ) );
@@ -619,7 +619,7 @@ static void attachRightIgnore( Program *prg, Tree **sp, PdaRun *pdaRun, ParseTre
parseTree->rightIgnore = last;
if ( dataChild != 0 ) {
- debug( REALM_PARSE, "attaching ignore right\n" );
+ debug( prg, REALM_PARSE, "attaching ignore right\n" );
Kid *ignoreKid = dataLast;
@@ -677,7 +677,7 @@ static void attachLeftIgnore( Program *prg, Tree **sp, PdaRun *pdaRun, ParseTree
parseTree->leftIgnore = last;
if ( dataChild != 0 ) {
- debug( REALM_PARSE, "attaching left ignore\n" );
+ debug( prg, REALM_PARSE, "attaching left ignore\n" );
Kid *ignoreKid = dataChild;
@@ -809,7 +809,7 @@ void handleError( Program *prg, Tree **sp, PdaRun *pdaRun )
}
else {
if ( isParserStopFinished( pdaRun ) ) {
- debug( REALM_PARSE, "stopping the parse\n" );
+ debug( prg, REALM_PARSE, "stopping the parse\n" );
pdaRun->stopParsing = true;
}
}
@@ -817,13 +817,13 @@ void handleError( Program *prg, Tree **sp, PdaRun *pdaRun )
void sendIgnore( Program *prg, Tree **sp, StreamImpl *is, FsmRun *fsmRun, PdaRun *pdaRun, long id )
{
- debug( REALM_PARSE, "ignoring: %s\n", prg->rtd->lelInfo[id].name );
+ debug( prg, REALM_PARSE, "ignoring: %s\n", prg->rtd->lelInfo[id].name );
/* Make the ignore string. */
Head *ignoreStr = extractMatch( prg, fsmRun, is );
updatePosition( is, ignoreStr->data, ignoreStr->length );
- debug( REALM_PARSE, "ignoring: %.*s\n", ignoreStr->length, ignoreStr->data );
+ debug( prg, REALM_PARSE, "ignoring: %.*s\n", ignoreStr->length, ignoreStr->data );
Tree *tree = treeAllocate( prg );
tree->refs = 1;
@@ -842,7 +842,7 @@ static void sendToken( Program *prg, Tree **sp, StreamImpl *is, FsmRun *fsmRun,
/* Make the token data. */
Head *tokdata = extractMatch( prg, fsmRun, is );
- debug( REALM_PARSE, "token: %s text: %.*s\n",
+ debug( prg, REALM_PARSE, "token: %s text: %.*s\n",
prg->rtd->lelInfo[id].name,
stringLength(tokdata), stringData(tokdata) );
@@ -886,7 +886,7 @@ static void sendIgnoreTree( Program *prg, Tree **sp, PdaRun *pdaRun, FsmRun *fsm
static void sendCi( Program *prg, Tree **sp, StreamImpl *is, FsmRun *fsmRun, PdaRun *pdaRun, int id )
{
- debug( REALM_PARSE, "token: CI\n" );
+ debug( prg, REALM_PARSE, "token: CI\n" );
/**/
@@ -899,7 +899,7 @@ static void sendCi( Program *prg, Tree **sp, StreamImpl *is, FsmRun *fsmRun, Pda
tokdata->location->column = is->column;
tokdata->location->byte = is->byte;
- debug( REALM_PARSE, "token: %s text: %.*s\n",
+ debug( prg, REALM_PARSE, "token: %s text: %.*s\n",
prg->rtd->lelInfo[id].name,
stringLength(tokdata), stringData(tokdata) );
@@ -923,7 +923,7 @@ static void sendCi( Program *prg, Tree **sp, StreamImpl *is, FsmRun *fsmRun, Pda
static void sendEof( Program *prg, Tree **sp, StreamImpl *is, FsmRun *fsmRun, PdaRun *pdaRun )
{
- debug( REALM_PARSE, "token: _EOF\n" );
+ debug( prg, REALM_PARSE, "token: _EOF\n" );
incrementSteps( pdaRun );
@@ -989,7 +989,7 @@ static void pushBtPoint( Program *prg, PdaRun *pdaRun )
tree = pdaRun->tokenList->kid->tree;
if ( tree != 0 ) {
- debug( REALM_PARSE, "pushing bt point with location byte %d\n",
+ debug( prg, REALM_PARSE, "pushing bt point with location byte %d\n",
( tree != 0 && tree->tokdata != 0 && tree->tokdata->location != 0 ) ?
tree->tokdata->location->byte : 0 );
@@ -1030,7 +1030,7 @@ long scanToken( Program *prg, PdaRun *pdaRun, FsmRun *fsmRun, StreamImpl *is )
fsmRun->p = fsmRun->pe = 0;
if ( fsmRun->tokstart != 0 )
fsmRun->eof = 1;
- debug( REALM_SCAN, "EOS *******************\n" );
+ debug( prg, REALM_SCAN, "EOS *******************\n" );
break;
case INPUT_EOF:
@@ -1127,7 +1127,7 @@ case PcrStart:
pdaRun->stop = false;
while ( true ) {
- debug( REALM_PARSE, "parse loop start %d:%d\n", is->line, is->column );
+ debug( prg, REALM_PARSE, "parse loop start %d:%d\n", is->line, is->column );
/* Pull the current scanner from the parser. This can change during
* parsing due to inputStream pushes, usually for the purpose of includes.
@@ -1145,13 +1145,13 @@ case PcrStart:
if ( pdaRun->tokenId == SCAN_ERROR &&
( prg->rtd->regionInfo[fsmRun->region].ciLelId > 0 ) )
{
- debug( REALM_PARSE, "sending a collect ignore\n" );
+ debug( prg, REALM_PARSE, "sending a collect ignore\n" );
sendCi( prg, sp, is, fsmRun, pdaRun, prg->rtd->regionInfo[fsmRun->region].ciLelId );
goto yes;
}
if ( pdaRun->tokenId == SCAN_TRY_AGAIN_LATER ) {
- debug( REALM_PARSE, "scanner says try again later\n" );
+ debug( prg, REALM_PARSE, "scanner says try again later\n" );
break;
}
@@ -1166,7 +1166,7 @@ case PcrStart:
pdaRun->frameId = prg->rtd->regionInfo[fsmRun->region].eofFrameId;
if ( prg->ctxDepParsing && pdaRun->frameId >= 0 ) {
- debug( REALM_PARSE, "HAVE PRE_EOF BLOCK\n" );
+ debug( prg, REALM_PARSE, "HAVE PRE_EOF BLOCK\n" );
pdaRun->fi = &prg->rtd->frameInfo[pdaRun->frameId];
pdaRun->code = pdaRun->fi->codeWV;
@@ -1178,24 +1178,24 @@ case PcrPreEof:
}
else if ( pdaRun->tokenId == SCAN_UNDO ) {
/* Fall through with parseInput = 0. FIXME: Do we need to send back ignore? */
- debug( REALM_PARSE, "invoking undo from the scanner\n" );
+ debug( prg, REALM_PARSE, "invoking undo from the scanner\n" );
}
else if ( pdaRun->tokenId == SCAN_ERROR ) {
/* Scanner error, maybe retry. */
if ( pdaRun->accumIgnore == 0 && pdaRunGetNextRegion( pdaRun, 1 ) != 0 ) {
- debug( REALM_PARSE, "scanner failed, trying next region\n" );
+ debug( prg, REALM_PARSE, "scanner failed, trying next region\n" );
pdaRun->nextRegionInd += 1;
goto skipSend;
}
else if ( pdaRun->numRetry > 0 ) {
- debug( REALM_PARSE, "invoking parse error from the scanner\n" );
+ debug( prg, REALM_PARSE, "invoking parse error from the scanner\n" );
/* Fall through to send null (error). */
pushBtPoint( prg, pdaRun );
}
else {
- debug( REALM_PARSE, "no alternate scanning regions\n" );
+ debug( prg, REALM_PARSE, "no alternate scanning regions\n" );
/* There are no alternative scanning regions to try, nor are
* there any alternatives stored in the current parse tree. No
@@ -1208,19 +1208,19 @@ case PcrPreEof:
}
}
else if ( pdaRun->tokenId == SCAN_LANG_EL ) {
- debug( REALM_PARSE, "sending an named lang el\n" );
+ debug( prg, REALM_PARSE, "sending an named lang el\n" );
/* A named language element (parsing colm program). */
prg->rtd->sendNamedLangEl( prg, sp, pdaRun, fsmRun, is );
}
else if ( pdaRun->tokenId == SCAN_TREE ) {
- debug( REALM_PARSE, "sending a tree\n" );
+ debug( prg, REALM_PARSE, "sending a tree\n" );
/* A tree already built. */
sendTree( prg, sp, pdaRun, fsmRun, is );
}
else if ( pdaRun->tokenId == SCAN_IGNORE ) {
- debug( REALM_PARSE, "sending an ignore token\n" );
+ debug( prg, REALM_PARSE, "sending an ignore token\n" );
/* A tree to ignore. */
sendIgnoreTree( prg, sp, pdaRun, fsmRun, is );
@@ -1228,7 +1228,7 @@ case PcrPreEof:
}
else if ( prg->ctxDepParsing && lelInfo[pdaRun->tokenId].frameId >= 0 ) {
/* Has a generation action. */
- debug( REALM_PARSE, "token gen action: %s\n",
+ debug( prg, REALM_PARSE, "token gen action: %s\n",
prg->rtd->lelInfo[pdaRun->tokenId].name );
/* Make the token data. */
@@ -1256,7 +1256,7 @@ case PcrGeneration:
goto skipSend;
}
else if ( lelInfo[pdaRun->tokenId].ignore ) {
- debug( REALM_PARSE, "sending an ignore token: %s\n",
+ debug( prg, REALM_PARSE, "sending an ignore token: %s\n",
prg->rtd->lelInfo[pdaRun->tokenId].name );
/* Is an ignore token. */
@@ -1264,7 +1264,7 @@ case PcrGeneration:
goto skipSend;
}
else {
- debug( REALM_PARSE, "sending an a plain old token: %s\n",
+ debug( prg, REALM_PARSE, "sending an a plain old token: %s\n",
prg->rtd->lelInfo[pdaRun->tokenId].name );
/* Is a plain token. */
@@ -1305,32 +1305,32 @@ skipSend:
* eventually. */
if ( pdaRun->triggerUndo ) {
- debug( REALM_PARSE, "parsing stopped by triggerUndo\n" );
+ debug( prg, REALM_PARSE, "parsing stopped by triggerUndo\n" );
break;
}
if ( is->eofSent ) {
- debug( REALM_PARSE, "parsing stopped by EOF\n" );
+ debug( prg, REALM_PARSE, "parsing stopped by EOF\n" );
break;
}
if ( pdaRun->stopParsing ) {
- debug( REALM_PARSE, "scanner has been stopped\n" );
+ debug( prg, REALM_PARSE, "scanner has been stopped\n" );
break;
}
if ( pdaRun->stop ) {
- debug( REALM_PARSE, "parsing has been stopped by consumedCount\n" );
+ debug( prg, REALM_PARSE, "parsing has been stopped by consumedCount\n" );
break;
}
if ( prg->induceExit ) {
- debug( REALM_PARSE, "parsing has been stopped by a call to exit\n" );
+ debug( prg, REALM_PARSE, "parsing has been stopped by a call to exit\n" );
break;
}
if ( pdaRun->parseError ) {
- debug( REALM_PARSE, "parsing stopped by a parse error\n" );
+ debug( prg, REALM_PARSE, "parsing stopped by a parse error\n" );
break;
}
}
@@ -1466,7 +1466,7 @@ void initPdaRun( Program *prg, PdaRun *pdaRun, PdaTables *tables,
pdaRun->revertOn = revertOn;
pdaRun->targetSteps = -1;
- debug( REALM_PARSE, "initializing PdaRun\n" );
+ debug( prg, REALM_PARSE, "initializing PdaRun\n" );
/* FIXME: need the right one here. */
pdaRun->cs = prg->rtd->startStates[pdaRun->parserId];
@@ -1562,7 +1562,7 @@ void commitKid( Program *prg, PdaRun *pdaRun, Tree **root, ParseTree *lel, Code
head:
/* Commit */
- debug( REALM_PARSE, "commit: visiting %s\n",
+ debug( prg, REALM_PARSE, "commit: visiting %s\n",
prg->rtd->lelInfo[lel->id].name );
/* Load up the parsed tree. */
@@ -1576,7 +1576,7 @@ head:
* the count of the reductions and do it when the count drops to zero. */
if ( tree->causeReduce > 0 ) {
/* The top reduce block does not correspond to this alg. */
- debug( REALM_PARSE, "commit: causeReduce found, delaying backup: %ld\n",
+ debug( prg, REALM_PARSE, "commit: causeReduce found, delaying backup: %ld\n",
(long)tree->causeReduce );
*causeReduce = tree->causeReduce;
}
@@ -1584,7 +1584,7 @@ head:
*rcode = backupOverRcode( *rcode );
//if ( **rcode == IN_RESTORE_LHS ) {
- // debug( REALM_PARSE, "commit: has restore_lhs\n" );
+ // debug( prg, REALM_PARSE, "commit: has restore_lhs\n" );
// read_tree_p( restore, (*rcode+1) );
//}
}
@@ -1607,7 +1607,7 @@ head:
*causeReduce -= 1;
if ( *causeReduce == 0 ) {
- debug( REALM_PARSE, "commit: causeReduce dropped to zero, backing up over rcode\n" );
+ debug( prg, REALM_PARSE, "commit: causeReduce dropped to zero, backing up over rcode\n" );
/* Cause reduce just dropped down to zero. */
*rcode = backupOverRcode( *rcode );
@@ -1670,7 +1670,7 @@ backup:
void commitFull( Program *prg, Tree **sp, PdaRun *pdaRun, long causeReduce )
{
- debug( REALM_PARSE, "running full commit\n" );
+ debug( prg, REALM_PARSE, "running full commit\n" );
ParseTree *parseTree = pdaRun->stackTop;
Code *rcode = pdaRun->reverseCode.data + pdaRun->reverseCode.tabLen;
@@ -1734,7 +1734,7 @@ again:
if ( pdaRun->lel->id < pdaRun->tables->keys[pdaRun->curState<<1] ||
pdaRun->lel->id > pdaRun->tables->keys[(pdaRun->curState<<1)+1] ) {
- debug( REALM_PARSE, "parse error, no transition 1\n" );
+ debug( prg, REALM_PARSE, "parse error, no transition 1\n" );
pushBtPoint( prg, pdaRun );
goto parseError;
}
@@ -1744,14 +1744,14 @@ again:
owner = pdaRun->tables->owners[indPos];
if ( owner != pdaRun->curState ) {
- debug( REALM_PARSE, "parse error, no transition 2\n" );
+ debug( prg, REALM_PARSE, "parse error, no transition 2\n" );
pushBtPoint( prg, pdaRun );
goto parseError;
}
pos = pdaRun->tables->indicies[indPos];
if ( pos < 0 ) {
- debug( REALM_PARSE, "parse error, no transition 3\n" );
+ debug( prg, REALM_PARSE, "parse error, no transition 3\n" );
pushBtPoint( prg, pdaRun );
goto parseError;
}
@@ -1769,7 +1769,7 @@ again:
*/
if ( *action & act_sb ) {
- debug( REALM_PARSE, "shifted: %s\n",
+ debug( prg, REALM_PARSE, "shifted: %s\n",
prg->rtd->lelInfo[pdaRun->lel->id].name );
/* Consume. */
pdaRun->parseInput = pdaRun->parseInput->next;
@@ -1801,7 +1801,7 @@ again:
if ( action[1] == 0 )
pdaRun->lel->retryLower = 0;
else {
- debug( REALM_PARSE, "retry: %p\n", pdaRun->stackTop );
+ debug( prg, REALM_PARSE, "retry: %p\n", pdaRun->stackTop );
pdaRun->lel->retryLower += 1;
assert( pdaRun->lel->retryUpper == 0 );
/* FIXME: Has the retry already been counted? */
@@ -1893,7 +1893,7 @@ again:
pdaRun->redLel->child = child;
pdaRun->redLel->shadow->tree->child = kidListConcat( attrs, dataChild );
- debug( REALM_PARSE, "reduced: %s rhsLen %d\n",
+ debug( prg, REALM_PARSE, "reduced: %s rhsLen %d\n",
prg->rtd->prodInfo[pdaRun->reduction].name, rhsLen );
if ( action[1] == 0 )
pdaRun->redLel->retryUpper = 0;
@@ -1901,7 +1901,7 @@ again:
pdaRun->redLel->retryUpper += 1;
assert( pdaRun->lel->retryLower == 0 );
pdaRun->numRetry += 1;
- debug( REALM_PARSE, "retry: %p\n", pdaRun->redLel );
+ debug( prg, REALM_PARSE, "retry: %p\n", pdaRun->redLel );
}
/* When the production is of zero length we stay in the same state.
@@ -1927,7 +1927,7 @@ case PcrReduction:
* copy above. */
if ( pdaRun->parsed != 0 ) {
if ( pdaRun->parsed != pdaRun->redLel->shadow->tree ) {
- debug( REALM_PARSE, "lhs tree was modified, adding a restore instruction\n" );
+ debug( prg, REALM_PARSE, "lhs tree was modified, adding a restore instruction\n" );
//
// /* Make it into a parse tree. */
// Tree *newPt = prepParseTree( prg, sp, pdaRun->redLel->tree );
@@ -1964,7 +1964,7 @@ case PcrReduction:
* when going backwards and when doing a commit. */
if ( induceReject ) {
- debug( REALM_PARSE, "error induced during reduction of %s\n",
+ debug( prg, REALM_PARSE, "error induced during reduction of %s\n",
prg->rtd->lelInfo[pdaRun->redLel->id].name );
pdaRun->redLel->state = pdaRun->curState;
pdaRun->redLel->next = pdaRun->stackTop;
@@ -1981,16 +1981,16 @@ case PcrReduction:
goto again;
parseError:
- debug( REALM_PARSE, "hit error, backtracking\n" );
+ debug( prg, REALM_PARSE, "hit error, backtracking\n" );
if ( pdaRun->numRetry == 0 ) {
- debug( REALM_PARSE, "out of retries failing parse\n" );
+ debug( prg, REALM_PARSE, "out of retries failing parse\n" );
goto fail;
}
while ( 1 ) {
if ( pdaRun->onDeck ) {
- debug( REALM_BYTECODE, "dropping out for reverse code call\n" );
+ debug( prg, REALM_BYTECODE, "dropping out for reverse code call\n" );
pdaRun->frameId = -1;
pdaRun->code = popReverseCode( &pdaRun->reverseCode );
@@ -2004,7 +2004,7 @@ case PcrReverse:
pdaRun->checkNext = false;
if ( pdaRun->next > 0 && pdaRun->tables->tokenRegions[pdaRun->next] != 0 ) {
- debug( REALM_PARSE, "found a new region\n" );
+ debug( prg, REALM_PARSE, "found a new region\n" );
pdaRun->numRetry -= 1;
pdaRun->cs = stackTopTarget( prg, pdaRun );
pdaRun->nextRegionInd = pdaRun->next;
@@ -2015,7 +2015,7 @@ case PcrReverse:
pdaRun->checkStop = false;
if ( pdaRun->stop ) {
- debug( REALM_PARSE, "stopping the backtracking, steps is %d\n", pdaRun->steps );
+ debug( prg, REALM_PARSE, "stopping the backtracking, steps is %d\n", pdaRun->steps );
pdaRun->cs = stackTopTarget( prg, pdaRun );
goto _out;
@@ -2028,7 +2028,7 @@ case PcrReverse:
assert( pdaRun->parseInput->retryUpper == 0 );
if ( pdaRun->parseInput->retryLower != 0 ) {
- debug( REALM_PARSE, "found retry targ: %p\n", pdaRun->parseInput );
+ debug( prg, REALM_PARSE, "found retry targ: %p\n", pdaRun->parseInput );
pdaRun->numRetry -= 1;
pdaRun->cs = pdaRun->parseInput->state;
@@ -2049,7 +2049,7 @@ case PcrReverse:
* shifted or a nonterminal that was reduced. */
assert( !(pdaRun->stackTop->id < prg->rtd->firstNonTermId) );
- debug( REALM_PARSE, "backing up over non-terminal: %s\n",
+ debug( prg, REALM_PARSE, "backing up over non-terminal: %s\n",
prg->rtd->lelInfo[pdaRun->stackTop->id].name );
/* Pop the item from the stack. */
@@ -2071,7 +2071,7 @@ case PcrReverse:
}
}
else if ( pdaRun->parseInput->flags & PF_HAS_RCODE ) {
- debug( REALM_PARSE, "tree has rcode, setting on deck\n" );
+ debug( prg, REALM_PARSE, "tree has rcode, setting on deck\n" );
pdaRun->onDeck = true;
pdaRun->parsed = 0;
@@ -2140,7 +2140,7 @@ case PcrReverse:
}
}
else if ( pdaRun->accumIgnore != 0 ) {
- debug( REALM_PARSE, "have accumulated ignore to undo\n" );
+ debug( prg, REALM_PARSE, "have accumulated ignore to undo\n" );
/* Send back any accumulated ignore tokens, then trigger error
* in the the parser. */
@@ -2174,7 +2174,7 @@ case PcrReverse:
/* Either we are dealing with a terminal that was
* shifted or a nonterminal that was reduced. */
if ( pdaRun->stackTop->id < prg->rtd->firstNonTermId ) {
- debug( REALM_PARSE, "backing up over effective terminal: %s\n",
+ debug( prg, REALM_PARSE, "backing up over effective terminal: %s\n",
prg->rtd->lelInfo[pdaRun->stackTop->id].name );
/* Pop the item from the stack. */
@@ -2193,7 +2193,7 @@ case PcrReverse:
detachLeftIgnore( prg, sp, pdaRun, fsmRun, pdaRun->parseInput );
}
else {
- debug( REALM_PARSE, "backing up over non-terminal: %s\n",
+ debug( prg, REALM_PARSE, "backing up over non-terminal: %s\n",
prg->rtd->lelInfo[pdaRun->stackTop->id].name );
/* Pop the item from the stack. */
diff --git a/colm/pool.c b/colm/pool.c
index a6c31593..93cabd2a 100644
--- a/colm/pool.c
+++ b/colm/pool.c
@@ -36,7 +36,7 @@ void initPoolAlloc( PoolAlloc *poolAlloc, int sizeofT )
void *poolAllocAllocate( PoolAlloc *poolAlloc )
{
- debug( REALM_POOL, "pool allocation\n" );
+ //debug( REALM_POOL, "pool allocation\n" );
#ifdef POOL_MALLOC
void *res = malloc( poolAlloc->sizeofT );
diff --git a/colm/program.c b/colm/program.c
index 09eba258..aececce1 100644
--- a/colm/program.c
+++ b/colm/program.c
@@ -36,9 +36,6 @@
void colmInit( long debugRealm )
{
- /* Always on because because logging is controlled with ifdefs in\n" the
- * runtime lib. */
- colmActiveRealm = debugRealm;
}
void clearGlobal( Program *prg, Tree **sp )
@@ -186,11 +183,13 @@ Tree *returnVal( struct ColmProgram *prg )
return prg->returnVal;
}
-Program *colmNewProgram( RuntimeData *rtd )
+Program *colmNewProgram( RuntimeData *rtd, long activeRealm )
{
Program *prg = malloc(sizeof(Program));
memset( prg, 0, sizeof(Program) );
+ prg->activeRealm = activeRealm;
+
assert( sizeof(Int) <= sizeof(Tree) );
assert( sizeof(Str) <= sizeof(Tree) );
assert( sizeof(Pointer) <= sizeof(Tree) );
diff --git a/colm/program.h b/colm/program.h
index 486c854e..5f1e88ed 100644
--- a/colm/program.h
+++ b/colm/program.h
@@ -100,6 +100,8 @@ typedef struct ColmRuntimeData
typedef struct ColmProgram
{
+ long activeRealm;
+
int argc;
const char **argv;
diff --git a/colm/tree.c b/colm/tree.c
index 2e95afa3..b1b46355 100644
--- a/colm/tree.c
+++ b/colm/tree.c
@@ -2098,7 +2098,7 @@ void appendFd( struct ColmPrintArgs *args, const char *data, int length )
Tree *treeTrim( struct ColmProgram *prg, Tree **sp, Tree *tree )
{
- debug( REALM_PARSE, "attaching left ignore\n" );
+ debug( prg, REALM_PARSE, "attaching left ignore\n" );
/* Make the ignore list for the left-ignore. */
Tree *leftIgnore = treeAllocate( prg );
@@ -2107,7 +2107,7 @@ Tree *treeTrim( struct ColmProgram *prg, Tree **sp, Tree *tree )
tree = pushLeftIgnore( prg, tree, leftIgnore );
- debug( REALM_PARSE, "attaching ignore right\n" );
+ debug( prg, REALM_PARSE, "attaching ignore right\n" );
/* Copy the ignore list first if we need to attach it as a right
* ignore. */
@@ -2186,10 +2186,10 @@ rec_call:
else
visitType = NonTerm;
- debug( REALM_PRINT, "visit type: %d\n", visitType );
+ debug( prg, REALM_PRINT, "visit type: %d\n", visitType );
if ( visitType == IgnoreData ) {
- debug( REALM_PRINT, "putting %p on ignore list\n", kid->tree );
+ debug( prg, REALM_PRINT, "putting %p on ignore list\n", kid->tree );
Kid *newIgnore = kidAllocate( prg );
newIgnore->next = leadingIgnore;
leadingIgnore = newIgnore;
@@ -2219,7 +2219,7 @@ rec_call:
if ( leadingIgnore->tree->flags & AF_SUPPRESS_LEFT ) {
/* We are moving left. Chop off the tail. */
- debug( REALM_PRINT, "suppressing left\n" );
+ debug( prg, REALM_PRINT, "suppressing left\n" );
freeKidList( prg, next );
break;
}
@@ -2250,7 +2250,7 @@ rec_call:
kid = ignore;
parent = 0;
- debug( REALM_PRINT, "rec call on %p\n", kid->tree );
+ debug( prg, REALM_PRINT, "rec call on %p\n", kid->tree );
vm_push( (SW) RecIgnoreList );
goto rec_call;
rec_return_il:
@@ -2283,7 +2283,7 @@ rec_call:
if ( visitType == Term || visitType == IgnoreData ) {
/* Print contents. */
if ( kid->tree->id < prg->rtd->firstNonTermId ) {
- debug( REALM_PRINT, "printing terminal %p\n", kid->tree );
+ debug( prg, REALM_PRINT, "printing terminal %p\n", kid->tree );
if ( kid->tree->id != 0 )
printArgs->printTerm( prg, sp, printArgs, kid );
}
@@ -2321,7 +2321,7 @@ skip_node:
/* If not currently skipping ignore data, then print it. Ignore data can
* be associated with terminals and nonterminals. */
if ( kid->tree->flags & AF_RIGHT_IGNORE ) {
- debug( REALM_PRINT, "right ignore\n" );
+ debug( prg, REALM_PRINT, "right ignore\n" );
vm_push( (SW)parent );
vm_push( (SW)kid );
parent = kid;
@@ -2339,20 +2339,20 @@ skip_null:
rt = (enum ReturnType)vm_pop();
switch ( rt ) {
case Done:
- debug( REALM_PRINT, "return: done\n" );
+ debug( prg, REALM_PRINT, "return: done\n" );
goto rec_return_top;
break;
case CollectIgnoreLeft:
- debug( REALM_PRINT, "return: ignore left\n" );
+ debug( prg, REALM_PRINT, "return: ignore left\n" );
goto rec_return_ign_left;
case CollectIgnoreRight:
- debug( REALM_PRINT, "return: ignore right\n" );
+ debug( prg, REALM_PRINT, "return: ignore right\n" );
goto rec_return_ign_right;
case RecIgnoreList:
- debug( REALM_PRINT, "return: ignore list\n" );
+ debug( prg, REALM_PRINT, "return: ignore list\n" );
goto rec_return_il;
case ChildPrint:
- debug( REALM_PRINT, "return: child print\n" );
+ debug( prg, REALM_PRINT, "return: child print\n" );
goto rec_return;
}
}
@@ -2381,7 +2381,7 @@ void printTreeArgs( Program *prg, Tree **sp, struct ColmPrintArgs *printArgs, Tr
void printTermTree( Program *prg, Tree **sp, struct ColmPrintArgs *printArgs, Kid *kid )
{
- debug( REALM_PRINT, "printing term %p\n", kid->tree );
+ debug( prg, REALM_PRINT, "printing term %p\n", kid->tree );
if ( kid->tree->id == LEL_ID_INT ) {
char buf[INT_SZ];