public static EcmaValue DefineProperty(EcmaValue target, EcmaValue property, EcmaValue attributes) { Guard.ArgumentIsObject(target); RuntimeObject obj = target.ToObject(); obj.DefinePropertyOrThrow(EcmaPropertyKey.FromValue(property), EcmaPropertyDescriptor.FromValue(attributes)); return(target); }
public static EcmaValue DefineProperties(EcmaValue target, EcmaValue properties) { Guard.ArgumentIsObject(target); RuntimeObject dst = target.ToObject(); foreach (EcmaPropertyEntry e in properties.ToObject().GetEnumerableOwnProperties(true)) { dst.DefinePropertyOrThrow(e.Key, EcmaPropertyDescriptor.FromValue(e.Value)); } return(target); }
public static EcmaValue[] CreateListFromArrayLike(EcmaValue value) { Guard.ArgumentIsObject(value); long len = value[WellKnownProperty.Length].ToLength(); EcmaValue[] arr = new EcmaValue[len]; for (long i = 0; i < len; i++) { arr[i] = value[i]; } return(arr); }
private bool TryGetResult(EcmaPropertyKey propertyKey, EcmaValue value, out bool done, out EcmaValue result) { RuntimeObject method = target.GetMethod(propertyKey); if (method == null) { result = value; done = true; return(false); } EcmaValue obj = method.Call(target, value); Guard.ArgumentIsObject(obj); done = obj[WellKnownProperty.Done].ToBoolean(); result = obj[WellKnownProperty.Value]; return(true); }
public bool MoveNext(params EcmaValue[] value) { if (this.done) { return(false); } EcmaValue result = this.nextMethod.Call(this.iterator, value); Guard.ArgumentIsObject(result); if (result[WellKnownProperty.Done]) { this.done = true; return(false); } this.Current = result[WellKnownProperty.Value]; return(true); }