use of com.github.anba.es6draft.runtime.types.builtins.ArrayObject in project es6draft by anba.
the class ReflectParser method toFunctionExpression.
private Object toFunctionExpression(MethodDefinition node, Void value) {
Object id;
if (isGetterOrSetter(node) || node.getPropertyName() instanceof ComputedPropertyName) {
id = NULL;
} else {
id = node.getPropertyName().accept(this, 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 = false;
switch(node.getType()) {
case AsyncFunction:
case AsyncGenerator:
// TODO: async functions
break;
case ConstructorGenerator:
case Generator:
generator = true;
break;
default:
}
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);
if (generator) {
addProperty(function, "style", GeneratorStyle.ES6.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(Module node, Void value) {
ArrayObject body = createList(node.getStatements(), value);
if (hasBuilder(Type.Program)) {
return call(Type.Program, node, body);
}
OrdinaryObject program = createNode(node, Type.Program);
addProperty(program, "body", body);
addProperty(program, "sourceType", "module");
return program;
}
use of com.github.anba.es6draft.runtime.types.builtins.ArrayObject in project es6draft by anba.
the class ReflectParser method visit.
@Override
public Object visit(AsyncFunctionDeclaration 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.FunctionDeclaration)) {
return call(Type.FunctionDeclaration, node, id, params, body, generator, expression);
}
OrdinaryObject function = createFunction(node, Type.FunctionDeclaration);
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.ArrayObject in project es6draft by anba.
the class ReflectParser method visit.
@Override
public Object visit(CallExpression 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);
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(LexicalDeclaration node, Void value) {
ArrayObject declarations = createList(node.getElements(), value);
String kind = node.isConstDeclaration() ? "const" : "let";
if (hasBuilder(Type.VariableDeclaration)) {
return call(Type.VariableDeclaration, node, kind, declarations);
}
OrdinaryObject declaration = createDeclaration(node, Type.VariableDeclaration);
addProperty(declaration, "declarations", declarations);
addProperty(declaration, "kind", kind);
return declaration;
}
Aggregations