本文整理汇总了C#中tcl.lang.Interp.newCallFrame方法的典型用法代码示例。如果您正苦于以下问题:C# Interp.newCallFrame方法的具体用法?C# Interp.newCallFrame怎么用?C# Interp.newCallFrame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tcl.lang.Interp
的用法示例。
在下文中一共展示了Interp.newCallFrame方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: cmdProc
public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv )
{
// Create the call frame and parameter bindings
CallFrame frame = interp.newCallFrame( this, argv );
// Execute the body
interp.pushDebugStack( srcFileName, srcLineNumber );
try
{
Parser.eval2( interp, body.array, body.index, body_length, 0 );
}
catch ( TclException e )
{
TCL.CompletionCode code = e.getCompletionCode();
if ( code == TCL.CompletionCode.RETURN )
{
TCL.CompletionCode realCode = interp.updateReturnInfo();
if ( realCode != TCL.CompletionCode.OK )
{
e.setCompletionCode( realCode );
throw;
}
}
else if ( code == TCL.CompletionCode.ERROR )
{
interp.addErrorInfo( "\n (procedure \"" + argv[0] + "\" line " + interp.errorLine + ")" );
throw;
}
else if ( code == TCL.CompletionCode.BREAK )
{
throw new TclException( interp, "invoked \"break\" outside of a loop" );
}
else if ( code == TCL.CompletionCode.CONTINUE )
{
throw new TclException( interp, "invoked \"continue\" outside of a loop" );
}
else
{
throw;
}
}
finally
{
interp.popDebugStack();
// The check below is a hack. The problem is that there
// could be unset traces on the variables, which cause
// scripts to be evaluated. This will clear the
// errInProgress flag, losing stack trace information if
// the procedure was exiting with an error. The code
// below preserves the flag. Unfortunately, that isn't
// really enough: we really should preserve the errorInfo
// variable too (otherwise a nested error in the trace
// script will trash errorInfo). What's really needed is
// a general-purpose mechanism for saving and restoring
// interpreter state.
if ( interp.errInProgress )
{
frame.dispose();
interp.errInProgress = true;
}
else
{
frame.dispose();
}
}
return TCL.CompletionCode.RETURN;
}
示例2: evalCmd
/*
*----------------------------------------------------------------------
*
* NamespaceEvalCmd -> evalCmd
*
* Invoked to implement the "namespace eval" command. Executes
* commands in a namespace. If the namespace does not already exist,
* it is created. Handles the following syntax:
*
* namespace eval name arg ?arg...?
*
* If more than one arg argument is specified, the command that is
* executed is the result of concatenating the arguments together with
* a space between each argument.
*
* Results:
* Returns if successful, raises TclException if something goes wrong.
*
* Side effects:
* Returns the result of the command in the interpreter's result
* object. If anything goes wrong, this procedure returns an error
* message as the result.
*
*----------------------------------------------------------------------
*/
private static void evalCmd(Interp interp, TclObject[] objv)
{
Namespace namespace_Renamed;
CallFrame frame;
string cmd;
string name;
int length;
if (objv.Length < 4)
{
throw new TclNumArgsException(interp, 2, objv, "name arg ?arg...?");
}
// Try to resolve the namespace reference, caching the result in the
// namespace object along the way.
namespace_Renamed = getNamespaceFromObj(interp, objv[2]);
// If the namespace wasn't found, try to create it.
if (namespace_Renamed == null)
{
name = objv[2].ToString();
namespace_Renamed = createNamespace(interp, name, null);
if (namespace_Renamed == null)
{
// FIXME : result hack, we get the interp result and throw it!
throw new TclException(interp, interp.getResult().ToString());
}
}
// Make the specified namespace the current namespace and evaluate
// the command(s).
frame = interp.newCallFrame();
pushCallFrame(interp, frame, namespace_Renamed, false);
try
{
if (objv.Length == 4)
{
interp.eval(objv[3], 0);
}
else
{
cmd = Util.concat(3, objv.Length, objv);
// eval() will delete the object when it decrements its
// refcount after eval'ing it.
interp.eval(cmd); // do not pass TCL_EVAL_DIRECT, for compiler only
}
}
catch (TclException ex)
{
if (ex.getCompletionCode() == TCL.CompletionCode.ERROR)
{
interp.addErrorInfo("\n (in namespace eval \"" + namespace_Renamed.fullName + "\" script line " + interp.errorLine + ")");
}
throw ex;
}
finally
{
popCallFrame(interp);
}
return ;
}
示例3: inscopeCmd
/*
*----------------------------------------------------------------------
*
* NamespaceInscopeCmd -> inscopeCmd
*
* Invoked to implement the "namespace inscope" command that executes a
* script in the context of a particular namespace. This command is not
* expected to be used directly by programmers; calls to it are
* generated implicitly when programs use "namespace code" commands
* to register callback scripts. Handles the following syntax:
*
* namespace inscope name arg ?arg...?
*
* The "namespace inscope" command is much like the "namespace eval"
* command except that it has lappend semantics and the namespace must
* already exist. It treats the first argument as a list, and appends
* any arguments after the first onto the end as proper list elements.
* For example,
*
* namespace inscope ::foo a b c d
*
* is equivalent to
*
* namespace eval ::foo [concat a [list b c d]]
*
* This lappend semantics is important because many callback scripts
* are actually prefixes.
*
* Results:
* Returns if successful, raises TclException if something goes wrong.
*
* Side effects:
* Returns a result in the Tcl interpreter's result object.
*
*----------------------------------------------------------------------
*/
private static void inscopeCmd(Interp interp, TclObject[] objv)
{
Namespace namespace_Renamed;
CallFrame frame;
int i, result;
if (objv.Length < 4)
{
throw new TclNumArgsException(interp, 2, objv, "name arg ?arg...?");
}
// Resolve the namespace reference.
namespace_Renamed = getNamespaceFromObj(interp, objv[2]);
if (namespace_Renamed == null)
{
throw new TclException(interp, "unknown namespace \"" + objv[2].ToString() + "\" in inscope namespace command");
}
// Make the specified namespace the current namespace.
frame = interp.newCallFrame();
pushCallFrame(interp, frame, namespace_Renamed, false);
// Execute the command. If there is just one argument, just treat it as
// a script and evaluate it. Otherwise, create a list from the arguments
// after the first one, then concatenate the first argument and the list
// of extra arguments to form the command to evaluate.
try
{
if (objv.Length == 4)
{
interp.eval(objv[3], 0);
}
else
{
TclObject[] concatObjv = new TclObject[2];
TclObject list;
string cmd;
list = TclList.newInstance();
for (i = 4; i < objv.Length; i++)
{
try
{
TclList.append(interp, list, objv[i]);
}
catch (TclException ex)
{
list.release(); // free unneeded obj
throw ex;
}
}
concatObjv[0] = objv[3];
concatObjv[1] = list;
cmd = Util.concat(0, 1, concatObjv);
interp.eval(cmd); // do not pass TCL_EVAL_DIRECT, for compiler only
list.release(); // we're done with the list object
}
//.........这里部分代码省略.........
示例4: getNamespaceForQualName
//.........这里部分代码省略.........
}
else
{
nsPtrPtr[0] = ns;
altNsPtrPtr[0] = altNs;
simpleNamePtr[0] = qualName.Substring(start_ind);
return ;
}
}
else
{
// start points to the beginning of a namespace qualifier ending
// in "::". Create new string with the namespace qualifier.
nsName = qualName.Substring(start_ind, (start_ind + len) - (start_ind));
}
// Look up the namespace qualifier nsName in the current namespace
// context. If it isn't found but TCL.VarFlag.CREATE_NS_IF_UNKNOWN is set,
// create that qualifying namespace. This is needed for procedures
// like Tcl_CreateCommand that cannot fail.
if (ns != null)
{
entryNs = (Namespace) ns.childTable[nsName];
if (entryNs != null)
{
ns = entryNs;
}
else if ((flags & TCL.VarFlag.CREATE_NS_IF_UNKNOWN) != 0)
{
CallFrame frame = interp.newCallFrame();
pushCallFrame(interp, frame, ns, false);
ns = createNamespace(interp, nsName, null);
popCallFrame(interp);
if (ns == null)
{
throw new System.SystemException("Could not create namespace " + nsName);
}
}
else
{
ns = null; // namespace not found and wasn't created
}
}
// Look up the namespace qualifier in the alternate search path too.
if (altNs != null)
{
altNs = (Namespace) altNs.childTable[nsName];
}
// If both search paths have failed, return null results.
if ((ns == null) && (altNs == null))
{
nsPtrPtr[0] = null;
altNsPtrPtr[0] = null;
simpleNamePtr[0] = null;
return ;