diff options
author | Adrian Thurston <thurston@complang.org> | 2015-04-03 15:09:15 -0400 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2015-04-03 15:09:15 -0400 |
commit | fa5f9a998a4138abed01557eadb577d316e3482d (patch) | |
tree | b1850d9de695e083a12f1d607afe81e1b31691c8 /src/program.c | |
parent | 9a03234d26ede0dda117b7b03cd5849834f17614 (diff) | |
download | colm-fa5f9a998a4138abed01557eadb577d316e3482d.tar.gz |
fixes for host-code function calls, added a couple test cases
Calls into colm programs was broken since recent changes to calling
conventions. Fixed and added a test case. Also added a test case for C
extensions to colm programs.
Diffstat (limited to 'src/program.c')
-rw-r--r-- | src/program.c | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/program.c b/src/program.c index 2c856e1b..aa3730df 100644 --- a/src/program.c +++ b/src/program.c @@ -217,56 +217,6 @@ void colm_run_program( Program *prg, int argc, const char **argv ) prg->argv = 0; } -Tree *colm_run_func( struct colm_program *prg, int frameId, - const char **params, int paramCount ) -{ - /* Make the arguments available to the program. */ - prg->argc = 0; - prg->argv = 0; - - Execution execution; - memset( &execution, 0, sizeof(execution) ); - - Tree **sp = prg->stackRoot; - - FrameInfo *fi = &prg->rtd->frameInfo[frameId]; - Code *code = fi->codeWC; - long stretch = fi->argSize + 4 + fi->frameSize; - vm_contiguous( stretch ); - - int p; - for ( p = 0; p < paramCount; p++ ) { - if ( params[p] == 0 ) { - vm_push_tree( 0 ); - } - else { - Head *head = stringAllocPointer( prg, params[p], strlen(params[p]) ); - Tree *tree = constructString( prg, head ); - treeUpref( tree ); - vm_push_tree( tree ); - } - } - - /* Set up the stack as if we have called. We allow a return value. */ - vm_push_tree( 0 ); - vm_push_tree( 0 ); - vm_push_tree( 0 ); - vm_push_tree( 0 ); - - execution.framePtr = vm_ptop(); - execution.frameId = frameId; - - /* Execution loop. */ - sp = colm_execute_code( prg, &execution, sp, code ); - - treeDownref( prg, sp, prg->returnVal ); - prg->returnVal = vm_pop_tree(); - - assert( sp == prg->stackRoot ); - - return prg->returnVal; -}; - static void colm_clear_heap( Program *prg, Tree **sp ) { struct colm_struct *hi = prg->heap.head; |