GetLocalField() public method

public GetLocalField ( String name ) : FieldInfo
name String
return System.Reflection.FieldInfo
Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
        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));
        }