use of com.github.anba.es6draft.runtime.types.builtins.ArrayObject 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.ArrayObject 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);
}
use of com.github.anba.es6draft.runtime.types.builtins.ArrayObject in project es6draft by anba.
the class ReflectParser method visit.
@Override
public Object visit(SuperNewExpression node, Void value) {
Object callee = superNode(node);
ArrayObject arguments = createList(node.getArguments(), value);
if (hasBuilder(Type.NewExpression)) {
return call(Type.NewExpression, node, callee, arguments);
}
OrdinaryObject expression = createExpression(node, Type.NewExpression);
addProperty(expression, "callee", callee);
addProperty(expression, "arguments", arguments);
return expression;
}
use of com.github.anba.es6draft.runtime.types.builtins.ArrayObject in project es6draft by anba.
the class ReflectParser method visit.
@Override
public Object visit(LegacyComprehension node, Void value) {
// Extract the single if-qualifier, if present
Expression test = null;
List<ComprehensionQualifier> qualifiers = node.getList();
ComprehensionQualifier last = lastElement(qualifiers);
if (last instanceof ComprehensionIf) {
test = ((ComprehensionIf) last).getTest();
qualifiers = qualifiers.subList(0, qualifiers.size() - 1);
}
Object body = node.getExpression().accept(this, value);
ArrayObject blocks = createList(qualifiers, value);
Object filter = acceptOrNull(test, value);
OrdinaryObject expression = createEmptyNode();
addProperty(expression, "body", body);
addProperty(expression, "blocks", blocks);
addProperty(expression, "filter", filter);
addProperty(expression, "style", "legacy");
return expression;
}
use of com.github.anba.es6draft.runtime.types.builtins.ArrayObject in project es6draft by anba.
the class ReflectParser method visit.
@Override
public Object visit(NativeCallExpression node, Void value) {
Object callee = node.getBase().accept(this, value);
ArrayObject arguments = createList(node.getArguments(), value);
if (hasBuilder(Type.CallExpression)) {
return call(Type.CallExpression, node, callee, arguments);
}
OrdinaryObject expression = createExpression(node, Type.CallExpression);
addProperty(expression, "callee", callee);
addProperty(expression, "arguments", arguments);
addProperty(expression, "native", true);
return expression;
}
Aggregations