diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2005-07-21 21:48:37 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2005-07-21 21:48:37 (GMT) |
commit | 6a77d40d48491f6d5c3dabe5a735ac475c14c493 (patch) | |
tree | c76bea3e15d9b35ebbc33ce09572debe570e3a00 /generic/tclCompile.c | |
parent | 62e6cfe58942a5ad17479f50213844599b49b9e6 (diff) | |
download | tcl-6a77d40d48491f6d5c3dabe5a735ac475c14c493.zip tcl-6a77d40d48491f6d5c3dabe5a735ac475c14c493.tar.gz tcl-6a77d40d48491f6d5c3dabe5a735ac475c14c493.tar.bz2 |
Compiler for [dict] and related changes.
Diffstat (limited to 'generic/tclCompile.c')
-rw-r--r-- | generic/tclCompile.c | 63 |
1 files changed, 57 insertions, 6 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c index 28edd75..6cc8428 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCompile.c,v 1.89 2005/07/14 13:41:41 dkf Exp $ + * RCS: @(#) $Id: tclCompile.c,v 1.90 2005/07/21 21:49:02 dkf Exp $ */ #include "tclInt.h" @@ -274,10 +274,9 @@ InstructionDesc tclInstructionTable[] = { * (operand-2) indices; pushes the new value. */ - {"return", 9, -1, 2, {OPERAND_INT4, OPERAND_UINT4}}, - /* Compiled [return], code, level are operands; options and result are - * on the stack. */ - + {"returnImm", 9, -1, 2, {OPERAND_INT4, OPERAND_UINT4}}, + /* Compiled [return], code, level are operands; options and result + * are on the stack. */ {"expon", 1, -1, 0, {OPERAND_NONE}}, /* Binary exponentiation operator: push (stknext ** stktop) */ @@ -311,6 +310,58 @@ InstructionDesc tclInstructionTable[] = { {"pushReturnOpts", 1, +1, 0, {OPERAND_NONE}}, /* Push the interpreter's return option dictionary as an object on the * stack. */ + {"returnStk", 1, -2, 0, {OPERAND_NONE}}, + /* Compiled [return]; options and result are on the stack, code and + * level are in the options. */ + + {"dictGet", 5, INT_MIN, 1, {OPERAND_UINT4}}, + /* The top op4 words (min 1) are a key path into the dictionary just + * below the keys on the stack, and all those values are replaced by + * the value read out of that key-path (like [dict get]). + * Stack: ... dict key1 ... keyN => ... value */ + {"dictSet", 5, INT_MIN, 2, {OPERAND_UINT4, OPERAND_LVT4}}, + /* Update a dictionary value such that the keys are a path pointing to + * the value. op4#1 = numKeys, op4#2 = LVTindex + * Stack: ... key1 ... keyN value => ... newDict */ + {"dictUnset", 5, INT_MIN, 2, {OPERAND_UINT4, OPERAND_LVT4}}, + /* Update a dictionary value such that the keys are not a path pointing + * to any value. op4#1 = numKeys, op4#2 = LVTindex + * Stack: ... key1 ... keyN => ... newDict */ + {"dictIncrImm", 5, 0, 2, {OPERAND_INT4, OPERAND_LVT4}}, + /* Update a dictionary value such that the value pointed to by key is + * incremented by some value (or set to it if the key isn't in the + * dictionary at all). op4#1 = incrAmount, op4#2 = LVTindex + * Stack: ... key => ... newDict */ + {"dictAppend", 5, -1, 1, {OPERAND_LVT4}}, + /* Update a dictionary value such that the value pointed to by key has + * some value string-concatenated onto it. op4 = LVTindex + * Stack: ... key valueToAppend => ... newDict */ + {"dictLappend", 5, -1, 1, {OPERAND_LVT4}}, + /* Update a dictionary value such that the value pointed to by key has + * some value list-appended onto it. op4 = LVTindex + * Stack: ... key valueToAppend => ... newDict */ + {"dictFirst", 5, +2, 1, {OPERAND_LVT4}}, + /* Begin iterating over the dictionary, using the local scalar + * indicated by op4 to hold the iterator state. If doneBool is true, + * dictDone *must* be called later on. + * Stack: ... dict => ... value key doneBool */ + {"dictNext", 5, +3, 1, {OPERAND_LVT4}}, + /* Get the next iteration from the iterator in op4's local scalar. + * Stack: ... => ... value key doneBool */ + {"dictDone", 5, 0, 1, {OPERAND_LVT4}}, + /* Terminate the iterator in op4's local scalar. */ + {"dictUpdateStart", 5, -2, 1, {OPERAND_LVT4}}, + /* Create the variables to mirror the state of the dictionary in the + * variable referred to by the immediate argument. + * Stack: ... keyList LVTindexList => ... + * Note that the list of LVT indices is assumed to be the same length + * as the keyList, and the indices should be only ever generated by the + * compiler. */ + {"dictUpdateEnd", 5, -2, 1, {OPERAND_LVT4}}, + /* Reflect the state of local variables back to the state of the + * dictionary in the variable referred to by the immediate argument. + * Stack: ... keyList LVTindexList => ... + * Same notes as in "dictUpdateStart" apply here. */ {0} }; @@ -1216,7 +1267,7 @@ TclCompileScript(interp, script, numBytes, envPtr) * offsets of the source and code for the command. */ - finishCommand: + finishCommand: EnterCmdExtentData(envPtr, currCmdIndex, commandLength, (envPtr->codeNext-envPtr->codeStart) - startCodeOffset); isFirstCmd = 0; |