use of com.github.anba.es6draft.runtime.types.Property in project es6draft by anba.
the class WrapperProxy method set.
@Override
public boolean set(ExecutionContext cx, long propertyKey, Object value, Object receiver) {
Property ownDesc = proxyTarget.getOwnProperty(cx, propertyKey);
if (ownDesc == null) {
ScriptObject parent = getPrototypeOf(cx);
if (parent != null) {
return parent.set(cx, propertyKey, value, receiver);
} else {
ownDesc = new Property(UNDEFINED, true, true, true);
}
}
if (ownDesc.isDataDescriptor()) {
if (!ownDesc.isWritable()) {
return false;
}
if (!Type.isObject(receiver)) {
return false;
}
ScriptObject _receiver = Type.objectValue(receiver);
Property existingDescriptor = _receiver.getOwnProperty(cx, propertyKey);
if (existingDescriptor != null) {
PropertyDescriptor valueDesc = new PropertyDescriptor(value);
return _receiver.defineOwnProperty(cx, propertyKey, valueDesc);
} else {
return CreateDataProperty(cx, _receiver, propertyKey, value);
}
}
assert ownDesc.isAccessorDescriptor();
Callable setter = ownDesc.getSetter();
if (setter == null) {
return false;
}
setter.call(cx, receiver, value);
return true;
}
use of com.github.anba.es6draft.runtime.types.Property in project es6draft by anba.
the class FunctionOperations method EvaluatePropertyDefinitionGenerator.
/**
* 14.4 Generator Function Definitions
* <p>
* 14.4.12 Runtime Semantics: PropertyDefinitionEvaluation
* <ul>
* <li>GeneratorMethod : * PropertyName ( StrictFormalParameters ) { FunctionBody }
* </ul>
*
* @param object
* the script object
* @param propKey
* the property key
* @param fd
* the function runtime info object
* @param cx
* the execution context
* @return the generator method
*/
public static OrdinaryGenerator EvaluatePropertyDefinitionGenerator(OrdinaryObject object, Object propKey, RuntimeInfo.Function fd, ExecutionContext cx) {
/* steps 1-2 (generated code) */
/* step 3 (not applicable) */
/* step 4 */
LexicalEnvironment<?> scope = cx.getLexicalEnvironment();
/* step 5 */
OrdinaryGenerator closure = GeneratorFunctionCreate(cx, FunctionKind.Method, fd, scope);
/* step 6 */
MakeMethod(closure, object);
/* step 7 */
OrdinaryObject prototype = ObjectCreate(cx, Intrinsics.GeneratorPrototype);
/* step 8 */
closure.infallibleDefineOwnProperty("prototype", new Property(prototype, true, false, false));
/* step 9 */
SetFunctionName(closure, propKey);
/* steps 10-11 (generated code) */
return closure;
}
use of com.github.anba.es6draft.runtime.types.Property in project es6draft by anba.
the class FunctionOperations method InstantiateGeneratorObject.
/**
* 14.4 Generator Function Definitions
* <p>
* 14.4.12 Runtime Semantics: InstantiateFunctionObject
*
* @param scope
* the current lexical scope
* @param cx
* the execution context
* @param fd
* the function runtime info object
* @return the new generator function instance
*/
public static OrdinaryGenerator InstantiateGeneratorObject(LexicalEnvironment<?> scope, ExecutionContext cx, RuntimeInfo.Function fd) {
/* step 1 (not applicable) */
/* step 2 */
String name = fd.functionName();
/* step 3 */
OrdinaryGenerator f = GeneratorFunctionCreate(cx, FunctionKind.Normal, fd, scope);
/* step 4 */
OrdinaryObject prototype = ObjectCreate(cx, Intrinsics.GeneratorPrototype);
/* step 5 */
f.infallibleDefineOwnProperty("prototype", new Property(prototype, true, false, false));
/* step 6 */
SetFunctionName(f, name);
/* step 7 */
return f;
}
use of com.github.anba.es6draft.runtime.types.Property in project es6draft by anba.
the class RegExpPrototype method findProperty.
private static Property findProperty(OrdinaryObject object, String name) {
final int MAX_PROTO_CHAIN_LENGTH = 5;
for (int i = 0; i < MAX_PROTO_CHAIN_LENGTH; ++i) {
Property p = object.lookupOwnProperty(name);
if (p != null) {
return p;
}
ScriptObject proto = object.getPrototype();
if (!(proto instanceof OrdinaryObject)) {
break;
}
object = (OrdinaryObject) proto;
}
return null;
}
use of com.github.anba.es6draft.runtime.types.Property in project es6draft by anba.
the class RegExpPrototype method isBuiltinRegExpPrototypeForExec.
private static boolean isBuiltinRegExpPrototypeForExec(ExecutionContext cx) {
OrdinaryObject prototype = cx.getIntrinsic(Intrinsics.RegExpPrototype);
Property exec = prototype.lookupOwnProperty("exec");
return exec != null && isBuiltinExec(cx.getRealm(), exec.getValue());
}
Aggregations