summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--generic/tclAssembly.c6
-rw-r--r--tests/assemble.test42
3 files changed, 45 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 0d2f292..5d6621f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,8 +5,7 @@
* generic/tclAssembly.c:
* generic/tclAssembly.h:
* tests/assemble.test: Added dictAppend, dictIncrImm, dictLappend,
- dictSet, dictUnset, nsupvar, upvar, and variable. (Still need tests
- for the last three.)
+ dictSet, dictUnset, nsupvar, upvar, and variable.
2010-10-02 Donal K. Fellows <dkf@users.sf.net>
diff --git a/generic/tclAssembly.c b/generic/tclAssembly.c
index 8232551..4797cc8 100644
--- a/generic/tclAssembly.c
+++ b/generic/tclAssembly.c
@@ -229,7 +229,7 @@ TalInstDesc TalInstructionTable[] = {
{"mult", ASSEM_1BYTE , INST_MULT , 2 , 1},
{"neq", ASSEM_1BYTE , INST_NEQ , 2 , 1},
{"not", ASSEM_1BYTE, INST_LNOT, 1, 1},
- {"nsupvar", ASSEM_LVT4, INST_NSUPVAR, 2, 1}.
+ {"nsupvar", ASSEM_LVT4, INST_NSUPVAR, 2, 1},
{"over", ASSEM_OVER, INST_OVER, INT_MIN, -1-1},
{"pop", ASSEM_1BYTE , INST_POP , 1 , 0},
{"reverse", ASSEM_REVERSE, INST_REVERSE, INT_MIN, -1-0},
@@ -273,8 +273,8 @@ TalInstDesc TalInstructionTable[] = {
{"unsetStk",
ASSEM_BOOL, INST_UNSET_STK, 1, 0},
{"uplus", ASSEM_1BYTE, INST_UPLUS, 1, 1},
- {"upvar", ASSEM_LVT4, INST_UPVAR, 2, 1}.
- {"variable",ASSEM_LVT4, INST_VARIABLE, 2, 1}.
+ {"upvar", ASSEM_LVT4, INST_UPVAR, 2, 1},
+ {"variable",ASSEM_LVT4, INST_VARIABLE, 1, 0},
{NULL, 0, 0,0}
};
diff --git a/tests/assemble.test b/tests/assemble.test
index b86e728..79ac9e2 100644
--- a/tests/assemble.test
+++ b/tests/assemble.test
@@ -1255,7 +1255,8 @@ test assemble-10.7 {expr - noncompilable} {
-result {1 {assembly code may not contain substitutions} {TCL ASSEM NOSUBST}}
}
-# assemble-11 - ASSEM_LVT4 (exist, existArray, dictAppend, dictLappend)
+# assemble-11 - ASSEM_LVT4 (exist, existArray, dictAppend, dictLappend,
+# nsupvar, variable, upvar)
test assemble-11.1 {exist - wrong # args} {
-body {
@@ -1334,6 +1335,45 @@ test assemble-11.7 {dictLappend} {
-cleanup {rename x {}}
}
+test assemble-11.8 {upvar} {
+ -body {
+ proc x {v} {
+ assemble {push 1; load v; upvar w; pop; load w}
+ }
+ proc y {} {
+ set z 123
+ x z
+ }
+ y
+ }
+ -result 123
+ -cleanup {rename x {}; rename y {}}
+}
+
+test assemble-11.9 {nsupvar} {
+ -body {
+ namespace eval q { variable v 123 }
+ proc x {} {
+ assemble {push q; push v; nsupvar y; pop; load y}
+ }
+ x
+ }
+ -result 123
+ -cleanup {namespace delete q; rename x {}}
+}
+
+test assemble-11.10 {variable} {
+ -body {
+ namespace eval q { namespace eval r {variable v 123}}
+ proc x {} {
+ assemble {push q::r::v; variable y; load y}
+ }
+ x
+ }
+ -result 123
+ -cleanup {namespace delete q; rename x {}}
+}
+
# assemble-12 - ASSEM_LVT1 (incr and incrArray)
test assemble-12.1 {incr - wrong # args} {