private AddNewField ( String name, Object value, FieldAttributes attributeFlags ) : |
||
name | String | |
value | Object | |
attributeFlags | FieldAttributes | |
return |
public static void JScriptPackage(string rootName, VsaEngine engine) { GlobalScope globalScope = ((IActivationObject)engine.ScriptObjectStackTop()).GetGlobalScope(); if (globalScope.GetLocalField(rootName) == null) { FieldInfo info = globalScope.AddNewField(rootName, Namespace.GetNamespace(rootName, engine), FieldAttributes.Literal | FieldAttributes.Public); } }
internal override AST PartiallyEvaluate() { String id = "regexp " + (RegExpLiteral.counter++).ToString(CultureInfo.InvariantCulture); GlobalScope gs = (GlobalScope)this.Engine.GetGlobalScope().GetObject(); JSGlobalField v = (JSGlobalField)gs.AddNewField(id, null, FieldAttributes.Assembly); v.type = new TypeExpression(new ConstantWrapper(Typeob.RegExpObject, this.context)); this.regExpVar = v; return(this); }
internal override AST PartiallyEvaluate() { string name = "regexp " + counter++.ToString(CultureInfo.InvariantCulture); GlobalScope scope = (GlobalScope)base.Engine.GetGlobalScope().GetObject(); JSGlobalField field = (JSGlobalField)scope.AddNewField(name, null, FieldAttributes.Assembly); field.type = new TypeExpression(new ConstantWrapper(Typeob.RegExpObject, base.context)); this.regExpVar = field; return(this); }
public static void JScriptImport(string name, VsaEngine engine) { int index = name.IndexOf('.'); string str = (index > 0) ? name.Substring(0, index) : name; GlobalScope globalScope = ((IActivationObject)engine.ScriptObjectStackTop()).GetGlobalScope(); if (globalScope.GetLocalField(str) == null) { FieldInfo info = globalScope.AddNewField(str, Namespace.GetNamespace(str, engine), FieldAttributes.Literal | FieldAttributes.Public); } engine.SetEnclosingContext(new WrappedNamespace(name, engine, false)); }
public static void JScriptImport(String name, VsaEngine engine) { int dotPos = name.IndexOf('.'); String rootName = dotPos > 0 ? name.Substring(0, dotPos) : name; GlobalScope scope = ((IActivationObject)engine.ScriptObjectStackTop()).GetGlobalScope(); FieldInfo field = scope.GetLocalField(rootName); if (field == null) { field = scope.AddNewField(rootName, Namespace.GetNamespace(rootName, engine), FieldAttributes.Public | FieldAttributes.Literal); } engine.SetEnclosingContext(new WrappedNamespace(name, engine, false)); }
internal override WrappedNamespace EvaluateAsWrappedNamespace(bool giveErrorIfNameInUse) { Namespace ns = Namespace.GetNamespace(this.name, this.Engine); GlobalScope scope = ((IActivationObject)Globals.ScopeStack.Peek()).GetGlobalScope(); FieldInfo field = giveErrorIfNameInUse ? scope.GetLocalField(this.name) : scope.GetField(this.name, BindingFlags.Public | BindingFlags.Static); if (field != null) { if (giveErrorIfNameInUse && (!field.IsLiteral || !(field.GetValue(null) is Namespace))) { this.context.HandleError(JSError.DuplicateName, true); } } else { field = scope.AddNewField(this.name, ns, FieldAttributes.Literal | FieldAttributes.Public); ((JSVariableField)field).type = new TypeExpression(new ConstantWrapper(Typeob.Namespace, this.context)); ((JSVariableField)field).originalContext = this.context; } return(new WrappedNamespace(this.name, this.Engine)); }
internal override WrappedNamespace EvaluateAsWrappedNamespace(bool giveErrorIfNameInUse) { Namespace namespace2 = Namespace.GetNamespace(base.name, base.Engine); GlobalScope globalScope = ((IActivationObject)base.Globals.ScopeStack.Peek()).GetGlobalScope(); FieldInfo info = giveErrorIfNameInUse ? globalScope.GetLocalField(base.name) : globalScope.GetField(base.name, BindingFlags.Public | BindingFlags.Static); if (info != null) { if (giveErrorIfNameInUse && (!info.IsLiteral || !(info.GetValue(null) is Namespace))) { base.context.HandleError(JSError.DuplicateName, true); } } else { info = globalScope.AddNewField(base.name, namespace2, FieldAttributes.Literal | FieldAttributes.Public); ((JSVariableField)info).type = new TypeExpression(new ConstantWrapper(Typeob.Namespace, base.context)); ((JSVariableField)info).originalContext = base.context; } return(new WrappedNamespace(base.name, base.Engine)); }