internal override WrappedNamespace EvaluateAsWrappedNamespace(bool giveErrorIfNameInUse) { WrappedNamespace root = this.rootObject.EvaluateAsWrappedNamespace(giveErrorIfNameInUse); String name = this.name; root.AddFieldOrUseExistingField(name, Namespace.GetNamespace(root.ToString() + "." + name, this.Engine), FieldAttributes.Literal); return(new WrappedNamespace(root.ToString() + "." + name, this.Engine)); }
internal Import(Context context, AST name) : base(context) { if (name != null) { WrappedNamespace ob = name.EvaluateAsWrappedNamespace(true); base.Engine.SetEnclosingContext(ob); this.name = ob.name; } }
internal Import(Context context, AST name) : base(context) { if (name == null) //could happen if constructed while in error recovery mode { return; } WrappedNamespace ns = name.EvaluateAsWrappedNamespace(true); this.Engine.SetEnclosingContext(ns); this.name = ns.name; }
internal Object EvaluateAsType() { WrappedNamespace ns = this.rootObject.EvaluateAsWrappedNamespace(false); Object result = ns.GetMemberValue(this.name); if (result != null && !(result is Missing)) { return(result); } Object ob = null; Member root = this.rootObject as Member; if (root == null) { Lookup lookup = this.rootObject as Lookup; if (lookup == null) { return(null); } ob = lookup.PartiallyEvaluate(); ConstantWrapper cw = ob as ConstantWrapper; if (cw != null) { ob = cw.value; } else { JSGlobalField f = lookup.member as JSGlobalField; if (f != null && f.IsLiteral) { ob = f.value; } else { return(null); } } } else { ob = root.EvaluateAsType(); } ClassScope csc = ob as ClassScope; if (csc != null) { MemberInfo[] members = csc.GetMember(this.name, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance); if (members.Length == 0) { return(null); } JSMemberField field = members[0] as JSMemberField; if (field == null || !field.IsLiteral || !(field.value is ClassScope) || !field.IsPublic && !field.IsAccessibleFrom(this.Engine.ScriptObjectStackTop())) { return(null); } return(field.value); } Type t = ob as Type; if (t != null) { return(t.GetNestedType(this.name)); } return(null); }