internal FunctionObject(string name, ParameterDeclaration[] parameter_declarations, TypeExpression return_type_expr, Block body, FunctionScope own_scope, ScriptObject enclosing_scope, Context funcContext, MethodAttributes attributes, CustomAttributeList customAttributes, bool isMethod) : base(body.Globals.globalObject.originalFunction.originalPrototype, name, parameter_declarations.Length) { this.parameter_declarations = parameter_declarations; int length = parameter_declarations.Length; this.formal_parameters = new string[length]; for (int i = 0; i < length; i++) { this.formal_parameters[i] = parameter_declarations[i].identifier; } this.argumentsSlotNumber = 0; this.return_type_expr = return_type_expr; if (this.return_type_expr != null) { own_scope.AddReturnValueField(); } this.body = body; this.method = null; this.parameterInfos = null; this.funcContext = funcContext; this.own_scope = own_scope; this.own_scope.owner = this; if ((!(enclosing_scope is ActivationObject) || !((ActivationObject) enclosing_scope).fast) && !isMethod) { this.argumentsSlotNumber = this.own_scope.GetNextSlotNumber(); JSLocalField field = (JSLocalField) this.own_scope.AddNewField("arguments", null, FieldAttributes.PrivateScope); field.type = new TypeExpression(new ConstantWrapper(Typeob.Object, funcContext)); field.isDefined = true; this.hasArgumentsObject = true; } else { this.hasArgumentsObject = false; } this.implementedIface = null; this.implementedIfaceMethod = null; this.isMethod = isMethod; this.isExpandoMethod = (customAttributes != null) && customAttributes.ContainsExpandoAttribute(); this.isStatic = this.own_scope.isStatic = (attributes & MethodAttributes.Static) != MethodAttributes.PrivateScope; this.suppressIL = false; this.noVersionSafeAttributeSpecified = true; this.fields = this.own_scope.GetLocalFields(); this.enclosing_scope = enclosing_scope; this.must_save_stack_locals = false; this.text = null; this.mb = null; this.cb = null; this.attributes = attributes; if (!this.isStatic) { this.attributes |= MethodAttributes.HideBySig; } this.globals = body.Globals; this.superConstructor = null; this.superConstructorCall = null; this.customAttributes = customAttributes; base.noExpando = false; this.clsCompliance = CLSComplianceSpec.NotAttributed; this.engineLocal = null; this.partiallyEvaluated = false; }
internal EnumDeclaration(Context context, IdentifierLiteral id, TypeExpression baseType, Block body, FieldAttributes attributes, CustomAttributeList customAttributes) : base(context, id, new TypeExpression(new ConstantWrapper(Typeob.Enum, null)), new TypeExpression[0], body, attributes, false, false, true, false, customAttributes) { this.baseType = (baseType != null) ? baseType : new TypeExpression(new ConstantWrapper(Typeob.Int32, null)); base.needsEngine = false; base.attributes &= TypeAttributes.NestedFamORAssem; TypeExpression expression = new TypeExpression(new ConstantWrapper(base.classob, base.context)); AST ast = new ConstantWrapper(-1, null); AST ast2 = new ConstantWrapper(1, null); JSMemberField[] fields = base.fields; for (int i = 0; i < fields.Length; i++) { FieldInfo info = fields[i]; JSVariableField field = (JSVariableField) info; field.attributeFlags = FieldAttributes.Literal | FieldAttributes.Static | FieldAttributes.Public; field.type = expression; if (field.value == null) { field.value = ast = new Plus(ast.context, ast, ast2); } else { ast = (AST) field.value; } field.value = new DeclaredEnumValue(field.value, field.Name, base.classob); } }
internal ParameterDeclaration(Type type, String identifier) : base() { this.identifier = identifier; this.type = new TypeExpression(new ConstantWrapper(type, null)); this.customAttributes = null; }
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; } }
public object[] GetCustomAttributes(bool inherit) { CustomAttributeList customAttributes = this.owner.customAttributes; if (customAttributes == null) { return(new object[0]); } return((object[])customAttributes.Evaluate()); }
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; } }
public override Object[] GetCustomAttributes(bool inherit) { if (this.cons != null) { CustomAttributeList caList = this.cons.customAttributes; if (caList != null) { return((Object[])caList.Evaluate(false)); } } return(new Object[0]); }
public override object[] GetCustomAttributes(bool inherit) { if (this.func != null) { CustomAttributeList customAttributes = this.func.customAttributes; if (customAttributes != null) { return((object[])customAttributes.Evaluate(inherit)); } } return(new object[0]); }
public Object[] GetCustomAttributes(bool inherit) { CustomAttributeList caList = this.owner.customAttributes; if (caList == null) { return(new Object[0]); } else { return((Object[])caList.Evaluate()); } }
internal ParameterDeclaration(Context context, String identifier, TypeExpression type, CustomAttributeList customAttributes) : base() { this.identifier = identifier; this.type = type == null ? new TypeExpression(new ConstantWrapper(Typeob.Object, context)) : type; this.context = context; ActivationObject current_scope = (ActivationObject)context.document.engine.Globals.ScopeStack.Peek(); if (current_scope.name_table[this.identifier] != null) //Only happens if there is another parameter declarations with the same name context.HandleError(JSError.DuplicateName, this.identifier, current_scope is ClassScope || current_scope.fast || type != null); else{ JSVariableField field = current_scope.AddNewField(this.identifier, null, 0); field.originalContext = context; } this.customAttributes = customAttributes; }
internal ParameterDeclaration(Context context, string identifier, TypeExpression type, CustomAttributeList customAttributes) { this.identifier = identifier; this.type = (type == null) ? new TypeExpression(new ConstantWrapper(Typeob.Object, context)) : type; this.context = context; ActivationObject obj2 = (ActivationObject) context.document.engine.Globals.ScopeStack.Peek(); if (obj2.name_table[this.identifier] != null) { context.HandleError(JSError.DuplicateName, this.identifier, ((obj2 is ClassScope) || obj2.fast) || (type != null)); } else { obj2.AddNewField(this.identifier, null, FieldAttributes.PrivateScope).originalContext = context; } this.customAttributes = customAttributes; }
internal Class(Context context, AST id, TypeExpression superTypeExpression, TypeExpression[] interfaces, Block body, FieldAttributes attributes, bool isAbstract, bool isFinal, bool isStatic, bool isInterface, CustomAttributeList customAttributes) : base(context) { this.name = id.ToString(); this.superTypeExpression = superTypeExpression; this.interfaces = interfaces; this.body = body; this.enclosingScope = (ScriptObject)Globals.ScopeStack.Peek(1); this.attributes = TypeAttributes.Class|TypeAttributes.Serializable; this.SetAccessibility(attributes); if (isAbstract) this.attributes |= TypeAttributes.Abstract; this.isAbstract = isAbstract || isInterface; this.isAlreadyPartiallyEvaluated = false; if (isFinal) this.attributes |= TypeAttributes.Sealed; if (isInterface) this.attributes |= TypeAttributes.Interface | TypeAttributes.Abstract; this.isCooked = false; this.cookedType = null; this.isExpando = false; this.isInterface = isInterface; this.isStatic = isStatic; this.needsEngine = !isInterface; this.validOn = (AttributeTargets)0; this.allowMultiple = true; this.classob = (ClassScope)Globals.ScopeStack.Peek(); this.classob.name = this.name; this.classob.owner = this; this.implicitDefaultConstructor = null; if (!isInterface && !(this is EnumDeclaration)) this.SetupConstructors(); this.EnterNameIntoEnclosingScopeAndGetOwnField(id, isStatic); this.fields = this.classob.GetMemberFields(); this.superClass = null; this.superIR = null; this.superMembers = null; this.firstIndex = null; this.fieldInitializer = null; this.customAttributes = customAttributes; this.clsCompliance = CLSComplianceSpec.NotAttributed; this.generateCodeForExpando = false; this.expandoItemProp = null; this.getHashTableMethod = null; this.getItem = null; this.setItem = null; }
internal ParameterDeclaration(Context context, string identifier, TypeExpression type, CustomAttributeList customAttributes) { this.identifier = identifier; this.type = (type == null) ? new TypeExpression(new ConstantWrapper(Typeob.Object, context)) : type; this.context = context; ActivationObject obj2 = (ActivationObject)context.document.engine.Globals.ScopeStack.Peek(); if (obj2.name_table[this.identifier] != null) { context.HandleError(JSError.DuplicateName, this.identifier, ((obj2 is ClassScope) || obj2.fast) || (type != null)); } else { obj2.AddNewField(this.identifier, null, FieldAttributes.PrivateScope).originalContext = context; } this.customAttributes = customAttributes; }
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 EnumDeclaration(Context context, IdentifierLiteral id, TypeExpression baseType, Block body, FieldAttributes attributes, CustomAttributeList customAttributes) : base(context, id, new TypeExpression(new ConstantWrapper(typeof(Enum), null)), new TypeExpression[0], body, attributes, false, false, true, false, customAttributes){ this.baseType = baseType != null ? baseType : new TypeExpression(new ConstantWrapper(Typeob.Int32, null)); this.needsEngine = false; this.attributes &= TypeAttributes.VisibilityMask; TypeExpression thisType = new TypeExpression(new ConstantWrapper(this.classob, this.context)); AST currentValue = new ConstantWrapper(-1, null); AST one = new ConstantWrapper(1, null); foreach (FieldInfo f in this.fields){ JSVariableField field = (JSVariableField)f; field.attributeFlags = FieldAttributes.Public|FieldAttributes.Static|FieldAttributes.Literal; field.type = thisType; if (field.value == null) field.value = currentValue = new Plus(currentValue.context, currentValue, one); else currentValue = (AST)field.value; field.value = new EnumWrapper(field.value, field.Name, this.classob); } }
internal ParameterDeclaration(Context context, String identifier, TypeExpression type, CustomAttributeList customAttributes) : base() { this.identifier = identifier; this.type = type == null ? new TypeExpression(new ConstantWrapper(Typeob.Object, context)) : type; this.context = context; ActivationObject current_scope = (ActivationObject)context.document.engine.Globals.ScopeStack.Peek(); if (current_scope.name_table[this.identifier] != null) { //Only happens if there is another parameter declarations with the same name context.HandleError(JSError.DuplicateName, this.identifier, current_scope is ClassScope || current_scope.fast || type != null); } else { JSVariableField field = current_scope.AddNewField(this.identifier, null, 0); field.originalContext = context; } this.customAttributes = customAttributes; }
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; }
private AST ParseVariableStatement(FieldAttributes visibility, CustomAttributeList customAttributes, JSToken kind) { Block block = new Block(this.currentToken.Clone()); bool flag = true; AST elem = null; Label_0015: this.noSkipTokenSet.Add(NoSkipTokenSet.s_EndOfLineToken); try { elem = this.ParseIdentifierInitializer(JSToken.None, visibility, customAttributes, kind); } catch (RecoveryTokenException exception) { if ((exception._partiallyComputedNode != null) && !flag) { block.Append(exception._partiallyComputedNode); block.context.UpdateWith(exception._partiallyComputedNode.context); exception._partiallyComputedNode = block; } if (this.IndexOfToken(NoSkipTokenSet.s_EndOfLineToken, exception) == -1) { throw exception; } if (flag) { elem = exception._partiallyComputedNode; } } finally { this.noSkipTokenSet.Remove(NoSkipTokenSet.s_EndOfLineToken); } if ((JSToken.Semicolon == this.currentToken.token) || (JSToken.RightCurly == this.currentToken.token)) { if (JSToken.Semicolon == this.currentToken.token) { elem.context.UpdateWith(this.currentToken); this.GetNextToken(); } } else { if (JSToken.Comma == this.currentToken.token) { flag = false; block.Append(elem); goto Label_0015; } if (!this.scanner.GotEndOfLine()) { this.ReportError(JSError.NoSemicolon, true); } } if (flag) { return elem; } block.Append(elem); block.context.UpdateWith(elem.context); return block; }
internal EnumDeclaration(Context context, IdentifierLiteral id, TypeExpression baseType, Block body, FieldAttributes attributes, CustomAttributeList customAttributes) : base(context, id, new TypeExpression(new ConstantWrapper(Typeob.Enum, null)), new TypeExpression[0], body, attributes, false, false, true, false, customAttributes) { this.baseType = (baseType != null) ? baseType : new TypeExpression(new ConstantWrapper(Typeob.Int32, null)); base.needsEngine = false; base.attributes &= TypeAttributes.NestedFamORAssem; TypeExpression expression = new TypeExpression(new ConstantWrapper(base.classob, base.context)); AST ast = new ConstantWrapper(-1, null); AST ast2 = new ConstantWrapper(1, null); JSMemberField[] fields = base.fields; for (int i = 0; i < fields.Length; i++) { FieldInfo info = fields[i]; JSVariableField field = (JSVariableField)info; field.attributeFlags = FieldAttributes.Literal | FieldAttributes.Static | FieldAttributes.Public; field.type = expression; if (field.value == null) { field.value = ast = new Plus(ast.context, ast, ast2); } else { ast = (AST)field.value; } field.value = new DeclaredEnumValue(field.value, field.Name, base.classob); } }
internal EnumDeclaration(Context context, IdentifierLiteral id, TypeExpression baseType, Block body, FieldAttributes attributes, CustomAttributeList customAttributes) : base(context, id, new TypeExpression(new ConstantWrapper(typeof(Enum), null)), new TypeExpression[0], body, attributes, false, false, true, false, customAttributes) { this.baseType = baseType != null ? baseType : new TypeExpression(new ConstantWrapper(Typeob.Int32, null)); this.needsEngine = false; this.attributes &= TypeAttributes.VisibilityMask; TypeExpression thisType = new TypeExpression(new ConstantWrapper(this.classob, this.context)); AST currentValue = new ConstantWrapper(-1, null); AST one = new ConstantWrapper(1, null); foreach (FieldInfo f in this.fields) { JSVariableField field = (JSVariableField)f; field.attributeFlags = FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal; field.type = thisType; if (field.value == null) { field.value = currentValue = new Plus(currentValue.context, currentValue, one); } else { currentValue = (AST)field.value; } field.value = new EnumWrapper(field.value, field.Name, this.classob); } }
private AST ParseEnum(FieldAttributes visibilitySpec, Context enumCtx, CustomAttributeList customAttributes) { IdentifierLiteral name = null; AST ast = null; TypeExpression baseType = null; Block body = null; AST ast2; this.GetNextToken(); if (JSToken.Identifier == this.currentToken.token) { name = new IdentifierLiteral(this.scanner.GetIdentifier(), this.currentToken.Clone()); } else { this.ReportError(JSError.NoIdentifier); if ((JSToken.Colon != this.currentToken.token) && (JSToken.LeftCurly != this.currentToken.token)) { this.SkipTokensAndThrow(); } name = new IdentifierLiteral("##Missing Enum Name##" + s_cDummyName++, this.CurrentPositionContext()); } this.GetNextToken(); if (JSToken.Colon == this.currentToken.token) { this.noSkipTokenSet.Add(NoSkipTokenSet.s_EnumBaseTypeNoSkipTokenSet); try { ast = this.ParseQualifiedIdentifier(JSError.NeedType); } catch (RecoveryTokenException exception) { if (this.IndexOfToken(NoSkipTokenSet.s_ClassExtendsNoSkipTokenSet, exception) == -1) { exception._partiallyComputedNode = null; throw exception; } ast = exception._partiallyComputedNode; } finally { this.noSkipTokenSet.Remove(NoSkipTokenSet.s_EnumBaseTypeNoSkipTokenSet); } } if (ast != null) { baseType = new TypeExpression(ast); } if (JSToken.LeftCurly != this.currentToken.token) { this.ReportError(JSError.NoLeftCurly); } ArrayList blockType = this.blockType; this.blockType = new ArrayList(0x10); SimpleHashtable labelTable = this.labelTable; this.labelTable = new SimpleHashtable(0x10); this.Globals.ScopeStack.Push(new ClassScope(name, ((IActivationObject) this.Globals.ScopeStack.Peek()).GetGlobalScope())); try { body = this.ParseClassBody(true, false); enumCtx.UpdateWith(body.context); EnumDeclaration target = new EnumDeclaration(enumCtx, name, baseType, body, visibilitySpec, customAttributes); if (customAttributes != null) { customAttributes.SetTarget(target); } ast2 = target; } catch (RecoveryTokenException exception2) { enumCtx.UpdateWith(exception2._partiallyComputedNode.context); exception2._partiallyComputedNode = new EnumDeclaration(enumCtx, name, baseType, (Block) exception2._partiallyComputedNode, visibilitySpec, customAttributes); if (customAttributes != null) { customAttributes.SetTarget(exception2._partiallyComputedNode); } throw exception2; } finally { this.Globals.ScopeStack.Pop(); this.blockType = blockType; this.labelTable = labelTable; } return ast2; }
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(); }
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) { MethodAttributes methodAttributes = (MethodAttributes)0; if ((attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Public) { methodAttributes = MethodAttributes.Public; } else if ((attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Private) { methodAttributes = MethodAttributes.Private; } else if ((attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Assembly) { methodAttributes = MethodAttributes.Assembly; } else if ((attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Family) { methodAttributes = MethodAttributes.Family; } else if ((attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.FamORAssem) { methodAttributes = MethodAttributes.FamORAssem; } else { methodAttributes = MethodAttributes.Public; } if ((attributes & FieldAttributes.Static) != 0 || !isMethod) { methodAttributes |= MethodAttributes.Static; } else { methodAttributes |= MethodAttributes.Virtual | MethodAttributes.NewSlot; } if (isAbstract) { methodAttributes |= MethodAttributes.Abstract; } if (isFinal) { methodAttributes |= MethodAttributes.Final; } this.name = id.ToString(); this.isMethod = isMethod; if (ifaceId != null) { if (isMethod) { this.ifaceId = new TypeExpression(ifaceId); methodAttributes &= ~MethodAttributes.MemberAccessMask; methodAttributes |= MethodAttributes.Private | MethodAttributes.Final; } else { this.declaringObject = new Member(ifaceId.context, ifaceId, id); this.name = this.declaringObject.ToString(); } } ScriptObject enclosingScope = Globals.ScopeStack.Peek(); if (attributes == 0 && !isAbstract && !isFinal) { if (enclosingScope is ClassScope) { attributes |= FieldAttributes.Public; } } else { if (!(enclosingScope is ClassScope)) { this.context.HandleError(JSError.NotInsideClass); attributes = (FieldAttributes)0; methodAttributes = MethodAttributes.Public; } } if (enclosingScope is ActivationObject) { this.inFastScope = ((ActivationObject)enclosingScope).fast; // if later on originalName != this.name this is a property getter/setter String originalName = this.name; // mangle the name if (isGetter) { methodAttributes |= MethodAttributes.SpecialName; this.name = "get_" + this.name; if (return_type == null) { return_type = new TypeExpression(new ConstantWrapper(Typeob.Object, context)); } } else if (isSetter) { methodAttributes |= MethodAttributes.SpecialName; this.name = "set_" + this.name; return_type = new TypeExpression(new ConstantWrapper(Typeob.Void, context)); } attributes &= FieldAttributes.FieldAccessMask; // create the function object this.func = new FunctionObject(this.name, formal_parameters, return_type, body, own_scope, enclosingScope, this.context, methodAttributes, customAttributes, this.isMethod); if (this.declaringObject != null) { return; } // check whether the function name (possibly mangled) is in use already String fieldName = this.name; if (this.ifaceId != null) { fieldName = ifaceId.ToString() + "." + fieldName; } JSVariableField localField = (JSVariableField)((ActivationObject)enclosingScope).name_table[fieldName]; if (localField != null && (!(localField is JSMemberField) || !(((JSMemberField)localField).value is FunctionObject) || this.func.isExpandoMethod)) { if (originalName != this.name) { localField.originalContext.HandleError(JSError.ClashWithProperty); } else { id.context.HandleError(JSError.DuplicateName, this.func.isExpandoMethod); if (localField.value is FunctionObject) { ((FunctionObject)localField.value).suppressIL = true; } } } // create or update the proper field if (this.isMethod) { if (!(localField is JSMemberField) || !(((JSMemberField)localField).value is FunctionObject) || originalName != this.name) { this.field = ((ActivationObject)enclosingScope).AddNewField(fieldName, this.func, attributes | FieldAttributes.Literal); if (originalName == this.name) // if it is a property do not assign the type { ((JSVariableField)this.field).type = new TypeExpression(new ConstantWrapper(Typeob.FunctionWrapper, this.context)); } } else { this.field = ((JSMemberField)localField).AddOverload(this.func, attributes | FieldAttributes.Literal); } } else if (enclosingScope is FunctionScope) { if (this.inFastScope) { attributes |= FieldAttributes.Literal; } this.field = ((FunctionScope)enclosingScope).AddNewField(this.name, attributes, this.func); if (this.field is JSLocalField) { JSLocalField locField = (JSLocalField)this.field; if (this.inFastScope) { locField.type = new TypeExpression(new ConstantWrapper(Typeob.ScriptFunction, this.context)); locField.attributeFlags |= FieldAttributes.Literal; } locField.debugOn = this.context.document.debugOn; locField.isDefined = true; } } else if (this.inFastScope) { this.field = ((ActivationObject)enclosingScope).AddNewField(this.name, this.func, attributes | FieldAttributes.Literal); ((JSVariableField)this.field).type = new TypeExpression(new ConstantWrapper(Typeob.ScriptFunction, this.context)); //Do not use typeof(Closure) for the field, since that has the arguments and callee properties, which are not //accessible in fast mode } else //enclosingScope is GlobalObject { this.field = ((ActivationObject)enclosingScope).AddNewField(this.name, this.func, attributes | FieldAttributes.Static); } ((JSVariableField)this.field).originalContext = context; // if it is a property create/update the PropertyInfo and assign the getter/setter if (originalName != this.name) { String propertyFieldName = originalName; if (this.ifaceId != null) { propertyFieldName = ifaceId.ToString() + "." + originalName; } FieldInfo prop = (FieldInfo)((ClassScope)enclosingScope).name_table[propertyFieldName]; if (prop != null) { // check whether a property was defined already if (prop.IsLiteral) { Object val = ((JSVariableField)prop).value; if (val is JSProperty) { this.enclosingProperty = (JSProperty)val; } } if (this.enclosingProperty == null) { id.context.HandleError(JSError.DuplicateName, true); // the matching name was not a property } } if (this.enclosingProperty == null) { this.enclosingProperty = new JSProperty(originalName); prop = ((ActivationObject)enclosingScope).AddNewField(propertyFieldName, this.enclosingProperty, attributes | FieldAttributes.Literal); ((JSMemberField)prop).originalContext = this.context; } else { if ((isGetter && this.enclosingProperty.getter != null) || (isSetter && this.enclosingProperty.setter != null)) { id.context.HandleError(JSError.DuplicateName, true); // duplicated setter or getter } } if (isGetter) { this.enclosingProperty.getter = new JSFieldMethod(this.field, enclosingScope); } else { this.enclosingProperty.setter = new JSFieldMethod(this.field, enclosingScope); } } } else //Might get here if function declaration is inside of an eval. { this.inFastScope = false; this.func = new FunctionObject(this.name, formal_parameters, return_type, body, own_scope, enclosingScope, this.context, MethodAttributes.Public, null, false); this.field = ((StackFrame)enclosingScope).AddNewField(this.name, new Closure(this.func), attributes | FieldAttributes.Static); } }
internal AssemblyCustomAttributeList(CustomAttributeList list) : base(list.context) { this.list = list; this.okToUse = false; }
private CustomAttributeList ParseCustomAttributeList() { CustomAttributeList list = new CustomAttributeList(this.currentToken.Clone()); while (true) { bool flag; Context context = this.currentToken.Clone(); bool canBeAttribute = true; AST func = this.ParseUnaryExpression(out flag, ref canBeAttribute, false, false); if (canBeAttribute) { if ((func is Lookup) || (func is Member)) { list.Append(new Microsoft.JScript.CustomAttribute(func.context, func, new ASTList(null))); } else { list.Append(((Call) func).ToCustomAttribute()); } } else if (this.tokensSkipped == 0) { this.ReportError(JSError.SyntaxError, context); } if (this.currentToken.token == JSToken.RightBracket) { return list; } if (this.currentToken.token == JSToken.Comma) { this.GetNextToken(); } else { this.ReportError(JSError.NoRightBracketOrComma); this.SkipTokensAndThrow(); } } }
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); } }
//--------------------------------------------------------------------------------------- // ParseEnum // // Enum : // 'enum' identifier [':' baseType] EnumBody (in the guise of ClassBody with a param) // //--------------------------------------------------------------------------------------- private AST ParseEnum(FieldAttributes visibilitySpec, Context enumCtx, CustomAttributeList customAttributes){ IdentifierLiteral name = null; AST baseId = null; TypeExpression baseType = null; Block body = null; GetNextToken(); if (JSToken.Identifier == this.currentToken.token){ name = new IdentifierLiteral(this.scanner.GetIdentifier(), this.currentToken.Clone()); }else{ ReportError(JSError.NoIdentifier); if (JSToken.Colon != this.currentToken.token && JSToken.LeftCurly != this.currentToken.token) SkipTokensAndThrow(); // what the is this? name = new IdentifierLiteral("##Missing Enum Name##" + s_cDummyName++, CurrentPositionContext()); } GetNextToken(); if (JSToken.Colon == this.currentToken.token){ this.noSkipTokenSet.Add(NoSkipTokenSet.s_EnumBaseTypeNoSkipTokenSet); try{ baseId = ParseQualifiedIdentifier(JSError.NeedType); }catch(RecoveryTokenException exc){ if (IndexOfToken(NoSkipTokenSet.s_ClassExtendsNoSkipTokenSet, exc) == -1){ exc._partiallyComputedNode = null; throw exc; }else{ baseId = exc._partiallyComputedNode; } }finally{ this.noSkipTokenSet.Remove(NoSkipTokenSet.s_EnumBaseTypeNoSkipTokenSet); } } if (baseId != null) baseType = new TypeExpression(baseId); if (JSToken.LeftCurly != this.currentToken.token) ReportError(JSError.NoLeftCurly); // make a new state and save the old one ArrayList blockType = this.blockType; this.blockType = new ArrayList(16); SimpleHashtable labelTable = this.labelTable; this.labelTable = new SimpleHashtable(16); Globals.ScopeStack.Push(new ClassScope(name, ((IActivationObject)Globals.ScopeStack.Peek()).GetGlobalScope())); //Give declarations a place to go while building AST try{ body = ParseClassBody(true, false); enumCtx.UpdateWith(body.context); EnumDeclaration result = new EnumDeclaration(enumCtx, name, baseType, body, visibilitySpec, customAttributes); if (customAttributes != null) customAttributes.SetTarget(result); return result; }catch(RecoveryTokenException exc){ enumCtx.UpdateWith(exc._partiallyComputedNode.context); exc._partiallyComputedNode = new EnumDeclaration(enumCtx, name, baseType, (Block)exc._partiallyComputedNode, visibilitySpec, customAttributes); if (customAttributes != null) customAttributes.SetTarget(exc._partiallyComputedNode); throw exc; }finally{ Globals.ScopeStack.Pop(); this.blockType = blockType; this.labelTable = labelTable; } }
//--------------------------------------------------------------------------------------- // ParseClass // // Class : // 'class' identifier OptionalExtends ClassBody // // Extends : // 'extends' QualifiedIdentifier // //--------------------------------------------------------------------------------------- private AST ParseClass(FieldAttributes visibilitySpec, bool isStatic, Context classCtx, bool isAbstract, bool isFinal, CustomAttributeList customAttributes){ AST name = null; AST baseId = null; TypeExpression baseType = null; Block body = null; ArrayList interfaces = new ArrayList(); bool isInterface = JSToken.Interface == this.currentToken.token; GetNextToken(); if (JSToken.Identifier == this.currentToken.token){ name = new IdentifierLiteral(this.scanner.GetIdentifier(), this.currentToken.Clone()); }else{ ReportError(JSError.NoIdentifier); if (JSToken.Extends != this.currentToken.token && JSToken.Implements != this.currentToken.token && JSToken.LeftCurly != this.currentToken.token) SkipTokensAndThrow(); // what the is this? name = new IdentifierLiteral("##Missing Class Name##" + s_cDummyName++, CurrentPositionContext()); } GetNextToken(); if (JSToken.Extends == this.currentToken.token || JSToken.Implements == this.currentToken.token){ if (isInterface && JSToken.Extends == this.currentToken.token) this.currentToken.token = JSToken.Implements; if (JSToken.Extends == this.currentToken.token){ this.noSkipTokenSet.Add(NoSkipTokenSet.s_ClassExtendsNoSkipTokenSet); try{ baseId = ParseQualifiedIdentifier(JSError.NeedType); }catch(RecoveryTokenException exc){ if (IndexOfToken(NoSkipTokenSet.s_ClassExtendsNoSkipTokenSet, exc) == -1){ exc._partiallyComputedNode = null; throw exc; }else{ baseId = exc._partiallyComputedNode; } }finally{ this.noSkipTokenSet.Remove(NoSkipTokenSet.s_ClassExtendsNoSkipTokenSet); } } if (JSToken.Implements == this.currentToken.token){ do{ AST typeId = null; this.noSkipTokenSet.Add(NoSkipTokenSet.s_ClassImplementsNoSkipTokenSet); try{ typeId = ParseQualifiedIdentifier(JSError.NeedType); interfaces.Add(new TypeExpression(typeId)); }catch(RecoveryTokenException exc){ if (IndexOfToken(NoSkipTokenSet.s_ClassImplementsNoSkipTokenSet, exc) == -1){ exc._partiallyComputedNode = null; throw exc; }else{ if (exc._partiallyComputedNode != null) interfaces.Add(new TypeExpression(exc._partiallyComputedNode)); } }finally{ this.noSkipTokenSet.Remove(NoSkipTokenSet.s_ClassImplementsNoSkipTokenSet); } }while (JSToken.Comma == this.currentToken.token); } } if (baseId != null) baseType = new TypeExpression(baseId); if (JSToken.LeftCurly != this.currentToken.token){ ReportError(JSError.NoLeftCurly); } // make a new state and save the old one ArrayList blockType = this.blockType; this.blockType = new ArrayList(16); SimpleHashtable labelTable = this.labelTable; this.labelTable = new SimpleHashtable(16); Globals.ScopeStack.Push(new ClassScope(name, ((IActivationObject)Globals.ScopeStack.Peek()).GetGlobalScope())); //Give declarations a place to go while building AST TypeExpression[] ifaces; try{ body = ParseClassBody(false, isInterface); classCtx.UpdateWith(body.context); ifaces = new TypeExpression[interfaces.Count]; interfaces.CopyTo(ifaces); Class result = new Class(classCtx, name, baseType, ifaces, body, visibilitySpec, isAbstract, isFinal, isStatic, isInterface, customAttributes); if (customAttributes != null) customAttributes.SetTarget(result); return result; }catch(RecoveryTokenException exc){ classCtx.UpdateWith(exc._partiallyComputedNode.context); ifaces = new TypeExpression[interfaces.Count]; interfaces.CopyTo(ifaces); exc._partiallyComputedNode = new Class(classCtx, name, baseType, ifaces, (Block)exc._partiallyComputedNode, visibilitySpec, isAbstract, isFinal, isStatic, isInterface, customAttributes); if (customAttributes != null) customAttributes.SetTarget(exc._partiallyComputedNode); throw exc; }finally{ Globals.ScopeStack.Pop(); this.blockType = blockType; this.labelTable = labelTable; } }
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(); }
internal ParameterDeclaration(Type type, String identifier) : base(){ this.identifier = identifier; this.type = new TypeExpression(new ConstantWrapper(type, null)); this.customAttributes = null; }
private AST ParseIdentifierInitializer(JSToken inToken, FieldAttributes visibility, CustomAttributeList customAttributes, JSToken kind) { Lookup identifier = null; TypeExpression type = null; AST initializer = null; RecoveryTokenException exception = null; this.GetNextToken(); if (JSToken.Identifier != this.currentToken.token) { string name = JSKeyword.CanBeIdentifier(this.currentToken.token); if (name != null) { this.ForceReportInfo(JSError.KeywordUsedAsIdentifier); identifier = new Lookup(name, this.currentToken.Clone()); } else { this.ReportError(JSError.NoIdentifier); identifier = new Lookup("#_Missing Identifier_#" + s_cDummyName++, this.CurrentPositionContext()); } } else { identifier = new Lookup(this.scanner.GetIdentifier(), this.currentToken.Clone()); } this.GetNextToken(); Context context = identifier.context.Clone(); this.noSkipTokenSet.Add(NoSkipTokenSet.s_VariableDeclNoSkipTokenSet); try { if (JSToken.Colon == this.currentToken.token) { try { type = this.ParseTypeExpression(); } catch (RecoveryTokenException exception2) { type = (TypeExpression) exception2._partiallyComputedNode; throw exception2; } finally { if (type != null) { context.UpdateWith(type.context); } } } if ((JSToken.Assign == this.currentToken.token) || (JSToken.Equal == this.currentToken.token)) { if (JSToken.Equal == this.currentToken.token) { this.ReportError(JSError.NoEqual, true); } this.GetNextToken(); try { initializer = this.ParseExpression(true, inToken); } catch (RecoveryTokenException exception3) { initializer = exception3._partiallyComputedNode; throw exception3; } finally { if (initializer != null) { context.UpdateWith(initializer.context); } } } } catch (RecoveryTokenException exception4) { if (this.IndexOfToken(NoSkipTokenSet.s_VariableDeclNoSkipTokenSet, exception4) == -1) { exception = exception4; } } finally { this.noSkipTokenSet.Remove(NoSkipTokenSet.s_VariableDeclNoSkipTokenSet); } AST target = null; if (JSToken.Var == kind) { target = new VariableDeclaration(context, identifier, type, initializer, visibility, customAttributes); } else { if (initializer == null) { this.ForceReportInfo(JSError.NoEqual); } target = new Constant(context, identifier, type, initializer, visibility, customAttributes); } if (customAttributes != null) { customAttributes.SetTarget(target); } if (exception != null) { exception._partiallyComputedNode = target; throw exception; } return target; }
//--------------------------------------------------------------------------------------- // FromASTListToCustomAttributeList // // Utility function that takes a list of AST nodes (Call and Lookup nodes) and makes // a CustomAttributeList. It is invoked once a list of calls and lookups is unambiguosly // parsed as a custom attribute list //--------------------------------------------------------------------------------------- private CustomAttributeList FromASTListToCustomAttributeList(ArrayList attributes){ CustomAttributeList customAttributes = null; if (attributes != null && attributes.Count > 0) customAttributes = new CustomAttributeList(((AST)attributes[0]).context); for (int i = 0, n = attributes.Count; i < n; i++){ ASTList args = new ASTList(null); if (attributes[i] is Lookup || attributes[i] is Member) customAttributes.Append(new CustomAttribute(((AST)attributes[i]).context, (AST)attributes[i], args)); else customAttributes.Append(((Call)attributes[i]).ToCustomAttribute()); } return customAttributes; }
private AST ParseFunction(FieldAttributes visibilitySpec, bool inExpression, Context fncCtx, bool isMethod, bool isAbstract, bool isFinal, bool isInterface, CustomAttributeList customAttributes, Call function) { AST ast2; if (this.demandFullTrustOnFunctionCreation) { new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand(); } IdentifierLiteral id = null; AST rootObject = null; ArrayList parameters = null; TypeExpression expression = null; Block body = null; bool isGetter = false; bool isSetter = false; if (function == null) { this.GetNextToken(); if (isMethod) { if (JSToken.Get == this.currentToken.token) { isGetter = true; this.GetNextToken(); } else if (JSToken.Set == this.currentToken.token) { isSetter = true; this.GetNextToken(); } } if (JSToken.Identifier == this.currentToken.token) { id = new IdentifierLiteral(this.scanner.GetIdentifier(), this.currentToken.Clone()); this.GetNextToken(); if (JSToken.AccessField == this.currentToken.token) { if (isInterface) { this.ReportError(JSError.SyntaxError, true); } this.GetNextToken(); if (JSToken.Identifier == this.currentToken.token) { rootObject = new Lookup(id.context); id = new IdentifierLiteral(this.scanner.GetIdentifier(), this.currentToken.Clone()); this.GetNextToken(); while (JSToken.AccessField == this.currentToken.token) { this.GetNextToken(); if (JSToken.Identifier == this.currentToken.token) { rootObject = new Member(rootObject.context.CombineWith(this.currentToken), rootObject, new ConstantWrapper(id.ToString(), id.context)); id = new IdentifierLiteral(this.scanner.GetIdentifier(), this.currentToken.Clone()); this.GetNextToken(); } else { this.ReportError(JSError.NoIdentifier, true); } } } else { this.ReportError(JSError.NoIdentifier, true); } } } else { string identifier = JSKeyword.CanBeIdentifier(this.currentToken.token); if (identifier != null) { this.ForceReportInfo(JSError.KeywordUsedAsIdentifier, isMethod); id = new IdentifierLiteral(identifier, this.currentToken.Clone()); this.GetNextToken(); } else { if (!inExpression) { identifier = this.currentToken.GetCode(); this.ReportError(JSError.NoIdentifier, true); this.GetNextToken(); } else { identifier = ""; } id = new IdentifierLiteral(identifier, this.CurrentPositionContext()); } } } else { id = function.GetName(); } ArrayList blockType = this.blockType; this.blockType = new ArrayList(0x10); SimpleHashtable labelTable = this.labelTable; this.labelTable = new SimpleHashtable(0x10); FunctionScope item = new FunctionScope(this.Globals.ScopeStack.Peek(), isMethod); this.Globals.ScopeStack.Push(item); try { parameters = new ArrayList(); Context context = null; if (function == null) { if (JSToken.LeftParen != this.currentToken.token) { this.ReportError(JSError.NoLeftParen); } this.GetNextToken(); while (JSToken.RightParen != this.currentToken.token) { if (context != null) { this.ReportError(JSError.ParamListNotLast, context, true); context = null; } string str2 = null; TypeExpression type = null; this.noSkipTokenSet.Add(NoSkipTokenSet.s_FunctionDeclNoSkipTokenSet); try { try { if (JSToken.ParamArray == this.currentToken.token) { context = this.currentToken.Clone(); this.GetNextToken(); } if ((JSToken.Identifier != this.currentToken.token) && ((str2 = JSKeyword.CanBeIdentifier(this.currentToken.token)) == null)) { if (JSToken.LeftCurly == this.currentToken.token) { this.ReportError(JSError.NoRightParen); break; } if (JSToken.Comma == this.currentToken.token) { this.ReportError(JSError.SyntaxError, true); } else { this.ReportError(JSError.SyntaxError, true); this.SkipTokensAndThrow(); } } else { if (str2 == null) { str2 = this.scanner.GetIdentifier(); } else { this.ForceReportInfo(JSError.KeywordUsedAsIdentifier); } Context context2 = this.currentToken.Clone(); this.GetNextToken(); if (JSToken.Colon == this.currentToken.token) { type = this.ParseTypeExpression(); if (type != null) { context2.UpdateWith(type.context); } } CustomAttributeList list3 = null; if (context != null) { list3 = new CustomAttributeList(context); list3.Append(new Microsoft.JScript.CustomAttribute(context, new Lookup("...", context), new ASTList(null))); } parameters.Add(new ParameterDeclaration(context2, str2, type, list3)); } if (JSToken.RightParen == this.currentToken.token) { break; } if (JSToken.Comma != this.currentToken.token) { if (JSToken.LeftCurly == this.currentToken.token) { this.ReportError(JSError.NoRightParen); break; } if ((JSToken.Identifier == this.currentToken.token) && (type == null)) { this.ReportError(JSError.NoCommaOrTypeDefinitionError); } else { this.ReportError(JSError.NoComma); } } this.GetNextToken(); } catch (RecoveryTokenException exception) { if (this.IndexOfToken(NoSkipTokenSet.s_FunctionDeclNoSkipTokenSet, exception) == -1) { throw exception; } } continue; } finally { this.noSkipTokenSet.Remove(NoSkipTokenSet.s_FunctionDeclNoSkipTokenSet); } } fncCtx.UpdateWith(this.currentToken); if (isGetter && (parameters.Count != 0)) { this.ReportError(JSError.BadPropertyDeclaration, true); isGetter = false; } else if (isSetter && (parameters.Count != 1)) { this.ReportError(JSError.BadPropertyDeclaration, true); isSetter = false; } this.GetNextToken(); if (JSToken.Colon == this.currentToken.token) { if (isSetter) { this.ReportError(JSError.SyntaxError); } this.noSkipTokenSet.Add(NoSkipTokenSet.s_StartBlockNoSkipTokenSet); try { expression = this.ParseTypeExpression(); } catch (RecoveryTokenException exception2) { if (this.IndexOfToken(NoSkipTokenSet.s_StartBlockNoSkipTokenSet, exception2) == -1) { exception2._partiallyComputedNode = null; throw exception2; } if (exception2._partiallyComputedNode != null) { expression = (TypeExpression) exception2._partiallyComputedNode; } } finally { this.noSkipTokenSet.Remove(NoSkipTokenSet.s_StartBlockNoSkipTokenSet); } if (isSetter) { expression = null; } } } else { function.GetParameters(parameters); } if ((JSToken.LeftCurly != this.currentToken.token) && (isAbstract || (isMethod && this.GuessIfAbstract()))) { if (!isAbstract) { isAbstract = true; this.ReportError(JSError.ShouldBeAbstract, fncCtx, true); } body = new Block(this.currentToken.Clone()); } else { if (JSToken.LeftCurly != this.currentToken.token) { this.ReportError(JSError.NoLeftCurly, true); } else if (isAbstract) { this.ReportError(JSError.AbstractWithBody, fncCtx, true); } this.blockType.Add(BlockType.Block); this.noSkipTokenSet.Add(NoSkipTokenSet.s_BlockNoSkipTokenSet); this.noSkipTokenSet.Add(NoSkipTokenSet.s_StartStatementNoSkipTokenSet); try { body = new Block(this.currentToken.Clone()); this.GetNextToken(); while (JSToken.RightCurly != this.currentToken.token) { try { body.Append(this.ParseStatement()); continue; } catch (RecoveryTokenException exception3) { if (exception3._partiallyComputedNode != null) { body.Append(exception3._partiallyComputedNode); } if (this.IndexOfToken(NoSkipTokenSet.s_StartStatementNoSkipTokenSet, exception3) == -1) { throw exception3; } continue; } } body.context.UpdateWith(this.currentToken); fncCtx.UpdateWith(this.currentToken); } catch (RecoveryTokenException exception4) { if (this.IndexOfToken(NoSkipTokenSet.s_BlockNoSkipTokenSet, exception4) == -1) { this.Globals.ScopeStack.Pop(); try { ParameterDeclaration[] declarationArray = new ParameterDeclaration[parameters.Count]; parameters.CopyTo(declarationArray); if (inExpression) { exception4._partiallyComputedNode = new FunctionExpression(fncCtx, id, declarationArray, expression, body, item, visibilitySpec); } else { exception4._partiallyComputedNode = new FunctionDeclaration(fncCtx, rootObject, id, declarationArray, expression, body, item, visibilitySpec, isMethod, isGetter, isSetter, isAbstract, isFinal, customAttributes); } if (customAttributes != null) { customAttributes.SetTarget(exception4._partiallyComputedNode); } } finally { this.Globals.ScopeStack.Push(item); } throw exception4; } } finally { this.blockType.RemoveAt(this.blockType.Count - 1); this.noSkipTokenSet.Remove(NoSkipTokenSet.s_StartStatementNoSkipTokenSet); this.noSkipTokenSet.Remove(NoSkipTokenSet.s_BlockNoSkipTokenSet); } this.GetNextToken(); } } finally { this.blockType = blockType; this.labelTable = labelTable; this.Globals.ScopeStack.Pop(); } ParameterDeclaration[] array = new ParameterDeclaration[parameters.Count]; parameters.CopyTo(array); if (inExpression) { ast2 = new FunctionExpression(fncCtx, id, array, expression, body, item, visibilitySpec); } else { ast2 = new FunctionDeclaration(fncCtx, rootObject, id, array, expression, body, item, visibilitySpec, isMethod, isGetter, isSetter, isAbstract, isFinal, customAttributes); } if (customAttributes != null) { customAttributes.SetTarget(ast2); } return ast2; }
//--------------------------------------------------------------------------------------- // ParseVariableStatement // // VariableStatement : // ('var' | 'const') VariableDeclarationList // // VariableDeclarationList : // VariableDeclaration | // VariableDeclaration ',' VariableDeclarationList // // VariableDeclaration : // Identifier Type Initializer // // Type : // <empty> | // ':' TypeExpression // // Initializer : // <empty> | // '=' AssignmentExpression //--------------------------------------------------------------------------------------- private AST ParseVariableStatement(FieldAttributes visibility, CustomAttributeList customAttributes, JSToken kind){ Block varList = new Block(this.currentToken.Clone()); bool single = true; AST vdecl = null; for (;;){ this.noSkipTokenSet.Add(NoSkipTokenSet.s_EndOfLineToken); try{ vdecl = ParseIdentifierInitializer(JSToken.None, visibility, customAttributes, kind); }catch(RecoveryTokenException exc){ // an exception is passing by, possibly bringing some info, save the info if any if (exc._partiallyComputedNode != null){ if (!single){ varList.Append(exc._partiallyComputedNode); varList.context.UpdateWith(exc._partiallyComputedNode.context); exc._partiallyComputedNode = varList; } } if (IndexOfToken(NoSkipTokenSet.s_EndOfLineToken, exc) == -1) throw exc; else{ if (single) vdecl = exc._partiallyComputedNode; } }finally{ this.noSkipTokenSet.Remove(NoSkipTokenSet.s_EndOfLineToken); } if (JSToken.Semicolon == this.currentToken.token || JSToken.RightCurly == this.currentToken.token){ if (JSToken.Semicolon == this.currentToken.token){ vdecl.context.UpdateWith(this.currentToken); GetNextToken(); } break; }else if (JSToken.Comma == this.currentToken.token){ single = false; varList.Append(vdecl); continue; }else if (this.scanner.GotEndOfLine()){ break; }else{ // assume the variable statement was terminated and move on ReportError(JSError.NoSemicolon, true); break; } } if (single) return vdecl; else{ varList.Append(vdecl); varList.context.UpdateWith(vdecl.context); return varList; } }
private CustomAttributeList FromASTListToCustomAttributeList(ArrayList attributes) { CustomAttributeList list = null; if ((attributes != null) && (attributes.Count > 0)) { list = new CustomAttributeList(((AST) attributes[0]).context); } int num = 0; int count = attributes.Count; while (num < count) { ASTList args = new ASTList(null); if ((attributes[num] is Lookup) || (attributes[num] is Member)) { list.Append(new Microsoft.JScript.CustomAttribute(((AST) attributes[num]).context, (AST) attributes[num], args)); } else { list.Append(((Call) attributes[num]).ToCustomAttribute()); } num++; } return list; }
//--------------------------------------------------------------------------------------- // ParseIdentifierInitializer // // Does the real work of parsing a single variable declaration. // inToken is JSToken.In whenever the potential expression that initialize a variable // cannot contain an 'in', as in the for statement. inToken is JSToken.None otherwise //--------------------------------------------------------------------------------------- private AST ParseIdentifierInitializer(JSToken inToken, FieldAttributes visibility, CustomAttributeList customAttributes, JSToken kind){ Lookup id = null; TypeExpression typeExpr = null; AST assignmentExpr = null; RecoveryTokenException except = null; GetNextToken(); if (JSToken.Identifier != this.currentToken.token){ String identifier = JSKeyword.CanBeIdentifier(this.currentToken.token); if (null != identifier){ ForceReportInfo(JSError.KeywordUsedAsIdentifier); id = new Lookup(identifier, this.currentToken.Clone()); }else{ // make up an identifier and keep going; life goes on... ReportError(JSError.NoIdentifier); id = new Lookup("#_Missing Identifier_#" + s_cDummyName++, CurrentPositionContext()); } }else id = new Lookup(this.scanner.GetIdentifier(), this.currentToken.Clone()); GetNextToken(); Context context = id.context.Clone(); this.noSkipTokenSet.Add(NoSkipTokenSet.s_VariableDeclNoSkipTokenSet); try{ if (JSToken.Colon == this.currentToken.token){ try{ typeExpr = ParseTypeExpression(); }catch(RecoveryTokenException exc){ typeExpr = (TypeExpression)exc._partiallyComputedNode; throw exc; }finally{ if (null != typeExpr) context.UpdateWith(typeExpr.context); } } if (JSToken.Assign == this.currentToken.token || JSToken.Equal == this.currentToken.token){ if (JSToken.Equal == this.currentToken.token) ReportError(JSError.NoEqual, true); GetNextToken(); try{ assignmentExpr = ParseExpression(true, inToken); }catch(RecoveryTokenException exc){ assignmentExpr = exc._partiallyComputedNode; throw exc; }finally{ if (null != assignmentExpr) context.UpdateWith(assignmentExpr.context); } } }catch(RecoveryTokenException exc){ // If the exception is in the vardecl no-skip set then we successfully // recovered to the end of the declaration and can just return // normally. Otherwise we re-throw after constructing the partial result. if (IndexOfToken(NoSkipTokenSet.s_VariableDeclNoSkipTokenSet, exc) == -1) except = exc; }finally{ this.noSkipTokenSet.Remove(NoSkipTokenSet.s_VariableDeclNoSkipTokenSet); } AST result = null; if (JSToken.Var == kind) result = new VariableDeclaration(context, id, typeExpr, assignmentExpr, visibility, customAttributes); else{ if (assignmentExpr == null) ForceReportInfo(JSError.NoEqual); result = new Constant(context, id, typeExpr, assignmentExpr, visibility, customAttributes); } if (customAttributes != null) customAttributes.SetTarget(result); if (null != except){ except._partiallyComputedNode = result; throw except; } return result; }
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) { MethodAttributes methodAttributes = (MethodAttributes)0; if ((attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Public) methodAttributes = MethodAttributes.Public; else if ((attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Private) methodAttributes = MethodAttributes.Private; else if ((attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Assembly) methodAttributes = MethodAttributes.Assembly; else if ((attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Family) methodAttributes = MethodAttributes.Family; else if ((attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.FamORAssem) methodAttributes = MethodAttributes.FamORAssem; else methodAttributes = MethodAttributes.Public; if ((attributes & FieldAttributes.Static) != 0 || !isMethod) methodAttributes |= MethodAttributes.Static; else methodAttributes |= MethodAttributes.Virtual | MethodAttributes.NewSlot; if (isAbstract) methodAttributes |= MethodAttributes.Abstract; if (isFinal) methodAttributes |= MethodAttributes.Final; this.name = id.ToString(); this.isMethod = isMethod; if (ifaceId != null){ if (isMethod){ this.ifaceId = new TypeExpression(ifaceId); methodAttributes &= ~MethodAttributes.MemberAccessMask; methodAttributes |= MethodAttributes.Private|MethodAttributes.Final; }else{ this.declaringObject = new Member(ifaceId.context, ifaceId, id); this.name = this.declaringObject.ToString(); } } ScriptObject enclosingScope = Globals.ScopeStack.Peek(); if (attributes == 0 && !isAbstract && !isFinal){ if (enclosingScope is ClassScope) attributes |= FieldAttributes.Public; }else{ if (!(enclosingScope is ClassScope)){ this.context.HandleError(JSError.NotInsideClass); attributes = (FieldAttributes)0; methodAttributes = MethodAttributes.Public; } } if (enclosingScope is ActivationObject){ this.inFastScope = ((ActivationObject)enclosingScope).fast; // if later on originalName != this.name this is a property getter/setter String originalName = this.name; // mangle the name if (isGetter){ methodAttributes |= MethodAttributes.SpecialName; this.name = "get_" + this.name; if (return_type == null) return_type = new TypeExpression(new ConstantWrapper(Typeob.Object, context)); }else if (isSetter){ methodAttributes |= MethodAttributes.SpecialName; this.name = "set_" + this.name; return_type = new TypeExpression(new ConstantWrapper(Typeob.Void, context)); } attributes &= FieldAttributes.FieldAccessMask; // create the function object this.func = new FunctionObject(this.name, formal_parameters, return_type, body, own_scope, enclosingScope, this.context, methodAttributes, customAttributes, this.isMethod); if (this.declaringObject != null) return; // check whether the function name (possibly mangled) is in use already String fieldName = this.name; if (this.ifaceId != null) fieldName = ifaceId.ToString()+"."+fieldName; JSVariableField localField = (JSVariableField)((ActivationObject)enclosingScope).name_table[fieldName]; if (localField != null && (!(localField is JSMemberField) || !(((JSMemberField)localField).value is FunctionObject) || this.func.isExpandoMethod)){ if (originalName != this.name) localField.originalContext.HandleError(JSError.ClashWithProperty); else{ id.context.HandleError(JSError.DuplicateName, this.func.isExpandoMethod); if (localField.value is FunctionObject) ((FunctionObject)localField.value).suppressIL = true; } } // create or update the proper field if (this.isMethod){ if (!(localField is JSMemberField) || !(((JSMemberField)localField).value is FunctionObject) || originalName != this.name){ this.field = ((ActivationObject)enclosingScope).AddNewField(fieldName, this.func, attributes|FieldAttributes.Literal); if (originalName == this.name) // if it is a property do not assign the type ((JSVariableField)this.field).type = new TypeExpression(new ConstantWrapper(Typeob.FunctionWrapper, this.context)); }else this.field = ((JSMemberField)localField).AddOverload(this.func, attributes|FieldAttributes.Literal); }else if (enclosingScope is FunctionScope){ if (this.inFastScope) attributes |= FieldAttributes.Literal; this.field = ((FunctionScope)enclosingScope).AddNewField(this.name, attributes, this.func); if (this.field is JSLocalField){ JSLocalField locField = (JSLocalField)this.field; if (this.inFastScope){ locField.type = new TypeExpression(new ConstantWrapper(Typeob.ScriptFunction, this.context)); locField.attributeFlags |= FieldAttributes.Literal; } locField.debugOn = this.context.document.debugOn; locField.isDefined = true; } }else if (this.inFastScope){ this.field = ((ActivationObject)enclosingScope).AddNewField(this.name, this.func, attributes|FieldAttributes.Literal); ((JSVariableField)this.field).type = new TypeExpression(new ConstantWrapper(Typeob.ScriptFunction, this.context)); //Do not use typeof(Closure) for the field, since that has the arguments and callee properties, which are not //accessible in fast mode }else //enclosingScope is GlobalObject this.field = ((ActivationObject)enclosingScope).AddNewField(this.name, this.func, attributes|FieldAttributes.Static); ((JSVariableField)this.field).originalContext = context; // if it is a property create/update the PropertyInfo and assign the getter/setter if (originalName != this.name){ String propertyFieldName = originalName; if (this.ifaceId != null) propertyFieldName = ifaceId.ToString()+"."+originalName; FieldInfo prop = (FieldInfo)((ClassScope)enclosingScope).name_table[propertyFieldName]; if (prop != null){ // check whether a property was defined already if (prop.IsLiteral){ Object val = ((JSVariableField)prop).value; if (val is JSProperty) this.enclosingProperty = (JSProperty)val; } if (this.enclosingProperty == null) id.context.HandleError(JSError.DuplicateName, true); // the matching name was not a property } if (this.enclosingProperty == null){ this.enclosingProperty = new JSProperty(originalName); prop = ((ActivationObject)enclosingScope).AddNewField(propertyFieldName, this.enclosingProperty, attributes|FieldAttributes.Literal); ((JSMemberField)prop).originalContext = this.context; }else{ if ((isGetter && this.enclosingProperty.getter != null) || (isSetter && this.enclosingProperty.setter != null)) id.context.HandleError(JSError.DuplicateName, true); // duplicated setter or getter } if (isGetter) this.enclosingProperty.getter = new JSFieldMethod(this.field, enclosingScope); else this.enclosingProperty.setter = new JSFieldMethod(this.field, enclosingScope); } }else{ //Might get here if function declaration is inside of an eval. this.inFastScope = false; this.func = new FunctionObject(this.name, formal_parameters, return_type, body, own_scope, enclosingScope, this.context, MethodAttributes.Public, null, false); this.field = ((StackFrame)enclosingScope).AddNewField(this.name, new Closure(this.func), attributes|FieldAttributes.Static); } }
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(); }
//--------------------------------------------------------------------------------------- // ParseFunction // // FunctionDeclaration : // VisibilityModifier 'function' GetSet Identifier '(' // FormalParameterList ')' '{' FunctionBody '}' // // GetSet: // <empty> | // 'get' | // 'set' // // FormalParameterList : // <empty> | // IdentifierList Identifier // // IdentifierList : // <empty> | // Identifier, IdentifierList //--------------------------------------------------------------------------------------- private AST ParseFunction(FieldAttributes visibilitySpec, bool inExpression, Context fncCtx, bool isMethod, bool isAbstract, bool isFinal, bool isInterface, CustomAttributeList customAttributes){ return ParseFunction(visibilitySpec, inExpression, fncCtx, isMethod, isAbstract, isFinal, isInterface, customAttributes, null); }
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); } }
internal AssemblyCustomAttributeList(CustomAttributeList list) : base(list.context) { this.list = list; this.okToUse = false; }
private AST ParseFunction(FieldAttributes visibilitySpec, bool inExpression, Context fncCtx, bool isMethod, bool isAbstract, bool isFinal, bool isInterface, CustomAttributeList customAttributes, Call function){ IdentifierLiteral name = null; AST interfaceName = null; ArrayList formalParameters = null; TypeExpression returnType = null; Block body = null; bool isGetter = false; bool isSetter = false; if (function == null){ GetNextToken(); if (isMethod) if (JSToken.Get == this.currentToken.token){ isGetter = true; GetNextToken(); }else if (JSToken.Set == this.currentToken.token){ isSetter = true; GetNextToken(); } // get the function name or make an anonymous function if in expression "position" if (JSToken.Identifier == this.currentToken.token){ name = new IdentifierLiteral(this.scanner.GetIdentifier(), this.currentToken.Clone()); GetNextToken(); if (JSToken.AccessField == this.currentToken.token){ if (isInterface) // "function IBar.foo()" is illegal in an interface declaration ReportError(JSError.SyntaxError, true); GetNextToken(); if (JSToken.Identifier == this.currentToken.token){ interfaceName = new Lookup(name.context); name = new IdentifierLiteral(this.scanner.GetIdentifier(), this.currentToken.Clone()); GetNextToken(); while (JSToken.AccessField == this.currentToken.token){ GetNextToken(); if (JSToken.Identifier == this.currentToken.token){ interfaceName = new Member(interfaceName.context.CombineWith(this.currentToken), interfaceName, new ConstantWrapper(name.ToString(), name.context)); name = new IdentifierLiteral(this.scanner.GetIdentifier(), this.currentToken.Clone()); GetNextToken(); }else ReportError(JSError.NoIdentifier, true); } }else ReportError(JSError.NoIdentifier, true); } }else{ string identifier = JSKeyword.CanBeIdentifier(this.currentToken.token); if (null != identifier){ ForceReportInfo(JSError.KeywordUsedAsIdentifier, isMethod); name = new IdentifierLiteral(identifier, this.currentToken.Clone()); GetNextToken(); }else{ if (!inExpression){ identifier = this.currentToken.GetCode(); ReportError(JSError.NoIdentifier, true); GetNextToken(); }else identifier = ""; name = new IdentifierLiteral(identifier, CurrentPositionContext()); } } }else{ // function was passed in, this is an error condition name = function.GetName(); } // make a new state and save the old one ArrayList blockType = this.blockType; this.blockType = new ArrayList(16); SimpleHashtable labelTable = this.labelTable; this.labelTable = new SimpleHashtable(16); FunctionScope fscope = new FunctionScope(Globals.ScopeStack.Peek(), isMethod); Globals.ScopeStack.Push(fscope); //Give declarations a place to go while building AST try{ formalParameters = new ArrayList(); Context paramArrayContext = null; if (function == null){ // get the formal parameters if (JSToken.LeftParen != this.currentToken.token) ReportError(JSError.NoLeftParen); GetNextToken(); // create the list of arguments and update the context while (JSToken.RightParen != this.currentToken.token){ if (paramArrayContext != null){ ReportError(JSError.ParamListNotLast, paramArrayContext, true); paramArrayContext = null; } String id = null; TypeExpression typeExpr = null; this.noSkipTokenSet.Add(NoSkipTokenSet.s_FunctionDeclNoSkipTokenSet); try{ if (JSToken.ParamArray == this.currentToken.token){ paramArrayContext = this.currentToken.Clone(); GetNextToken(); } if (JSToken.Identifier != this.currentToken.token && (id = JSKeyword.CanBeIdentifier(this.currentToken.token)) == null){ if (JSToken.LeftCurly == this.currentToken.token){ ReportError(JSError.NoRightParen); break; }else if (JSToken.Comma == this.currentToken.token){ // We're missing an argument (or previous argument was malformed and // we skipped to the comma.) Keep trying to parse the argument list -- // we will skip the comma below. ReportError(JSError.SyntaxError, true); }else{ ReportError(JSError.SyntaxError, true); SkipTokensAndThrow(); } }else{ if (null == id) id = this.scanner.GetIdentifier(); else ForceReportInfo(JSError.KeywordUsedAsIdentifier); Context paramCtx = this.currentToken.Clone(); GetNextToken(); if (JSToken.Colon == this.currentToken.token){ typeExpr = ParseTypeExpression(); if (null != typeExpr) paramCtx.UpdateWith(typeExpr.context); } CustomAttributeList custAttrs = null; if (paramArrayContext != null){ custAttrs = new CustomAttributeList(paramArrayContext); custAttrs.Append(new CustomAttribute(paramArrayContext, new Lookup("...", paramArrayContext), new ASTList(null))); } formalParameters.Add(new ParameterDeclaration(paramCtx, id, typeExpr, custAttrs)); } // got an arg, it should be either a ',' or ')' if (JSToken.RightParen == this.currentToken.token) break; else if (JSToken.Comma != this.currentToken.token){ // deal with error in some "intelligent" way if (JSToken.LeftCurly == this.currentToken.token){ ReportError(JSError.NoRightParen); break; }else{ if (JSToken.Identifier == this.currentToken.token && typeExpr == null){ // it's possible that the guy was writing the type in C/C++ style (i.e. int x) ReportError(JSError.NoCommaOrTypeDefinitionError); }else ReportError(JSError.NoComma); } } GetNextToken(); }catch(RecoveryTokenException exc){ if (IndexOfToken(NoSkipTokenSet.s_FunctionDeclNoSkipTokenSet, exc) == -1) throw exc; }finally{ this.noSkipTokenSet.Remove(NoSkipTokenSet.s_FunctionDeclNoSkipTokenSet); } } fncCtx.UpdateWith(this.currentToken); // if it is a getter/setter must have 0/1 arg only if (isGetter && formalParameters.Count != 0){ ReportError(JSError.BadPropertyDeclaration, true); isGetter = false; }else if (isSetter && formalParameters.Count != 1){ ReportError(JSError.BadPropertyDeclaration, true); isSetter = false; } GetNextToken(); // check the return type if (JSToken.Colon == this.currentToken.token){ if (isSetter) ReportError(JSError.SyntaxError); this.noSkipTokenSet.Add(NoSkipTokenSet.s_StartBlockNoSkipTokenSet); try{ returnType = ParseTypeExpression(); }catch(RecoveryTokenException exc){ if (IndexOfToken(NoSkipTokenSet.s_StartBlockNoSkipTokenSet, exc) == -1){ exc._partiallyComputedNode = null; throw exc; }else{ if (exc._partiallyComputedNode != null) returnType = (TypeExpression)exc._partiallyComputedNode; } }finally{ this.noSkipTokenSet.Remove(NoSkipTokenSet.s_StartBlockNoSkipTokenSet); } if (isSetter) returnType = null; } }else{ // function was passed in, this is an error condition function.GetParameters(formalParameters); } // read the function body of non-abstract functions. if (JSToken.LeftCurly != this.currentToken.token && (isAbstract || (isMethod && GuessIfAbstract()))){ if (!isAbstract){ isAbstract = true; ReportError(JSError.ShouldBeAbstract, fncCtx, true); } body = new Block(this.currentToken.Clone()); }else{ if (JSToken.LeftCurly != this.currentToken.token) ReportError(JSError.NoLeftCurly, true); else if (isAbstract) ReportError(JSError.AbstractWithBody, fncCtx, true); this.blockType.Add(BlockType.Block); this.noSkipTokenSet.Add(NoSkipTokenSet.s_BlockNoSkipTokenSet); this.noSkipTokenSet.Add(NoSkipTokenSet.s_StartStatementNoSkipTokenSet); try{ // parse the block locally to get the exact end of function body = new Block(this.currentToken.Clone()); GetNextToken(); while (JSToken.RightCurly != this.currentToken.token){ try{ body.Append(ParseStatement()); }catch(RecoveryTokenException exc){ if (exc._partiallyComputedNode != null){ body.Append(exc._partiallyComputedNode); } if (IndexOfToken(NoSkipTokenSet.s_StartStatementNoSkipTokenSet, exc) == -1) throw exc; } } body.context.UpdateWith(this.currentToken); fncCtx.UpdateWith(this.currentToken); }catch(RecoveryTokenException exc){ if (IndexOfToken(NoSkipTokenSet.s_BlockNoSkipTokenSet, exc) == -1){ Globals.ScopeStack.Pop(); //Pop current scope so that FunctionDeclaration sees proper scope stack try{ ParameterDeclaration[] foParameters = new ParameterDeclaration[formalParameters.Count]; formalParameters.CopyTo(foParameters); if (inExpression) exc._partiallyComputedNode = new FunctionExpression(fncCtx, name, foParameters, returnType, body, fscope, visibilitySpec); else exc._partiallyComputedNode = new FunctionDeclaration(fncCtx, interfaceName, name, foParameters, returnType, body, fscope, visibilitySpec, isMethod, isGetter, isSetter, isAbstract, isFinal, customAttributes); if (customAttributes != null) customAttributes.SetTarget(exc._partiallyComputedNode); }finally{ Globals.ScopeStack.Push(fscope); //Push it back so that the next finally can pop it } throw exc; } }finally{ this.blockType.RemoveAt(this.blockType.Count - 1); this.noSkipTokenSet.Remove(NoSkipTokenSet.s_StartStatementNoSkipTokenSet); this.noSkipTokenSet.Remove(NoSkipTokenSet.s_BlockNoSkipTokenSet); } GetNextToken(); } }finally{ // restore state this.blockType = blockType; this.labelTable = labelTable; Globals.ScopeStack.Pop(); } ParameterDeclaration[] fParameters = new ParameterDeclaration[formalParameters.Count]; formalParameters.CopyTo(fParameters); AST func; if (inExpression) func = new FunctionExpression(fncCtx, name, fParameters, returnType, body, fscope, visibilitySpec); else func = new FunctionDeclaration(fncCtx, interfaceName, name, fParameters, returnType, body, fscope, visibilitySpec, isMethod, isGetter, isSetter, isAbstract, isFinal, customAttributes); if (customAttributes != null) customAttributes.SetTarget(func); return func; }
private CustomAttributeList ParseCustomAttributeList(){ CustomAttributeList result = new CustomAttributeList(this.currentToken.Clone()); do{ Context attrStart = currentToken.Clone(); bool bAssign, canBeAttribute = true; AST statement = ParseUnaryExpression(out bAssign, ref canBeAttribute, false, false); if (canBeAttribute){ if (statement is Lookup || statement is Member) result.Append(new CustomAttribute(statement.context, statement, new ASTList(null))); else result.Append(((Call)statement).ToCustomAttribute()); }else if (this.tokensSkipped == 0) ReportError(JSError.SyntaxError, attrStart); if (this.currentToken.token == JSToken.RightBracket) return result; else if (this.currentToken.token == JSToken.Comma) this.GetNextToken(); else{ ReportError(JSError.NoRightBracketOrComma); SkipTokensAndThrow(); } }while(true); }
private AST ParseClass(FieldAttributes visibilitySpec, bool isStatic, Context classCtx, bool isAbstract, bool isFinal, CustomAttributeList customAttributes) { AST name = null; AST ast2 = null; TypeExpression superTypeExpression = null; Block body = null; TypeExpression[] expressionArray; AST ast4; ArrayList list = new ArrayList(); bool isInterface = JSToken.Interface == this.currentToken.token; this.GetNextToken(); if (JSToken.Identifier == this.currentToken.token) { name = new IdentifierLiteral(this.scanner.GetIdentifier(), this.currentToken.Clone()); } else { this.ReportError(JSError.NoIdentifier); if (((JSToken.Extends != this.currentToken.token) && (JSToken.Implements != this.currentToken.token)) && (JSToken.LeftCurly != this.currentToken.token)) { this.SkipTokensAndThrow(); } name = new IdentifierLiteral("##Missing Class Name##" + s_cDummyName++, this.CurrentPositionContext()); } this.GetNextToken(); if ((JSToken.Extends == this.currentToken.token) || (JSToken.Implements == this.currentToken.token)) { if (isInterface && (JSToken.Extends == this.currentToken.token)) { this.currentToken.token = JSToken.Implements; } if (JSToken.Extends == this.currentToken.token) { this.noSkipTokenSet.Add(NoSkipTokenSet.s_ClassExtendsNoSkipTokenSet); try { ast2 = this.ParseQualifiedIdentifier(JSError.NeedType); } catch (RecoveryTokenException exception) { if (this.IndexOfToken(NoSkipTokenSet.s_ClassExtendsNoSkipTokenSet, exception) == -1) { exception._partiallyComputedNode = null; throw exception; } ast2 = exception._partiallyComputedNode; } finally { this.noSkipTokenSet.Remove(NoSkipTokenSet.s_ClassExtendsNoSkipTokenSet); } } if (JSToken.Implements == this.currentToken.token) { do { AST expression = null; this.noSkipTokenSet.Add(NoSkipTokenSet.s_ClassImplementsNoSkipTokenSet); try { expression = this.ParseQualifiedIdentifier(JSError.NeedType); list.Add(new TypeExpression(expression)); } catch (RecoveryTokenException exception2) { if (this.IndexOfToken(NoSkipTokenSet.s_ClassImplementsNoSkipTokenSet, exception2) == -1) { exception2._partiallyComputedNode = null; throw exception2; } if (exception2._partiallyComputedNode != null) { list.Add(new TypeExpression(exception2._partiallyComputedNode)); } } finally { this.noSkipTokenSet.Remove(NoSkipTokenSet.s_ClassImplementsNoSkipTokenSet); } } while (JSToken.Comma == this.currentToken.token); } } if (ast2 != null) { superTypeExpression = new TypeExpression(ast2); } if (JSToken.LeftCurly != this.currentToken.token) { this.ReportError(JSError.NoLeftCurly); } ArrayList blockType = this.blockType; this.blockType = new ArrayList(0x10); SimpleHashtable labelTable = this.labelTable; this.labelTable = new SimpleHashtable(0x10); this.Globals.ScopeStack.Push(new ClassScope(name, ((IActivationObject) this.Globals.ScopeStack.Peek()).GetGlobalScope())); try { body = this.ParseClassBody(false, isInterface); classCtx.UpdateWith(body.context); expressionArray = new TypeExpression[list.Count]; list.CopyTo(expressionArray); Class target = new Class(classCtx, name, superTypeExpression, expressionArray, body, visibilitySpec, isAbstract, isFinal, isStatic, isInterface, customAttributes); if (customAttributes != null) { customAttributes.SetTarget(target); } ast4 = target; } catch (RecoveryTokenException exception3) { classCtx.UpdateWith(exception3._partiallyComputedNode.context); expressionArray = new TypeExpression[list.Count]; list.CopyTo(expressionArray); exception3._partiallyComputedNode = new Class(classCtx, name, superTypeExpression, expressionArray, (Block) exception3._partiallyComputedNode, visibilitySpec, isAbstract, isFinal, isStatic, isInterface, customAttributes); if (customAttributes != null) { customAttributes.SetTarget(exception3._partiallyComputedNode); } throw exception3; } finally { this.Globals.ScopeStack.Pop(); this.blockType = blockType; this.labelTable = labelTable; } return ast4; }