コード例 #1
0
        internal Procedure(Interp interp, NamespaceCmd.Namespace ns, string name, TclObject args, TclObject b, string sFileName, int sLineNumber)
        {
            this.ns       = ns;
            srcFileName   = sFileName;
            srcLineNumber = sLineNumber;

            // Break up the argument list into argument specifiers, then process
            // each argument specifier.

            int numArgs = TclList.getLength(interp, args);

            argList = new TclObject[numArgs][];
            for (int i = 0; i < numArgs; i++)
            {
                argList[i] = new TclObject[2];
            }

            for (int i = 0; i < numArgs; i++)
            {
                // Now divide the specifier up into name and default.

                TclObject argSpec = TclList.index(interp, args, i);
                int       specLen = TclList.getLength(interp, argSpec);

                if (specLen == 0)
                {
                    throw new TclException(interp, "procedure \"" + name + "\" has argument with no name");
                }
                if (specLen > 2)
                {
                    throw new TclException(interp, "too many fields in argument " + "specifier \"" + argSpec + "\"");
                }

                argList[i][0] = TclList.index(interp, argSpec, 0);
                argList[i][0].preserve();
                if (specLen == 2)
                {
                    argList[i][1] = TclList.index(interp, argSpec, 1);
                    argList[i][1].preserve();
                }
                else
                {
                    argList[i][1] = null;
                }
            }


            if (numArgs > 0 && (argList[numArgs - 1][0].ToString().Equals("args")))
            {
                isVarArgs = true;
            }
            else
            {
                isVarArgs = false;
            }


            body        = new CharPointer(b.ToString());
            body_length = body.length();
        }
コード例 #2
0
        public void  disposeCmd()
        {
            //body.release();
            body = null;
            for (int i = 0; i < argList.Length; i++)
            {
                argList[i][0].release();
                argList[i][0] = null;

                if (argList[i][1] != null)
                {
                    argList[i][1].release();
                    argList[i][1] = null;
                }
            }
            argList = null;
        }
コード例 #3
0
ファイル: ParseAdaptor.cs プロジェクト: Jaden-J/csharp-sqlite
    internal static ParseResult parseNestedCmd( Interp interp, string inString, int index, int length )
    {
      CharPointer script;
      TclObject obj;

      // Check for the easy case where the last character in the string is '['.
      if ( index == length )
      {
        throw new TclException( interp, "missing close-bracket" );
      }

      script = new CharPointer( inString );
      script.index = index;

      interp.evalFlags |= Parser.TCL_BRACKET_TERM;
      Parser.eval2( interp, script.array, script.index, length - index, 0 );
      obj = interp.getResult();
      obj.preserve();
      return ( new ParseResult( obj, index + interp.termOffset + 1 ) );
    }
コード例 #4
0
        internal static ParseResult parseNestedCmd(Interp interp, string inString, int index, int length)
        {
            CharPointer script;
            TclObject   obj;

            // Check for the easy case where the last character in the string is '['.
            if (index == length)
            {
                throw new TclException(interp, "missing close-bracket");
            }

            script       = new CharPointer(inString);
            script.index = index;

            interp.evalFlags |= Parser.TCL_BRACKET_TERM;
            Parser.eval2(interp, script.array, script.index, length - index, 0);
            obj = interp.getResult();
            obj.preserve();
            return(new ParseResult(obj, index + interp.termOffset + 1));
        }
コード例 #5
0
ファイル: ParseAdaptor.cs プロジェクト: Jaden-J/csharp-sqlite
    internal static ParseResult parseQuotes( Interp interp, string inString, int index, int length )
    {
      TclObject obj;
      TclParse parse = null;
      TclToken token;
      CharPointer script;

      try
      {

        script = new CharPointer( inString );
        script.index = index;

        parse = new TclParse( interp, script.array, length, null, 0 );

        System.Diagnostics.Debug.WriteLine( "string is \"" + inString + "\"" );
        System.Diagnostics.Debug.WriteLine( "script.array is \"" + new string( script.array ) + "\"" );

        System.Diagnostics.Debug.WriteLine( "index is " + index );
        System.Diagnostics.Debug.WriteLine( "length is " + length );

        System.Diagnostics.Debug.WriteLine( "parse.endIndex is " + parse.endIndex );


        parse.commandStart = script.index;
        token = parse.getToken( 0 );
        token.type = Parser.TCL_TOKEN_WORD;
        token.script_array = script.array;
        token.script_index = script.index;
        parse.numTokens++;
        parse.numWords++;
        parse = Parser.parseTokens( script.array, script.index, Parser.TYPE_QUOTE, parse );

        // Check for the error condition where the parse did not end on
        // a '"' char. Is this happened raise an error.

        if ( script.array[parse.termIndex] != '"' )
        {
          throw new TclException( interp, "missing \"" );
        }

        // if there was no error then parsing will continue after the
        // last char that was parsed from the string

        script.index = parse.termIndex + 1;

        // Finish filling in the token for the word and check for the
        // special case of a word consisting of a single range of
        // literal text.

        token = parse.getToken( 0 );
        token.size = script.index - token.script_index;
        token.numComponents = parse.numTokens - 1;
        if ( ( token.numComponents == 1 ) && ( parse.getToken( 1 ).type == Parser.TCL_TOKEN_TEXT ) )
        {
          token.type = Parser.TCL_TOKEN_SIMPLE_WORD;
        }
        parse.commandSize = script.index - parse.commandStart;
        if ( parse.numTokens > 0 )
        {
          obj = Parser.evalTokens( interp, parse.tokenList, 1, parse.numTokens - 1 );
        }
        else
        {
          throw new TclRuntimeError( "parseQuotes error: null obj result" );
        }
      }
      finally
      {
        parse.release();
      }

      return ( new ParseResult( obj, script.index ) );
    }
コード例 #6
0
ファイル: CharPointer.cs プロジェクト: Jaden-J/csharp-sqlite
 internal CharPointer( CharPointer c )
 {
   this.array = c.array;
   this.index = c.index;
 }
コード例 #7
0
ファイル: Parser.cs プロジェクト: Jaden-J/csharp-sqlite
    internal static bool commandComplete( string inString, int length )
    // Number of bytes in script.
    {
      TclParse parse;

      CharPointer src = new CharPointer( inString );

      do
      {
        parse = parseCommand( null, src.array, src.index, length, null, 0, false );

        src.index = parse.commandStart + parse.commandSize;

        parse.release(); // Release parser resources

        if ( src.index >= length )
        {
          break;
        }
      }
      while ( parse.result == TCL.CompletionCode.OK );

      if ( parse.incomplete )
      {
        return false;
      }
      return true;
    }
コード例 #8
0
ファイル: Parser.cs プロジェクト: Jaden-J/csharp-sqlite
    public static ParseResult parseVar( Interp interp, string inString )
    {
      TclParse parse;
      TclObject obj;

      System.Diagnostics.Debug.WriteLine( "Entered parseVar()" );
      System.Diagnostics.Debug.Write( "now to parse var off the string \"" + inString + "\"" );


      CharPointer src = new CharPointer( inString );
      parse = parseVarName( interp, src.array, src.index, -1, null, false );
      if ( parse.result != TCL.CompletionCode.OK )
      {

        throw new TclException( interp, interp.getResult().ToString() );
      }

      try
      {
        System.Diagnostics.Debug.Write( "parsed " + parse.numTokens + " tokens" );

        if ( parse.numTokens == 1 )
        {
          // There isn't a variable name after all: the $ is just a $.
          return new ParseResult( "$", 1 );
        }

        obj = evalTokens( interp, parse.tokenList, 0, parse.numTokens );
        if ( !obj.Shared )
        {
          throw new TclRuntimeError( "parseVar got temporary object from evalTokens" );
        }
        return new ParseResult( obj, parse.tokenList[0].size );
      }
      finally
      {
        parse.release(); // Release parser resources
      }
    }
コード例 #9
0
        internal static ParseResult parseQuotes(Interp interp, string inString, int index, int length)
        {
            TclObject   obj;
            TclParse    parse = null;
            TclToken    token;
            CharPointer script;

            try
            {
                script       = new CharPointer(inString);
                script.index = index;

                parse = new TclParse(interp, script.array, length, null, 0);

                System.Diagnostics.Debug.WriteLine("string is \"" + inString + "\"");
                System.Diagnostics.Debug.WriteLine("script.array is \"" + new string( script.array ) + "\"");

                System.Diagnostics.Debug.WriteLine("index is " + index);
                System.Diagnostics.Debug.WriteLine("length is " + length);

                System.Diagnostics.Debug.WriteLine("parse.endIndex is " + parse.endIndex);


                parse.commandStart = script.index;
                token              = parse.getToken(0);
                token.type         = Parser.TCL_TOKEN_WORD;
                token.script_array = script.array;
                token.script_index = script.index;
                parse.numTokens++;
                parse.numWords++;
                parse = Parser.parseTokens(script.array, script.index, Parser.TYPE_QUOTE, parse);

                // Check for the error condition where the parse did not end on
                // a '"' char. Is this happened raise an error.

                if (script.array[parse.termIndex] != '"')
                {
                    throw new TclException(interp, "missing \"");
                }

                // if there was no error then parsing will continue after the
                // last char that was parsed from the string

                script.index = parse.termIndex + 1;

                // Finish filling in the token for the word and check for the
                // special case of a word consisting of a single range of
                // literal text.

                token               = parse.getToken(0);
                token.size          = script.index - token.script_index;
                token.numComponents = parse.numTokens - 1;
                if ((token.numComponents == 1) && (parse.getToken(1).type == Parser.TCL_TOKEN_TEXT))
                {
                    token.type = Parser.TCL_TOKEN_SIMPLE_WORD;
                }
                parse.commandSize = script.index - parse.commandStart;
                if (parse.numTokens > 0)
                {
                    obj = Parser.evalTokens(interp, parse.tokenList, 1, parse.numTokens - 1);
                }
                else
                {
                    throw new TclRuntimeError("parseQuotes error: null obj result");
                }
            }
            finally
            {
                parse.release();
            }

            return(new ParseResult(obj, script.index));
        }
コード例 #10
0
    internal Procedure( Interp interp, NamespaceCmd.Namespace ns, string name, TclObject args, TclObject b, string sFileName, int sLineNumber )
    {
      this.ns = ns;
      srcFileName = sFileName;
      srcLineNumber = sLineNumber;

      // Break up the argument list into argument specifiers, then process
      // each argument specifier.

      int numArgs = TclList.getLength( interp, args );
      argList = new TclObject[numArgs][];
      for ( int i = 0; i < numArgs; i++ )
      {
        argList[i] = new TclObject[2];
      }

      for ( int i = 0; i < numArgs; i++ )
      {
        // Now divide the specifier up into name and default.

        TclObject argSpec = TclList.index( interp, args, i );
        int specLen = TclList.getLength( interp, argSpec );

        if ( specLen == 0 )
        {
          throw new TclException( interp, "procedure \"" + name + "\" has argument with no name" );
        }
        if ( specLen > 2 )
        {

          throw new TclException( interp, "too many fields in argument " + "specifier \"" + argSpec + "\"" );
        }

        argList[i][0] = TclList.index( interp, argSpec, 0 );
        argList[i][0].preserve();
        if ( specLen == 2 )
        {
          argList[i][1] = TclList.index( interp, argSpec, 1 );
          argList[i][1].preserve();
        }
        else
        {
          argList[i][1] = null;
        }
      }


      if ( numArgs > 0 && ( argList[numArgs - 1][0].ToString().Equals( "args" ) ) )
      {
        isVarArgs = true;
      }
      else
      {
        isVarArgs = false;
      }


      body = new CharPointer( b.ToString() );
      body_length = body.length();
    }
コード例 #11
0
    public void disposeCmd()
    {
      //body.release();
      body = null;
      for ( int i = 0; i < argList.Length; i++ )
      {
        argList[i][0].release();
        argList[i][0] = null;

        if ( argList[i][1] != null )
        {
          argList[i][1].release();
          argList[i][1] = null;
        }
      }
      argList = null;
    }
コード例 #12
0
 internal static BackSlashResult backslash( string s, int i, int len )
 {
   CharPointer script = new CharPointer( s.Substring( 0, ( len ) - ( 0 ) ) );
   script.index = i;
   return Parser.backslash( script.array, script.index );
 }
コード例 #13
0
    public void eval( string inString, int flags )
    {
      int evalFlags = this.evalFlags;
      this.evalFlags &= ~Parser.TCL_ALLOW_EXCEPTIONS;

      CharPointer script = new CharPointer( inString );
      try
      {
        Parser.eval2( this, script.array, script.index, script.length(), flags );
      }
      catch ( TclException e )
      {

        if ( nestLevel != 0 )
        {
          throw;
        }

        // Update the interpreter's evaluation level count. If we are again at
        // the top level, process any unusual return code returned by the
        // evaluated code. Note that we don't propagate an exception that
        // has a TCL.CompletionCode.RETURN error code when updateReturnInfo() returns TCL.CompletionCode.OK.

        TCL.CompletionCode result = e.getCompletionCode();

        if ( result == TCL.CompletionCode.RETURN )
        {
          result = updateReturnInfo();
        }
        if ( result != TCL.CompletionCode.EXIT && result != TCL.CompletionCode.OK && result != TCL.CompletionCode.ERROR && ( evalFlags & Parser.TCL_ALLOW_EXCEPTIONS ) == 0 )
        {
          processUnexpectedResult( result );
        }
        if ( result != TCL.CompletionCode.OK )
        {
          e.setCompletionCode( result );
          throw;
        }
      }
    }
コード例 #14
0
 internal CharPointer(CharPointer c)
 {
     this.array = c.array;
     this.index = c.index;
 }