ToString() public method

public ToString ( ) : String
return String
コード例 #1
0
ファイル: constant.cs プロジェクト: ydunk/masters
        internal Constant(Context context, Lookup identifier, TypeExpression type, AST value, FieldAttributes attributes, CustomAttributeList customAttributes)
            : base(context)
        {
            this.attributes       = attributes | FieldAttributes.InitOnly;
            this.customAttributes = customAttributes;
            this.completion       = new Completion();
            this.identifier       = identifier;
            this.name             = identifier.ToString();
            this.value            = value;
            ScriptObject current_scope = (ScriptObject)Globals.ScopeStack.Peek();

            while (current_scope is WithObject) //Can only happen at run time and only if there is an eval
            {
                current_scope = current_scope.GetParent();
            }
            if (current_scope is ClassScope)
            {
                if (this.name == ((ClassScope)current_scope).name)
                {
                    identifier.context.HandleError(JSError.CannotUseNameOfClass);
                    this.name = this.name + " const";
                }
                if (attributes == 0)
                {
                    attributes = FieldAttributes.Public;
                }
            }
            else
            {
                if (attributes != 0)
                {
                    this.context.HandleError(JSError.NotInsideClass);
                }
                attributes = FieldAttributes.Public;
            }
            FieldInfo field = ((IActivationObject)current_scope).GetLocalField(this.name);

            if (field != null)
            {
                identifier.context.HandleError(JSError.DuplicateName, true);
                this.name = this.name + " const";
            }
            if (current_scope is ActivationObject)
            {
                this.field = ((ActivationObject)current_scope).AddNewField(this.identifier.ToString(), value, attributes);
            }
            else
            {
                this.field = ((StackFrame)current_scope).AddNewField(this.identifier.ToString(), value, attributes | FieldAttributes.Static);
            }
            this.field.type             = type;
            this.field.customAttributes = customAttributes;
            this.field.originalContext  = context;
            if (this.field is JSLocalField)
            {
                // emit debug info for the local only if this block of code is in a section that has debug set
                ((JSLocalField)this.field).debugOn = this.identifier.context.document.debugOn;
            }
        }
コード例 #2
0
        internal Constant(Context context, Lookup identifier, TypeExpression type, AST value, FieldAttributes attributes, CustomAttributeList customAttributes) : base(context)
        {
            this.attributes       = attributes | FieldAttributes.InitOnly;
            this.customAttributes = customAttributes;
            this.completion       = new Completion();
            this.identifier       = identifier;
            this.name             = identifier.ToString();
            this.value            = value;
            ScriptObject parent = base.Globals.ScopeStack.Peek();

            while (parent is WithObject)
            {
                parent = parent.GetParent();
            }
            if (parent is ClassScope)
            {
                if (this.name == ((ClassScope)parent).name)
                {
                    identifier.context.HandleError(JSError.CannotUseNameOfClass);
                    this.name = this.name + " const";
                }
                if (attributes == FieldAttributes.PrivateScope)
                {
                    attributes = FieldAttributes.Public;
                }
            }
            else
            {
                if (attributes != FieldAttributes.PrivateScope)
                {
                    base.context.HandleError(JSError.NotInsideClass);
                }
                attributes = FieldAttributes.Public;
            }
            if (((IActivationObject)parent).GetLocalField(this.name) != null)
            {
                identifier.context.HandleError(JSError.DuplicateName, true);
                this.name = this.name + " const";
            }
            if (parent is ActivationObject)
            {
                this.field = ((ActivationObject)parent).AddNewField(this.identifier.ToString(), value, attributes);
            }
            else
            {
                this.field = ((StackFrame)parent).AddNewField(this.identifier.ToString(), value, attributes | FieldAttributes.Static);
            }
            this.field.type             = type;
            this.field.customAttributes = customAttributes;
            this.field.originalContext  = context;
            if (this.field is JSLocalField)
            {
                ((JSLocalField)this.field).debugOn = this.identifier.context.document.debugOn;
            }
        }
コード例 #3
0
 internal Constant(Context context, Lookup identifier, TypeExpression type, AST value, FieldAttributes attributes, CustomAttributeList customAttributes)
   : base(context){
   this.attributes = attributes | FieldAttributes.InitOnly;
   this.customAttributes = customAttributes;
   this.completion = new Completion();
   this.identifier = identifier;
   this.name = identifier.ToString();
   this.value = value;
   ScriptObject current_scope = (ScriptObject)Globals.ScopeStack.Peek();
   while (current_scope is WithObject) //Can only happen at run time and only if there is an eval
     current_scope = current_scope.GetParent();
   if (current_scope is ClassScope){
     if (this.name == ((ClassScope)current_scope).name){
       identifier.context.HandleError(JSError.CannotUseNameOfClass);
       this.name = this.name + " const";
     }
     if (attributes == 0) attributes = FieldAttributes.Public;
   }else{
     if (attributes != 0)
       this.context.HandleError(JSError.NotInsideClass);
     attributes = FieldAttributes.Public;
   }
   FieldInfo field = ((IActivationObject)current_scope).GetLocalField(this.name);
   if (field != null){
     identifier.context.HandleError(JSError.DuplicateName, true);
     this.name = this.name + " const";
   }
   if (current_scope is ActivationObject)
     this.field = ((ActivationObject)current_scope).AddNewField(this.identifier.ToString(), value, attributes);
   else
     this.field = ((StackFrame)current_scope).AddNewField(this.identifier.ToString(), value, attributes|FieldAttributes.Static);
   this.field.type = type;
   this.field.customAttributes = customAttributes;
   this.field.originalContext = context;
   if (this.field is JSLocalField)
     // emit debug info for the local only if this block of code is in a section that has debug set
     ((JSLocalField)this.field).debugOn = this.identifier.context.document.debugOn;
 }
コード例 #4
0
ファイル: jsparser.cs プロジェクト: ArildF/masters
      //---------------------------------------------------------------------------------------
      // ParseNamedBreakpoint
      //
      //  Used by the debugger to parsed a named breakpoint, that is a name of a function with
      //  possible arguments and optionally followed by an il offset
      //---------------------------------------------------------------------------------------
      internal String[] ParseNamedBreakpoint(out int argNumber){
        argNumber = 0;

        // parse the function name
        AST function = ParseQualifiedIdentifier(JSError.SyntaxError);
        if (function != null){
          String[] parsedFunction = new String[4];
          parsedFunction[0] = function.ToString();

          if (JSToken.LeftParen == this.currentToken.token){
            String id = null;
            String typeString = null;
            AST qualid = null;

            parsedFunction[1] = "";

            GetNextToken();
            // parse the formal parameters
            while (JSToken.RightParen != this.currentToken.token){
              id = null;
              if (JSToken.Identifier != this.currentToken.token && (id = JSKeyword.CanBeIdentifier(this.currentToken.token)) == null){
                return null;
              }else{
                if (null == id)
                  id = this.scanner.GetIdentifier();
                qualid = new Lookup(id, this.currentToken.Clone());
                GetNextToken();
                if (JSToken.AccessField == this.currentToken.token){
                  qualid = ParseScopeSequence(qualid, JSError.SyntaxError);
                  typeString = qualid.ToString();
                  while (JSToken.LeftBracket == this.currentToken.token){
                    GetNextToken();
                    if (JSToken.RightBracket != this.currentToken.token)
                      return null;
                    typeString += "[]";
                    GetNextToken();
                  }
                }else if (JSToken.Colon == this.currentToken.token){
                  GetNextToken();
                  if (JSToken.RightParen == this.currentToken.token)
                    return null;
                  continue;
                }else{
                  typeString = qualid.ToString();
                }
                parsedFunction[1] += typeString + " ";
              }
              argNumber++;

              if (JSToken.Comma == this.currentToken.token){
                GetNextToken();
                if (JSToken.RightParen == this.currentToken.token)
                  return null;
              }
            }

            GetNextToken();

            // parse a return value if any
            if (JSToken.Colon == this.currentToken.token){
              GetNextToken();
              id = null;
              if (JSToken.Identifier != this.currentToken.token && (id = JSKeyword.CanBeIdentifier(this.currentToken.token)) == null){
                return null;
              }else{
                if (null == id)
                  id = this.scanner.GetIdentifier();
                qualid = new Lookup(id, this.currentToken.Clone());
                GetNextToken();
                if (JSToken.AccessField == this.currentToken.token){
                  qualid = ParseScopeSequence(qualid, JSError.SyntaxError);
                  parsedFunction[2] = qualid.ToString();
                  while (JSToken.LeftBracket == this.currentToken.token){
                    GetNextToken();
                    if (JSToken.RightBracket != this.currentToken.token)
                      return null;
                    parsedFunction[2] += "[]";
                    GetNextToken();
                  }
                }else{
                  parsedFunction[2] = qualid.ToString();
                }
              }
            }

          }

          if (JSToken.Plus == this.currentToken.token){
            GetNextToken();
            if (JSToken.IntegerLiteral != this.currentToken.token)
              return null;
            parsedFunction[3] = this.currentToken.GetCode();
            GetNextToken();
          }

          if (JSToken.EndOfFile != this.currentToken.token)
            return null; // some extra crap
          return parsedFunction;
        }
        return null;
      }
コード例 #5
0
 internal string[] ParseNamedBreakpoint(out int argNumber)
 {
     argNumber = 0;
     AST ast = this.ParseQualifiedIdentifier(JSError.SyntaxError);
     if (ast == null)
     {
         return null;
     }
     string[] strArray = new string[4];
     strArray[0] = ast.ToString();
     if (JSToken.LeftParen == this.currentToken.token)
     {
         string name = null;
         string str2 = null;
         AST qualid = null;
         strArray[1] = "";
         this.GetNextToken();
         while (JSToken.RightParen != this.currentToken.token)
         {
             string[] strArray2;
             name = null;
             if ((JSToken.Identifier != this.currentToken.token) && ((name = JSKeyword.CanBeIdentifier(this.currentToken.token)) == null))
             {
                 return null;
             }
             if (name == null)
             {
                 name = this.scanner.GetIdentifier();
             }
             qualid = new Lookup(name, this.currentToken.Clone());
             this.GetNextToken();
             if (JSToken.AccessField == this.currentToken.token)
             {
                 str2 = this.ParseScopeSequence(qualid, JSError.SyntaxError).ToString();
                 while (JSToken.LeftBracket == this.currentToken.token)
                 {
                     this.GetNextToken();
                     if (JSToken.RightBracket != this.currentToken.token)
                     {
                         return null;
                     }
                     str2 = str2 + "[]";
                     this.GetNextToken();
                 }
             }
             else
             {
                 if (JSToken.Colon == this.currentToken.token)
                 {
                     this.GetNextToken();
                     if (JSToken.RightParen == this.currentToken.token)
                     {
                         return null;
                     }
                     continue;
                 }
                 str2 = qualid.ToString();
             }
             (strArray2 = strArray)[1] = strArray2[1] + str2 + " ";
             argNumber++;
             if (JSToken.Comma == this.currentToken.token)
             {
                 this.GetNextToken();
                 if (JSToken.RightParen == this.currentToken.token)
                 {
                     return null;
                 }
             }
         }
         this.GetNextToken();
         if (JSToken.Colon == this.currentToken.token)
         {
             this.GetNextToken();
             name = null;
             if ((JSToken.Identifier != this.currentToken.token) && ((name = JSKeyword.CanBeIdentifier(this.currentToken.token)) == null))
             {
                 return null;
             }
             if (name == null)
             {
                 name = this.scanner.GetIdentifier();
             }
             qualid = new Lookup(name, this.currentToken.Clone());
             this.GetNextToken();
             if (JSToken.AccessField == this.currentToken.token)
             {
                 qualid = this.ParseScopeSequence(qualid, JSError.SyntaxError);
                 strArray[2] = qualid.ToString();
                 while (JSToken.LeftBracket == this.currentToken.token)
                 {
                     string[] strArray3;
                     this.GetNextToken();
                     if (JSToken.RightBracket != this.currentToken.token)
                     {
                         return null;
                     }
                     (strArray3 = strArray)[2] = strArray3[2] + "[]";
                     this.GetNextToken();
                 }
             }
             else
             {
                 strArray[2] = qualid.ToString();
             }
         }
     }
     if (JSToken.FirstBinaryOp == this.currentToken.token)
     {
         this.GetNextToken();
         if (JSToken.IntegerLiteral != this.currentToken.token)
         {
             return null;
         }
         strArray[3] = this.currentToken.GetCode();
         this.GetNextToken();
     }
     if (this.currentToken.token != JSToken.EndOfFile)
     {
         return null;
     }
     return strArray;
 }