当前位置: 首页>>代码示例>>C#>>正文


C# Interp.getCommand方法代码示例

本文整理汇总了C#中tcl.lang.Interp.getCommand方法的典型用法代码示例。如果您正苦于以下问题:C# Interp.getCommand方法的具体用法?C# Interp.getCommand怎么用?C# Interp.getCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tcl.lang.Interp的用法示例。


在下文中一共展示了Interp.getCommand方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: evalObjv

    public static void evalObjv( Interp interp, TclObject[] objv, int length, int flags )
    {
      Command cmd;
      WrappedCommand wCmd = null;
      TclObject[] newObjv;
      int i;
      CallFrame savedVarFrame; //Saves old copy of interp.varFrame
      // in case TCL.EVAL_GLOBAL was set.

      interp.resetResult();
      if ( objv.Length == 0 )
      {
        return;
      }

      // If the interpreter was deleted, return an error.

      if ( interp.deleted )
      {
        interp.setResult( "attempt to call eval in deleted interpreter" );
        interp.setErrorCode( TclString.newInstance( "CORE IDELETE {attempt to call eval in deleted interpreter}" ) );
        throw new TclException( TCL.CompletionCode.ERROR );
      }

      // Check depth of nested calls to eval:  if this gets too large,
      // it's probably because of an infinite loop somewhere.

      if ( interp.nestLevel >= interp.maxNestingDepth )
      {
        throw new TclException( interp, "too many nested calls to eval (infinite loop?)" );
      }
      interp.nestLevel++;

      try
      {
        // Find the procedure to execute this command. If there isn't one,
        // then see if there is a command "unknown".  If so, create a new
        // word array with "unknown" as the first word and the original
        // command words as arguments.  Then call ourselves recursively
        // to execute it.


        cmd = interp.getCommand( objv[0].ToString() );
        if ( cmd == null )
          wCmd = interp.getObjCommand( objv[0].ToString() );
        // See if we are running as a slave interpretor, and this is a windows command        
        if ( cmd == null && wCmd == null && interp.slave != null )
        {
          wCmd = interp.slave.masterInterp.getObjCommand( objv[0].ToString() );
        }
        if ( cmd == null && wCmd == null )
        {
          newObjv = new TclObject[objv.Length + 1];
          for ( i = ( objv.Length - 1 ); i >= 0; i-- )
          {
            newObjv[i + 1] = objv[i];
          }
          newObjv[0] = TclString.newInstance( "unknown" );
          newObjv[0].preserve();
          cmd = interp.getCommand( "unknown" );
          if ( cmd == null )
          {

            Debug.Assert( false, "invalid command name \"" + objv[0].ToString() + "\"" );
            throw new TclException( interp, "invalid command name \"" + objv[0].ToString() + "\"" );
          }
          else
          {
            evalObjv( interp, newObjv, length, 0 );
          }
          newObjv[0].release();
          return;
        }

        // Finally, invoke the Command's cmdProc.

        interp.cmdCount++;
        savedVarFrame = interp.varFrame;
        if ( ( flags & TCL.EVAL_GLOBAL ) != 0 )
        {
          interp.varFrame = null;
        }

        int rc = 0;
        if ( cmd != null )
        {
          if ( cmd.cmdProc( interp, objv ) == TCL.CompletionCode.EXIT )
            throw new TclException( TCL.CompletionCode.EXIT );
        }
        else
        {
          rc = wCmd.objProc( wCmd.objClientData, interp, objv.Length, objv );
          if ( rc != 0 )
          {
            if ( rc == TCL.TCL_RETURN )
              throw new TclException( TCL.CompletionCode.RETURN );
            throw new TclException( TCL.CompletionCode.ERROR );
          }
        }
        interp.varFrame = savedVarFrame;
//.........这里部分代码省略.........
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:101,代码来源:Parser.cs

示例2: cmdProc

		public TCL.CompletionCode cmdProc(Interp interp, TclObject[] objv)
		{
			if (objv.Length < 2)
			{
				throw new TclNumArgsException(interp, 1, objv, "cmd ?arg ...?");
			}
			int cmd = TclIndex.get(interp, objv[1], options, "option", 0);
			
			switch (cmd)
			{
				
				case OPT_ALIAS:  {
						if (objv.Length >= 4)
						{
							Interp slaveInterp = getInterp(interp, objv[2]);
							
							if (objv.Length == 4)
							{
								InterpAliasCmd.describe(interp, slaveInterp, objv[3]);
                return TCL.CompletionCode.RETURN;
              }
							
							if ((objv.Length == 5) && ("".Equals(objv[4].ToString())))
							{
								InterpAliasCmd.delete(interp, slaveInterp, objv[3]);
                return TCL.CompletionCode.RETURN;
              }
							if (objv.Length > 5)
							{
								Interp masterInterp = getInterp(interp, objv[4]);
								
								if ("".Equals(objv[5].ToString()))
								{
									if (objv.Length == 6)
									{
										InterpAliasCmd.delete(interp, slaveInterp, objv[3]);
                    return TCL.CompletionCode.RETURN;
                  }
								}
								else
								{
									InterpAliasCmd.create(interp, slaveInterp, masterInterp, objv[3], objv[5], 6, objv);
                  return TCL.CompletionCode.RETURN;
                }
							}
						}
						throw new TclNumArgsException(interp, 2, objv, "slavePath slaveCmd ?masterPath masterCmd? ?args ..?");
					}
				
				case OPT_ALIASES:  {
						Interp slaveInterp = getInterp(interp, objv);
						InterpAliasCmd.list(interp, slaveInterp);
						break;
					}
				
				case OPT_CREATE:  {
						
						// Weird historical rules: "-safe" is accepted at the end, too.
						
						bool safe = interp.isSafe;
						
						TclObject slaveNameObj = null;
						bool last = false;
						for (int i = 2; i < objv.Length; i++)
						{
							
							if ((!last) && (objv[i].ToString()[0] == '-'))
							{
								int index = TclIndex.get(interp, objv[i], createOptions, "option", 0);
								if (index == OPT_CREATE_SAFE)
								{
									safe = true;
									continue;
								}
								i++;
								last = true;
							}
							if (slaveNameObj != null)
							{
								throw new TclNumArgsException(interp, 2, objv, "?-safe? ?--? ?path?");
							}
							slaveNameObj = objv[i];
						}
						if (slaveNameObj == null)
						{
							
							// Create an anonymous interpreter -- we choose its name and
							// the name of the command. We check that the command name
							// that we use for the interpreter does not collide with an
							// existing command in the master interpreter.
							
							int i = 0;
							while (interp.getCommand("interp" + i) != null)
							{
								i++;
							}
							slaveNameObj = TclString.newInstance("interp" + i);
						}
						InterpSlaveCmd.create(interp, slaveNameObj, safe);
						interp.setResult(slaveNameObj);
//.........这里部分代码省略.........
开发者ID:Belxjander,项目名称:Asuna,代码行数:101,代码来源:InterpCmd.cs


注:本文中的tcl.lang.Interp.getCommand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。