diff options
author | Adrian Thurston <thurston@complang.org> | 2014-12-25 16:02:14 -0500 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2014-12-25 16:02:14 -0500 |
commit | e9a6e75710c42ab1a80c3cf54c5131e2bc4329e1 (patch) | |
tree | 1037ec581e8d9e88b46a3dd26812512cdc44bb48 | |
parent | 4bd915e48b6b6278ed8c4b7be95781535f2ce10a (diff) | |
download | colm-e9a6e75710c42ab1a80c3cf54c5131e2bc4329e1.tar.gz |
converted the global object to a struct
-rw-r--r-- | src/bytecode.c | 167 | ||||
-rw-r--r-- | src/bytecode.h | 43 | ||||
-rw-r--r-- | src/compiler.cc | 2 | ||||
-rw-r--r-- | src/compiler.h | 2 | ||||
-rw-r--r-- | src/consinit.cc | 2 | ||||
-rw-r--r-- | src/declare.cc | 13 | ||||
-rw-r--r-- | src/loadinit.cc | 1 | ||||
-rw-r--r-- | src/parser.cc | 10 | ||||
-rw-r--r-- | src/parsetree.h | 5 | ||||
-rw-r--r-- | src/pdabuild.cc | 2 | ||||
-rw-r--r-- | src/pdacodegen.cc | 1 | ||||
-rw-r--r-- | src/program.c | 31 | ||||
-rw-r--r-- | src/program.h | 1 | ||||
-rw-r--r-- | src/struct.c | 12 | ||||
-rw-r--r-- | src/struct.h | 2 | ||||
-rw-r--r-- | src/synthesis.cc | 27 |
16 files changed, 186 insertions, 135 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index 0f2a078d..f526476c 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -780,18 +780,20 @@ again: vm_push( exec->parser->pdaRun->context ); break; } + + /* + * LOAD_GLOBAL + */ case IN_LOAD_GLOBAL_R: { debug( prg, REALM_BYTECODE, "IN_LOAD_GLOBAL_R\n" ); - treeUpref( prg->global ); - vm_push( prg->global ); + vm_push_val( prg->global ); break; } case IN_LOAD_GLOBAL_WV: { debug( prg, REALM_BYTECODE, "IN_LOAD_GLOBAL_WV\n" ); - treeUpref( prg->global ); - vm_push( prg->global ); + vm_push_val( prg->global ); /* Set up the reverse instruction. */ rcodeUnitStart( exec ); @@ -803,17 +805,16 @@ again: /* This is identical to the _R version, but using it for writing * would be confusing. */ - treeUpref( prg->global ); - vm_push( prg->global ); + vm_push_val( prg->global ); break; } case IN_LOAD_GLOBAL_BKT: { debug( prg, REALM_BYTECODE, "IN_LOAD_GLOBAL_BKT\n" ); - treeUpref( prg->global ); - vm_push( prg->global ); + vm_push_val( prg->global ); break; } + case IN_LOAD_PARSER_R: { debug( prg, REALM_BYTECODE, "IN_LOAD_PARSER_R\n" ); @@ -3490,17 +3491,6 @@ again: vm_push( 0 ); break; } - case IN_INIT_LOCALS: { - Half size; - read_half( size ); - - debug( prg, REALM_BYTECODE, "IN_INIT_LOCALS %hd\n", size ); - - exec->framePtr = vm_ptop(); - vm_pushn( size ); - memset( vm_ptop(), 0, sizeof(Word) * size ); - break; - } case IN_CALL_WV: { Half funcId; read_half( funcId ); @@ -3738,28 +3728,6 @@ again: vm_push( (Tree*)prg->stderrVal ); break; } - case IN_LOAD_ARGV: { - Half field; - read_half( field ); - debug( prg, REALM_BYTECODE, "IN_LOAD_ARGV %lu\n", field ); - - /* Tree comes back upreffed. */ - Tree *tree = constructArgv( prg, prg->argc, prg->argv ); - setField( prg, prg->global, field, tree ); - break; - } - - case IN_LOAD_ARGV0: { - Half field; - read_half( field ); - debug( prg, REALM_BYTECODE, "IN_LOAD_ARGV0 %lu\n", field ); - - /* Tree comes back upreffed. */ - Tree *tree = constructArgv0( prg, prg->argc, prg->argv ); - setField( prg, prg->global, field, tree ); - break; - } - case IN_SYSTEM: { debug( prg, REALM_BYTECODE, "IN_SYSTEM\n" ); @@ -3784,39 +3752,80 @@ again: case IN_FN: { c = *instr++; switch ( c ) { - case IN_STR_ATOI: { - debug( prg, REALM_BYTECODE, "IN_STR_ATOI\n" ); - - Str *str = (Str*)vm_pop(); - Word res = strAtoi( str->value ); - Tree *integer = constructInteger( prg, res ); - treeUpref( integer ); - vm_push( integer ); - treeDownref( prg, sp, (Tree*)str ); - break; - } - case IN_STR_UORD8: { - debug( prg, REALM_BYTECODE, "IN_STR_UORD8\n" ); - - Str *str = (Str*)vm_pop(); - Word res = strUord8( str->value ); - Tree *tree = constructInteger( prg, res ); - treeUpref( tree ); - vm_push( tree ); - treeDownref( prg, sp, (Tree*)str ); - break; - } - case IN_STR_UORD16: { - debug( prg, REALM_BYTECODE, "IN_STR_UORD16\n" ); - - Str *str = (Str*)vm_pop(); - Word res = strUord16( str->value ); - Tree *tree = constructInteger( prg, res ); - treeUpref( tree ); - vm_push( tree ); - treeDownref( prg, sp, (Tree*)str ); - break; - } + case IN_STR_ATOI: { + debug( prg, REALM_BYTECODE, "IN_STR_ATOI\n" ); + + Str *str = (Str*)vm_pop(); + Word res = strAtoi( str->value ); + Tree *integer = constructInteger( prg, res ); + treeUpref( integer ); + vm_push( integer ); + treeDownref( prg, sp, (Tree*)str ); + break; + } + case IN_STR_UORD8: { + debug( prg, REALM_BYTECODE, "IN_STR_UORD8\n" ); + + Str *str = (Str*)vm_pop(); + Word res = strUord8( str->value ); + Tree *tree = constructInteger( prg, res ); + treeUpref( tree ); + vm_push( tree ); + treeDownref( prg, sp, (Tree*)str ); + break; + } + case IN_STR_UORD16: { + debug( prg, REALM_BYTECODE, "IN_STR_UORD16\n" ); + + Str *str = (Str*)vm_pop(); + Word res = strUord16( str->value ); + Tree *tree = constructInteger( prg, res ); + treeUpref( tree ); + vm_push( tree ); + treeDownref( prg, sp, (Tree*)str ); + break; + } + case IN_LOAD_ARGV0: { + Half field; + read_half( field ); + debug( prg, REALM_BYTECODE, "IN_LOAD_ARGV0 %lu\n", field ); + + /* Tree comes back upreffed. */ + Tree *tree = constructArgv0( prg, prg->argc, prg->argv ); + setField( prg, prg->global, field, tree ); + break; + } + case IN_LOAD_ARGV: { + Half field; + read_half( field ); + debug( prg, REALM_BYTECODE, "IN_LOAD_ARGV %lu\n", field ); + + /* Tree comes back upreffed. */ + Tree *tree = constructArgv( prg, prg->argc, prg->argv ); + setField( prg, prg->global, field, tree ); + break; + } + case IN_INIT_LOCALS: { + Half size; + read_half( size ); + + debug( prg, REALM_BYTECODE, "IN_INIT_LOCALS %hd\n", size ); + + exec->framePtr = vm_ptop(); + vm_pushn( size ); + memset( vm_ptop(), 0, sizeof(Word) * size ); + break; + } + case IN_STOP: { + debug( prg, REALM_BYTECODE, "IN_STOP\n" ); + + FrameInfo *fi = &prg->rtd->frameInfo[exec->frameId]; + downrefLocalTrees( prg, sp, exec->framePtr, fi->locals, fi->localsLen ); + vm_popn( fi->frameSize ); + + fflush( stdout ); + goto out; + } } break; } @@ -3858,16 +3867,6 @@ again: goto out; } - case IN_STOP: { - debug( prg, REALM_BYTECODE, "IN_STOP\n" ); - - FrameInfo *fi = &prg->rtd->frameInfo[exec->frameId]; - downrefLocalTrees( prg, sp, exec->framePtr, fi->locals, fi->localsLen ); - vm_popn( fi->frameSize ); - - fflush( stdout ); - goto out; - } /* Halt is a default instruction given by the compiler when it is * asked to generate and instruction it doesn't have. It is deliberate diff --git a/src/bytecode.h b/src/bytecode.h index c88c2933..218aa44e 100644 --- a/src/bytecode.h +++ b/src/bytecode.h @@ -19,6 +19,14 @@ extern "C" { typedef unsigned long ulong; typedef unsigned char uchar; +/* + * 0x1c + * 0x8b + * 0x90 + * 0xb8 + * 0xed + */ + #define IN_LOAD_INT 0x01 #define IN_LOAD_STR 0x02 #define IN_LOAD_NIL 0x03 @@ -52,7 +60,6 @@ typedef unsigned char uchar; #define IN_CONCAT_STR 0x1a #define IN_TREE_TRIM 0x1b -#define IN_INIT_LOCALS 0x1c #define IN_POP 0x1d #define IN_POP_N_WORDS 0x1e #define IN_DUP_TOP 0x1f @@ -198,13 +205,12 @@ typedef unsigned char uchar; #define IN_PRINT_XML 0x89 #define IN_PRINT_STREAM 0x8a -#define IN_HALT 0x8b #define IN_CALL_WC 0x8c #define IN_CALL_WV 0x8d #define IN_RET 0x8e #define IN_YIELD 0x8f -#define IN_STOP 0x90 +#define IN_HALT 0x8b #define IN_INT_TO_STR 0x97 @@ -256,8 +262,6 @@ typedef unsigned char uchar; #define IN_GET_STDIN 0xb5 #define IN_GET_STDOUT 0xb6 #define IN_GET_STDERR 0xb7 -#define IN_LOAD_ARGV 0xb8 -#define IN_LOAD_ARGV0 0xed #define IN_TO_UPPER 0xb9 #define IN_TO_LOWER 0xba #define IN_EXIT 0xbb @@ -342,6 +346,11 @@ typedef unsigned char uchar; #define IN_STR_SORD16 0x04 #define IN_STR_UORD32 0x05 #define IN_STR_SORD32 0x06 +#define IN_LOAD_ARGV 0x07 +#define IN_LOAD_ARGV0 0x08 +#define IN_INIT_LOCALS 0x09 +#define IN_STOP 0x0a + enum TYPE { @@ -445,14 +454,23 @@ enum LEL_ID { #define IFR_RFR 0 /* return frame pointer */ /* Exported to modules other than bytecode.c */ -#define vm_push(i) ( ( sp == prg->sb_beg ? (sp = vm_bs_add(prg, sp, 1)) : 0 ), (*(--sp) = (i)) ) -#define vm_pushn(n) ( ( (sp-(n)) < prg->sb_beg ? (sp = vm_bs_add(prg, sp, n)) : 0 ), (sp -= (n)) ) +#define vm_push(i) \ + ( ( sp == prg->sb_beg ? (sp = vm_bs_add(prg, sp, 1)) : 0 ), (*(--sp) = (i)) ) + +#define vm_pushn(n) \ + ( ( (sp-(n)) < prg->sb_beg ? (sp = vm_bs_add(prg, sp, n)) : 0 ), (sp -= (n)) ) + +#define vm_pop() \ + ({ SW r = *sp; (sp+1) >= prg->sb_end ? (sp = vm_bs_pop(prg, sp, 1)) : (sp += 1); r; }) -#define vm_pop() ({ SW r = *sp; (sp+1) >= prg->sb_end ? (sp = vm_bs_pop(prg, sp, 1)) : (sp += 1); r; }) -#define vm_pop_ignore() ({ (sp+1) >= prg->sb_end ? (sp = vm_bs_pop(prg, sp, 1)) : (sp += 1); }) -#define vm_popn(n) ({ (sp+(n)) >= prg->sb_end ? (sp = vm_bs_pop(prg, sp, n)) : (sp += (n)); }) +#define vm_pop_ignore() \ + ({ (sp+1) >= prg->sb_end ? (sp = vm_bs_pop(prg, sp, 1)) : (sp += 1); }) -#define vm_contiguous(n) ( ( (sp-(n)) < prg->sb_beg ? (sp = vm_bs_add(prg, sp, n)) : 0 ) ) +#define vm_popn(n) \ + ({ (sp+(n)) >= prg->sb_end ? (sp = vm_bs_pop(prg, sp, n)) : (sp += (n)); }) + +#define vm_contiguous(n) \ + ( ( (sp-(n)) < prg->sb_beg ? (sp = vm_bs_add(prg, sp, n)) : 0 ) ) #define vm_top() (*sp) #define vm_ptop() (sp) @@ -464,6 +482,9 @@ enum LEL_ID { #define vm_local_iframe(o) (exec->iframePtr[o]) #define vm_plocal_iframe(o) (&exec->iframePtr[o]) +#define vm_push_val(i) \ + vm_push( ((Tree*)i) ) + void vm_init( struct colm_program * ); Tree** vm_bs_add( struct colm_program *, Tree **, int ); Tree** vm_bs_pop( struct colm_program *, Tree **, int ); diff --git a/src/compiler.cc b/src/compiler.cc index 0894cbaa..7978f631 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -360,6 +360,8 @@ Compiler::Compiler( ) firstNonTermId(0), prodIdIndex(0), + global(0), + globalSel(0), globalObjectDef(0), argv0(0), argvList(0), diff --git a/src/compiler.h b/src/compiler.h index b9ab5bba..5db5dd2b 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -876,6 +876,8 @@ struct Compiler ConsList replList; ParserTextList parserTextList; + StructDef *global; + StructEl *globalSel; ObjectDef *globalObjectDef; ObjectField *argv0; ObjectField *argvList; diff --git a/src/consinit.cc b/src/consinit.cc index cf1e83c4..0f63ab84 100644 --- a/src/consinit.cc +++ b/src/consinit.cc @@ -766,12 +766,14 @@ void ConsInit::parseInput( StmtList *stmtList ) void ConsInit::exportTree( StmtList *stmtList ) { + /* reference P */ QualItemVect *qual = new QualItemVect; LangVarRef *varRef = LangVarRef::cons( internal, 0, curLocalFrame->rootScope, qual, String("P") ); LangExpr *expr = LangExpr::cons( LangTerm::cons( internal, LangTerm::VarRefType, varRef ) ); + /* Assign P to ColmTree */ NamespaceQual *nspaceQual = NamespaceQual::cons( curNspace() ); TypeRef *typeRef = TypeRef::cons( internal, nspaceQual, String("start"), RepeatNone ); ObjectField *program = ObjectField::cons( internal, diff --git a/src/declare.cc b/src/declare.cc index 08f84193..0a1073fb 100644 --- a/src/declare.cc +++ b/src/declare.cc @@ -421,19 +421,22 @@ void Namespace::declare( Compiler *pd ) lel->objectDef = c->context->objectDef; } - for ( StructDefList::Iter c = structDefList; c.lte(); c++ ) { - StructEl *sel = declareStruct( pd, this, c->name, c->context ); - sel->context = c->context; + for ( StructDefList::Iter s = structDefList; s.lte(); s++ ) { + StructEl *sel = declareStruct( pd, this, s->name, s->context ); + sel->context = s->context; /* If the token has the same name as the region it is in, then also * insert it into the symbol map for the parent region. */ - if ( strcmp( c->name, this->name ) == 0 ) { + if ( strcmp( s->name, this->name ) == 0 ) { /* Insert the name into the top of the region stack after popping the * region just created. We need it in the parent. */ TypeMapEl *typeMapEl = new TypeMapEl( - TypeMapEl::StructType, c->name, sel ); + TypeMapEl::StructType, s->name, sel ); this->parentNamespace->typeMap.insert( typeMapEl ); } + + if ( s == pd->global ) + pd->globalSel = sel; } for ( TokenDefListNs::Iter tokenDef = tokenDefList; tokenDef.lte(); tokenDef++ ) { diff --git a/src/loadinit.cc b/src/loadinit.cc index 26d9c277..e38621fa 100644 --- a/src/loadinit.cc +++ b/src/loadinit.cc @@ -347,6 +347,7 @@ void LoadInit::go( long activeRealm ) argv[2] = 0; colm_program *program = colm_new_program( &colm_object ); + colm_set_debug( program, 0x3 ); colm_run_program( program, 2, argv ); /* Extract the parse tree. */ diff --git a/src/parser.cc b/src/parser.cc index b7892480..1aeb3787 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -18,13 +18,17 @@ using std::endl; void BaseParser::init() { /* Set up the root namespace. */ - Namespace *rootNamespace = createRootNamespace(); - pd->rootNamespace = rootNamespace; + pd->rootNamespace = createRootNamespace(); /* Set up the global object. */ String global = "global"; pd->globalObjectDef = ObjectDef::cons( ObjectDef::UserType, global, pd->nextObjectId++ ); + + Context *context = new Context( internal, 0 ); + pd->global = new StructDef( global, context ); + pd->rootNamespace->structDefList.append( pd->global ); + context->objectDef = pd->globalObjectDef; /* Initialize the dictionary of graphs. This is our symbol table. The * initialization needs to be done on construction which happens at the @@ -894,7 +898,7 @@ void BaseParser::structHead( const InputLoc &loc, const String &data, Context *context = new Context( loc, 0 ); contextStack.push( context ); - StructDef *structDef = new StructDef( data, context, nspace ); + StructDef *structDef = new StructDef( data, context ); nspace->structDefList.append( structDef ); context->objectDef = ObjectDef::cons( objectType, diff --git a/src/parsetree.h b/src/parsetree.h index b9725ecf..9ed57523 100644 --- a/src/parsetree.h +++ b/src/parsetree.h @@ -586,12 +586,11 @@ typedef DList<StructEl> StructElList; struct StructDef { - StructDef( const String &name, Context *context, Namespace *nspace ) - : name(name), context(context), nspace(nspace) {} + StructDef( const String &name, Context *context ) + : name(name), context(context) {} String name; Context *context; - Namespace *nspace; StructDef *prev, *next; }; diff --git a/src/pdabuild.cc b/src/pdabuild.cc index 1b5f52c4..f9cadb20 100644 --- a/src/pdabuild.cc +++ b/src/pdabuild.cc @@ -1642,11 +1642,13 @@ void Compiler::makeRuntimeData() runtimeData->anyId = anyLangEl->id; runtimeData->eofId = 0; //eofLangEl->id; runtimeData->noTokenId = noTokenLangEl->id; + runtimeData->globalId = globalSel->id; runtimeData->fsmExecute = &internalFsmExecute; runtimeData->sendNamedLangEl = &internalSendNamedLangEl; runtimeData->initBindings = &internalInitBindings; runtimeData->popBinding = &internalPopBinding; + } /* Borrow alg->state for mapsTo. */ diff --git a/src/pdacodegen.cc b/src/pdacodegen.cc index 5ac78e44..c2828060 100644 --- a/src/pdacodegen.cc +++ b/src/pdacodegen.cc @@ -481,6 +481,7 @@ void PdaCodeGen::writeRuntimeData( RuntimeData *runtimeData, PdaTables *pdaTable " " << runtimeData->anyId << ",\n" " " << runtimeData->eofId << ",\n" " " << runtimeData->noTokenId << ",\n" + " " << runtimeData->globalId << ",\n" " &fsmExecute,\n" " &sendNamedLangEl,\n" " &initBindings,\n" diff --git a/src/program.c b/src/program.c index 3ebf8438..d2e3096a 100644 --- a/src/program.c +++ b/src/program.c @@ -8,6 +8,7 @@ #include <colm/pool.h> #include <colm/debug.h> #include <colm/config.h> +#include <colm/struct.h> #include <alloca.h> #include <sys/mman.h> @@ -17,28 +18,16 @@ #define VM_STACK_SIZE (8192) -static void colm_clear_global( Program *prg, Tree **sp ) +static void colm_alloc_global( Program *prg ) { - /* Downref all the fields in the global object. */ - int g; - for ( g = 0; g < prg->rtd->globalSize; g++ ) { - //assert( colm_get_attr( global, g )->refs == 1 ); - treeDownref( prg, sp, colm_get_attr( prg->global, g ) ); - } - - /* Free the global object. */ - if ( prg->rtd->globalSize > 0 ) - freeAttrs( prg, prg->global->child ); - treeFree( prg, prg->global ); + /* Alloc the global. */ + prg->global = (Tree*) colm_new_struct( prg, prg->rtd->globalId ) ; } -static void colm_alloc_global( Program *prg ) +static void colm_clear_global( Program *prg, Tree **sp ) { - /* Alloc the global. */ - Tree *tree = treeAllocate( prg ); - tree->child = allocAttrs( prg, prg->rtd->globalSize ); - tree->refs = 1; - prg->global = tree; + colm_delete_struct( prg, sp, prg->global ); + prg->global = 0; } void vm_init( Program *prg ) @@ -300,11 +289,7 @@ static void colm_clear_heap( Program *prg, Tree **sp ) struct colm_struct *hi = prg->heap.head; while ( hi != 0 ) { struct colm_struct *next = hi->next; - short *t = prg->rtd->selInfo[hi->id].trees; - int i, len = prg->rtd->selInfo[hi->id].treesLen; - for ( i = 0; i < len; i++ ) - treeDownref( prg, sp, ((Tree**)(hi+1))[t[i]] ); - free( hi ); + colm_delete_struct( prg, sp, hi ); hi = next; } } diff --git a/src/program.h b/src/program.h index 03fd1d6b..ab9ebcd1 100644 --- a/src/program.h +++ b/src/program.h @@ -74,6 +74,7 @@ typedef struct colm_sections long anyId; long eofId; long noTokenId; + long globalId; void (*fsmExecute)( struct _FsmRun *fsmRun, struct _StreamImpl *inputStream ); void (*sendNamedLangEl)( struct colm_program *prg, Tree **tree, struct _PdaRun *pdaRun, diff --git a/src/struct.c b/src/struct.c index 8a13e9b5..5b37cb27 100644 --- a/src/struct.c +++ b/src/struct.c @@ -1,6 +1,9 @@ #include <colm/program.h> #include <colm/struct.h> +#include <stdlib.h> +#include <string.h> + struct colm_struct *colm_new_struct( Program *prg, int id ) { int structSize = prg->rtd->selInfo[id].size; @@ -22,3 +25,12 @@ struct colm_struct *colm_new_struct( Program *prg, int id ) return item; } + +void colm_delete_struct( Program *prg, Tree **sp, struct colm_struct *el ) +{ + short *t = prg->rtd->selInfo[el->id].trees; + int i, len = prg->rtd->selInfo[el->id].treesLen; + for ( i = 0; i < len; i++ ) + treeDownref( prg, sp, ((Tree**)(el+1))[t[i]] ); + free( el ); +} diff --git a/src/struct.h b/src/struct.h index 85bbe2d1..1f5d87b6 100644 --- a/src/struct.h +++ b/src/struct.h @@ -4,5 +4,7 @@ ((struct colm_tree**)(((struct colm_struct*)obj)+1))[field] struct colm_struct *colm_new_struct( struct colm_program *prg, int id ); +void colm_delete_struct( struct colm_program *prg, struct colm_tree **sp, + struct colm_struct *el ); #endif diff --git a/src/synthesis.cc b/src/synthesis.cc index b0ed2971..60e0d3ee 100644 --- a/src/synthesis.cc +++ b/src/synthesis.cc @@ -2502,7 +2502,9 @@ void Compiler::compileReductionCode( Production *prod ) /* Add the alloc frame opcode. We don't have the right * frame size yet. We will fill it in later. */ + code.append( IN_FN ); code.append( IN_INIT_LOCALS ); + int fsLoc = code.length(); code.appendHalf( 0 ); long afterInit = code.length(); @@ -2511,7 +2513,7 @@ void Compiler::compileReductionCode( Production *prod ) /* We have the frame size now. Set in the alloc frame instruction. */ long frameSize = block->localFrame->size(); - code.setHalf( 1, frameSize ); + code.setHalf( fsLoc, frameSize ); /* Might need to load right hand side values. */ addProdRHSLoads( prod, code, afterInit ); @@ -2539,7 +2541,9 @@ void Compiler::compileTranslateBlock( LangEl *langEl ) /* Add the alloc frame opcode. We don't have the right * frame size yet. We will fill it in later. */ + code.append( IN_FN ); code.append( IN_INIT_LOCALS ); + int fsLoc = code.length(); code.appendHalf( 0 ); if ( langEl->tokenDef->reCaptureVect.length() > 0 ) { @@ -2552,7 +2556,7 @@ void Compiler::compileTranslateBlock( LangEl *langEl ) /* We have the frame size now. Set in the alloc frame instruction. */ long frameSize = block->localFrame->size(); - code.setHalf( 1, frameSize ); + code.setHalf( fsLoc, frameSize ); code.append( IN_PCR_RET ); @@ -2577,7 +2581,9 @@ void Compiler::compilePreEof( TokenRegion *region ) /* Add the alloc frame opcode. We don't have the right * frame size yet. We will fill it in later. */ + code.append( IN_FN ); code.append( IN_INIT_LOCALS ); + int fsLoc = code.length(); code.appendHalf( 0 ); /* Set the local frame and compile the reduce block. */ @@ -2585,7 +2591,7 @@ void Compiler::compilePreEof( TokenRegion *region ) /* We have the frame size now. Set in the alloc frame instruction. */ long frameSize = block->localFrame->size(); - code.setHalf( 1, frameSize ); + code.setHalf( fsLoc, frameSize ); code.append( IN_PCR_RET ); @@ -2625,12 +2631,16 @@ void Compiler::compileRootBlock( ) /* Add the alloc frame opcode. We don't have the right * frame size yet. We will fill it in later. */ + code.append( IN_FN ); code.append( IN_INIT_LOCALS ); + int fsLoc = code.length(); code.appendHalf( 0 ); + code.append( IN_FN ); code.append( IN_LOAD_ARGV0 ); code.appendHalf( argv0_Offset() ); + code.append( IN_FN ); code.append( IN_LOAD_ARGV ); code.appendHalf( argvOffset() ); @@ -2638,8 +2648,9 @@ void Compiler::compileRootBlock( ) /* We have the frame size now. Store it in frame init. */ long frameSize = rootLocalFrame->size(); - code.setHalf( 1, frameSize ); + code.setHalf( fsLoc, frameSize ); + code.append( IN_FN ); code.append( IN_STOP ); /* Make the local trees descriptor. */ @@ -2871,7 +2882,9 @@ void Compiler::compileUserIter( Function *func, CodeVect &code ) /* Add the alloc frame opcode. We don't have the right * frame size yet. We will fill it in later. */ + code.append( IN_FN ); code.append( IN_INIT_LOCALS ); + int fsLoc = code.length(); code.appendHalf( 0 ); /* Compile the block. */ @@ -2879,7 +2892,7 @@ void Compiler::compileUserIter( Function *func, CodeVect &code ) /* We have the frame size now. Set in the alloc frame instruction. */ int frameSize = func->localFrame->size(); - code.setHalf( 1, frameSize ); + code.setHalf( fsLoc, frameSize ); /* Check for a return statement. */ if ( block->stmtList->length() == 0 || @@ -2921,7 +2934,9 @@ void Compiler::compileFunction( Function *func, CodeVect &code ) /* Add the alloc frame opcode. We don't have the right * frame size yet. We will fill it in later. */ + code.append( IN_FN ); code.append( IN_INIT_LOCALS ); + int fsLoc = code.length(); code.appendHalf( 0 ); /* Compile the block. */ @@ -2929,7 +2944,7 @@ void Compiler::compileFunction( Function *func, CodeVect &code ) /* We have the frame size now. Set in the alloc frame instruction. */ int frameSize = func->localFrame->size(); - code.setHalf( 1, frameSize ); + code.setHalf( fsLoc, frameSize ); /* Check for a return statement. */ if ( block->stmtList->length() == 0 || |