summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--generic/tclAssembly.c16
-rw-r--r--generic/tclAssembly.h1
-rw-r--r--tests/assemble.test69
4 files changed, 87 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 5d6621f..d19843c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,7 +5,7 @@
* generic/tclAssembly.c:
* generic/tclAssembly.h:
* tests/assemble.test: Added dictAppend, dictIncrImm, dictLappend,
- dictSet, dictUnset, nsupvar, upvar, and variable.
+ dictSet, dictUnset, nop, regexp, 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 4797cc8..71e7412 100644
--- a/generic/tclAssembly.c
+++ b/generic/tclAssembly.c
@@ -228,10 +228,12 @@ TalInstDesc TalInstructionTable[] = {
{"mod", ASSEM_1BYTE, INST_MOD, 2, 1},
{"mult", ASSEM_1BYTE , INST_MULT , 2 , 1},
{"neq", ASSEM_1BYTE , INST_NEQ , 2 , 1},
+ {"nop", ASSEM_1BYTE, INST_NOP, 0, 0},
{"not", ASSEM_1BYTE, INST_LNOT, 1, 1},
{"nsupvar", ASSEM_LVT4, INST_NSUPVAR, 2, 1},
{"over", ASSEM_OVER, INST_OVER, INT_MIN, -1-1},
{"pop", ASSEM_1BYTE , INST_POP , 1 , 0},
+ {"regexp", ASSEM_REGEXP, INST_REGEXP, 2, 1},
{"reverse", ASSEM_REVERSE, INST_REVERSE, INT_MIN, -1-0},
{"rshift", ASSEM_1BYTE , INST_RSHIFT , 2 , 1},
{"store", ASSEM_LVT, (INST_STORE_SCALAR1<<8
@@ -1308,6 +1310,20 @@ AssembleOneLine(AssembleEnv* assemEnvPtr)
BBEmitInstInt4(assemEnvPtr, tblind, opnd, opnd+1);
break;
+ case ASSEM_REGEXP:
+ if (parsePtr->numWords != 2) {
+ Tcl_WrongNumArgs(interp, 1, &instNameObj, "boolean");
+ goto cleanup;
+ }
+ if (GetBooleanOperand(assemEnvPtr, &tokenPtr, &opnd) != TCL_OK) {
+ goto cleanup;
+ }
+ {
+ int flags = TCL_REG_ADVANCED | (opnd ? TCL_REG_NOCASE : 0);
+ BBEmitInstInt1(assemEnvPtr, tblind, flags, 0);
+ }
+ break;
+
case ASSEM_REVERSE:
if (parsePtr->numWords != 2) {
Tcl_WrongNumArgs(interp, 1, &instNameObj, "count");
diff --git a/generic/tclAssembly.h b/generic/tclAssembly.h
index 7f1a36e..1f67e4f 100644
--- a/generic/tclAssembly.h
+++ b/generic/tclAssembly.h
@@ -77,6 +77,7 @@ typedef enum TalInstType {
ASSEM_LVT4, /* One 4-byte operand that references a local variable */
ASSEM_OVER, /* OVER: 4-byte operand count, consumes N+1, produces N+2 */
ASSEM_PUSH, /* one literal operand */
+ ASSEM_REGEXP, /* One Boolean operand, but weird mapping to call flags */
ASSEM_REVERSE, /* REVERSE: 4-byte operand count, consumes N, produces N */
ASSEM_SINT1, /* One 1-byte signed-integer operand (INCR_STK_IMM) */
ASSEM_SINT4_LVT4,
diff --git a/tests/assemble.test b/tests/assemble.test
index 79ac9e2..36afe80 100644
--- a/tests/assemble.test
+++ b/tests/assemble.test
@@ -843,6 +843,13 @@ test assemble-7.45 {listNotIn} {
-result 1
}
+test assemble-7.46 {nop} {
+ -body {
+ assemble { push x; nop; nop; nop}
+ }
+ -result x
+}
+
# assemble-8 ASSEM_LVT and FindLocalVar
test assemble-8.1 {load, wrong # args} {
@@ -2920,6 +2927,68 @@ test assemble-28.6 {dictIncrImm} {
-cleanup {rename x {}}
}
+# assemble-29 - ASSEM_REGEXP
+
+test assemble-29.1 {regexp - wrong # args} {
+ -body {
+ assemble {regexp}
+ }
+ -returnCodes error
+ -match glob
+ -result {wrong # args*}
+}
+
+test assemble-29.2 {regexp - wrong # args} {
+ -body {
+ assemble {regexp too many}
+ }
+ -returnCodes error
+ -match glob
+ -result {wrong # args*}
+}
+
+test assemble-29.3 {regexp - bad subst} {
+ -body {
+ assemble {regexp $foo}
+ }
+ -returnCodes error
+ -match glob
+ -result {assembly code may not contain substitutions}
+}
+
+test assemble-29.4 {regexp - not a boolean} {
+ -body {
+ proc x {} {
+ assemble {regexp rubbish}
+ }
+ x
+ }
+ -returnCodes error
+ -result {expected boolean value but got "rubbish"}
+ -cleanup {rename x {}}
+}
+
+test assemble-29.5 {regexp} {
+ -body {
+ assemble {push br.*br; push abracadabra; regexp false}
+ }
+ -result 1
+}
+
+test assemble-29.6 {regexp} {
+ -body {
+ assemble {push br.*br; push aBRacadabra; regexp false}
+ }
+ -result 0
+}
+
+test assemble-29.7 {regexp} {
+ -body {
+ assemble {push br.*br; push aBRacadabra; regexp true}
+ }
+ -result 1
+}
+
test assemble-30.1 {unbalanced stack} {
-body {
list \