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


C# Interp.getVar方法代码示例

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


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

示例1: cmdProc

    public TCL.CompletionCode cmdProc( Interp interp, TclObject[] objv )
    {
      TclObject varValue = null;

      if ( objv.Length < 2 )
      {
        throw new TclNumArgsException( interp, 1, objv, "varName ?value value ...?" );
      }
      else if ( objv.Length == 2 )
      {
        interp.resetResult();
        interp.setResult( interp.getVar( objv[1], 0 ) );
      }
      else
      {
        for ( int i = 2; i < objv.Length; i++ )
        {
          varValue = interp.setVar( objv[1], objv[i], TCL.VarFlag.APPEND_VALUE );
        }

        if ( varValue != null )
        {
          interp.resetResult();
          interp.setResult( varValue );
        }
        else
        {
          interp.resetResult();
        }
      }
      return TCL.CompletionCode.RETURN;
    }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:32,代码来源:AppendCmd.cs

示例2: cmdProc

    public TCL.CompletionCode cmdProc( Interp interp, TclObject[] argv )
    {
      bool debug;

      if ( argv.Length == 2 )
      {
        System.Diagnostics.Debug.WriteLine( "getting value of \"" + argv[1].ToString() + "\"" );

        interp.setResult( interp.getVar( argv[1], 0 ) );
      }
      else if ( argv.Length == 3 )
      {
        System.Diagnostics.Debug.WriteLine( "setting value of \"" + argv[1].ToString() + "\" to \"" + argv[2].ToString() + "\"" );
        interp.setResult( interp.setVar( argv[1], argv[2], 0 ) );
      }
      else
      {
        throw new TclNumArgsException( interp, 1, argv, "varName ?newValue?" );
      }
      return TCL.CompletionCode.RETURN;
    }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:21,代码来源:SetCmd.cs

示例3: traceProc

    public void traceProc( Interp interp, string name1, string name2, TCL.VarFlag flags )
    {
      // If the variable is unset, then recreate the trace and restore
      // the default value of the format string.

      if ( ( flags & TCL.VarFlag.TRACE_UNSETS ) != 0 )
      {
        if ( ( ( flags & TCL.VarFlag.TRACE_DESTROYED ) != 0 ) && ( ( flags & TCL.VarFlag.INTERP_DESTROYED ) == 0 ) )
        {
          interp.traceVar( name1, name2, new PrecTraceProc(), TCL.VarFlag.GLOBAL_ONLY | TCL.VarFlag.TRACE_WRITES | TCL.VarFlag.TRACE_READS | TCL.VarFlag.TRACE_UNSETS );
          Util.precision = Util.DEFAULT_PRECISION;
        }
        return;
      }

      // When the variable is read, reset its value from our shared
      // value. This is needed in case the variable was modified in
      // some other interpreter so that this interpreter's value is
      // out of date.

      if ( ( flags & TCL.VarFlag.TRACE_READS ) != 0 )
      {
        interp.setVar( name1, name2, TclInteger.newInstance( Util.precision ), flags & TCL.VarFlag.GLOBAL_ONLY );
        return;
      }

      // The variable is being written. Check the new value and disallow
      // it if it isn't reasonable.
      //
      // (ToDo) Disallow it if this is a safe interpreter (we don't want
      // safe interpreters messing up the precision of other
      // interpreters).

      TclObject tobj = null;
      try
      {
        tobj = interp.getVar( name1, name2, ( flags & TCL.VarFlag.GLOBAL_ONLY ) );
      }
      catch ( TclException e )
      {
        // Do nothing when var does not exist.
      }

      string value;

      if ( tobj != null )
      {

        value = tobj.ToString();
      }
      else
      {
        value = "";
      }

      StrtoulResult r = Util.strtoul( value, 0, 10 );

      if ( ( r == null ) || ( r.value <= 0 ) || ( r.value > TCL_MAX_PREC ) || ( r.value > 100 ) || ( r.index == 0 ) || ( r.index != value.Length ) )
      {
        interp.setVar( name1, name2, TclInteger.newInstance( Util.precision ), TCL.VarFlag.GLOBAL_ONLY );
        throw new TclException( interp, "improper value for precision" );
      }

      Util.precision = (int)r.value;
    }
开发者ID:Belxjander,项目名称:Asuna,代码行数:65,代码来源:Util.cs

示例4: evalTokens

    internal static TclObject evalTokens( Interp interp, TclToken[] tokenList, int tIndex, int count )
    {
      TclObject result, index, value;
      TclToken token;
      string p = null;
      string varName;
      BackSlashResult bs;

      // The only tricky thing about this procedure is that it attempts to
      // avoid object creation and string copying whenever possible.  For
      // example, if the value is just a nested command, then use the
      // command's result object directly.

      result = null;
      for ( ; count > 0; count-- )
      {
        token = tokenList[tIndex];

        // The switch statement below computes the next value to be
        // concat to the result, as either a range of text or an
        // object.

        value = null;
        switch ( token.type )
        {

          case TCL_TOKEN_TEXT:
            p = token.TokenString;
            break;


          case TCL_TOKEN_BS:
            bs = backslash( token.script_array, token.script_index );
            if ( bs.isWordSep )
            {
              p = "\\" + bs.c;
            }
            else
            {
              System.Char ch = bs.c;
              p = ch.ToString();
            }
            break;


          case TCL_TOKEN_COMMAND:
            interp.evalFlags |= Parser.TCL_BRACKET_TERM;
            token.script_index++;

            //should the nest level be changed???
            //interp.nestLevel++;

            eval2( interp, token.script_array, token.script_index, token.size - 2, 0 );

            token.script_index--;
            //interp.nestLevel--;
            value = interp.getResult();
            break;


          case TCL_TOKEN_VARIABLE:
            if ( token.numComponents == 1 )
            {
              index = null;
            }
            else
            {
              index = evalTokens( interp, tokenList, tIndex + 2, token.numComponents - 1 );
              if ( index == null )
              {
                return null;
              }
            }
            varName = tokenList[tIndex + 1].TokenString;

            // In order to get the existing expr parser to work with the
            // new Parser, we test the interp.noEval flag which is set
            // by the expr parser.  If it is != 0, then we do not evaluate 
            // the variable.  This should be removed when the new expr
            // parser is implemented.

            if ( interp.noEval == 0 )
            {
              if ( index != null )
              {
                try
                {

                  value = interp.getVar( varName, index.ToString(), 0 );
                }
                finally
                {
                  index.release();
                }
              }
              else
              {
                value = interp.getVar( varName, null, 0 );
              }
            }
//.........这里部分代码省略.........
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:101,代码来源:Parser.cs

示例5: transferResult

    internal void transferResult( Interp sourceInterp, TCL.CompletionCode result )
    {
      if ( sourceInterp == this )
      {
        return;
      }

      if ( result == TCL.CompletionCode.ERROR )
      {
        TclObject obj;

        // An error occurred, so transfer error information from the source
        // interpreter to the target interpreter.  Setting the flags tells
        // the target interp that it has inherited a partial traceback
        // chain, not just a simple error message.

        if ( !sourceInterp.errAlreadyLogged )
        {
          sourceInterp.addErrorInfo( "" );
        }
        sourceInterp.errAlreadyLogged = true;

        resetResult();

        obj = sourceInterp.getVar( "errorInfo", TCL.VarFlag.GLOBAL_ONLY );
        setVar( "errorInfo", obj, TCL.VarFlag.GLOBAL_ONLY );

        obj = sourceInterp.getVar( "errorCode", TCL.VarFlag.GLOBAL_ONLY );
        setVar( "errorCode", obj, TCL.VarFlag.GLOBAL_ONLY );

        errInProgress = true;
        errCodeSet = true;
      }

      returnCode = result;
      setResult( sourceInterp.getResult() );
      sourceInterp.resetResult();

      if ( result != TCL.CompletionCode.OK )
      {

        throw new TclException( this, getResult().ToString(), result );
      }
    }
开发者ID:R4P3-NET,项目名称:AccountingServerEmulatorSource,代码行数:44,代码来源:Interp.cs

示例6: InfoPatchLevelCmd

    /*
    *----------------------------------------------------------------------
    *
    * InfoPatchLevelCmd --
    *
    *      Called to implement the "info patchlevel" command that returns the
    *      default value for an argument to a procedure. Handles the following
    *      syntax:
    *
    *          info patchlevel
    *
    * Results:
    *      Returns if successful, raises TclException otherwise.
    *
    * Side effects:
    *      Returns a result in the interpreter's result object.
    *
    *----------------------------------------------------------------------
    */

    private static void InfoPatchLevelCmd( Interp interp, TclObject[] objv )
    {
      if ( objv.Length != 2 )
      {
        throw new TclNumArgsException( interp, 2, objv, null );
      }

      interp.setResult( interp.getVar( "tcl_patchLevel", TCL.VarFlag.GLOBAL_ONLY ) );
      return;
    }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:30,代码来源:InfoCmd.cs

示例7: InfoLibraryCmd

    /*
    *----------------------------------------------------------------------
    *
    * InfoLibraryCmd --
    *
    *      Called to implement the "info library" command that returns the
    *      library directory for the Tcl installation. Handles the following
    *      syntax:
    *
    *          info library
    *
    * Results:
    *      Returns if successful, raises TclException otherwise.
    *
    * Side effects:
    *      Returns a result in the interpreter's result object.
    *
    *----------------------------------------------------------------------
    */

    private static void InfoLibraryCmd( Interp interp, TclObject[] objv )
    {
      if ( objv.Length != 2 )
      {
        throw new TclNumArgsException( interp, 2, objv, null );
      }
      try
      {
        interp.setResult( interp.getVar( "tcl_library", TCL.VarFlag.GLOBAL_ONLY ) );
        return;
      }
      catch ( TclException e )
      {
        // If the variable has not been defined
        throw new TclException( interp, "no library has been specified for Tcl" );
      }
    }
开发者ID:Jaden-J,项目名称:csharp-sqlite,代码行数:37,代码来源:InfoCmd.cs

示例8: cmdProc


//.........这里部分代码省略.........
            {

              pattern = objv[3].ToString();
            }

            Hashtable table = (Hashtable)var.value;
            TclObject tobj = TclList.newInstance();

            string arrayName = objv[2].ToString();
            string key, strValue;
            Var var2;

            // Go through each key in the hash table.  If there is a 
            // pattern, test for a match.  Each valid key and its value 
            // is written into sbuf, which is returned.

            // FIXME : do we need to port over the 8.1 code for this loop?

            for ( IDictionaryEnumerator e = table.GetEnumerator(); e.MoveNext(); )
            {
              key = ( (string)e.Key );
              var2 = (Var)e.Value;
              if ( var2.isVarUndefined() )
              {
                continue;
              }

              if ( (System.Object)pattern != null && !Util.stringMatch( key, pattern ) )
              {
                continue;
              }


              strValue = interp.getVar( arrayName, key, 0 ).ToString();

              TclList.append( interp, tobj, TclString.newInstance( key ) );
              TclList.append( interp, tobj, TclString.newInstance( strValue ) );
            }
            interp.setResult( tobj );
            break;
          }

        case OPT_NAMES:
          {

            if ( ( objv.Length != 3 ) && ( objv.Length != 4 ) )
            {
              throw new TclNumArgsException( interp, 2, objv, "arrayName ?pattern?" );
            }
            if ( notArray )
            {
              return TCL.CompletionCode.RETURN;
            }

            string pattern = null;
            if ( objv.Length == 4 )
            {

              pattern = objv[3].ToString();
            }

            Hashtable table = (Hashtable)var.value;
            TclObject tobj = TclList.newInstance();
            string key;

            // Go through each key in the hash table.  If there is a 
开发者ID:R4P3-NET,项目名称:AccountingServerEmulatorSource,代码行数:67,代码来源:ArrayCmd.cs

示例9: cmdProc

		/// <summary> 
		/// Tcl_LappendObjCmd -> LappendCmd.cmdProc
		/// 
		/// This procedure is invoked to process the "lappend" Tcl command.
		/// See the user documentation for details on what it does.
		/// </summary>
		
		public TCL.CompletionCode cmdProc(Interp interp, TclObject[] objv)
		{
			TclObject varValue, newValue = null;
      int i;//int numElems, i, j;
			bool createdNewObj, createVar;
			
			if (objv.Length < 2)
			{
				throw new TclNumArgsException(interp, 1, objv, "varName ?value value ...?");
			}
			if (objv.Length == 2)
			{
				try
				{
					newValue = interp.getVar(objv[1], 0);
				}
				catch (TclException e)
				{
					// The variable doesn't exist yet. Just create it with an empty
					// initial value.
					varValue = TclList.newInstance();
					
					try
					{
						newValue = interp.setVar(objv[1], varValue, 0);
					}
					finally
					{
						if (newValue == null)
							varValue.release(); // free unneeded object
					}
					
					interp.resetResult();
          return TCL.CompletionCode.RETURN;
				}
			}
			else
			{
				// We have arguments to append. We used to call Tcl_SetVar2 to
				// append each argument one at a time to ensure that traces were run
				// for each append step. We now append the arguments all at once
				// because it's faster. Note that a read trace and a write trace for
				// the variable will now each only be called once. Also, if the
				// variable's old value is unshared we modify it directly, otherwise
				// we create a new copy to modify: this is "copy on write".
				
				createdNewObj = false;
				createVar = true;
				
				try
				{
					varValue = interp.getVar(objv[1], 0);
				}
				catch (TclException e)
				{
					// We couldn't read the old value: either the var doesn't yet
					// exist or it's an array element. If it's new, we will try to
					// create it with Tcl_ObjSetVar2 below.
					
					// FIXME : not sure we even need this parse for anything!
					// If we do not need to parse could we at least speed it up a bit
					
					string varName;
					int nameBytes;
					
					
					varName = objv[1].ToString();
					nameBytes = varName.Length; // Number of Unicode chars in string
					
					for (i = 0; i < nameBytes; i++)
					{
						if (varName[i] == '(')
						{
							i = nameBytes - 1;
							if (varName[i] == ')')
							{
								// last char is ')' => array ref
								createVar = false;
							}
							break;
						}
					}
					varValue = TclList.newInstance();
					createdNewObj = true;
				}
				
				// We only take this branch when the catch branch was not run
				if (createdNewObj == false && varValue.Shared)
				{
					varValue = varValue.duplicate();
					createdNewObj = true;
				}
				
//.........这里部分代码省略.........
开发者ID:Belxjander,项目名称:Asuna,代码行数:101,代码来源:LappendCmd.cs

示例10: doTildeSubst

    internal static string doTildeSubst( Interp interp, string user )
    {
      string dir;

      if ( user.Length == 0 )
      {
        try
        {

          dir = interp.getVar( "env", "HOME", TCL.VarFlag.GLOBAL_ONLY ).ToString();
        }
        catch ( System.Exception e )
        {
          throw new TclException( interp, "couldn't find HOME environment variable to expand path" );
        }
        return dir;
      }

      // WARNING:  Java does not support other users.  "dir" is always null,
      // but it should be the home directory (corresponding to the user name), as
      // specified in the password file.

      dir = null;
      if ( (System.Object)dir == null )
      {
        throw new TclException( interp, "user \"" + user + "\" doesn't exist" );
      }
      return dir;
    }
开发者ID:R4P3-NET,项目名称:AccountingServerEmulatorSource,代码行数:29,代码来源:FileUtil.cs


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