Exemplo n.º 1
0
        public override Completion Evaluate(Interpreter interpreter)
        {
            var baseValueComp = indexedMemberExpression.Evaluate(interpreter).GetValue();

            if (baseValueComp.IsAbrupt())
            {
                return(baseValueComp);
            }
            var baseValue        = baseValueComp.value !;
            var propertyNameComp = indexerExpression.Evaluate(interpreter).GetValue();

            if (propertyNameComp.IsAbrupt())
            {
                return(propertyNameComp);
            }
            var propertyNameValue = propertyNameComp.value !;
            var coercible         = baseValue.RequireObjectCoercible();

            if (coercible.IsAbrupt())
            {
                return(coercible);
            }
            var propertyKey = propertyNameValue.ToPropertyKey();

            if (propertyKey.IsAbrupt())
            {
                return(propertyKey);
            }
            return(Completion.NormalCompletion(new ReferenceValue(baseValue, propertyKey.Other !, IsStrictMode)));
        }
Exemplo n.º 2
0
        public override Completion Evaluate(Interpreter interpreter)
        {
            var @ref     = memberExpression.Evaluate(interpreter);
            var funcComp = @ref.GetValue();

            if (funcComp.IsAbrupt())
            {
                return(funcComp);
            }
            var func = funcComp.value !;

            if (func == UndefinedValue.Instance && @ref.value is ReferenceValue r)
            {
                return(Completion.ThrowReferenceError($"Cannot call undefined method {r.referencedName } on a {r.baseValue.GetType().Name}"));
            }

            if (@ref.value is ReferenceValue referenceValue && !referenceValue.baseValue.IsPrimitive() && referenceValue.referencedName == "eval")
            {
                if (func == interpreter.CurrentRealm().Intrinsics.Eval)
                {
                    var argList = arguments.ArgumentListEvaluation();
                    if (argList.IsAbrupt())
                    {
                        return(argList);
                    }
                    if (!argList.Other.Any())
                    {
                        return(Completion.NormalCompletion(UndefinedValue.Instance));
                    }
                    var evalText  = argList.Other ![0];
Exemplo n.º 3
0
        public override Completion Evaluate(Interpreter interpreter)
        {
            var baseValueComp = dotMemberExpression.Evaluate(interpreter).GetValue();

            if (baseValueComp.IsAbrupt())
            {
                return(baseValueComp);
            }
            var baseValue = baseValueComp.value !;
            var coercible = baseValue.RequireObjectCoercible();

            if (coercible.IsAbrupt())
            {
                return(coercible);
            }
            return(Completion.NormalCompletion(new ReferenceValue(baseValue, dotIdentifierName, IsStrictMode)));
        }