use of com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject in project es6draft by anba.
the class ReflectParser method visit.
@Override
public Object visit(AsyncFunctionExpression node, Void value) {
Object id = acceptOrNull(node.getIdentifier(), value);
ArrayObject params = createList(getParameterBindings(node.getParameters()), value);
ArrayObject defaults = createListWithNull(getParameterDefaults(node.getParameters()), value);
Object rest = acceptOrNull(getRestParameter(node.getParameters()), value);
Object body = createFunctionBody(node, value);
// TODO: flag for async
boolean generator = false;
boolean expression = false;
if (hasBuilder(Type.FunctionExpression)) {
return call(Type.FunctionExpression, node, id, params, body, generator, expression);
}
OrdinaryObject function = createFunction(node, Type.FunctionExpression);
addProperty(function, "id", id);
addProperty(function, "params", params);
addProperty(function, "defaults", defaults);
addProperty(function, "body", body);
addProperty(function, "rest", rest);
addProperty(function, "generator", generator);
addProperty(function, "expression", expression);
return function;
}
use of com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject in project es6draft by anba.
the class ReflectParser method visit.
@Override
public Object visit(BindingProperty node, Void value) {
Object key;
if (node.getPropertyName() == null) {
// BindingProperty : SingleNameBinding
key = node.getBinding().accept(this, value);
} else {
key = node.getPropertyName().accept(this, value);
}
Object _value;
if (node.getInitializer() == null) {
_value = node.getBinding().accept(this, value);
} else {
_value = toAssignmentExpression(node.getBinding(), node.getInitializer(), value);
}
String kind = "init";
boolean method = false;
boolean shorthand = node.getPropertyName() == null;
boolean computed = node.getPropertyName() instanceof ComputedPropertyName;
if (hasBuilder(Type.PropertyPattern)) {
return call(Type.PropertyPattern, node, kind, key, _value);
}
// not PropertyPattern!
OrdinaryObject property = createNode(node, Type.Property);
addProperty(property, "key", key);
addProperty(property, "value", _value);
addProperty(property, "kind", kind);
addProperty(property, "method", method);
addProperty(property, "shorthand", shorthand);
addProperty(property, "computed", computed);
return property;
}
use of com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject in project es6draft by anba.
the class ReflectParser method createNode.
private OrdinaryObject createNode(Type type) {
OrdinaryObject object = createEmptyNode();
addNodeInfo(object, type);
return object;
}
use of com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject in project es6draft by anba.
the class ReflectParser method createLabelledStatement.
private <STATEMENT extends Statement & AbruptNode> Object createLabelledStatement(STATEMENT node, Object body) {
if (node.getLabelSet().isEmpty()) {
return body;
}
Iterator<String> labels = new ArrayDeque<>(node.getLabelSet()).descendingIterator();
while (labels.hasNext()) {
Object label = createIdentifier(labels.next());
if (hasBuilder(Type.LabeledStatement)) {
body = call(Type.LabeledStatement, node, label, body);
} else {
OrdinaryObject statement = createStatement(node, Type.LabeledStatement);
addProperty(statement, "label", label);
addProperty(statement, "body", body);
body = statement;
}
}
return body;
}
use of com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject in project es6draft by anba.
the class ReflectParser method visit.
@Override
public Object visit(AsyncGeneratorExpression node, Void value) {
Object id = acceptOrNull(node.getIdentifier(), value);
ArrayObject params = createList(getParameterBindings(node.getParameters()), value);
ArrayObject defaults = createListWithNull(getParameterDefaults(node.getParameters()), value);
Object rest = acceptOrNull(getRestParameter(node.getParameters()), value);
Object body = createFunctionBody(node, value);
// TODO: flag for async generator
boolean generator = false;
boolean expression = false;
if (hasBuilder(Type.FunctionExpression)) {
return call(Type.FunctionExpression, node, id, params, body, generator, expression);
}
OrdinaryObject function = createFunction(node, Type.FunctionExpression);
addProperty(function, "id", id);
addProperty(function, "params", params);
addProperty(function, "defaults", defaults);
addProperty(function, "body", body);
addProperty(function, "rest", rest);
addProperty(function, "generator", generator);
addProperty(function, "expression", expression);
return function;
}
Aggregations