summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2015-04-05 17:24:50 -0400
committerAdrian Thurston <thurston@complang.org>2015-04-05 17:24:50 -0400
commit4736c6c09d90162a112c17fc82bfc75da8efc4e2 (patch)
treed3b2da221a4a10382acb8f8078f8b5ea00d9e7a8
parentf71dde2a1ee0bc0045f9c0333d135e3261a690cb (diff)
downloadcolm-4736c6c09d90162a112c17fc82bfc75da8efc4e2.tar.gz
add destroy2 to unwind code for user iters
Will likely need to distinguish between a destroy and unwind for user iterators. Destroy is akin to the return, wheres unwind forces unwinding of the called iterator's stack.
-rw-r--r--src/bytecode.c11
-rw-r--r--src/bytecode.h2
-rw-r--r--src/synthesis.cc5
3 files changed, 16 insertions, 2 deletions
diff --git a/src/bytecode.c b/src/bytecode.c
index 3a8cfcc9..ed51f8f0 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -3511,6 +3511,17 @@ again:
break;
}
+ case IN_UITER_DESTROY2: {
+ short field;
+ read_half( field );
+
+ debug( prg, REALM_BYTECODE, "IN_UITER_DESTROY %hd\n", field );
+
+ UserIter *uiter = (UserIter*) vm_get_local(exec, field);
+ userIterDestroy2( prg, &sp, uiter );
+ break;
+ }
+
case IN_RET: {
FrameInfo *fi = &prg->rtd->frameInfo[exec->frameId];
downref_local_trees( prg, sp, exec, fi->locals, fi->localsLen );
diff --git a/src/bytecode.h b/src/bytecode.h
index 8b1ab496..2b4cb5b9 100644
--- a/src/bytecode.h
+++ b/src/bytecode.h
@@ -168,6 +168,7 @@ typedef unsigned long colm_value_t;
#define IN_REV_TRITER_PREV_CHILD 0x4c
#define IN_UITER_DESTROY 0x4d
+#define IN_UITER_DESTROY2 0x71
#define IN_UITER_CREATE_WV 0x4e
#define IN_UITER_CREATE_WC 0x4f
#define IN_UITER_ADVANCE 0x50
@@ -209,7 +210,6 @@ typedef unsigned long colm_value_t;
#define IN_GET_VLIST_MEM_WV 0x70
#define IN_GET_VLIST_MEM_BKT 0x5c
-// 0x71
// 0x73
// 0x74
// 0x75
diff --git a/src/synthesis.cc b/src/synthesis.cc
index f90005c4..7210d2ff 100644
--- a/src/synthesis.cc
+++ b/src/synthesis.cc
@@ -2204,7 +2204,10 @@ void LangStmt::compileForIterBody( Compiler *pd,
/* Add the cleanup for the current loop. */
int lcLen = pd->unwindCode.length();
pd->unwindCode.insertHalf( 0, objField->offset );
- pd->unwindCode.insert( 0, objField->iterImpl->inDestroy );
+ int c = objField->iterImpl->inDestroy;
+ if ( c == IN_UITER_DESTROY )
+ c = IN_UITER_DESTROY2;
+ pd->unwindCode.insert( 0, c ); //objField->iterImpl->inDestroy );
/* Compile the contents. */
for ( StmtList::Iter stmt = *stmtList; stmt.lte(); stmt++ )