diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2012-12-18 10:21:34 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2012-12-18 10:21:34 (GMT) |
commit | 81a67b9cf4d7fa11160de36419042e5f5812cc5c (patch) | |
tree | a3ef61d217fa5bb2731a2bda48fb8c7c5a9a5086 /generic | |
parent | 569360bf40839acdb1eefefb0cf1fbb8b7e33083 (diff) | |
download | tcl-81a67b9cf4d7fa11160de36419042e5f5812cc5c.zip tcl-81a67b9cf4d7fa11160de36419042e5f5812cc5c.tar.gz tcl-81a67b9cf4d7fa11160de36419042e5f5812cc5c.tar.bz2 |
Better version that can handle simple composite array keys as well. As long as
they are free of command substitutions, we can still safely omit the exception
processor code.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclCompCmdsSZ.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c index 71a1dfc..7bead0d 100644 --- a/generic/tclCompCmdsSZ.c +++ b/generic/tclCompCmdsSZ.c @@ -838,19 +838,32 @@ TclSubstCompile( continue; case TCL_TOKEN_VARIABLE: /* - * Simple variable access; can only generate TCL_OK or TCL_ERROR - * so no need to generate elaborate exception-management code. + * Check for simple variable access; see if we can only generate + * TCL_OK or TCL_ERROR from the substituted variable read; if so, + * there is no need to generate elaborate exception-management + * code. Note that the first component of TCL_TOKEN_VARIABLE is + * always TCL_TOKEN_TEXT... */ - if (tokenPtr->numComponents == 1 || (tokenPtr->numComponents == 2 - && tokenPtr[2].type == TCL_TOKEN_TEXT)) { - envPtr->line = bline; - TclCompileVarSubst(interp, tokenPtr, envPtr); - bline = envPtr->line; - count++; - continue; + if (tokenPtr->numComponents > 1) { + int i, foundCommand = 0; + + for (i=2 ; i<=tokenPtr->numComponents ; i++) { + if (tokenPtr[i].type == TCL_TOKEN_COMMAND) { + foundCommand = 1; + break; + } + } + if (foundCommand) { + break; + } } - break; + + envPtr->line = bline; + TclCompileVarSubst(interp, tokenPtr, envPtr); + bline = envPtr->line; + count++; + continue; } while (count > 255) { |