ScopeOfClassMemberInitializer() static private method

static private ScopeOfClassMemberInitializer ( ScriptObject scope ) : ClassScope
scope ScriptObject
return ClassScope
Exemplo n.º 1
0
        internal override AST PartiallyEvaluate()
        {
            ScriptObject enclosingScope = Globals.ScopeStack.Peek();

            if (ClassScope.ScopeOfClassMemberInitializer(enclosingScope) != null)
            {
                this.context.HandleError(JSError.MemberInitializerCannotContainFuncExpr);
                return(this);
            }
            ScriptObject scope = enclosingScope;

            while (scope is WithObject || scope is BlockScope)
            {
                scope = scope.GetParent();
            }
            FunctionScope fscope = scope as FunctionScope;

            if (fscope != null)
            {
                fscope.closuresMightEscape = true;
            }
            if (scope != enclosingScope)
            {
                this.func.own_scope.SetParent(new WithObject(new JSObject(), this.func.own_scope.GetGlobalScope()));
            }
            this.func.PartiallyEvaluate();
            return(this);
        }
        internal override AST PartiallyEvaluate()
        {
            ScriptObject obj2 = base.Globals.ScopeStack.Peek();

            if (ClassScope.ScopeOfClassMemberInitializer(obj2) != null)
            {
                base.context.HandleError(JSError.MemberInitializerCannotContainFuncExpr);
                return(this);
            }
            ScriptObject parent = obj2;

            while ((parent is WithObject) || (parent is BlockScope))
            {
                parent = parent.GetParent();
            }
            FunctionScope scope = parent as FunctionScope;

            if (scope != null)
            {
                scope.closuresMightEscape = true;
            }
            if (parent != obj2)
            {
                this.func.own_scope.SetParent(new WithObject(new JSObject(), this.func.own_scope.GetGlobalScope()));
            }
            this.func.PartiallyEvaluate();
            return(this);
        }
Exemplo n.º 3
0
        internal override AST PartiallyEvaluate()
        {
            VsaEngine    engine = this.Engine;
            ScriptObject scope  = Globals.ScopeStack.Peek();

            ClassScope cscope = ClassScope.ScopeOfClassMemberInitializer(scope);

            if (null != cscope)
            {
                if (cscope.inStaticInitializerCode)
                {
                    cscope.staticInitializerUsesEval = true;
                }
                else
                {
                    cscope.instanceInitializerUsesEval = true;
                }
            }

            if (engine.doFast)
            {
                engine.PushScriptObject(new BlockScope(scope));
            }
            else
            {
                while (scope is WithObject || scope is BlockScope)
                {
                    if (scope is BlockScope)
                    {
                        ((BlockScope)scope).isKnownAtCompileTime = false;
                    }
                    scope = scope.GetParent();
                }
            }
            try
            {
                this.operand = this.operand.PartiallyEvaluate();
                if (this.unsafeOption != null)
                {
                    this.unsafeOption = this.unsafeOption.PartiallyEvaluate();
                }
                if (this.enclosingFunctionScope != null && this.enclosingFunctionScope.owner == null)
                {
                    this.context.HandleError(JSError.NotYetImplemented);
                }
                return(this);
            }
            finally
            {
                if (engine.doFast)
                {
                    this.Engine.PopScriptObject();
                }
            }
        }
Exemplo n.º 4
0
        internal override AST PartiallyEvaluate()
        {
            AST          ast;
            VsaEngine    engine = base.Engine;
            ScriptObject parent = base.Globals.ScopeStack.Peek();
            ClassScope   scope  = ClassScope.ScopeOfClassMemberInitializer(parent);

            if (scope != null)
            {
                if (scope.inStaticInitializerCode)
                {
                    scope.staticInitializerUsesEval = true;
                }
                else
                {
                    scope.instanceInitializerUsesEval = true;
                }
            }
            if (!engine.doFast)
            {
                while ((parent is WithObject) || (parent is BlockScope))
                {
                    if (parent is BlockScope)
                    {
                        ((BlockScope)parent).isKnownAtCompileTime = false;
                    }
                    parent = parent.GetParent();
                }
            }
            else
            {
                engine.PushScriptObject(new BlockScope(parent));
            }
            try
            {
                this.operand = this.operand.PartiallyEvaluate();
                if (this.unsafeOption != null)
                {
                    this.unsafeOption = this.unsafeOption.PartiallyEvaluate();
                }
                if ((this.enclosingFunctionScope != null) && (this.enclosingFunctionScope.owner == null))
                {
                    base.context.HandleError(JSError.NotYetImplemented);
                }
                ast = this;
            }
            finally
            {
                if (engine.doFast)
                {
                    base.Engine.PopScriptObject();
                }
            }
            return(ast);
        }