summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2014-01-22 22:02:08 -0500
committerAdrian Thurston <thurston@complang.org>2014-01-22 22:03:23 -0500
commite838d570382dc4e68e62001fab78ba41b801a15f (patch)
treef9eb2dc45dada379c9726214dff50eae0b37b169
parentcf182ef774382c82db56d4c29b8addd69bfc2737 (diff)
downloadcolm-e838d570382dc4e68e62001fab78ba41b801a15f.tar.gz
don't use sp offset for make_tree, removes need for contiguous
-rw-r--r--src/bytecode.c15
-rw-r--r--src/tree.c11
-rw-r--r--src/tree.h2
3 files changed, 14 insertions, 14 deletions
diff --git a/src/bytecode.c b/src/bytecode.c
index 478a718b..434eec02 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -2651,16 +2651,19 @@ again:
}
case IN_MAKE_TREE: {
uchar nargs;
+ int i;
read_byte( nargs );
debug( prg, REALM_BYTECODE, "IN_MAKE_TREE\n" );
- Tree *result = makeTree( prg, sp, nargs );
- long i;
- for ( i = 0; i < nargs; i++ ) {
- Tree *arg = vm_pop();
- treeDownref( prg, sp, arg );
- }
+ Tree *arg[nargs];
+ for ( i = nargs-1; i >= 0; i-- )
+ arg[i] = vm_pop();
+
+ Tree *result = makeTree( prg, arg, nargs );
+ for ( i = 0; i < nargs; i++ )
+ treeDownref( prg, sp, arg[i] );
+
vm_push( result );
break;
}
diff --git a/src/tree.c b/src/tree.c
index 6688973a..a8c1f393 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -755,12 +755,9 @@ Tree *castTree( Program *prg, int langElId, Tree *tree )
return newTree;
}
-Tree *makeTree( Program *prg, Tree **root, long nargs )
+Tree *makeTree( Program *prg, Tree **args, long nargs )
{
- Tree **const sp = root;
- Tree **base = vm_ptop() + nargs;
-
- Int *idInt = (Int*)base[-1];
+ Int *idInt = (Int*)args[0];
long id = idInt->value;
LangElInfo *lelInfo = prg->rtd->lelInfo;
@@ -773,9 +770,9 @@ Tree *makeTree( Program *prg, Tree **root, long nargs )
Kid *attrs = allocAttrs( prg, objectLength );
Kid *last = 0, *child = 0;
- for ( id = 0; id < nargs-1; id++ ) {
+ for ( id = 1; id < nargs; id++ ) {
Kid *kid = kidAllocate( prg );
- kid->tree = base[-2-id];
+ kid->tree = args[id];
treeUpref( kid->tree );
if ( last == 0 )
diff --git a/src/tree.h b/src/tree.h
index 58c9dad5..6d76b661 100644
--- a/src/tree.h
+++ b/src/tree.h
@@ -268,7 +268,7 @@ Tree *constructStream( struct colm_program *prg );
int testFalse( struct colm_program *prg, Tree *tree );
-Tree *makeTree( struct colm_program *prg, Tree **root, long nargs );
+Tree *makeTree( struct colm_program *prg, Tree **args, long nargs );
Stream *openFile( struct colm_program *prg, Tree *name, Tree *mode );
Stream *openStreamFd( struct colm_program *prg, char *name, long fd );
Kid *copyIgnoreList( struct colm_program *prg, Kid *ignoreHeader );