private ArrayList Errors = new ArrayList(10); // A list of the pending background error handlers. internal BgErrorMgr(Interp i) { Interp = i; BgerrorCmdObj = TclString.NewInstance("bgerror"); BgerrorCmdObj.Preserve(); Errors = new ArrayList(10); }
internal static void eval(Interp interp, Interp slaveInterp, int objIx, TclObject[] objv) { TCL.CompletionCode result; slaveInterp.preserve(); slaveInterp.allowExceptions(); try { if (objIx + 1 == objv.Length) { slaveInterp.Eval(objv[objIx], 0); } else { TclObject obj = TclList.NewInstance(); for (int ix = objIx; ix < objv.Length; ix++) { TclList.Append(interp, obj, objv[ix]); } obj.Preserve(); slaveInterp.Eval(obj, 0); obj.Release(); } result = slaveInterp._returnCode; } catch (TclException e) { result = e.GetCompletionCode(); } slaveInterp.release(); interp.transferResult(slaveInterp, result); }
internal static void create(Interp interp, Interp slaveInterp, Interp masterInterp, TclObject name, TclObject targetName, int objIx, TclObject[] objv) { string inString = name.ToString(); InterpAliasCmd alias = new InterpAliasCmd(); alias.name = name; name.Preserve(); alias.slaveInterp = slaveInterp; alias.targetInterp = masterInterp; alias.prefix = TclList.NewInstance(); alias.prefix.Preserve(); TclList.Append(interp, alias.prefix, targetName); TclList.insert(interp, alias.prefix, 1, objv, objIx, objv.Length - 1); slaveInterp.CreateCommand(inString, alias); alias.slaveCmd = NamespaceCmd.findCommand(slaveInterp, inString, null, 0); try { interp.preventAliasLoop(slaveInterp, alias.slaveCmd); } catch (TclException e) { // Found an alias loop! The last call to Tcl_CreateObjCommand made // the alias point to itself. Delete the command and its alias // record. Be careful to wipe out its client data first, so the // command doesn't try to delete itself. slaveInterp.DeleteCommandFromToken(alias.slaveCmd); throw; } // Make an entry in the alias table. If it already exists delete // the alias command. Then retry. if (slaveInterp._aliasTable.ContainsKey(inString)) { InterpAliasCmd oldAlias = (InterpAliasCmd)slaveInterp._aliasTable[inString]; slaveInterp.DeleteCommandFromToken(oldAlias.slaveCmd); } alias.aliasEntry = inString; SupportClass.PutElement(slaveInterp._aliasTable, inString, alias); // Create the new command. We must do it after deleting any old command, // because the alias may be pointing at a renamed alias, as in: // // interp alias {} foo {} bar # Create an alias "foo" // rename foo zop # Now rename the alias // interp alias {} foo {} zop # Now recreate "foo"... SupportClass.PutElement(masterInterp._targetTable, alias.slaveCmd, slaveInterp); interp.SetResult(name); }
public static void Tcl_SetLongObj(TclObject to, long result) { while (to.Shared) { to.Release(); } TclLong.set(to, result); to.Preserve(); }
public static void Tcl_SetIntObj(TclObject to, int result ) { while (to.Shared) { to.Release(); } TclInteger.set(to, result); to.Preserve(); }
/// <summary> /// Chain this frame into the call frame stack and binds the parameters values to the formal parameters of the procedure. /// </summary> /// <param name="proc"> /// the procedure. /// </param> /// <param name="proc"> /// argv the parameter values. /// </param> /// <exception cref=""> /// TclException if wrong number of arguments. /// </exception> internal void Chain(Procedure proc, TclObject[] objv) { // FIXME: double check this ns thing in case where proc is renamed to different ns. NS = proc.NS; Objv = objv; // FIXME : quick level hack : fix later Level = (Interp.VarFrame == null ? 1 : Interp.VarFrame.Level + 1); Caller = Interp.Frame; CallerVar = Interp.VarFrame; Interp.Frame = this; Interp.VarFrame = this; // parameter bindings int numArgs = proc.ArgList.Length; if (!proc.isVarArgs && objv.Length - 1 > numArgs) { WrongNumProcArgs(objv[0], proc); } for (int i = 0, j = 1; i < numArgs; i++, j++) { // Handle the special case of the last formal being "args". When it occurs, assign it a list consisting of // all the remaining actual arguments. TclObject varName = proc.ArgList[i][0]; TclObject value = null; if (i == (numArgs - 1) && proc.isVarArgs) { value = TclList.NewInstance(); value.Preserve(); for (int k = j; k < objv.Length; k++) { TclList.Append(Interp, value, objv[k]); } Interp.SetVar(varName, value, 0); value.Release(); } else { if (j < objv.Length) { value = objv[j]; } else if (proc.ArgList[i][1] != null) { value = proc.ArgList[i][1]; } else { WrongNumProcArgs(objv[0], proc); } Interp.SetVar(varName, value, 0); } } }
/// <summary> DupListInternalRep -> duplicate /// /// Returns a dupilcate of the current object. /// /// </summary> /// <param name="obj">the TclObject that contains this internalRep. /// </param> public IInternalRep Duplicate() { int size = vector.Count; TclList newList = new TclList(size); for (int i = 0; i < size; i++) { TclObject tobj = (TclObject)vector[i]; tobj.Preserve(); newList.vector.Add(tobj); } return(newList); }
/// <summary> Tcl_ListObjAppendElement -> TclList.append() /// /// Appends a TclObject element to a list object. /// /// </summary> /// <param name="interp">current interpreter. /// </param> /// <param name="tobj">the TclObject to append an element to. /// </param> /// <param name="elemObj">the element to append to the object. /// </param> /// <exception cref=""> TclException if tobj cannot be converted into a list. /// </exception> public static void Append(Interp interp, TclObject tobj, TclObject elemObj) { if (tobj.Shared) { throw new TclRuntimeError("TclList.append() called with shared object"); } setListFromAny(interp, tobj); tobj.invalidateStringRep(); TclList tlist = (TclList)tobj.InternalRep; elemObj.Preserve(); tlist.vector.Add(elemObj); }
public TCL.CompletionCode CmdProc(Interp interp, TclObject[] argv) { targetInterp.preserve(); targetInterp._nestLevel++; targetInterp.ResetResult(); targetInterp.allowExceptions(); // Append the arguments to the command prefix and invoke the command // in the target interp's global namespace. TclObject[] prefv = TclList.getElements(interp, prefix); TclObject cmd = TclList.NewInstance(); cmd.Preserve(); TclList.replace(interp, cmd, 0, 0, prefv, 0, prefv.Length - 1); TclList.replace(interp, cmd, prefv.Length, 0, argv, 1, argv.Length - 1); TclObject[] cmdv = TclList.getElements(interp, cmd); TCL.CompletionCode result = targetInterp.invoke(cmdv, Interp.INVOKE_NO_TRACEBACK); cmd.Release(); targetInterp._nestLevel--; // Check if we are at the bottom of the stack for the target interpreter. // If so, check for special return codes. if (targetInterp._nestLevel == 0) { if (result == TCL.CompletionCode.RETURN) { result = targetInterp.updateReturnInfo(); } if (result != TCL.CompletionCode.OK && result != TCL.CompletionCode.ERROR) { try { targetInterp.processUnexpectedResult(result); } catch (TclException e) { result = e.GetCompletionCode(); } } } targetInterp.release(); interp.transferResult(targetInterp, result); return(TCL.CompletionCode.RETURN); }
/// <summary> See Tcl user documentation for details.</summary> public TCL.CompletionCode CmdProc(Interp interp, TclObject[] argv) { TclObject list = TclList.NewInstance(); list.Preserve(); try { for (int i = 1; i < argv.Length; i++) { TclList.Append(interp, list, argv[i]); } interp.SetResult(list); } finally { list.Release(); } return(TCL.CompletionCode.RETURN); }
/// <summary> Splits a list (in string rep) up into its constituent fields. /// /// </summary> /// <param name="interp">current interpreter. /// </param> /// <param name="v">store the list elements in this vector. /// </param> /// <param name="s">the string to convert into a list. /// </param> /// <exception cref=""> TclException if the object doesn't contain a valid list. /// </exception> private static void splitList(Interp interp, ArrayList v, string s) { int len = s.Length; int i = 0; while (i < len) { FindElemResult res = Util.findElement(interp, s, i, len); if (res == null) { break; } else { TclObject tobj = TclString.NewInstance(res.Elem); tobj.Preserve(); v.Add(tobj); } i = res.ElemEnd; } }
internal ParseResult(StringBuilder sbuf, int ni) { Value = TclString.NewInstance(sbuf.ToString()); Value.Preserve(); nextIndex = ni; }
internal ParseResult(string s, int ni) { Value = TclString.NewInstance(s); Value.Preserve(); nextIndex = ni; }
/// <summary> Create an empty parsed word.</summary> internal ParseResult() { Value = TclString.NewInstance(""); Value.Preserve(); }
/// <summary> See Tcl user documentation for details.</summary> /// <exception cref=""> TclException If incorrect number of arguments. /// </exception> public TCL.CompletionCode CmdProc(Interp interp, TclObject[] argv) { if (argv.Length != 4) { throw new TclNumArgsException(interp, 1, argv, "list first last"); } int size = TclList.getLength(interp, argv[1]); int first; int last; first = Util.getIntForIndex(interp, argv[2], size - 1); last = Util.getIntForIndex(interp, argv[3], size - 1); if (last < 0) { interp.ResetResult(); return(TCL.CompletionCode.RETURN); } if (first >= size) { interp.ResetResult(); return(TCL.CompletionCode.RETURN); } if (first <= 0 && last >= size) { interp.SetResult(argv[1]); return(TCL.CompletionCode.RETURN); } if (first < 0) { first = 0; } if (first >= size) { first = size - 1; } if (last < 0) { last = 0; } if (last >= size) { last = size - 1; } if (first > last) { interp.ResetResult(); return(TCL.CompletionCode.RETURN); } TclObject list = TclList.NewInstance(); list.Preserve(); try { for (int i = first; i <= last; i++) { TclList.Append(interp, list, TclList.index(interp, argv[1], i)); } interp.SetResult(list); } finally { list.Release(); } return(TCL.CompletionCode.RETURN); }
public static void Tcl_SetBooleanObj(TclObject to, int result) { to.stringRep = TclBoolean.newInstance(result != 0).ToString(); to.Preserve(); }
public static void Tcl_IncrRefCount(TclObject to) { to.Preserve(); }
public static void Tcl_DStringInit(out TclObject str) { str = TclString.NewInstance(""); str.Preserve(); }
/// <summary> This procedure is invoked to process the "split" Tcl /// command. See Tcl user documentation for details. /// /// </summary> /// <param name="interp">the current interpreter. /// </param> /// <param name="argv">command arguments. /// </param> /// <exception cref=""> TclException If incorrect number of arguments. /// </exception> public TCL.CompletionCode CmdProc(Interp interp, TclObject[] argv) { char[] splitChars = null; string inString; if (argv.Length == 2) { splitChars = defSplitChars; } else if (argv.Length == 3) { splitChars = argv[2].ToString().ToCharArray(); } else { throw new TclNumArgsException(interp, 1, argv, "string ?splitChars?"); } inString = argv[1].ToString(); int len = inString.Length; int num = splitChars.Length; /* * Handle the special case of splitting on every character. */ if (num == 0) { TclObject list = TclList.NewInstance(); list.Preserve(); try { for (int i = 0; i < len; i++) { TclList.Append(interp, list, TclString.NewInstance(inString[i])); } interp.SetResult(list); } finally { list.Release(); } return(TCL.CompletionCode.RETURN); } /* * Normal case: split on any of a given set of characters. * Discard instances of the split characters. */ TclObject list2 = TclList.NewInstance(); int elemStart = 0; list2.Preserve(); try { int i, j; for (i = 0; i < len; i++) { char c = inString[i]; for (j = 0; j < num; j++) { if (c == splitChars[j]) { TclList.Append(interp, list2, TclString.NewInstance(inString.Substring(elemStart, (i) - (elemStart)))); elemStart = i + 1; break; } } } if (i != 0) { TclList.Append(interp, list2, TclString.NewInstance(inString.Substring(elemStart))); } interp.SetResult(list2); } finally { list2.Release(); } return(TCL.CompletionCode.RETURN); }
public override int processEvent(int flags) { // See if the command is a complete Tcl command if (Interp.commandComplete(command)) { if (Tcl.Lang.ConsoleThread.debug) { WriteLine("line was a complete command"); } bool eval_exception = true; TclObject commandObj = TclString.NewInstance(command); try { commandObj.Preserve(); Enclosing_Instance.interp.recordAndEval(commandObj, 0); eval_exception = false; } catch (TclException e) { if (Tcl.Lang.ConsoleThread.debug) { WriteLine("eval returned exceptional condition"); } TCL.CompletionCode code = e.GetCompletionCode(); switch (code) { case TCL.CompletionCode.ERROR: Enclosing_Instance.putLine(Enclosing_Instance.err, Enclosing_Instance.interp.GetResult().ToString()); break; case TCL.CompletionCode.BREAK: Enclosing_Instance.putLine(Enclosing_Instance.err, "invoked \"break\" outside of a loop"); break; case TCL.CompletionCode.CONTINUE: Enclosing_Instance.putLine(Enclosing_Instance.err, "invoked \"continue\" outside of a loop"); break; default: Enclosing_Instance.putLine(Enclosing_Instance.err, "command returned bad code: " + code); break; } } finally { commandObj.Release(); } if (!eval_exception) { if (Tcl.Lang.ConsoleThread.debug) { WriteLine("eval returned normally"); } string evalResult = Enclosing_Instance.interp.GetResult().ToString(); if (Tcl.Lang.ConsoleThread.debug) { WriteLine("eval result was \"" + evalResult + "\""); } if (evalResult.Length > 0) { Enclosing_Instance.putLine(Enclosing_Instance.out_Renamed, evalResult); } } // Empty out the incoming command buffer Enclosing_Instance.sbuf.Length = 0; // See if the user set a custom shell prompt for the next command TclObject prompt; try { prompt = Enclosing_Instance.interp.GetVar("tcl_prompt1", TCL.VarFlag.GLOBAL_ONLY); } catch (TclException e) { prompt = null; } if (prompt != null) { try { Enclosing_Instance.interp.Eval(prompt.ToString(), TCL.EVAL_GLOBAL); } catch (TclException e) { Enclosing_Instance.put(Enclosing_Instance.out_Renamed, "% "); } } else { Enclosing_Instance.put(Enclosing_Instance.out_Renamed, "% "); } return(1); } else { // Interp.commandComplete() returned false if (Tcl.Lang.ConsoleThread.debug) { WriteLine("line was not a complete command"); } // We don't have a complete command yet. Print out a level 2 // prompt message and wait for further inputs. TclObject prompt; try { prompt = Enclosing_Instance.interp.GetVar("tcl_prompt2", TCL.VarFlag.GLOBAL_ONLY); } catch (TclException) { prompt = null; } if (prompt != null) { try { Enclosing_Instance.interp.Eval(prompt.ToString(), TCL.EVAL_GLOBAL); } catch (TclException e) { Enclosing_Instance.put(Enclosing_Instance.out_Renamed, ""); } } else { Enclosing_Instance.put(Enclosing_Instance.out_Renamed, ""); } return(1); } } // end processEvent method
public TCL.CompletionCode CmdProc(Interp interp, TclObject[] argv) { int i; Notifier notifier = (Notifier)interp.GetNotifier(); Object info; if (_assocData == null) { // Create the "after" information associated for this interpreter, if it doesn't already exist. _assocData = (AfterAssocData)interp.GetAssocData("tclAfter"); if (_assocData == null) { _assocData = new AfterAssocData(this); interp.SetAssocData("tclAfter", _assocData); } } if (argv.Length < 2) { throw new TclNumArgsException(interp, 1, argv, "option ?arg arg ...?"); } // First lets see if the command was passed a number as the first argument. bool isNumber = false; int ms = 0; if (argv[1].InternalRep is TclInteger) { ms = TclInteger.Get(interp, argv[1]); isNumber = true; } else { string s = argv[1].ToString(); if (s.Length > 0 && char.IsDigit(s[0])) { ms = TclInteger.Get(interp, argv[1]); isNumber = true; } } if (isNumber) { if (ms < 0) { ms = 0; } if (argv.Length == 2) { // Sleep for at least the given milliseconds and return. long endTime = DateTime.Now.Ticks / 10000 + ms; while (true) { try { Thread.Sleep(ms); return(TCL.CompletionCode.RETURN); } catch (ThreadInterruptedException e) { // We got interrupted. Sleep again if we havn't slept long enough yet. long sysTime = System.DateTime.Now.Ticks / 10000; if (sysTime >= endTime) { return(TCL.CompletionCode.RETURN); } ms = (int)(endTime - sysTime); continue; } } } TclObject cmd = GetCmdObject(argv); cmd.Preserve(); _assocData.LastAfterId++; TimerInfo timerInfo = new TimerInfo(this, notifier, ms); timerInfo.Interp = interp; timerInfo.Command = cmd; timerInfo.Id = _assocData.LastAfterId; _assocData.Handlers.Add(timerInfo); interp.SetResult("after#" + timerInfo.Id); return(TCL.CompletionCode.RETURN); } // If it's not a number it must be a subcommand. int index; try { index = TclIndex.Get(interp, argv[1], _validOpts, "option", 0); } catch (TclException e) { throw new TclException(interp, "bad argument \"" + argv[1] + "\": must be cancel, idle, info, or a number"); } switch (index) { case OPT_CANCEL: if (argv.Length < 3) { throw new TclNumArgsException(interp, 2, argv, "id|command"); } TclObject arg = GetCmdObject(argv); arg.Preserve(); // Search the timer/idle handler by id or by command. info = null; for (i = 0; i < _assocData.Handlers.Count; i++) { Object obj = _assocData.Handlers[i]; if (obj is TimerInfo) { TclObject cmd = ((TimerInfo)obj).Command; if (cmd == arg || cmd.ToString().Equals(arg.ToString())) { info = obj; break; } } else { TclObject cmd = ((IdleInfo)obj).Command; if (cmd == arg || cmd.ToString().Equals(arg.ToString())) { info = obj; break; } } } if (info == null) { info = GetAfterEvent(arg.ToString()); } arg.Release(); // Cancel the handler. if (info != null) { if (info is TimerInfo) { ((TimerInfo)info).Cancel(); ((TimerInfo)info).Command.Release(); } else { ((IdleInfo)info).Cancel(); ((IdleInfo)info).Command.Release(); } SupportClass.VectorRemoveElement(_assocData.Handlers, info); } break; case OPT_IDLE: if (argv.Length < 3) { throw new TclNumArgsException(interp, 2, argv, "script script ..."); } TclObject cmd2 = GetCmdObject(argv); cmd2.Preserve(); _assocData.LastAfterId++; IdleInfo idleInfo = new IdleInfo(this, notifier); idleInfo.Interp = interp; idleInfo.Command = cmd2; idleInfo.Id = _assocData.LastAfterId; _assocData.Handlers.Add(idleInfo); interp.SetResult("after#" + idleInfo.Id); break; case OPT_INFO: if (argv.Length == 2) { // No id is given. Return a list of current after id's. TclObject list = TclList.NewInstance(); for (i = 0; i < _assocData.Handlers.Count; i++) { int id; Object obj = _assocData.Handlers[i]; if (obj is TimerInfo) { id = ((TimerInfo)obj).Id; } else { id = ((IdleInfo)obj).Id; } TclList.Append(interp, list, TclString.NewInstance("after#" + id)); } interp.ResetResult(); interp.SetResult(list); return(TCL.CompletionCode.RETURN); } if (argv.Length != 3) { throw new TclNumArgsException(interp, 2, argv, "?id?"); } // Return command and type of the given after id. info = GetAfterEvent(argv[2].ToString()); if (info == null) { throw new TclException(interp, "event \"" + argv[2] + "\" doesn't exist"); } TclObject list2 = TclList.NewInstance(); TclList.Append(interp, list2, ((info is TimerInfo) ? ((TimerInfo)info).Command : ((IdleInfo)info).Command)); TclList.Append(interp, list2, TclString.NewInstance((info is TimerInfo) ? "timer" : "idle")); interp.ResetResult(); interp.SetResult(list2); break; } return(TCL.CompletionCode.RETURN); }
public TCL.CompletionCode CmdProc(Interp interp, TclObject[] objv) { int len; if (objv.Length < 2) { throw new TclNumArgsException(interp, 1, objv, "option [arg arg ...]"); } int opt = TclIndex.Get(interp, objv[1], validCmds, "option", 0); switch (opt) { case OPT_VARIABLE: case OPT_VDELETE: if (objv.Length != 5) { if (opt == OPT_VARIABLE) { throw new TclNumArgsException(interp, 1, objv, "variable name ops command"); } else { throw new TclNumArgsException(interp, 1, objv, "vdelete name ops command"); } } TCL.VarFlag flags = 0; string ops = objv[3].ToString(); len = ops.Length; { for (int i = 0; i < len; i++) { switch (ops[i]) { case 'r': flags |= TCL.VarFlag.TRACE_READS; break; case 'w': flags |= TCL.VarFlag.TRACE_WRITES; break; case 'u': flags |= TCL.VarFlag.TRACE_UNSETS; break; default: flags = 0; goto check_ops_brk; } } } check_ops_brk: ; if (flags == 0) { throw new TclException(interp, "bad operations \"" + objv[3] + "\": should be one or more of rwu"); } if (opt == OPT_VARIABLE) { CmdTraceProc trace = new CmdTraceProc(objv[4].ToString(), flags); Var.TraceVar(interp, objv[2], flags, trace); } else { // Search through all of our traces on this variable to // see if there's one with the given command. If so, then // delete the first one that matches. ArrayList traces = Var.getTraces(interp, objv[2].ToString(), 0); if (traces != null) { len = traces.Count; for (int i = 0; i < len; i++) { TraceRecord rec = (TraceRecord)traces[i]; if (rec.trace is CmdTraceProc) { CmdTraceProc proc = (CmdTraceProc)rec.trace; if (proc.flags == flags && proc.command.ToString().Equals(objv[4].ToString())) { Var.UntraceVar(interp, objv[2], flags, proc); break; } } } } } break; case OPT_VINFO: if (objv.Length != 3) { throw new TclNumArgsException(interp, 2, objv, "name"); } ArrayList traces2 = Var.getTraces(interp, objv[2].ToString(), 0); if (traces2 != null) { len = traces2.Count; TclObject list = TclList.NewInstance(); TclObject cmd = null; list.Preserve(); try { for (int i = 0; i < len; i++) { TraceRecord rec = (TraceRecord)traces2[i]; if (rec.trace is CmdTraceProc) { CmdTraceProc proc = (CmdTraceProc)rec.trace; TCL.VarFlag mode = proc.flags; mode &= (TCL.VarFlag.TRACE_READS | TCL.VarFlag.TRACE_WRITES | TCL.VarFlag.TRACE_UNSETS); int modeInt = (int)mode; modeInt /= ((int)TCL.VarFlag.TRACE_READS); cmd = TclList.NewInstance(); TclList.Append(interp, cmd, opStr[modeInt]); TclList.Append(interp, cmd, TclString.NewInstance(proc.command)); TclList.Append(interp, list, cmd); } } interp.SetResult(list); } finally { list.Release(); } } break; } return(TCL.CompletionCode.RETURN); }
/// <summary> This procedure is invoked to process the "subst" Tcl command. /// See the user documentation for details on what it does. /// /// </summary> /// <param name="interp">the current interpreter. /// </param> /// <param name="argv">command arguments. /// </param> /// <exception cref=""> TclException if wrong # of args or invalid argument(s). /// </exception> public TCL.CompletionCode CmdProc(Interp interp, TclObject[] argv) { int currentObjIndex, len, i; int objc = argv.Length - 1; bool doBackslashes = true; bool doCmds = true; bool doVars = true; StringBuilder result = new StringBuilder(); string s; char c; for (currentObjIndex = 1; currentObjIndex < objc; currentObjIndex++) { if (!argv[currentObjIndex].ToString().StartsWith("-")) { break; } int opt = TclIndex.Get(interp, argv[currentObjIndex], validCmds, "switch", 0); switch (opt) { case OPT_NOBACKSLASHES: doBackslashes = false; break; case OPT_NOCOMMANDS: doCmds = false; break; case OPT_NOVARS: doVars = false; break; default: throw new TclException(interp, "SubstCmd.cmdProc: bad option " + opt + " index to cmds"); } } if (currentObjIndex != objc) { throw new TclNumArgsException(interp, currentObjIndex, argv, "?-nobackslashes? ?-nocommands? ?-novariables? string"); } /* * Scan through the string one character at a time, performing * command, variable, and backslash substitutions. */ s = argv[currentObjIndex].ToString(); len = s.Length; i = 0; while (i < len) { c = s[i]; if ((c == '[') && doCmds) { ParseResult res; try { interp._evalFlags = Parser.TCL_BRACKET_TERM; interp.Eval(s.Substring(i + 1, (len) - (i + 1))); TclObject interp_result = interp.GetResult(); interp_result.Preserve(); res = new ParseResult(interp_result, i + interp._termOffset); } catch (TclException e) { i = e.errIndex + 1; throw; } i = res.nextIndex + 2; result.Append(res.Value.ToString()); res.Release(); } else if (c == '\r') { /* * (ToDo) may not be portable on Mac */ i++; } else if ((c == '$') && doVars) { ParseResult vres = Parser.parseVar(interp, s.Substring(i, (len) - (i))); i += vres.nextIndex; result.Append(vres.Value.ToString()); vres.Release(); } else if ((c == '\\') && doBackslashes) { BackSlashResult bs = Tcl.Lang.Interp.backslash(s, i, len); i = bs.NextIndex; if (bs.IsWordSep) { break; } else { result.Append(bs.C); } } else { result.Append(c); i++; } } interp.SetResult(result.ToString()); return(TCL.CompletionCode.RETURN); }