public virtual void Construct(ref CallFrame callFrame) { DValue proto = new DValue(); PrototypePropertyDescriptor.Get(this, ref proto); var protoObj = proto.AsDObject(); if (_prototypeMapMetadata == null || _prototypeMapMetadata.Prototype != protoObj) { _prototypeMapMetadata = Runtime.Instance.GetMapMetadataOfPrototype(protoObj); } callFrame.Function = this; if (Metadata != null) { callFrame.This = (new DObject(Metadata.TypicalConstructedFieldsLength, _prototypeMapMetadata.Root)); } else { callFrame.This = (new DObject(0, _prototypeMapMetadata.Root)); } JittedCode(ref callFrame); if (Metadata != null && Metadata.TypicalConstructedFieldsLength < callFrame.This.Fields.Length) { Metadata.TypicalConstructedFieldsLength = callFrame.This.Fields.Length; } if (ValueTypesHelper.IsObject(callFrame.Return.ValueType)) { callFrame.This = callFrame.Return.AsDObject(); } }
public static bool Run(mdr.DObject i0, mdr.DFunction i1) { //var prototype = func.GetFieldByFieldIndex(mdr.DType.PrototypeIndex); var prototype = new mdr.DValue(); i1.PrototypePropertyDescriptor.Get(i1, ref prototype); return(i0.Prototype == prototype.AsDObject()); }
public PropertyMap.DeleteStatus DeletePropertyDescriptor(ref DValue field) { switch (field.ValueType) { case ValueTypes.Undefined: return(DeletePropertyDescriptor(Runtime.Instance.DefaultDUndefined.ToString())); case ValueTypes.String: return(DeletePropertyDescriptor(field.AsString())); case ValueTypes.Char: return(DeletePropertyDescriptor(field.AsChar())); case ValueTypes.Boolean: return(DeletePropertyDescriptor(field.AsBoolean())); case ValueTypes.Float: return(DeletePropertyDescriptor(field.AsFloat())); case ValueTypes.Double: return(DeletePropertyDescriptor(field.AsDouble())); case ValueTypes.Int8: return(DeletePropertyDescriptor(field.AsInt8())); case ValueTypes.Int16: return(DeletePropertyDescriptor(field.AsInt16())); case ValueTypes.Int32: return(DeletePropertyDescriptor(field.AsInt32())); case ValueTypes.Int64: return(DeletePropertyDescriptor(field.AsInt64())); case ValueTypes.UInt8: return(DeletePropertyDescriptor(field.AsUInt8())); case ValueTypes.UInt16: return(DeletePropertyDescriptor(field.AsUInt16())); case ValueTypes.UInt32: return(DeletePropertyDescriptor(field.AsUInt32())); case ValueTypes.UInt64: return(DeletePropertyDescriptor(field.AsUInt64())); case ValueTypes.Object: case ValueTypes.Function: case ValueTypes.Array: //case ValueTypes.Property: return(DeletePropertyDescriptor(field.AsDObject().ToString())); case ValueTypes.Null: return(DeletePropertyDescriptor(Runtime.Instance.DefaultDNull.ToString())); //default: // return DeletePropertyDescriptor(field.ToString()); //This should never happen } Trace.Fail(new InvalidOperationException(string.Format("Cannot delete property using field index type {0}", field.ValueType))); return(PropertyMap.DeleteStatus.NotFound); }
public static bool Run(mdr.DObject i0, mdr.DFunction i1) { //var prototype = func.GetFieldByFieldIndex(mdr.DType.PrototypeIndex); var prototype = new mdr.DValue(); i1.PrototypePropertyDescriptor.Get(i1, ref prototype); return (i0.Prototype == prototype.AsDObject()); }
/// <summary> /// if the toString property of the input is a callable, calls it and sets the result in the output /// </summary> /// <param name="input">input</param> /// <param name="output">The return value of toString property</param> /// <returns>true if toString is callable and returns a primitive value, otherwise return false</returns> public static bool CallToStringProperty(ref mdr.DValue input, out mdr.DValue output) { return(CallToStringProperty(input.AsDObject(), out output)); }
/// <summary> /// ECMA-262, 8.12.8: Implements [[DefaultValue]] for JS objects /// </summary> /// <param name="input"></param> /// <param name="output"></param> /// <param name="stringHint">Specifies whether the hint is string or number. Default is number.</param> public static void DefaultValue(ref mdr.DValue input, out mdr.DValue output, bool stringHint = false) { Debug.Assert(ValueTypesHelper.IsObject(input.ValueType)); DefaultValue(input.AsDObject(), out output, stringHint); }