Exemple #1
0
 private static ScriptValue LastIndexOf(ScriptArguments arg)
 {
     throw new NotImplementedException();
 }
Exemple #2
0
 private static ScriptValue ToLocaleString(ScriptArguments arg)
 {
     throw new NotImplementedException();
 }
Exemple #3
0
 private static ScriptValue IsFinite(ScriptArguments arg)
 {
     throw new NotImplementedException();
 }
Exemple #4
0
 private static ScriptValue GetInt16(ScriptArguments arg)
 {
     throw new NotImplementedException();
 }
Exemple #5
0
 private static ScriptValue Throw(ScriptArguments arg)
 {
     throw new System.NotImplementedException();
 }
 private static ScriptValue Is([NotNull] ScriptArguments arg)
 {
     //https://tc39.github.io/ecma262/#sec-object.is
     return(arg[0].SameValue(arg[1]));
 }
 private static ScriptValue ValueOf([NotNull] ScriptArguments arg)
 {
     //https://tc39.github.io/ecma262/#sec-object.prototype.valueof
     return(arg.Agent.ToObject(arg.ThisValue));
 }
Exemple #8
0
 private static ScriptValue Pow([NotNull] ScriptArguments arg)
 {
     //https://tc39.github.io/ecma262/#sec-math.pow
     return(EvaluateWalker.Exponentiation(arg[0], arg[1], arg.Agent));
 }
Exemple #9
0
 private static ScriptValue Random([NotNull] ScriptArguments arg)
 {
     return(arg.Function.Realm.Random.NextDouble());
 }
Exemple #10
0
 private static ScriptValue Ceiling([NotNull] ScriptArguments arg)
 {
     //https://tc39.github.io/ecma262/#sec-math.ceil
     return(Math.Ceiling(arg.Agent.ToNumber(arg[0])));
 }
Exemple #11
0
 private static ScriptValue Fround(ScriptArguments arg)
 {
     throw new NotImplementedException();
 }
Exemple #12
0
 private static ScriptValue TypedArray(ScriptArguments arg)
 {
     throw new NotImplementedException();
 }
Exemple #13
0
 private static ScriptValue GetToStringTag(ScriptArguments arg)
 {
     throw new NotImplementedException();
 }
Exemple #14
0
 private static ScriptValue ReduceRight(ScriptArguments arg)
 {
     throw new NotImplementedException();
 }
 private static ScriptValue GetOwnPropertyNames([NotNull] ScriptArguments arg)
 {
     //https://tc39.github.io/ecma262/#sec-object.getownpropertynames
     return(GetOwnPropertyKeys(arg.Agent, arg[0], ScriptValue.Type.String));
 }
Exemple #16
0
 private static ScriptValue Sin([NotNull] ScriptArguments arg)
 {
     return(Math.Sin(arg.Agent.ToNumber(arg[0])));
 }
 private static ScriptValue GetOwnPropertySymbols([NotNull] ScriptArguments arg)
 {
     return(GetOwnPropertyKeys(arg.Agent, arg[0], ScriptValue.Type.Symbol));
 }
Exemple #18
0
 private static ScriptValue Atan([NotNull] ScriptArguments arg)
 {
     //https://tc39.github.io/ecma262/#sec-math.atan
     return(Math.Atan(arg.Agent.ToNumber(arg[0])));
 }
        private static ScriptValue ToString([NotNull] ScriptArguments arg)
        {
            //https://tc39.github.io/ecma262/#sec-object.prototype.tostring
            if (arg.ThisValue == ScriptValue.Undefined)
            {
                return("[object Undefined]");
            }

            if (arg.ThisValue == ScriptValue.Null)
            {
                return("[object Null]");
            }

            var    obj = arg.Agent.ToObject(arg.ThisValue);
            string builtinTag;

            if (arg.Agent.IsArray(obj))
            {
                builtinTag = "Array";
            }
            else if (obj is ScriptStringObject)
            {
                builtinTag = "String";
            }
            else if (obj.SpecialObjectType == SpecialObjectType.ArgumentsObject)
            {
                builtinTag = "Arguments";
            }
            else if (obj.IsCallable)
            {
                builtinTag = "Function";
            }
            else
            {
                switch (obj.SpecialObjectType)
                {
                case SpecialObjectType.Error:
                    builtinTag = "Error";
                    break;

                case SpecialObjectType.Boolean:
                    builtinTag = "Boolean";
                    break;

                case SpecialObjectType.Number:
                    builtinTag = "Number";
                    break;

                case SpecialObjectType.Date:
                    builtinTag = "Date";
                    break;

                case SpecialObjectType.RegExp:
                    builtinTag = "RegExp";
                    break;

                default:
                    builtinTag = "Object";
                    break;
                }
            }

            var tag = obj.Get(Symbol.ToStringTag);

            if (tag.IsString)
            {
                builtinTag = (string)tag;
            }

            return($"[object {builtinTag}]");
        }
 private static ScriptValue SharedArrayBuffer(ScriptArguments arg)
 {
     throw new System.NotImplementedException();
 }
Exemple #21
0
 private static ScriptValue GetByteOffset(ScriptArguments arg)
 {
     throw new NotImplementedException();
 }
 private static ScriptValue GetByteLength(ScriptArguments arg)
 {
     throw new System.NotImplementedException();
 }
Exemple #23
0
 private static ScriptValue SetUint32(ScriptArguments arg)
 {
     throw new NotImplementedException();
 }
 private static ScriptValue ToPrimitive([NotNull] ScriptArguments arg)
 {
     //https://tc39.github.io/ecma262/#sec-symbol.prototype-@@toprimitive
     return(ThisSymbolValue(arg.Agent, arg.ThisValue));
 }
Exemple #25
0
 private static ScriptValue GeneratorFunction([NotNull] ScriptArguments arg)
 {
     //https://tc39.github.io/ecma262/#sec-generatorfunction
     return(FunctionIntrinsics.CreateDynamicFunction(arg.Function, arg.NewTarget, FunctionKind.Generator, arg));
 }
Exemple #26
0
 private static ScriptValue Iterator([NotNull] ScriptArguments arg)
 {
     return(arg.ThisValue);
 }
Exemple #27
0
 private static ScriptValue ValueOf([NotNull] ScriptArguments arg)
 {
     //https://tc39.github.io/ecma262/#sec-number.prototype.valueof
     return(ThisNumberValue(arg.Agent, arg.ThisValue));
 }
 private static ScriptValue DefineProperties([NotNull] ScriptArguments arg)
 {
     //https://tc39.github.io/ecma262/#sec-object.defineproperties
     return(ObjectDefineProperties(arg.Agent, arg[0], arg[1]));
 }
Exemple #29
0
 private static ScriptValue IsSafeInteger(ScriptArguments arg)
 {
     throw new NotImplementedException();
 }
Exemple #30
0
 private static ScriptValue Includes(ScriptArguments arg)
 {
     throw new NotImplementedException();
 }