use of com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject in project es6draft by anba.
the class ReflectParser method visit.
@Override
public Object visit(ReturnStatement node, Void value) {
Object argument = acceptOrNull(node.getExpression(), value);
if (hasBuilder(Type.ReturnStatement)) {
return call(Type.ReturnStatement, node, argument);
}
OrdinaryObject statement = createStatement(node, Type.ReturnStatement);
addProperty(statement, "argument", argument);
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(ExportDeclaration node, Void value) {
Object declaration = NULL;
Object expression = NULL;
Object specifiers = NULL;
Object source = NULL;
switch(node.getType()) {
case All:
specifiers = createListFromValues(Collections.singletonList(createNode(Type.ExportBatchSpecifier)));
source = createLiteral(node.getModuleSpecifier());
break;
case External:
// TODO: default entry and namespace export
specifiers = node.getExportClause().accept(this, value);
source = createLiteral(node.getModuleSpecifier());
break;
case Local:
specifiers = node.getExportClause().accept(this, value);
break;
case Variable:
declaration = node.getVariableStatement().accept(this, value);
break;
case Declaration:
declaration = node.getDeclaration().accept(this, value);
break;
case DefaultHoistableDeclaration:
declaration = node.getHoistableDeclaration().accept(this, value);
break;
case DefaultClassDeclaration:
declaration = node.getClassDeclaration().accept(this, value);
break;
case DefaultExpression:
expression = node.getExpression().accept(this, value);
break;
default:
throw new AssertionError();
}
OrdinaryObject exportDecl = createModuleItem(node, Type.ExportDeclaration);
addProperty(exportDecl, "declaration", declaration);
addProperty(exportDecl, "expression", expression);
addProperty(exportDecl, "specifiers", specifiers);
addProperty(exportDecl, "source", source);
return exportDecl;
}
use of com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject in project es6draft by anba.
the class ReflectParser method createIdentifier.
private Object createIdentifier(String name) {
if (hasBuilder(Type.Identifier)) {
return call(Type.Identifier, null, name);
}
OrdinaryObject identifier = createNode(Type.Identifier);
addProperty(identifier, "name", name);
return identifier;
}
use of com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject in project es6draft by anba.
the class ReflectParser method visit.
@Override
public Object visit(ConditionalExpression node, Void value) {
Object test = node.getTest().accept(this, value);
Object consequent = node.getThen().accept(this, value);
Object alternate = node.getOtherwise().accept(this, value);
if (hasBuilder(Type.ConditionalExpression)) {
return call(Type.ConditionalExpression, node, test, consequent, alternate);
}
OrdinaryObject expression = createExpression(node, Type.ConditionalExpression);
addProperty(expression, "test", test);
addProperty(expression, "consequent", consequent);
addProperty(expression, "alternate", alternate);
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(ElementAccessor node, Void value) {
Object object = node.getBase().accept(this, value);
Object property = node.getElement().accept(this, value);
boolean computed = true;
if (hasBuilder(Type.MemberExpression)) {
return call(Type.MemberExpression, node, object, property, computed);
}
OrdinaryObject expression = createExpression(node, Type.MemberExpression);
addProperty(expression, "object", object);
addProperty(expression, "property", property);
addProperty(expression, "computed", computed);
return expression;
}
Aggregations