private GetTypeBuilder ( ) : |
||
return |
private void ConvertClassScopesAndEnumWrappers(ArrayList vals) { for (int i = 0, n = vals.Count; i < n; i++) { ClassScope csc = vals[i] as ClassScope; if (csc != null) { vals[i] = csc.GetTypeBuilder(); continue; } EnumWrapper wrapper = vals[i] as EnumWrapper; if (wrapper != null) { vals[i] = wrapper.ToNumericValue(); } } }
private void ConvertClassScopesAndEnumWrappers(ArrayList vals) { int num = 0; int count = vals.Count; while (num < count) { ClassScope scope = vals[num] as ClassScope; if (scope != null) { vals[num] = scope.GetTypeBuilder(); } else { EnumWrapper wrapper = vals[num] as EnumWrapper; if (wrapper != null) { vals[num] = wrapper.ToNumericValue(); } } num++; } }
private void TranslateToILObjectForMember(ILGenerator il, Type obType, bool noValue, MemberInfo mem) { this.thereIsAnObjectOnTheStack = true; if (mem is IWrappedMember) { Object obj = ((IWrappedMember)mem).GetWrappedObject(); if (obj is LenientGlobalObject) { this.EmitILToLoadEngine(il); il.Emit(OpCodes.Call, CompilerGlobals.getLenientGlobalObjectMethod); } else if (obj is Type || obj is ClassScope) { if (obType.IsAssignableFrom(Typeob.Type)) { (new ConstantWrapper(obj, null)).TranslateToIL(il, Typeob.Type); return; } //this.name is the name of an instance member of the superclass of the class (or an outer class) in which this expression appears //get class instance on stack ScriptObject scope = Globals.ScopeStack.Peek(); while (scope is WithObject || scope is BlockScope) { scope = scope.GetParent(); } if (scope is FunctionScope) { FunctionObject func = ((FunctionScope)scope).owner; if (func.isMethod) { il.Emit(OpCodes.Ldarg_0); } else //Need to get the StackFrame.closureInstance on the stack { this.EmitILToLoadEngine(il); il.Emit(OpCodes.Call, CompilerGlobals.scriptObjectStackTopMethod); scope = this.Globals.ScopeStack.Peek(); while (scope is WithObject || scope is BlockScope) { il.Emit(OpCodes.Call, CompilerGlobals.getParentMethod); scope = scope.GetParent(); } il.Emit(OpCodes.Castclass, Typeob.StackFrame); il.Emit(OpCodes.Ldfld, CompilerGlobals.closureInstanceField); } } else if (scope is ClassScope) { il.Emit(OpCodes.Ldarg_0); //Inside instance initializer } //If dealing with a member of an outer class, get the outer class instance on the stack scope = Globals.ScopeStack.Peek(); while (scope != null) { ClassScope csc = scope as ClassScope; if (csc != null) //Might be dealing with a reference from within a nested class to an instance member of an outer class { if (csc.IsSameOrDerivedFrom(obType)) { break; } il.Emit(OpCodes.Ldfld, csc.outerClassField); } scope = scope.GetParent(); } } else { this.TranslateToILDefaultThisObject(il, this.lexLevel); Convert.Emit(this, il, Typeob.Object, obType); } } else { ScriptObject scope = Globals.ScopeStack.Peek(); while (scope is WithObject || scope is BlockScope) { scope = scope.GetParent(); } if (scope is FunctionScope) { FunctionObject func = ((FunctionScope)scope).owner; if (!func.isMethod) //Need to get the StackFrame.closureInstance on the stack { this.EmitILToLoadEngine(il); il.Emit(OpCodes.Call, CompilerGlobals.scriptObjectStackTopMethod); scope = this.Globals.ScopeStack.Peek(); while (scope is WithObject || scope is BlockScope) { il.Emit(OpCodes.Call, CompilerGlobals.getParentMethod); scope = scope.GetParent(); } il.Emit(OpCodes.Castclass, Typeob.StackFrame); il.Emit(OpCodes.Ldfld, CompilerGlobals.closureInstanceField); while (scope != null) { if (scope is ClassScope) //Might be dealing with a reference from within a nested class to an instance member of an outer class { ClassScope csc = (ClassScope)scope; if (csc.IsSameOrDerivedFrom(obType)) { break; } il.Emit(OpCodes.Castclass, csc.GetTypeBuilder()); il.Emit(OpCodes.Ldfld, csc.outerClassField); } scope = scope.GetParent(); } il.Emit(OpCodes.Castclass, obType); return; } } il.Emit(OpCodes.Ldarg_0); while (scope != null) { if (scope is ClassScope) //Might be dealing with a reference from within a nested class to an instance member of an outer class { ClassScope csc = (ClassScope)scope; if (csc.IsSameOrDerivedFrom(obType)) { break; } il.Emit(OpCodes.Ldfld, csc.outerClassField); } scope = scope.GetParent(); } } }
private void TranslateToILObjectForMember(ILGenerator il, Type obType, bool noValue, MemberInfo mem) { this.thereIsAnObjectOnTheStack = true; if (mem is IWrappedMember) { object wrappedObject = ((IWrappedMember)mem).GetWrappedObject(); if (wrappedObject is LenientGlobalObject) { base.EmitILToLoadEngine(il); il.Emit(OpCodes.Call, CompilerGlobals.getLenientGlobalObjectMethod); } else if ((wrappedObject is Type) || (wrappedObject is ClassScope)) { if (obType.IsAssignableFrom(Typeob.Type)) { new ConstantWrapper(wrappedObject, null).TranslateToIL(il, Typeob.Type); } else { ScriptObject parent = base.Globals.ScopeStack.Peek(); while ((parent is WithObject) || (parent is BlockScope)) { parent = parent.GetParent(); } if (parent is FunctionScope) { if (((FunctionScope)parent).owner.isMethod) { il.Emit(OpCodes.Ldarg_0); } else { base.EmitILToLoadEngine(il); il.Emit(OpCodes.Call, CompilerGlobals.scriptObjectStackTopMethod); parent = base.Globals.ScopeStack.Peek(); while ((parent is WithObject) || (parent is BlockScope)) { il.Emit(OpCodes.Call, CompilerGlobals.getParentMethod); parent = parent.GetParent(); } il.Emit(OpCodes.Castclass, Typeob.StackFrame); il.Emit(OpCodes.Ldfld, CompilerGlobals.closureInstanceField); } } else if (parent is ClassScope) { il.Emit(OpCodes.Ldarg_0); } for (parent = base.Globals.ScopeStack.Peek(); parent != null; parent = parent.GetParent()) { ClassScope scope = parent as ClassScope; if (scope != null) { if (scope.IsSameOrDerivedFrom(obType)) { return; } il.Emit(OpCodes.Ldfld, scope.outerClassField); } } } } else { this.TranslateToILDefaultThisObject(il, this.lexLevel); Microsoft.JScript.Convert.Emit(this, il, Typeob.Object, obType); } } else { ScriptObject obj5 = base.Globals.ScopeStack.Peek(); while ((obj5 is WithObject) || (obj5 is BlockScope)) { obj5 = obj5.GetParent(); } if (!(obj5 is FunctionScope) || ((FunctionScope)obj5).owner.isMethod) { il.Emit(OpCodes.Ldarg_0); while (obj5 != null) { if (obj5 is ClassScope) { ClassScope scope3 = (ClassScope)obj5; if (scope3.IsSameOrDerivedFrom(obType)) { return; } il.Emit(OpCodes.Ldfld, scope3.outerClassField); } obj5 = obj5.GetParent(); } } else { base.EmitILToLoadEngine(il); il.Emit(OpCodes.Call, CompilerGlobals.scriptObjectStackTopMethod); obj5 = base.Globals.ScopeStack.Peek(); while ((obj5 is WithObject) || (obj5 is BlockScope)) { il.Emit(OpCodes.Call, CompilerGlobals.getParentMethod); obj5 = obj5.GetParent(); } il.Emit(OpCodes.Castclass, Typeob.StackFrame); il.Emit(OpCodes.Ldfld, CompilerGlobals.closureInstanceField); while (obj5 != null) { if (obj5 is ClassScope) { ClassScope scope2 = (ClassScope)obj5; if (scope2.IsSameOrDerivedFrom(obType)) { break; } il.Emit(OpCodes.Castclass, scope2.GetTypeBuilder()); il.Emit(OpCodes.Ldfld, scope2.outerClassField); } obj5 = obj5.GetParent(); } il.Emit(OpCodes.Castclass, obType); } } }