internal FunctionObject(Type t, string name, string method_name, string[] formal_parameters, JSLocalField[] fields, bool must_save_stack_locals, bool hasArgumentsObject, string text, VsaEngine engine) : base(engine.Globals.globalObject.originalFunction.originalPrototype, name, formal_parameters.Length) { base.engine = engine; this.formal_parameters = formal_parameters; this.argumentsSlotNumber = 0; this.body = null; this.method = TypeReflector.GetTypeReflectorFor(Globals.TypeRefs.ToReferenceContext(t)).GetMethod(method_name, BindingFlags.Public | BindingFlags.Static); this.parameterInfos = this.method.GetParameters(); if (!Microsoft.JScript.CustomAttribute.IsDefined(this.method, typeof(JSFunctionAttribute), false)) { this.isMethod = true; } else { JSFunctionAttributeEnum attributeValue = ((JSFunctionAttribute) Microsoft.JScript.CustomAttribute.GetCustomAttributes(this.method, typeof(JSFunctionAttribute), false)[0]).attributeValue; this.isExpandoMethod = (attributeValue & JSFunctionAttributeEnum.IsExpandoMethod) != JSFunctionAttributeEnum.None; } this.funcContext = null; this.own_scope = null; this.fields = fields; this.must_save_stack_locals = must_save_stack_locals; this.hasArgumentsObject = hasArgumentsObject; this.text = text; this.attributes = MethodAttributes.Public; this.globals = engine.Globals; this.superConstructor = null; this.superConstructorCall = null; this.enclosing_scope = this.globals.ScopeStack.Peek(); base.noExpando = false; this.clsCompliance = CLSComplianceSpec.NotAttributed; }
internal FunctionScope(ScriptObject parent, bool isMethod) : base(parent) { base.isKnownAtCompileTime = true; this.isMethod = isMethod; this.mustSaveStackLocals = false; if ((parent != null) && (parent is ActivationObject)) { base.fast = ((ActivationObject) parent).fast; } else { base.fast = false; } this.returnVar = null; this.owner = null; this.isStatic = false; this.nested_functions = null; this.fields_for_nested_functions = null; if (parent is FunctionScope) { this.ProvidesOuterScopeLocals = new SimpleHashtable(0x10); } else { this.ProvidesOuterScopeLocals = null; } this.closuresMightEscape = false; }
internal CallableExpression(AST expression) : base(expression.context, ""){ this.expression = expression; JSLocalField field = new JSLocalField("", null, 0, Missing.Value); this.expressionInferredType = expression.InferType(field); field.inferred_type = this.expressionInferredType; this.member = field; this.members = new MemberInfo[]{field}; }
// Build a function declaration closure. public static Closure JScriptFunctionDeclaration (RuntimeTypeHandle handle, String name, String method_name, String[] formal_parameters, JSLocalField[] fields, bool must_save_stack_locals, bool hasArgumentsObject, String text, Object declaringObject, VsaEngine engine) { // TODO return null; }
internal void AddReturnValueField() { if (base.name_table["return value"] == null) { this.returnVar = new JSLocalField("return value", this, base.field_table.Count, Microsoft.JScript.Missing.Value); base.name_table["return value"] = this.returnVar; base.field_table.Add(this.returnVar); } }
internal CallableExpression(AST expression) : base(expression.context, "") { this.expression = expression; JSLocalField field = new JSLocalField("", null, 0, Missing.Value); this.expressionInferredType = expression.InferType(field); field.inferred_type = this.expressionInferredType; this.member = field; this.members = new MemberInfo[] { field }; }
internal JSLocalField(String name, FunctionScope scope, int slotNumber, Object value) : base(name, scope, FieldAttributes.Static|FieldAttributes.Public) { this.slotNumber = slotNumber; this.inferred_type = null; this.dependents = null; this.value = value; this.debugOn = false; this.outerField = null; this.isDefined = false; this.isUsedBeforeDefinition = false; }
internal override void TranslateToILInitializer(ILGenerator il) { this.func.TranslateToIL(base.compilerGlobals); this.func_local = il.DeclareLocal(Typeob.FunctionObject); il.Emit(OpCodes.Ldtoken, this.func.classwriter); il.Emit(OpCodes.Ldstr, this.name); il.Emit(OpCodes.Ldstr, this.func.GetName()); int length = this.func.formal_parameters.Length; ConstantWrapper.TranslateToILInt(il, length); il.Emit(OpCodes.Newarr, Typeob.String); for (int i = 0; i < length; i++) { il.Emit(OpCodes.Dup); ConstantWrapper.TranslateToILInt(il, i); il.Emit(OpCodes.Ldstr, this.func.formal_parameters[i]); il.Emit(OpCodes.Stelem_Ref); } length = this.func.fields.Length; ConstantWrapper.TranslateToILInt(il, length); il.Emit(OpCodes.Newarr, Typeob.JSLocalField); for (int j = 0; j < length; j++) { JSLocalField field = this.func.fields[j]; il.Emit(OpCodes.Dup); ConstantWrapper.TranslateToILInt(il, j); il.Emit(OpCodes.Ldstr, field.Name); il.Emit(OpCodes.Ldtoken, field.FieldType); ConstantWrapper.TranslateToILInt(il, field.slotNumber); il.Emit(OpCodes.Newobj, CompilerGlobals.jsLocalFieldConstructor); il.Emit(OpCodes.Stelem_Ref); } if (this.func.must_save_stack_locals) { il.Emit(OpCodes.Ldc_I4_1); } else { il.Emit(OpCodes.Ldc_I4_0); } if (this.func.hasArgumentsObject) { il.Emit(OpCodes.Ldc_I4_1); } else { il.Emit(OpCodes.Ldc_I4_0); } il.Emit(OpCodes.Ldstr, this.func.ToString()); base.EmitILToLoadEngine(il); il.Emit(OpCodes.Call, CompilerGlobals.jScriptFunctionExpressionMethod); il.Emit(OpCodes.Stloc, this.func_local); }
internal JSLocalField(String name, FunctionScope scope, int slotNumber, Object value) : base(name, scope, FieldAttributes.Static | FieldAttributes.Public) { this.slotNumber = slotNumber; this.inferred_type = null; this.dependents = null; this.value = value; this.debugOn = false; this.outerField = null; this.isDefined = false; this.isUsedBeforeDefinition = false; }
public static FunctionObject JScriptFunctionExpression (RuntimeTypeHandle handle, string name, string methodName, string [] formalParams, JSLocalField [] fields, bool mustSaveStackLocals, bool hasArgumentsObject, string text, VsaEngine engine) { MethodInfo method = engine.ScriptObjectStackTop ().GetType ().GetMethod (methodName); FunctionObject fun = new FunctionObject (method); fun.source = text; fun.vsa_engine = engine; return fun; }
public static Closure JScriptFunctionDeclaration(RuntimeTypeHandle handle, string name, string methodName, string [] formalParameters, JSLocalField [] fields, bool mustSaveStackLocals, bool hasArgumentsObjects, string text, Object declaringObject, VsaEngine engine) { FunctionObject f = new FunctionObject (name, null, null, null, null); f.source = text; MethodInfo method = engine.ScriptObjectStackTop ().GetType ().GetMethod (methodName); f.method = method; f.vsa_engine = engine; return new Closure (f); }
internal StackFrame(ScriptObject parent, JSLocalField[] fields, Object[] local_vars, Object thisObject) : base(parent) { this.caller_arguments = null; this.fields = fields; this.localVars = local_vars; this.nestedFunctionScope = null; this.thisObject = thisObject; if (parent is StackFrame) this.closureInstance = ((StackFrame)parent).closureInstance; else if (parent is JSObject) this.closureInstance = parent; else this.closureInstance = null; }
internal void HandleUnitializedVariables() { int num = 0; int count = base.field_table.Count; while (num < count) { JSLocalField field = (JSLocalField)base.field_table[num]; if (field.isUsedBeforeDefinition) { field.SetInferredType(Typeob.Object, null); } num++; } }
internal FunctionScope(ScriptObject parent, bool isMethod) : base(parent) { this.isKnownAtCompileTime = true; this.isMethod = isMethod; this.mustSaveStackLocals = false; if (parent != null && parent is ActivationObject) this.fast = ((ActivationObject)parent).fast; else this.fast = false; this.returnVar = null; this.owner = null; //Given its real value inside new FunctionObject this.isStatic = false; //Given its real value elsewhere this.nested_functions = null; this.fields_for_nested_functions = null; if (parent is FunctionScope) this.ProvidesOuterScopeLocals = new SimpleHashtable(16); else this.ProvidesOuterScopeLocals = null; this.closuresMightEscape = false; }
public override object GetValue(object obj) { if (((base.attributeFlags & FieldAttributes.Literal) == FieldAttributes.PrivateScope) || (base.value is FunctionObject)) { while (obj is BlockScope) { obj = ((BlockScope)obj).GetParent(); } StackFrame parent = (StackFrame)obj; JSLocalField outerField = this.outerField; int slotNumber = this.slotNumber; while (outerField != null) { slotNumber = outerField.slotNumber; parent = (StackFrame)parent.GetParent(); outerField = outerField.outerField; } return(parent.localVars[slotNumber]); } return(base.value); }
internal override void SetPartialValue(AST partial_value) { if ((base.members != null) && (base.members.Length != 0)) { if (base.member is JSLocalField) { JSLocalField member = (JSLocalField)base.member; if (member.type == null) { IReflect ir = partial_value.InferType(member); if ((ir == Typeob.String) && (partial_value is Plus)) { member.SetInferredType(Typeob.Object, partial_value); return; } member.SetInferredType(ir, partial_value); return; } member.isDefined = true; } Binding.AssignmentCompatible(this.InferType(null), partial_value, partial_value.InferType(null), base.isFullyResolved); } }
void AddNameTo(ScriptObject enclosingScope) { while (enclosingScope is WithObject) //Can only happen at run time and only if there is an eval { enclosingScope = enclosingScope.GetParent(); } FieldInfo field = ((IActivationObject)enclosingScope).GetLocalField(this.name); if (field != null) { return; } if (enclosingScope is ActivationObject) { if (enclosingScope is FunctionScope) { field = ((ActivationObject)enclosingScope).AddNewField(this.name, null, FieldAttributes.Public); } else { field = ((ActivationObject)enclosingScope).AddNewField(this.name, null, FieldAttributes.Public | FieldAttributes.Static); } } else { field = ((StackFrame)enclosingScope).AddNewField(this.name, null, FieldAttributes.Public); } JSLocalField lfield = field as JSLocalField; if (lfield != null) { // emit debug info for the local only if this block of code is in a section that has debug set lfield.debugOn = this.context.document.debugOn; lfield.isDefined = true; } this.field = (JSVariableField)field; }
public override Object GetValue(Object obj) { if ((this.attributeFlags & FieldAttributes.Literal) != (FieldAttributes)0 && !(this.value is FunctionObject)) { return(this.value); } else { while (obj is BlockScope) { obj = ((BlockScope)obj).GetParent(); } StackFrame sf = (StackFrame)obj; JSLocalField f = this.outerField; int slot = this.slotNumber; while (f != null) { slot = f.slotNumber; sf = (StackFrame)sf.GetParent(); f = f.outerField; } return(sf.localVars[slot]); } }
public virtual string Eval(string expr, bool allowUnsafe) { string str = null; JSLocalField[] fields = new JSLocalField[] { new JSLocalField("expr", typeof(string).TypeHandle, 0), new JSLocalField("return value", typeof(string).TypeHandle, 1) }; StackFrame.PushStackFrameForMethod(this, fields, ((INeedEngine) this).GetEngine()); try { ((StackFrame) ((INeedEngine) this).GetEngine().ScriptObjectStackTop()).localVars[0] = expr; ((StackFrame) ((INeedEngine) this).GetEngine().ScriptObjectStackTop()).localVars[1] = str; var localVars = ((StackFrame) ((INeedEngine) this).GetEngine().ScriptObjectStackTop()).localVars; expr = Convert.ToString(((StackFrame) ((INeedEngine) this).GetEngine().ScriptObjectStackTop()).localVars[0], true); str = Convert.ToString(((StackFrame) ((INeedEngine) this).GetEngine().ScriptObjectStackTop()).localVars[1], true); var objArray2 = ((StackFrame) ((INeedEngine) this).GetEngine().ScriptObjectStackTop()).localVars; str = Convert.ToString(Microsoft.JScript.Eval.JScriptEvaluate(expr, allowUnsafe ? "unsafe" : null, ((INeedEngine) this).GetEngine()), true); ((StackFrame) ((INeedEngine) this).GetEngine().ScriptObjectStackTop()).localVars[0] = expr; ((StackFrame) ((INeedEngine) this).GetEngine().ScriptObjectStackTop()).localVars[1] = str; var objArray3 = ((StackFrame) ((INeedEngine) this).GetEngine().ScriptObjectStackTop()).localVars; } finally { ((INeedEngine) this).GetEngine().PopScriptObject(); } return str; }
public static FunctionObject JScriptFunctionExpression(RuntimeTypeHandle handle, string name, string method_name, string[] formal_params, JSLocalField[] fields, bool must_save_stack_locals, bool hasArgumentsObject, string text, VsaEngine engine) { return new FunctionObject(Type.GetTypeFromHandle(handle), name, method_name, formal_params, fields, must_save_stack_locals, hasArgumentsObject, text, engine); }
public override MemberInfo[] GetMember(string name, BindingFlags bindingAttr) { FieldInfo info = (FieldInfo)base.name_table[name]; if (info != null) { return(new MemberInfo[] { info }); } bool flag = false; ScriptObject parent = base.parent; while (parent is FunctionScope) { FunctionScope scope = (FunctionScope)parent; flag = scope.isMethod && !scope.isStatic; JSLocalField field = (JSLocalField)scope.name_table[name]; if (field == null) { parent = parent.GetParent(); } else { if (field.IsLiteral && !(field.value is FunctionObject)) { return(new MemberInfo[] { field }); } JSLocalField field2 = new JSLocalField(field.Name, this, base.field_table.Count, Microsoft.JScript.Missing.Value) { outerField = field, debugOn = field.debugOn }; if ((!field2.debugOn && this.owner.funcContext.document.debugOn) && scope.owner.funcContext.document.debugOn) { field2.debugOn = Array.IndexOf <string>(scope.owner.formal_parameters, field.Name) >= 0; } field2.isDefined = field.isDefined; field2.debuggerName = "outer." + field2.Name; if (field.IsLiteral) { field2.attributeFlags |= FieldAttributes.Literal; field2.value = field.value; } this.AddOuterScopeField(name, field2); if (this.ProvidesOuterScopeLocals[parent] == null) { this.ProvidesOuterScopeLocals[parent] = parent; } ((FunctionScope)parent).mustSaveStackLocals = true; return(new MemberInfo[] { field2 }); } } if ((parent is ClassScope) && flag) { MemberInfo[] member = parent.GetMember(name, bindingAttr & ~BindingFlags.DeclaredOnly); int length = member.Length; bool flag2 = false; for (int i = 0; i < length; i++) { MethodInfo info3; PropertyInfo info4; MemberInfo info2 = member[i]; MemberTypes memberType = info2.MemberType; if (memberType != MemberTypes.Field) { if (memberType == MemberTypes.Method) { goto Label_029E; } if (memberType == MemberTypes.Property) { goto Label_02C7; } } else { info = (FieldInfo)info2; if (info.IsLiteral) { JSMemberField field3 = info as JSMemberField; if (((field3 != null) && (field3.value is ClassScope)) && !((ClassScope)field3.value).owner.IsStatic) { flag2 = true; } } if (!info.IsStatic && !info.IsLiteral) { member[i] = new JSClosureField(info); flag2 = true; } } continue; Label_029E: info3 = (MethodInfo)info2; if (!info3.IsStatic) { member[i] = new JSClosureMethod(info3); flag2 = true; } continue; Label_02C7: info4 = (PropertyInfo)info2; MethodInfo getMethod = JSProperty.GetGetMethod(info4, (bindingAttr & BindingFlags.NonPublic) != BindingFlags.Default); MethodInfo setMethod = JSProperty.GetSetMethod(info4, (bindingAttr & BindingFlags.NonPublic) != BindingFlags.Default); bool flag3 = false; if ((getMethod != null) && !getMethod.IsStatic) { flag3 = true; getMethod = new JSClosureMethod(getMethod); } if ((setMethod != null) && !setMethod.IsStatic) { flag3 = true; setMethod = new JSClosureMethod(setMethod); } if (flag3) { member[i] = new JSClosureProperty(info4, getMethod, setMethod); flag2 = true; } } if (flag2) { this.GiveOuterFunctionsTheBadNews(); } if (length > 0) { return(member); } } if ((bindingAttr & BindingFlags.DeclaredOnly) != BindingFlags.Default) { return(new MemberInfo[0]); } return(parent.GetMember(name, bindingAttr)); }
public override MemberInfo[] GetMember(String name, BindingFlags bindingAttr) { FieldInfo field = (FieldInfo)(this.name_table[name]); if (field != null) { return new MemberInfo[] { field } } ; bool nestedInInstanceMethod = false; ScriptObject parent = this.parent; //Treat locals of outer functions as if they were locals of this function while (parent is FunctionScope) { FunctionScope fscope = (FunctionScope)parent; nestedInInstanceMethod = fscope.isMethod && !fscope.isStatic; JSLocalField lfield = (JSLocalField)fscope.name_table[name]; if (lfield == null) { parent = parent.GetParent(); continue; } if (lfield.IsLiteral && !(lfield.value is FunctionObject)) { return new MemberInfo[] { lfield } } ; JSLocalField f = new JSLocalField(lfield.Name, this, this.field_table.Count, Missing.Value); f.outerField = lfield; f.debugOn = lfield.debugOn; if (!f.debugOn && this.owner.funcContext.document.debugOn && fscope.owner.funcContext.document.debugOn) { //Check to see it is off because outer field is a parameter f.debugOn = Array.IndexOf(fscope.owner.formal_parameters, lfield.Name) >= 0; } f.isDefined = lfield.isDefined; f.debuggerName = "outer" + "." + f.Name; if (lfield.IsLiteral) { f.attributeFlags |= FieldAttributes.Literal; f.value = lfield.value; } this.AddOuterScopeField(name, f); if (this.ProvidesOuterScopeLocals[parent] == null) { this.ProvidesOuterScopeLocals[parent] = parent; } ((FunctionScope)parent).mustSaveStackLocals = true; return(new MemberInfo[] { f }); } if (parent is ClassScope && nestedInInstanceMethod) { //return class members as if they were local to the function. It is more convenient to wrap up instance members //at this stage than it is to figure out later that a special case is involved. MemberInfo[] members = parent.GetMember(name, bindingAttr & ~BindingFlags.DeclaredOnly); int n = members.Length; bool giveBadNews = false; for (int i = 0; i < n; i++) { MemberInfo member = members[i]; switch (member.MemberType) { case MemberTypes.Field: field = (FieldInfo)member; if (field.IsLiteral) { JSMemberField mfield = field as JSMemberField; if (mfield != null && mfield.value is ClassScope && !((ClassScope)mfield.value).owner.IsStatic) { giveBadNews = true; } } if (!field.IsStatic && !field.IsLiteral) { members[i] = new JSClosureField(field); giveBadNews = true; } break; case MemberTypes.Method: MethodInfo meth = (MethodInfo)member; if (!meth.IsStatic) { members[i] = new JSClosureMethod(meth); giveBadNews = true; } break; case MemberTypes.Property: PropertyInfo prop = (PropertyInfo)member; MethodInfo getMeth = JSProperty.GetGetMethod(prop, (bindingAttr & BindingFlags.NonPublic) != 0); MethodInfo setMeth = JSProperty.GetSetMethod(prop, (bindingAttr & BindingFlags.NonPublic) != 0); bool nonStatic = false; if (getMeth != null && !getMeth.IsStatic) { nonStatic = true; getMeth = new JSClosureMethod(getMeth); } if (setMeth != null && !setMeth.IsStatic) { nonStatic = true; setMeth = new JSClosureMethod(setMeth); } if (nonStatic) { members[i] = new JSClosureProperty(prop, getMeth, setMeth); giveBadNews = true; } break; } } if (giveBadNews) { this.GiveOuterFunctionsTheBadNews(); //They have to create explicit stack frames } if (n > 0) { return(members); } } if ((bindingAttr & BindingFlags.DeclaredOnly) != 0) { return(new MemberInfo[0]); } return(parent.GetMember(name, bindingAttr)); }
internal void AddFieldForLocalScopeDebugInfo(JSLocalField field) { this.localFieldsForDebugInfo.Add(field); }
private void TranslateToILClosure(ILGenerator il) { if (!this.func.isStatic) { il.Emit(OpCodes.Ldarg_0); } il.Emit(OpCodes.Ldtoken, this.func.classwriter != null ? this.func.classwriter : compilerGlobals.classwriter); il.Emit(OpCodes.Ldstr, this.name); il.Emit(OpCodes.Ldstr, this.func.GetName()); int n = this.func.formal_parameters.Length; ConstantWrapper.TranslateToILInt(il, n); il.Emit(OpCodes.Newarr, Typeob.String); for (int i = 0; i < n; i++) { il.Emit(OpCodes.Dup); ConstantWrapper.TranslateToILInt(il, i); il.Emit(OpCodes.Ldstr, this.func.formal_parameters[i]); il.Emit(OpCodes.Stelem_Ref); } n = this.func.fields.Length; ConstantWrapper.TranslateToILInt(il, n); il.Emit(OpCodes.Newarr, CompilerGlobals.jsLocalFieldClass); for (int i = 0; i < n; i++) { JSLocalField field = this.func.fields[i]; il.Emit(OpCodes.Dup); ConstantWrapper.TranslateToILInt(il, i); il.Emit(OpCodes.Ldstr, field.Name); il.Emit(OpCodes.Ldtoken, field.FieldType); ConstantWrapper.TranslateToILInt(il, field.slotNumber); il.Emit(OpCodes.Newobj, CompilerGlobals.jsLocalFieldConstructor); il.Emit(OpCodes.Stelem_Ref); } if (this.func.must_save_stack_locals) { il.Emit(OpCodes.Ldc_I4_1); } else { il.Emit(OpCodes.Ldc_I4_0); } if (this.func.hasArgumentsObject) { il.Emit(OpCodes.Ldc_I4_1); } else { il.Emit(OpCodes.Ldc_I4_0); } il.Emit(OpCodes.Ldstr, this.func.ToString()); if (!this.func.isStatic) { il.Emit(OpCodes.Ldarg_0); } else { il.Emit(OpCodes.Ldnull); } this.EmitILToLoadEngine(il); il.Emit(OpCodes.Call, CompilerGlobals.jScriptFunctionDeclarationMethod); }
public static void PushStackFrameForStaticMethod (RuntimeTypeHandle thisClass, JSLocalField [] fields, VsaEngine engine) { throw new NotImplementedException (); }
public static void PushStackFrameForMethod(Object thisob, JSLocalField[] fields, VsaEngine engine){ Globals globals = engine.Globals; IActivationObject top = (IActivationObject)globals.ScopeStack.Peek(); String currentNamespace = thisob.GetType().Namespace; WithObject wob = null; if (currentNamespace != null && currentNamespace.Length > 0){ wob = new WithObject(top.GetGlobalScope(), new WrappedNamespace(currentNamespace, engine)); wob.isKnownAtCompileTime = true; //For use by an eval inside this method wob = new WithObject(wob, thisob); }else wob = new WithObject(top.GetGlobalScope(), thisob); wob.isKnownAtCompileTime = true; StackFrame sf = new StackFrame(wob, fields, new Object[fields.Length], thisob); sf.closureInstance = thisob; globals.ScopeStack.GuardedPush(sf); }
internal void TranslateToILToRestoreLocals(ILGenerator il, JSLocalField[] notToBeRestored){ this.TranslateToILToCopyOuterScopeLocals(il, true, notToBeRestored); if (!this.must_save_stack_locals) return; int offset = (this.attributes&MethodAttributes.Static) == MethodAttributes.Static ? 0 : 1; int extras = 3; if (this.isMethod) extras = 0; else if (!this.hasArgumentsObject) extras = 2; int n = this.fields.Length; this.TranslateToILToLoadEngine(il); il.Emit(OpCodes.Call, CompilerGlobals.scriptObjectStackTopMethod); ScriptObject scope = globals.ScopeStack.Peek(); while (scope is WithObject || scope is BlockScope){ il.Emit(OpCodes.Call, CompilerGlobals.getParentMethod); scope = scope.GetParent(); } il.Emit(OpCodes.Castclass, CompilerGlobals.stackFrameClass); il.Emit(OpCodes.Ldfld, CompilerGlobals.localVarsField); for (int i = 0; i < n; i++){ if (notToBeRestored != null && IsPresentIn(this.fields[i], notToBeRestored)) continue; if (this.fields[i].IsLiteral) continue; il.Emit(OpCodes.Dup); int j = System.Array.IndexOf(this.formal_parameters, this.fields[i].Name); ConstantWrapper.TranslateToILInt(il, this.fields[i].slotNumber); il.Emit(OpCodes.Ldelem_Ref); Convert.Emit(this.body, il, Typeob.Object, this.fields[i].FieldType); if (j >= 0 || (this.fields[i].Name.Equals("arguments") && this.hasArgumentsObject)){ il.Emit(OpCodes.Starg, (short)(j+extras+offset)); }else{ il.Emit(OpCodes.Stloc, (LocalBuilder)this.fields[i].metaData); } } il.Emit(OpCodes.Pop); }
internal void AddOuterScopeField(string name, JSLocalField field) { base.name_table[name] = field; base.field_table.Add(field); }
public override MemberInfo[] GetMember(string name, BindingFlags bindingAttr) { FieldInfo info = (FieldInfo) base.name_table[name]; if (info != null) { return new MemberInfo[] { info }; } bool flag = false; ScriptObject parent = base.parent; while (parent is FunctionScope) { FunctionScope scope = (FunctionScope) parent; flag = scope.isMethod && !scope.isStatic; JSLocalField field = (JSLocalField) scope.name_table[name]; if (field == null) { parent = parent.GetParent(); } else { if (field.IsLiteral && !(field.value is FunctionObject)) { return new MemberInfo[] { field }; } JSLocalField field2 = new JSLocalField(field.Name, this, base.field_table.Count, Microsoft.JScript.Missing.Value) { outerField = field, debugOn = field.debugOn }; if ((!field2.debugOn && this.owner.funcContext.document.debugOn) && scope.owner.funcContext.document.debugOn) { field2.debugOn = Array.IndexOf<string>(scope.owner.formal_parameters, field.Name) >= 0; } field2.isDefined = field.isDefined; field2.debuggerName = "outer." + field2.Name; if (field.IsLiteral) { field2.attributeFlags |= FieldAttributes.Literal; field2.value = field.value; } this.AddOuterScopeField(name, field2); if (this.ProvidesOuterScopeLocals[parent] == null) { this.ProvidesOuterScopeLocals[parent] = parent; } ((FunctionScope) parent).mustSaveStackLocals = true; return new MemberInfo[] { field2 }; } } if ((parent is ClassScope) && flag) { MemberInfo[] member = parent.GetMember(name, bindingAttr & ~BindingFlags.DeclaredOnly); int length = member.Length; bool flag2 = false; for (int i = 0; i < length; i++) { MethodInfo info3; PropertyInfo info4; MemberInfo info2 = member[i]; MemberTypes memberType = info2.MemberType; if (memberType != MemberTypes.Field) { if (memberType == MemberTypes.Method) { goto Label_029E; } if (memberType == MemberTypes.Property) { goto Label_02C7; } } else { info = (FieldInfo) info2; if (info.IsLiteral) { JSMemberField field3 = info as JSMemberField; if (((field3 != null) && (field3.value is ClassScope)) && !((ClassScope) field3.value).owner.IsStatic) { flag2 = true; } } if (!info.IsStatic && !info.IsLiteral) { member[i] = new JSClosureField(info); flag2 = true; } } continue; Label_029E: info3 = (MethodInfo) info2; if (!info3.IsStatic) { member[i] = new JSClosureMethod(info3); flag2 = true; } continue; Label_02C7: info4 = (PropertyInfo) info2; MethodInfo getMethod = JSProperty.GetGetMethod(info4, (bindingAttr & BindingFlags.NonPublic) != BindingFlags.Default); MethodInfo setMethod = JSProperty.GetSetMethod(info4, (bindingAttr & BindingFlags.NonPublic) != BindingFlags.Default); bool flag3 = false; if ((getMethod != null) && !getMethod.IsStatic) { flag3 = true; getMethod = new JSClosureMethod(getMethod); } if ((setMethod != null) && !setMethod.IsStatic) { flag3 = true; setMethod = new JSClosureMethod(setMethod); } if (flag3) { member[i] = new JSClosureProperty(info4, getMethod, setMethod); flag2 = true; } } if (flag2) { this.GiveOuterFunctionsTheBadNews(); } if (length > 0) { return member; } } if ((bindingAttr & BindingFlags.DeclaredOnly) != BindingFlags.Default) { return new MemberInfo[0]; } return parent.GetMember(name, bindingAttr); }
public static Closure JScriptFunctionDeclaration(RuntimeTypeHandle handle, String name, String method_name, String[] formal_parameters, JSLocalField[] fields, bool must_save_stack_locals, bool hasArgumentsObject, String text, Object declaringObject, VsaEngine engine){ Type t = Type.GetTypeFromHandle(handle); FunctionObject func = new FunctionObject(t, name, method_name, formal_parameters, fields, must_save_stack_locals, hasArgumentsObject, text, engine); return new Closure(func, declaringObject); }
private void TranslateToILToCopyLocalsToNestedScope(ILGenerator il, FunctionScope nestedScope, JSLocalField[] notToBeRestored) { int length = this.fields.Length; for (int i = 0; i < length; i++) { JSLocalField outerLocalField = nestedScope.GetOuterLocalField(this.fields[i].Name); if (((outerLocalField != null) && (outerLocalField.outerField == this.fields[i])) && ((notToBeRestored == null) || !IsPresentIn(outerLocalField, notToBeRestored))) { il.Emit(OpCodes.Dup); ConstantWrapper.TranslateToILInt(il, this.fields[i].slotNumber); il.Emit(OpCodes.Ldelem_Ref); Microsoft.JScript.Convert.Emit(this.body, il, Typeob.Object, this.fields[i].FieldType); il.Emit(OpCodes.Stloc, (LocalBuilder) outerLocalField.metaData); } } il.Emit(OpCodes.Pop); }
internal void AddReturnValueField(){ if (this.name_table["return value"] != null) return; this.returnVar = new JSLocalField("return value", this, this.field_table.Count, Missing.Value); this.name_table["return value"] = this.returnVar; this.field_table.Add(this.returnVar); }
internal void AddOuterScopeField(String name, JSLocalField field){ this.name_table[name] = field; this.field_table.Add(field); }
internal void AddFieldForLocalScopeDebugInfo(JSLocalField field){ this.localFieldsForDebugInfo.Add(field); }
public static void PushStackFrameForStaticMethod(RuntimeTypeHandle thisclass, JSLocalField[] fields, VsaEngine engine){ PushStackFrameForMethod(Type.GetTypeFromHandle(thisclass), fields, engine); }
internal JSLocalField[] GetLocalFields(){ int n = this.field_table.Count; JSLocalField[] result = new JSLocalField[this.field_table.Count]; for (int i = 0; i < n; i++) result[i] = (JSLocalField)this.field_table[i]; return result; }
public override MemberInfo[] GetMember(String name, BindingFlags bindingAttr){ FieldInfo field = (FieldInfo)(this.name_table[name]); if (field != null) return new MemberInfo[]{field}; bool nestedInInstanceMethod = false; ScriptObject parent = this.parent; //Treat locals of outer functions as if they were locals of this function while (parent is FunctionScope){ FunctionScope fscope = (FunctionScope)parent; nestedInInstanceMethod = fscope.isMethod && !fscope.isStatic; JSLocalField lfield = (JSLocalField)fscope.name_table[name]; if (lfield == null){ parent = parent.GetParent(); continue; } if (lfield.IsLiteral && !(lfield.value is FunctionObject)) return new MemberInfo[]{lfield}; JSLocalField f = new JSLocalField(lfield.Name, this, this.field_table.Count, Missing.Value); f.outerField = lfield; f.debugOn = lfield.debugOn; if (!f.debugOn && this.owner.funcContext.document.debugOn && fscope.owner.funcContext.document.debugOn){ //Check to see it is off because outer field is a parameter f.debugOn = Array.IndexOf(fscope.owner.formal_parameters, lfield.Name) >= 0; } f.isDefined = lfield.isDefined; f.debuggerName = "outer" + "." + f.Name; if (lfield.IsLiteral){ f.attributeFlags |= FieldAttributes.Literal; f.value = lfield.value; } this.AddOuterScopeField(name, f); if (this.ProvidesOuterScopeLocals[parent] == null) this.ProvidesOuterScopeLocals[parent] = parent; ((FunctionScope)parent).mustSaveStackLocals = true; return new MemberInfo[]{f}; } if (parent is ClassScope && nestedInInstanceMethod){ //return class members as if they were local to the function. It is more convenient to wrap up instance members //at this stage than it is to figure out later that a special case is involved. MemberInfo[] members = parent.GetMember(name, bindingAttr&~BindingFlags.DeclaredOnly); int n = members.Length; bool giveBadNews = false; for (int i = 0; i < n; i++){ MemberInfo member = members[i]; switch(member.MemberType){ case MemberTypes.Field: field = (FieldInfo)member; if (field.IsLiteral){ JSMemberField mfield = field as JSMemberField; if (mfield != null && mfield.value is ClassScope && !((ClassScope)mfield.value).owner.IsStatic) giveBadNews = true; } if (!field.IsStatic && !field.IsLiteral){ members[i] = new JSClosureField(field); giveBadNews = true; } break; case MemberTypes.Method: MethodInfo meth = (MethodInfo)member; if (!meth.IsStatic){ members[i] = new JSClosureMethod(meth); giveBadNews = true; } break; case MemberTypes.Property: PropertyInfo prop = (PropertyInfo)member; MethodInfo getMeth = JSProperty.GetGetMethod(prop, (bindingAttr&BindingFlags.NonPublic) != 0); MethodInfo setMeth = JSProperty.GetSetMethod(prop, (bindingAttr&BindingFlags.NonPublic) != 0); bool nonStatic = false; if (getMeth != null && !getMeth.IsStatic){ nonStatic = true; getMeth = new JSClosureMethod(getMeth); } if (setMeth != null && !setMeth.IsStatic){ nonStatic = true; setMeth = new JSClosureMethod(setMeth); } if (nonStatic){ members[i] = new JSClosureProperty(prop, getMeth, setMeth); giveBadNews = true; } break; } } if (giveBadNews) this.GiveOuterFunctionsTheBadNews(); //They have to create explicit stack frames if (n > 0) return members; } if ((bindingAttr&BindingFlags.DeclaredOnly) != 0) return new MemberInfo[0]; return parent.GetMember(name, bindingAttr); }
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); } }
public static void PushStackFrameForMethod (object thisObj, JSLocalField [] fields, VsaEngine engine) { throw new NotImplementedException (); }
internal JSLocalField[] GetLocalFields() { int count = base.field_table.Count; JSLocalField[] fieldArray = new JSLocalField[base.field_table.Count]; for (int i = 0; i < count; i++) { fieldArray[i] = (JSLocalField) base.field_table[i]; } return fieldArray; }
internal void TranslateToILToRestoreLocals(ILGenerator il, JSLocalField[] notToBeRestored) { this.TranslateToILToCopyOuterScopeLocals(il, true, notToBeRestored); if (this.must_save_stack_locals) { int num = ((this.attributes & MethodAttributes.Static) == MethodAttributes.Static) ? 0 : 1; int num2 = 3; if (this.isMethod) { num2 = 0; } else if (!this.hasArgumentsObject) { num2 = 2; } int length = this.fields.Length; this.TranslateToILToLoadEngine(il); il.Emit(OpCodes.Call, CompilerGlobals.scriptObjectStackTopMethod); for (ScriptObject obj2 = this.globals.ScopeStack.Peek(); (obj2 is WithObject) || (obj2 is BlockScope); obj2 = obj2.GetParent()) { il.Emit(OpCodes.Call, CompilerGlobals.getParentMethod); } il.Emit(OpCodes.Castclass, Typeob.StackFrame); il.Emit(OpCodes.Ldfld, CompilerGlobals.localVarsField); for (int i = 0; i < length; i++) { if (((notToBeRestored == null) || !IsPresentIn(this.fields[i], notToBeRestored)) && !this.fields[i].IsLiteral) { il.Emit(OpCodes.Dup); int index = Array.IndexOf<string>(this.formal_parameters, this.fields[i].Name); ConstantWrapper.TranslateToILInt(il, this.fields[i].slotNumber); il.Emit(OpCodes.Ldelem_Ref); Microsoft.JScript.Convert.Emit(this.body, il, Typeob.Object, this.fields[i].FieldType); if ((index >= 0) || (this.fields[i].Name.Equals("arguments") && this.hasArgumentsObject)) { il.Emit(OpCodes.Starg, (short) ((index + num2) + num)); } else { il.Emit(OpCodes.Stloc, (LocalBuilder) this.fields[i].metaData); } } } il.Emit(OpCodes.Pop); } }
internal void AddOuterScopeField(String name, JSLocalField field) { this.name_table[name] = field; this.field_table.Add(field); }
private bool IsNestedFunctionField(JSLocalField field) { return ((field.value != null) && (field.value is FunctionObject)); }
private void TranslateToILToCopyOuterScopeLocals(ILGenerator il, bool copyToNested, JSLocalField[] notToBeRestored) { if ((this.own_scope.ProvidesOuterScopeLocals != null) && (this.own_scope.ProvidesOuterScopeLocals.count != 0)) { ScriptObject obj2; this.TranslateToILToLoadEngine(il); il.Emit(OpCodes.Call, CompilerGlobals.scriptObjectStackTopMethod); for (obj2 = this.globals.ScopeStack.Peek(); (obj2 is WithObject) || (obj2 is BlockScope); obj2 = obj2.GetParent()) { il.Emit(OpCodes.Call, CompilerGlobals.getParentMethod); } for (obj2 = this.enclosing_scope; obj2 != null; obj2 = obj2.GetParent()) { il.Emit(OpCodes.Call, CompilerGlobals.getParentMethod); if (((obj2 is FunctionScope) && (((FunctionScope) obj2).owner != null)) && (this.own_scope.ProvidesOuterScopeLocals[obj2] != null)) { il.Emit(OpCodes.Dup); il.Emit(OpCodes.Castclass, Typeob.StackFrame); il.Emit(OpCodes.Ldfld, CompilerGlobals.localVarsField); if (copyToNested) { ((FunctionScope) obj2).owner.TranslateToILToCopyLocalsToNestedScope(il, this.own_scope, notToBeRestored); } else { ((FunctionScope) obj2).owner.TranslateToILToCopyLocalsFromNestedScope(il, this.own_scope); } } else if ((obj2 is GlobalScope) || (obj2 is ClassScope)) { break; } } il.Emit(OpCodes.Pop); } }
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); } }