use of com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject in project es6draft by anba.
the class ReflectParser method visit.
@Override
public Object visit(BlockStatement node, Void value) {
ArrayObject body = createList(node.getStatements(), value);
if (hasBuilder(Type.BlockStatement)) {
return call(Type.BlockStatement, node, body);
}
OrdinaryObject statement = createStatement(node, Type.BlockStatement);
addProperty(statement, "body", body);
return statement;
}
use of com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject in project es6draft by anba.
the class ReflectParser method visit.
@Override
public Object visit(GeneratorExpression 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);
boolean generator = true;
boolean expression = false;
if (hasBuilder(Type.FunctionExpression)) {
return call(Type.FunctionExpression, node, id, params, body, generator, expression);
}
GeneratorStyle style = node instanceof LegacyGeneratorExpression ? GeneratorStyle.Legacy : GeneratorStyle.ES6;
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, "style", style.name);
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 addNodeInfo.
private void addNodeInfo(OrdinaryObject holder, Node node, Type type) {
Object loc = location ? createSourceLocation(node) : NULL;
addSourceLocation(holder, loc);
addType(holder, type);
}
use of com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject in project es6draft by anba.
the class ReflectParser method visit.
@Override
public Object visit(GeneratorComprehension node, Void value) {
// Comprehension/LegacyComprehension already created a partial result
OrdinaryObject expression = (OrdinaryObject) node.getComprehension().accept(this, value);
if (hasBuilder(Type.GeneratorExpression)) {
Object body = Get(cx, expression, "body");
Object blocks = Get(cx, expression, "blocks");
Object filter = Get(cx, expression, "filter");
return call(Type.GeneratorExpression, node, body, blocks, filter);
}
addNodeInfo(expression, node, Type.GeneratorExpression);
return expression;
}
use of com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject in project es6draft by anba.
the class ReflectParser method visit.
@Override
public Object visit(SwitchStatement node, Void value) {
Object switchStatement;
Object discriminant = node.getExpression().accept(this, value);
ArrayObject cases = createList(node.getClauses(), value);
boolean lexical = !LexicallyScopedDeclarations(node).isEmpty();
if (hasBuilder(Type.SwitchStatement)) {
switchStatement = call(Type.SwitchStatement, node, discriminant, cases, lexical);
} else {
OrdinaryObject statement = createStatement(node, Type.SwitchStatement);
addProperty(statement, "discriminant", discriminant);
addProperty(statement, "cases", cases);
addProperty(statement, "lexical", lexical);
switchStatement = statement;
}
return createLabelledStatement(node, switchStatement);
}
Aggregations