Exemple #1
0
        public override Completion GetValue(EvaluationContext context)
        {
            // need to notify correct node when taking shortcut
            context.LastSyntaxNode = _expression;

            return(Completion.Normal(_value, _expression.Location));
        }
Exemple #2
0
        public override Completion GetValue(EvaluationContext context)
        {
            // need to notify correct node when taking shortcut
            context.LastSyntaxNode = _expression;

            GetValueAndCheckIterator(context, out var objectInstance, out var iterator);
            return(Completion.Normal(objectInstance, _expression.Location));
        }
Exemple #3
0
        public override Completion GetValue(EvaluationContext context)
        {
            var engine  = context.Engine;
            var funcEnv = JintEnvironment.NewDeclarativeEnvironment(engine, engine.ExecutionContext.LexicalEnvironment);

            var closure = new ScriptFunctionInstance(
                engine,
                _function,
                funcEnv,
                _function.ThisMode);

            closure.MakeConstructor();

            if (_function.Name != null)
            {
                funcEnv.CreateMutableBindingAndInitialize(_function.Name, canBeDeleted: false, closure);
            }

            return(Completion.Normal(closure, _expression.Location));
        }
        public override Completion GetValue(EvaluationContext context)
        {
            // need to notify correct node when taking shortcut
            context.LastSyntaxNode = _expression;

            if (_calculatedValue is not null)
            {
                return(Completion.Normal(_calculatedValue, _expression.Location));
            }

            var strict = StrictModeScope.IsStrictModeCode;
            var engine = context.Engine;
            var env    = engine.ExecutionContext.LexicalEnvironment;

            if (JintEnvironment.TryGetIdentifierEnvironmentWithBindingValue(
                    env,
                    _expressionName,
                    strict,
                    out _,
                    out var value))
            {
                if (value is null)
                {
                    ExceptionHelper.ThrowReferenceError(engine.Realm, _expressionName.Key.Name + " has not been initialized");
                }
            }
            else
            {
                var reference = engine._referencePool.Rent(JsValue.Undefined, _expressionName.StringValue, strict, thisValue: null);
                value = engine.GetValue(reference, true);
            }

            // make sure arguments access freezes state
            if (value is ArgumentsInstance argumentsInstance)
            {
                argumentsInstance.Materialize();
            }

            return(Completion.Normal(value, _expression.Location));
        }