diff options
author | Adrian Thurston <thurston@complang.org> | 2014-11-05 16:38:46 -0500 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2014-11-05 16:38:46 -0500 |
commit | c20284bb779dee69799a09c6257f80c2ab868aec (patch) | |
tree | 03c2804b6d1aba527fb496875ca9949ca647ec1a | |
parent | f7f9e0dd3dbe41772677556fff9f25fd51d64356 (diff) | |
download | colm-c20284bb779dee69799a09c6257f80c2ab868aec.tar.gz |
print the func we are returning to in IN_RET
-rw-r--r-- | src/bytecode.c | 14 | ||||
-rw-r--r-- | src/pdabuild.cc | 9 | ||||
-rw-r--r-- | src/pdacodegen.cc | 7 | ||||
-rw-r--r-- | src/pdarun.h | 2 |
4 files changed, 23 insertions, 9 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index 1b7a1380..3e66869d 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -3550,15 +3550,16 @@ again: read_half( funcId ); FunctionInfo *fi = &prg->rtd->functionInfo[funcId]; + FrameInfo *fr = &prg->rtd->frameInfo[fi->frameId]; - debug( prg, REALM_BYTECODE, "IN_CALL_WV %s\n", fi->name ); + debug( prg, REALM_BYTECODE, "IN_CALL_WV %s\n", fr->name ); vm_push( 0 ); /* Return value. */ vm_push( (SW)instr ); vm_push( (SW)exec->framePtr ); vm_push( (SW)exec->frameId ); - instr = prg->rtd->frameInfo[fi->frameId].codeWV; + instr = fr->codeWV; exec->framePtr = vm_ptop(); exec->frameId = fi->frameId; break; @@ -3568,15 +3569,16 @@ again: read_half( funcId ); FunctionInfo *fi = &prg->rtd->functionInfo[funcId]; + FrameInfo *fr = &prg->rtd->frameInfo[fi->frameId]; - debug( prg, REALM_BYTECODE, "IN_CALL_WC %s\n", fi->name ); + debug( prg, REALM_BYTECODE, "IN_CALL_WC %s\n", fr->name ); vm_push( 0 ); /* Return value. */ vm_push( (SW)instr ); vm_push( (SW)exec->framePtr ); vm_push( (SW)exec->frameId ); - instr = prg->rtd->frameInfo[fi->frameId].codeWC; + instr = fr->codeWC; exec->framePtr = vm_ptop(); exec->frameId = fi->frameId; break; @@ -3672,7 +3674,6 @@ again: break; } case IN_RET: { - debug( prg, REALM_BYTECODE, "IN_RET\n" ); FrameInfo *fi = &prg->rtd->frameInfo[exec->frameId]; downrefLocalTrees( prg, sp, exec->framePtr, fi->locals, fi->localsLen ); @@ -3685,6 +3686,9 @@ again: vm_popn( fi->argSize ); vm_push( retVal ); + fi = &prg->rtd->frameInfo[exec->frameId]; + debug( prg, REALM_BYTECODE, "IN_RET %s\n", fi->name ); + /* This if for direct calls of functions. */ if ( instr == 0 ){ //assert( sp == root ); diff --git a/src/pdabuild.cc b/src/pdabuild.cc index 3fdaefe1..8472ab44 100644 --- a/src/pdabuild.cc +++ b/src/pdabuild.cc @@ -1454,22 +1454,27 @@ void Compiler::makeRuntimeData() runtimeData->numFunctions = count; memset( runtimeData->functionInfo, 0, sizeof(FunctionInfo)*count ); for ( FunctionList::Iter func = functionList; func.lte(); func++ ) { - runtimeData->functionInfo[func->funcId].name = func->name; + runtimeData->functionInfo[func->funcId].frameId = -1; CodeBlock *block = func->codeBlock; if ( block != 0 ) { runtimeData->functionInfo[func->funcId].frameId = block->frameId; + /* Name. */ + runtimeData->frameInfo[block->frameId].name = func->name; + + /* Code. */ runtimeData->frameInfo[block->frameId].codeWV = block->codeWV.data; runtimeData->frameInfo[block->frameId].codeLenWV = block->codeWV.length(); - runtimeData->frameInfo[block->frameId].codeWC = block->codeWC.data; runtimeData->frameInfo[block->frameId].codeLenWC = block->codeWC.length(); + /* Locals. */ runtimeData->frameInfo[block->frameId].locals = makeLocalInfo( block->locals ); runtimeData->frameInfo[block->frameId].localsLen = block->locals.locals.length(); + /* Meta. */ runtimeData->frameInfo[block->frameId].frameSize = func->localFrame->size(); runtimeData->frameInfo[block->frameId].argSize = func->paramListSize; } diff --git a/src/pdacodegen.cc b/src/pdacodegen.cc index 0d9a2807..b420ab82 100644 --- a/src/pdacodegen.cc +++ b/src/pdacodegen.cc @@ -204,6 +204,12 @@ void PdaCodeGen::writeRuntimeData( RuntimeData *runtimeData, PdaTables *pdaTable for ( int i = 0; i < runtimeData->numFrames; i++ ) { out << "\t{ "; + /* The Name. */ + if ( runtimeData->frameInfo[i].name ) + out << "\"" << runtimeData->frameInfo[i].name << "\", "; + else + out << "\"\", "; + if ( runtimeData->frameInfo[i].codeLenWV > 0 ) out << "code_" << i << "_wv, "; else @@ -308,7 +314,6 @@ void PdaCodeGen::writeRuntimeData( RuntimeData *runtimeData, PdaTables *pdaTable out << "static FunctionInfo " << functionInfo() << "[] = {\n"; for ( int i = 0; i < runtimeData->numFunctions; i++ ) { out << "\t{ " << - "\"" << runtimeData->functionInfo[i].name << "\", " << runtimeData->functionInfo[i].frameId << ", " << runtimeData->functionInfo[i].argSize << ", " << runtimeData->functionInfo[i].frameSize; diff --git a/src/pdarun.h b/src/pdarun.h index 4c41e675..4a262cff 100644 --- a/src/pdarun.h +++ b/src/pdarun.h @@ -106,7 +106,6 @@ long listLength(List *list); typedef struct _FunctionInfo { - const char *name; long frameId; long argSize; long frameSize; @@ -196,6 +195,7 @@ typedef struct _LocalInfo typedef struct _FrameInfo { + const char *name; Code *codeWV; long codeLenWV; Code *codeWC; |