use of com.github.anba.es6draft.runtime.types.Property in project es6draft by anba.
the class FunctionObject method AddRestrictedFunctionProperties.
/**
* 9.2.7 AddRestrictedFunctionProperties ( F, realm )
*
* @param <FUNCTION>
* the function type
* @param f
* the function object
* @param realm
* the realm object
*/
public static <FUNCTION extends OrdinaryObject & Callable> void AddRestrictedFunctionProperties(FUNCTION f, Realm realm) {
/* steps 1-2 */
Callable thrower = realm.getThrowTypeError();
/* step 3 */
f.infallibleDefineOwnProperty("caller", new Property(thrower, thrower, false, true));
/* step 4 */
f.infallibleDefineOwnProperty("arguments", new Property(thrower, thrower, false, true));
}
use of com.github.anba.es6draft.runtime.types.Property in project es6draft by anba.
the class FunctionObject method SetFunctionName.
/**
* 9.2.11 SetFunctionName (F, name, prefix)
*
* @param <FUNCTION>
* the function type
* @param f
* the function object
* @param name
* the function name
* @param prefix
* the function name prefix
*/
public static <FUNCTION extends OrdinaryObject & Callable> void SetFunctionName(FUNCTION f, PrivateName name, String prefix) {
/* step 1 */
assert f.isExtensible() && !f.ordinaryHasOwnProperty("name");
/* steps 2-4 (not applicable) */
/* step 5 */
String sname = name.toString();
/* step 6 */
if (prefix != null) {
sname = prefix + " " + sname;
}
/* step 7 */
assert sname.length() <= StringObject.MAX_LENGTH;
f.infallibleDefineOwnProperty("name", new Property(sname, false, false, true));
}
use of com.github.anba.es6draft.runtime.types.Property in project es6draft by anba.
the class FunctionObject method SetFunctionName.
/**
* 9.2.11 SetFunctionName (F, name, prefix)
*
* @param <FUNCTION>
* the function type
* @param f
* the function object
* @param name
* the function name
* @param prefix
* the function name prefix
*/
public static <FUNCTION extends OrdinaryObject & Callable> void SetFunctionName(FUNCTION f, Symbol name, String prefix) {
/* step 1 */
assert f.isExtensible() && !f.ordinaryHasOwnProperty("name");
/* steps 2-3 (not applicable) */
/* step 4 */
String description = name.getDescription();
String sname = description == null ? "" : "[" + description + "]";
/* step 5 */
if (prefix != null) {
sname = prefix + " " + sname;
}
/* step 6 */
assert sname.length() <= StringObject.MAX_LENGTH;
f.infallibleDefineOwnProperty("name", new Property(sname, false, false, true));
}
use of com.github.anba.es6draft.runtime.types.Property in project es6draft by anba.
the class FunctionObject method FunctionInitialize.
/**
* 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope)
*
* @param <FUNCTION>
* the function type
* @param f
* the function object
* @param kind
* the function kind
* @param function
* the function code
* @param scope
* the lexical environment
* @param executable
* the executable object
* @return the function object
*/
public static <FUNCTION extends FunctionObject> FUNCTION FunctionInitialize(FUNCTION f, FunctionKind kind, RuntimeInfo.Function function, LexicalEnvironment<?> scope, Executable executable) {
FunctionObject fo = (FunctionObject) f;
assert fo.function == null && function != null : "function object already initialized";
assert fo.functionKind == kind : String.format("%s != %s", fo.functionKind, kind);
/* step 1 */
assert f.isExtensible() && !f.ordinaryHasOwnProperty("length");
/* step 2 */
int len = function.expectedArgumentCount();
/* step 3 */
f.infallibleDefineOwnProperty("length", new Property(len, false, false, true));
/* step 4 */
boolean strict = fo.strict;
/* step 5 */
fo.environment = scope;
/* steps 6-8 */
fo.function = function;
fo.callMethod = tailCallAdapter(function, f);
fo.tailCallMethod = function.callMethod();
fo.constructMethod = tailConstructAdapter(function, f);
/* steps 9-11 */
if (kind == FunctionKind.Arrow) {
fo.thisMode = ThisMode.Lexical;
} else if (strict) {
fo.thisMode = ThisMode.Strict;
} else {
fo.thisMode = ThisMode.Global;
}
fo.executable = executable;
/* step 12 */
return f;
}
use of com.github.anba.es6draft.runtime.types.Property in project es6draft by anba.
the class OrdinaryObject method ordinaryGet.
/**
* 9.1.8.1 OrdinaryGet (O, P, Receiver)
*
* @param cx
* the execution context
* @param propertyKey
* the property key
* @param receiver
* the receiver object
* @return the property value
*/
protected final Object ordinaryGet(ExecutionContext cx, Symbol propertyKey, Object receiver) {
/* step 1 (implicit) */
/* step 2 */
Property desc = getOwnProperty(cx, propertyKey);
/* step 3 */
if (desc == null) {
ScriptObject parent = getPrototypeOf(cx);
if (parent == null) {
return UNDEFINED;
}
return parent.get(cx, propertyKey, receiver);
}
/* step 4 */
if (desc.isDataDescriptor()) {
return desc.getValue();
}
/* step 5 */
assert desc.isAccessorDescriptor();
/* step 6 */
Callable getter = desc.getGetter();
/* step 7 */
if (getter == null) {
return UNDEFINED;
}
/* step 8 */
return getter.call(cx, receiver, EMPTY_ARRAY);
}
Aggregations