Пример #1
0
 internal StaticInitializer(Context context, Block body, FunctionScope own_scope)
   : base(context) {
   this.func = new FunctionObject(null, new ParameterDeclaration[0], null, body, own_scope, Globals.ScopeStack.Peek(), context, MethodAttributes.Private|MethodAttributes.Static);
   this.func.isMethod = true;
   this.func.hasArgumentsObject = false;
   this.completion = new Completion();
 }
Пример #2
0
 internal If(Context context, AST condition, AST true_branch, AST false_branch)
   : base(context) {
   this.condition = condition;
   this.operand1 = true_branch;
   this.operand2 = false_branch;
   this.completion = new Completion();
 }
Пример #3
0
 internal override Object Evaluate(){
   if (this.operand1 == null && this.operand2 == null)
     return this.completion;
   Completion c = null;
   if (this.condition != null){ 
     if (Convert.ToBoolean(this.condition.Evaluate()) == true)
       c = (Completion)this.operand1.Evaluate();
     else if (this.operand2 != null)
       c = (Completion)this.operand2.Evaluate();
     else
       c = new Completion();
   }else
     if (this.operand1 != null)
       c = (Completion)this.operand1.Evaluate();
     else
       c = (Completion)this.operand2.Evaluate();
   this.completion.value = c.value;
   if (c.Continue > 1)
     this.completion.Continue = c.Continue - 1;
   else
     this.completion.Continue = 0;  
   if (c.Exit > 0)
     this.completion.Exit = c.Exit - 1;
   else
     this.completion.Exit = 0;
   if (c.Return)
     return c;
   return this.completion;
 }
 internal For(Context context, AST initializer, AST condition, AST incrementer, AST body) : base(context)
 {
     this.initializer = initializer;
     this.condition = condition;
     this.incrementer = incrementer;
     this.body = body;
     this.completion = new Completion();
 }
 internal override object Evaluate()
 {
     this.completion.Continue = 0;
     this.completion.Exit = 0;
     this.completion.value = null;
     object expression = this.expression.Evaluate();
     Completion completion = null;
     int count = this.cases.count;
     int num = 0;
     while (num < count)
     {
         if (num != this.default_case)
         {
             completion = ((SwitchCase) this.cases[num]).Evaluate(expression);
             if (completion != null)
             {
                 break;
             }
         }
         num++;
     }
     if (completion == null)
     {
         if (this.default_case < 0)
         {
             return this.completion;
         }
         num = this.default_case;
         completion = (Completion) ((SwitchCase) this.cases[num]).Evaluate();
     }
 Label_00A6:
     if (completion.value != null)
     {
         this.completion.value = completion.value;
     }
     if (completion.Continue > 0)
     {
         this.completion.Continue = completion.Continue - 1;
     }
     else if (completion.Exit > 0)
     {
         this.completion.Exit = completion.Exit - 1;
     }
     else
     {
         if (completion.Return)
         {
             return completion;
         }
         if (num >= (count - 1))
         {
             return this.completion;
         }
         completion = (Completion) ((SwitchCase) this.cases[++num]).Evaluate();
         goto Label_00A6;
     }
     return this.completion;
 }
Пример #6
0
 internal With(Context context, AST obj, AST block)
   : base(context) {
   this.obj = obj;
   this.block = block;
   this.completion = new Completion();
   ScriptObject scope = Globals.ScopeStack.Peek();
   if (scope is FunctionScope)
     this.enclosing_function = (FunctionScope)scope;
   else
     this.enclosing_function = null;
 }
 internal override object Evaluate()
 {
     if ((this.operand1 != null) || (this.operand2 != null))
     {
         Completion completion = null;
         if (this.condition != null)
         {
             if (Microsoft.JScript.Convert.ToBoolean(this.condition.Evaluate()))
             {
                 completion = (Completion) this.operand1.Evaluate();
             }
             else if (this.operand2 != null)
             {
                 completion = (Completion) this.operand2.Evaluate();
             }
             else
             {
                 completion = new Completion();
             }
         }
         else if (this.operand1 != null)
         {
             completion = (Completion) this.operand1.Evaluate();
         }
         else
         {
             completion = (Completion) this.operand2.Evaluate();
         }
         this.completion.value = completion.value;
         if (completion.Continue > 1)
         {
             this.completion.Continue = completion.Continue - 1;
         }
         else
         {
             this.completion.Continue = 0;
         }
         if (completion.Exit > 0)
         {
             this.completion.Exit = completion.Exit - 1;
         }
         else
         {
             this.completion.Exit = 0;
         }
         if (completion.Return)
         {
             return completion;
         }
     }
     return this.completion;
 }
Пример #8
0
 internal Switch(Context context, AST expression, ASTList cases)
   : base(context) {
   this.expression = expression;
   this.cases = cases;
   this.default_case = -1;
   for (int i = 0, n = this.cases.count; i < n; i++){
     if (((SwitchCase)(this.cases[i])).IsDefault()){
       this.default_case = i;
       break;
     }
   }
   this.completion = new Completion();
 }
 internal With(Context context, AST obj, AST block) : base(context)
 {
     this.obj = obj;
     this.block = block;
     this.completion = new Completion();
     ScriptObject obj2 = base.Globals.ScopeStack.Peek();
     if (obj2 is FunctionScope)
     {
         this.enclosing_function = (FunctionScope) obj2;
     }
     else
     {
         this.enclosing_function = null;
     }
 }
 internal VariableDeclaration(Context context, Lookup identifier, TypeExpression type, AST initializer, FieldAttributes attributes, CustomAttributeList customAttributes)
   : base(context) {
   if (initializer != null)
     this.context.UpdateWith(initializer.context);
   else if (type != null)
     this.context.UpdateWith(type.context);
   this.identifier = identifier;
   this.type = type;
   this.initializer = initializer;
   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();
   String name = this.identifier.ToString();
   if (current_scope is ClassScope){
     if (name == ((ClassScope)current_scope).name){
       identifier.context.HandleError(JSError.CannotUseNameOfClass);
       name = name + " var";
     }
   }else{
     if (attributes != (FieldAttributes)0){
       this.context.HandleError(JSError.NotInsideClass);
       attributes = FieldAttributes.Public;
     }else
       attributes |= FieldAttributes.Public;
   }
   FieldInfo field = ((IActivationObject)current_scope).GetLocalField(name);
   if (field != null){
     if (field.IsLiteral || current_scope is ClassScope || type != null)
       identifier.context.HandleError(JSError.DuplicateName, true);
     this.type = type = null;
   }
   if (current_scope is ActivationObject)
     if (field == null || field is JSVariableField)
       this.field = ((ActivationObject)current_scope).AddFieldOrUseExistingField(this.identifier.ToString(), Missing.Value, attributes);
     else
       this.field = ((ActivationObject)current_scope).AddNewField(this.identifier.ToString(), null, attributes);
   else
     this.field = ((StackFrame)current_scope).AddNewField(this.identifier.ToString(), null, 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;
   this.completion = new Completion();
 }
Пример #11
0
 internal ForIn(Context context, AST var, AST initializer, AST collection, AST body)
   : base(context) {
   if (var != null){
     this.var = var;
     this.inExpressionContext = this.var.context.Clone();
   }else{
     VariableDeclaration decl = (VariableDeclaration)initializer;
     this.var = decl.identifier;
     if (decl.initializer == null)
       decl.initializer = new ConstantWrapper(null, null); //Suppress warning
     this.inExpressionContext = initializer.context.Clone();
   }
   this.initializer = initializer;
   this.collection = collection;
   this.inExpressionContext.UpdateWith(this.collection.context);
   this.body = body;
   this.completion = new Completion();
 }
 internal Switch(Context context, AST expression, ASTList cases) : base(context)
 {
     this.expression = expression;
     this.cases = cases;
     this.default_case = -1;
     int num = 0;
     int count = this.cases.count;
     while (num < count)
     {
         if (((SwitchCase) this.cases[num]).IsDefault())
         {
             this.default_case = num;
             break;
         }
         num++;
     }
     this.completion = new Completion();
 }
Пример #13
0
 internal Return(Context context, AST operand, bool leavesFinally)
   : base(context) {
   this.completion = new Completion();
   this.completion.Return = true;
   this.operand = operand;
   ScriptObject scope = Globals.ScopeStack.Peek();
   while (!(scope is FunctionScope)){
     scope = scope.GetParent();
     if (scope == null){
       this.context.HandleError(JSError.BadReturn);
       scope = new FunctionScope(null);
     }
   }
   this.enclosingFunctionScope = ((FunctionScope)scope);
   if (this.operand != null && this.enclosingFunctionScope.returnVar == null)
     this.enclosingFunctionScope.AddReturnValueField();
   this.leavesFinally = leavesFinally;
 }
 internal override object Evaluate()
 {
     try
     {
         JScriptWith(this.obj.Evaluate(), base.Engine);
     }
     catch (JScriptException exception)
     {
         exception.context = this.obj.context;
         throw exception;
     }
     Completion completion = null;
     try
     {
         completion = (Completion) this.block.Evaluate();
     }
     finally
     {
         base.Globals.ScopeStack.Pop();
     }
     if (completion.Continue > 1)
     {
         this.completion.Continue = completion.Continue - 1;
     }
     else
     {
         this.completion.Continue = 0;
     }
     if (completion.Exit > 0)
     {
         this.completion.Exit = completion.Exit - 1;
     }
     else
     {
         this.completion.Exit = 0;
     }
     if (completion.Return)
     {
         return completion;
     }
     return this.completion;
 }
 internal override object Evaluate()
 {
     object obj2;
     base.Globals.ScopeStack.Push(this.scope);
     try
     {
         int num = 0;
         int count = this.classList.count;
         while (num < count)
         {
             this.classList[num].Evaluate();
             num++;
         }
         obj2 = new Completion();
     }
     finally
     {
         base.Globals.ScopeStack.Pop();
     }
     return obj2;
 }
 internal Return(Context context, AST operand, bool leavesFinally) : base(context)
 {
     this.completion = new Completion();
     this.completion.Return = true;
     this.operand = operand;
     ScriptObject parent = base.Globals.ScopeStack.Peek();
     while (!(parent is FunctionScope))
     {
         parent = parent.GetParent();
         if (parent == null)
         {
             base.context.HandleError(JSError.BadReturn);
             parent = new FunctionScope(null);
         }
     }
     this.enclosingFunctionScope = (FunctionScope) parent;
     if ((this.operand != null) && (this.enclosingFunctionScope.returnVar == null))
     {
         this.enclosingFunctionScope.AddReturnValueField();
     }
     this.leavesFinally = leavesFinally;
 }
Пример #17
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;
 }
        internal VariableDeclaration(Context context, Lookup identifier, TypeExpression type, AST initializer, FieldAttributes attributes, CustomAttributeList customAttributes)
            : base(context)
        {
            if (initializer != null)
            {
                this.context.UpdateWith(initializer.context);
            }
            else if (type != null)
            {
                this.context.UpdateWith(type.context);
            }
            this.identifier  = identifier;
            this.type        = type;
            this.initializer = initializer;
            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();
            }
            String name = this.identifier.ToString();

            if (current_scope is ClassScope)
            {
                if (name == ((ClassScope)current_scope).name)
                {
                    identifier.context.HandleError(JSError.CannotUseNameOfClass);
                    name = name + " var";
                }
            }
            else
            {
                if (attributes != (FieldAttributes)0)
                {
                    this.context.HandleError(JSError.NotInsideClass);
                    attributes = FieldAttributes.Public;
                }
                else
                {
                    attributes |= FieldAttributes.Public;
                }
            }
            FieldInfo field = ((IActivationObject)current_scope).GetLocalField(name);

            if (field != null)
            {
                if (field.IsLiteral || current_scope is ClassScope || type != null)
                {
                    identifier.context.HandleError(JSError.DuplicateName, true);
                }
                this.type = type = null;
            }
            if (current_scope is ActivationObject)
            {
                if (field == null || field is JSVariableField)
                {
                    this.field = ((ActivationObject)current_scope).AddFieldOrUseExistingField(this.identifier.ToString(), Missing.Value, attributes);
                }
                else
                {
                    this.field = ((ActivationObject)current_scope).AddNewField(this.identifier.ToString(), null, attributes);
                }
            }
            else
            {
                this.field = ((StackFrame)current_scope).AddNewField(this.identifier.ToString(), null, 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;
            }
            this.completion = new Completion();
        }
 internal FunctionDeclaration(Context context, AST ifaceId, IdentifierLiteral id, ParameterDeclaration[] formal_parameters, TypeExpression return_type, Block body, FunctionScope own_scope, FieldAttributes attributes, bool isMethod, bool isGetter, bool isSetter, bool isAbstract, bool isFinal, CustomAttributeList customAttributes) : base(context)
 {
     this.completion = new Completion();
     MethodAttributes privateScope = MethodAttributes.PrivateScope;
     if ((attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Public)
     {
         privateScope = MethodAttributes.Public;
     }
     else if ((attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Private)
     {
         privateScope = MethodAttributes.Private;
     }
     else if ((attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Assembly)
     {
         privateScope = MethodAttributes.Assembly;
     }
     else if ((attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Family)
     {
         privateScope = MethodAttributes.Family;
     }
     else if ((attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.FamORAssem)
     {
         privateScope = MethodAttributes.FamORAssem;
     }
     else
     {
         privateScope = MethodAttributes.Public;
     }
     if (((attributes & FieldAttributes.Static) != FieldAttributes.PrivateScope) || !isMethod)
     {
         privateScope |= MethodAttributes.Static;
     }
     else
     {
         privateScope |= MethodAttributes.NewSlot | MethodAttributes.Virtual;
     }
     if (isAbstract)
     {
         privateScope |= MethodAttributes.Abstract;
     }
     if (isFinal)
     {
         privateScope |= MethodAttributes.Final;
     }
     this.name = id.ToString();
     this.isMethod = isMethod;
     if (ifaceId != null)
     {
         if (isMethod)
         {
             this.ifaceId = new TypeExpression(ifaceId);
             privateScope &= ~MethodAttributes.MemberAccessMask;
             privateScope |= MethodAttributes.Final | MethodAttributes.Private;
         }
         else
         {
             this.declaringObject = new Member(ifaceId.context, ifaceId, id);
             this.name = this.declaringObject.ToString();
         }
     }
     ScriptObject obj2 = base.Globals.ScopeStack.Peek();
     if (((attributes == FieldAttributes.PrivateScope) && !isAbstract) && !isFinal)
     {
         if (obj2 is ClassScope)
         {
             attributes |= FieldAttributes.Public;
         }
     }
     else if (!(obj2 is ClassScope))
     {
         base.context.HandleError(JSError.NotInsideClass);
         attributes = FieldAttributes.PrivateScope;
         privateScope = MethodAttributes.Public;
     }
     if (obj2 is ActivationObject)
     {
         this.inFastScope = ((ActivationObject) obj2).fast;
         string name = this.name;
         if (isGetter)
         {
             privateScope |= MethodAttributes.SpecialName;
             this.name = "get_" + this.name;
             if (return_type == null)
             {
                 return_type = new TypeExpression(new ConstantWrapper(Typeob.Object, context));
             }
         }
         else if (isSetter)
         {
             privateScope |= MethodAttributes.SpecialName;
             this.name = "set_" + this.name;
             return_type = new TypeExpression(new ConstantWrapper(Typeob.Void, context));
         }
         attributes &= FieldAttributes.FieldAccessMask;
         MethodAttributes attributes3 = privateScope & MethodAttributes.MemberAccessMask;
         if ((((privateScope & MethodAttributes.Virtual) != MethodAttributes.PrivateScope) && ((privateScope & MethodAttributes.Final) == MethodAttributes.PrivateScope)) && (((attributes3 == MethodAttributes.Private) || (attributes3 == MethodAttributes.Assembly)) || (attributes3 == MethodAttributes.FamANDAssem)))
         {
             privateScope |= MethodAttributes.CheckAccessOnOverride;
         }
         this.func = new FunctionObject(this.name, formal_parameters, return_type, body, own_scope, obj2, base.context, privateScope, customAttributes, this.isMethod);
         if (this.declaringObject == null)
         {
             string str2 = this.name;
             if (this.ifaceId != null)
             {
                 str2 = ifaceId.ToString() + "." + str2;
             }
             JSVariableField field = (JSVariableField) ((ActivationObject) obj2).name_table[str2];
             if ((field != null) && ((!(field is JSMemberField) || !(((JSMemberField) field).value is FunctionObject)) || this.func.isExpandoMethod))
             {
                 if (name != this.name)
                 {
                     field.originalContext.HandleError(JSError.ClashWithProperty);
                 }
                 else
                 {
                     id.context.HandleError(JSError.DuplicateName, this.func.isExpandoMethod);
                     if (field.value is FunctionObject)
                     {
                         ((FunctionObject) field.value).suppressIL = true;
                     }
                 }
             }
             if (this.isMethod)
             {
                 if ((!(field is JSMemberField) || !(((JSMemberField) field).value is FunctionObject)) || (name != this.name))
                 {
                     this.field = ((ActivationObject) obj2).AddNewField(str2, this.func, attributes | FieldAttributes.Literal);
                     if (name == this.name)
                     {
                         this.field.type = new TypeExpression(new ConstantWrapper(Typeob.FunctionWrapper, base.context));
                     }
                 }
                 else
                 {
                     this.field = ((JSMemberField) field).AddOverload(this.func, attributes | FieldAttributes.Literal);
                 }
             }
             else if (obj2 is FunctionScope)
             {
                 if (this.inFastScope)
                 {
                     attributes |= FieldAttributes.Literal;
                 }
                 this.field = ((FunctionScope) obj2).AddNewField(this.name, attributes, this.func);
                 if (this.field is JSLocalField)
                 {
                     JSLocalField field2 = (JSLocalField) this.field;
                     if (this.inFastScope)
                     {
                         field2.type = new TypeExpression(new ConstantWrapper(Typeob.ScriptFunction, base.context));
                         field2.attributeFlags |= FieldAttributes.Literal;
                     }
                     field2.debugOn = base.context.document.debugOn;
                     field2.isDefined = true;
                 }
             }
             else if (this.inFastScope)
             {
                 this.field = ((ActivationObject) obj2).AddNewField(this.name, this.func, attributes | FieldAttributes.Literal);
                 this.field.type = new TypeExpression(new ConstantWrapper(Typeob.ScriptFunction, base.context));
             }
             else
             {
                 this.field = ((ActivationObject) obj2).AddNewField(this.name, this.func, attributes | FieldAttributes.Static);
             }
             this.field.originalContext = context;
             if (name != this.name)
             {
                 string str3 = name;
                 if (this.ifaceId != null)
                 {
                     str3 = ifaceId.ToString() + "." + name;
                 }
                 FieldInfo info = (FieldInfo) ((ClassScope) obj2).name_table[str3];
                 if (info != null)
                 {
                     if (info.IsLiteral)
                     {
                         object obj3 = ((JSVariableField) info).value;
                         if (obj3 is JSProperty)
                         {
                             this.enclosingProperty = (JSProperty) obj3;
                         }
                     }
                     if (this.enclosingProperty == null)
                     {
                         id.context.HandleError(JSError.DuplicateName, true);
                     }
                 }
                 if (this.enclosingProperty == null)
                 {
                     this.enclosingProperty = new JSProperty(name);
                     ((JSMemberField) ((ActivationObject) obj2).AddNewField(str3, this.enclosingProperty, attributes | FieldAttributes.Literal)).originalContext = base.context;
                 }
                 else if ((isGetter && (this.enclosingProperty.getter != null)) || (isSetter && (this.enclosingProperty.setter != null)))
                 {
                     id.context.HandleError(JSError.DuplicateName, true);
                 }
                 if (isGetter)
                 {
                     this.enclosingProperty.getter = new JSFieldMethod(this.field, obj2);
                 }
                 else
                 {
                     this.enclosingProperty.setter = new JSFieldMethod(this.field, obj2);
                 }
             }
         }
     }
     else
     {
         this.inFastScope = false;
         this.func = new FunctionObject(this.name, formal_parameters, return_type, body, own_scope, obj2, base.context, MethodAttributes.Public, null, false);
         this.field = ((StackFrame) obj2).AddNewField(this.name, new Closure(this.func), attributes | FieldAttributes.Static);
     }
 }
Пример #20
0
 internal Block(Context context)
     : base(context)
 {
     this.completion = new Completion();
     this.list       = new ArrayList();
 }
Пример #21
0
 internal Block(Context context)
   : base(context) {
   this.completion = new Completion();
   this.list = new ArrayList();
 }
Пример #22
0
        internal override Object Evaluate()
        {
            this.completion.Continue = 0;
            this.completion.Exit     = 0;
            this.completion.value    = null;
            Object     val = this.expression.Evaluate();
            Completion c = null;
            int        i, n = this.cases.count;

            for (i = 0; i < n; i++)
            {
                if (i == this.default_case)
                {
                    continue;
                }
                c = ((SwitchCase)(this.cases[i])).Evaluate(val);
                if (c != null)
                {
                    break;
                }
            }
            if (c == null)
            {
                if (this.default_case >= 0)
                {
                    i = this.default_case;
                    c = (Completion)((SwitchCase)(this.cases[i])).Evaluate();
                }
                else
                {
                    return(this.completion);
                }
            }
            while (true)
            {
                if (c.value != null)
                {
                    this.completion.value = c.value;
                }
                if (c.Continue > 0)
                {
                    this.completion.Continue = c.Continue - 1;
                    break;
                }
                if (c.Exit > 0)
                {
                    this.completion.Exit = c.Exit - 1;
                    break;
                }
                if (c.Return)
                {
                    return(c);
                }
                if (i >= n - 1)
                {
                    return(this.completion);
                }
                c = (Completion)((SwitchCase)(this.cases[++i])).Evaluate();
            }
            return(this.completion);
        }
Пример #23
0
        internal FunctionDeclaration(Context context, AST ifaceId, IdentifierLiteral id, ParameterDeclaration[] formal_parameters, TypeExpression return_type, Block body, FunctionScope own_scope, FieldAttributes attributes, bool isMethod, bool isGetter, bool isSetter, bool isAbstract, bool isFinal, CustomAttributeList customAttributes) : base(context)
        {
            this.completion = new Completion();
            MethodAttributes privateScope = MethodAttributes.PrivateScope;

            if ((attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Public)
            {
                privateScope = MethodAttributes.Public;
            }
            else if ((attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Private)
            {
                privateScope = MethodAttributes.Private;
            }
            else if ((attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Assembly)
            {
                privateScope = MethodAttributes.Assembly;
            }
            else if ((attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Family)
            {
                privateScope = MethodAttributes.Family;
            }
            else if ((attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.FamORAssem)
            {
                privateScope = MethodAttributes.FamORAssem;
            }
            else
            {
                privateScope = MethodAttributes.Public;
            }
            if (((attributes & FieldAttributes.Static) != FieldAttributes.PrivateScope) || !isMethod)
            {
                privateScope |= MethodAttributes.Static;
            }
            else
            {
                privateScope |= MethodAttributes.NewSlot | MethodAttributes.Virtual;
            }
            if (isAbstract)
            {
                privateScope |= MethodAttributes.Abstract;
            }
            if (isFinal)
            {
                privateScope |= MethodAttributes.Final;
            }
            this.name     = id.ToString();
            this.isMethod = isMethod;
            if (ifaceId != null)
            {
                if (isMethod)
                {
                    this.ifaceId  = new TypeExpression(ifaceId);
                    privateScope &= ~MethodAttributes.MemberAccessMask;
                    privateScope |= MethodAttributes.Final | MethodAttributes.Private;
                }
                else
                {
                    this.declaringObject = new Member(ifaceId.context, ifaceId, id);
                    this.name            = this.declaringObject.ToString();
                }
            }
            ScriptObject obj2 = base.Globals.ScopeStack.Peek();

            if (((attributes == FieldAttributes.PrivateScope) && !isAbstract) && !isFinal)
            {
                if (obj2 is ClassScope)
                {
                    attributes |= FieldAttributes.Public;
                }
            }
            else if (!(obj2 is ClassScope))
            {
                base.context.HandleError(JSError.NotInsideClass);
                attributes   = FieldAttributes.PrivateScope;
                privateScope = MethodAttributes.Public;
            }
            if (obj2 is ActivationObject)
            {
                this.inFastScope = ((ActivationObject)obj2).fast;
                string name = this.name;
                if (isGetter)
                {
                    privateScope |= MethodAttributes.SpecialName;
                    this.name     = "get_" + this.name;
                    if (return_type == null)
                    {
                        return_type = new TypeExpression(new ConstantWrapper(Typeob.Object, context));
                    }
                }
                else if (isSetter)
                {
                    privateScope |= MethodAttributes.SpecialName;
                    this.name     = "set_" + this.name;
                    return_type   = new TypeExpression(new ConstantWrapper(Typeob.Void, context));
                }
                attributes &= FieldAttributes.FieldAccessMask;
                MethodAttributes attributes3 = privateScope & MethodAttributes.MemberAccessMask;
                if ((((privateScope & MethodAttributes.Virtual) != MethodAttributes.PrivateScope) && ((privateScope & MethodAttributes.Final) == MethodAttributes.PrivateScope)) && (((attributes3 == MethodAttributes.Private) || (attributes3 == MethodAttributes.Assembly)) || (attributes3 == MethodAttributes.FamANDAssem)))
                {
                    privateScope |= MethodAttributes.CheckAccessOnOverride;
                }
                this.func = new FunctionObject(this.name, formal_parameters, return_type, body, own_scope, obj2, base.context, privateScope, customAttributes, this.isMethod);
                if (this.declaringObject == null)
                {
                    string str2 = this.name;
                    if (this.ifaceId != null)
                    {
                        str2 = ifaceId.ToString() + "." + str2;
                    }
                    JSVariableField field = (JSVariableField)((ActivationObject)obj2).name_table[str2];
                    if ((field != null) && ((!(field is JSMemberField) || !(((JSMemberField)field).value is FunctionObject)) || this.func.isExpandoMethod))
                    {
                        if (name != this.name)
                        {
                            field.originalContext.HandleError(JSError.ClashWithProperty);
                        }
                        else
                        {
                            id.context.HandleError(JSError.DuplicateName, this.func.isExpandoMethod);
                            if (field.value is FunctionObject)
                            {
                                ((FunctionObject)field.value).suppressIL = true;
                            }
                        }
                    }
                    if (this.isMethod)
                    {
                        if ((!(field is JSMemberField) || !(((JSMemberField)field).value is FunctionObject)) || (name != this.name))
                        {
                            this.field = ((ActivationObject)obj2).AddNewField(str2, this.func, attributes | FieldAttributes.Literal);
                            if (name == this.name)
                            {
                                this.field.type = new TypeExpression(new ConstantWrapper(Typeob.FunctionWrapper, base.context));
                            }
                        }
                        else
                        {
                            this.field = ((JSMemberField)field).AddOverload(this.func, attributes | FieldAttributes.Literal);
                        }
                    }
                    else if (obj2 is FunctionScope)
                    {
                        if (this.inFastScope)
                        {
                            attributes |= FieldAttributes.Literal;
                        }
                        this.field = ((FunctionScope)obj2).AddNewField(this.name, attributes, this.func);
                        if (this.field is JSLocalField)
                        {
                            JSLocalField field2 = (JSLocalField)this.field;
                            if (this.inFastScope)
                            {
                                field2.type            = new TypeExpression(new ConstantWrapper(Typeob.ScriptFunction, base.context));
                                field2.attributeFlags |= FieldAttributes.Literal;
                            }
                            field2.debugOn   = base.context.document.debugOn;
                            field2.isDefined = true;
                        }
                    }
                    else if (this.inFastScope)
                    {
                        this.field      = ((ActivationObject)obj2).AddNewField(this.name, this.func, attributes | FieldAttributes.Literal);
                        this.field.type = new TypeExpression(new ConstantWrapper(Typeob.ScriptFunction, base.context));
                    }
                    else
                    {
                        this.field = ((ActivationObject)obj2).AddNewField(this.name, this.func, attributes | FieldAttributes.Static);
                    }
                    this.field.originalContext = context;
                    if (name != this.name)
                    {
                        string str3 = name;
                        if (this.ifaceId != null)
                        {
                            str3 = ifaceId.ToString() + "." + name;
                        }
                        FieldInfo info = (FieldInfo)((ClassScope)obj2).name_table[str3];
                        if (info != null)
                        {
                            if (info.IsLiteral)
                            {
                                object obj3 = ((JSVariableField)info).value;
                                if (obj3 is JSProperty)
                                {
                                    this.enclosingProperty = (JSProperty)obj3;
                                }
                            }
                            if (this.enclosingProperty == null)
                            {
                                id.context.HandleError(JSError.DuplicateName, true);
                            }
                        }
                        if (this.enclosingProperty == null)
                        {
                            this.enclosingProperty = new JSProperty(name);
                            ((JSMemberField)((ActivationObject)obj2).AddNewField(str3, this.enclosingProperty, attributes | FieldAttributes.Literal)).originalContext = base.context;
                        }
                        else if ((isGetter && (this.enclosingProperty.getter != null)) || (isSetter && (this.enclosingProperty.setter != null)))
                        {
                            id.context.HandleError(JSError.DuplicateName, true);
                        }
                        if (isGetter)
                        {
                            this.enclosingProperty.getter = new JSFieldMethod(this.field, obj2);
                        }
                        else
                        {
                            this.enclosingProperty.setter = new JSFieldMethod(this.field, obj2);
                        }
                    }
                }
            }
            else
            {
                this.inFastScope = false;
                this.func        = new FunctionObject(this.name, formal_parameters, return_type, body, own_scope, obj2, base.context, MethodAttributes.Public, null, false);
                this.field       = ((StackFrame)obj2).AddNewField(this.name, new Closure(this.func), attributes | FieldAttributes.Static);
            }
        }
Пример #24
0
 internal Break(Context context, int count, bool leavesFinally)
   : base(context) {
   this.completion = new Completion();
   this.completion.Exit = count;
   this.leavesFinally = leavesFinally;
 }
Пример #25
0
        internal override Object Evaluate()
        {
            int        i  = Globals.ScopeStack.Size();
            int        j  = Globals.CallContextStack.Size();
            Completion bc = null;
            Completion fc = null;

            try{
                Object eValue = null;
                try{
                    bc = (Completion)this.body.Evaluate();
                }catch (Exception e) {
                    if (this.handler == null)
                    {
                        throw;
                    }
                    eValue = e;
                    if (this.type != null)
                    {
                        Type ht = this.type.ToType();
                        if (Typeob.Exception.IsAssignableFrom(ht))
                        {
                            if (!ht.IsInstanceOfType(e))
                            {
                                throw;
                            }
                        }
                        else if (!ht.IsInstanceOfType(eValue = JScriptExceptionValue(e, this.Engine)))
                        {
                            throw;
                        }
                    }
                    else
                    {
                        eValue = JScriptExceptionValue(e, this.Engine);
                    }
                }catch {
                    eValue = new JScriptException(JSError.NonClsException);
                }

                if (eValue != null)
                {
                    Globals.ScopeStack.TrimToSize(i);
                    Globals.CallContextStack.TrimToSize(j);
                    if (this.handler_scope != null)
                    {
                        this.handler_scope.SetParent(Globals.ScopeStack.Peek());
                        Globals.ScopeStack.Push(this.handler_scope);
                    }
                    if (this.field != null)
                    {
                        this.field.SetValue(Globals.ScopeStack.Peek(), eValue);
                    }
                    bc = (Completion)this.handler.Evaluate();
                }
            }finally{
                Globals.ScopeStack.TrimToSize(i);
                Globals.CallContextStack.TrimToSize(j);
                if (this.finally_block != null)
                {
                    fc = (Completion)this.finally_block.Evaluate();
                }
            }
            if (bc == null || fc != null && (fc.Exit > 0 || fc.Continue > 0 || fc.Return))
            {
                bc = fc;
            }
            else
            {
                if (fc != null && fc.value is Missing)
                {
                    bc.value = fc.value;
                }
            }
            Completion result = new Completion();

            result.Continue = bc.Continue - 1;
            result.Exit     = bc.Exit - 1;
            result.Return   = bc.Return;
            result.value    = bc.value;
            return(result);
        }
 internal VariableDeclaration(Context context, Lookup identifier, TypeExpression type, AST initializer, FieldAttributes attributes, CustomAttributeList customAttributes) : base(context)
 {
     if (initializer != null)
     {
         base.context.UpdateWith(initializer.context);
     }
     else if (type != null)
     {
         base.context.UpdateWith(type.context);
     }
     this.identifier = identifier;
     this.type = type;
     this.initializer = initializer;
     ScriptObject parent = base.Globals.ScopeStack.Peek();
     while (parent is WithObject)
     {
         parent = parent.GetParent();
     }
     string name = this.identifier.ToString();
     if (parent is ClassScope)
     {
         if (name == ((ClassScope) parent).name)
         {
             identifier.context.HandleError(JSError.CannotUseNameOfClass);
             name = name + " var";
         }
     }
     else if (attributes != FieldAttributes.PrivateScope)
     {
         base.context.HandleError(JSError.NotInsideClass);
         attributes = FieldAttributes.Public;
     }
     else
     {
         attributes |= FieldAttributes.Public;
     }
     FieldInfo localField = ((IActivationObject) parent).GetLocalField(name);
     if (localField != null)
     {
         if ((localField.IsLiteral || (parent is ClassScope)) || (type != null))
         {
             identifier.context.HandleError(JSError.DuplicateName, true);
         }
         this.type = (TypeExpression) (type = null);
     }
     if (parent is ActivationObject)
     {
         if ((localField == null) || (localField is JSVariableField))
         {
             this.field = ((ActivationObject) parent).AddFieldOrUseExistingField(this.identifier.ToString(), Microsoft.JScript.Missing.Value, attributes);
         }
         else
         {
             this.field = ((ActivationObject) parent).AddNewField(this.identifier.ToString(), null, attributes);
         }
     }
     else
     {
         this.field = ((StackFrame) parent).AddNewField(this.identifier.ToString(), null, 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;
     }
     this.completion = new Completion();
 }
Пример #27
0
 internal While(Context context, AST condition, AST body)
   : base(context) {
   this.condition = condition;
   this.body = body;
   this.completion = new Completion();
 }
Пример #28
0
      internal override Object Evaluate(){
        int i = Globals.ScopeStack.Size();
        int j = Globals.CallContextStack.Size();
        Completion bc = null;
        Completion fc = null;
        try{
          try{
            bc = (Completion)this.body.Evaluate();
          }catch(Exception e){
            if (this.handler == null) throw;
            Object eValue = e;
            if (this.type != null){
              Type ht = this.type.ToType();
              if (typeof(Exception).IsAssignableFrom(ht)){
                if (!ht.IsInstanceOfType(e)) throw;
              }else if (!ht.IsInstanceOfType(eValue = JScriptExceptionValue(e, this.Engine)))
                throw;
            }else
              eValue = JScriptExceptionValue(e, this.Engine);

            Globals.ScopeStack.TrimToSize(i);
            Globals.CallContextStack.TrimToSize(j);
            if (this.handler_scope != null){
              this.handler_scope.SetParent(Globals.ScopeStack.Peek());
              Globals.ScopeStack.Push(this.handler_scope);
            }
            if (this.field != null)
              this.field.SetValue(Globals.ScopeStack.Peek(), eValue);
            bc = (Completion)this.handler.Evaluate();
          }
        }finally{
          Globals.ScopeStack.TrimToSize(i);
          Globals.CallContextStack.TrimToSize(j);
          if (this.finally_block != null){
            fc = (Completion)this.finally_block.Evaluate();
          }
        }
        if (bc == null || fc != null && (fc.Exit > 0 || fc.Continue > 0 || fc.Return))
          bc = fc;
        else{
          if (fc != null && fc.value is Missing)
            bc.value = fc.value;
        }
        Completion result = new Completion();
        result.Continue = bc.Continue - 1;
        result.Exit = bc.Exit - 1;
        result.Return = bc.Return;
        result.value = bc.value;
        return result;
      }
 internal Print(Context context, AST operand) : base(context)
 {
     this.operand = (ASTList) operand;
     this.completion = new Completion();
 }
Пример #30
0
 internal Expression(Context context, AST operand)
   : base(context) {
   this.operand = operand;
   this.completion = new Completion();
 }
Пример #31
0
 internal Continue(Context context, int count, bool leavesFinally)
   : base(context) {
   this.completion = new Completion();
   this.completion.Continue = count;
   this.leavesFinally = leavesFinally;
 }
Пример #32
0
 internal SwitchCase(Context context, AST case_value, AST statements)
   : base(context) {
   this.case_value = case_value;
   this.statements = statements;
   this.completion = new Completion();
 }
Пример #33
0
 internal Expression(Context context, AST operand)
     : base(context)
 {
     this.operand    = operand;
     this.completion = new Completion();
 }