Search in sources :

Example 16 with OrdinaryObject

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;
}
Also used : ArrayObject(com.github.anba.es6draft.runtime.types.builtins.ArrayObject) OrdinaryObject(com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject) ScriptObject(com.github.anba.es6draft.runtime.types.ScriptObject) RegExpObject(com.github.anba.es6draft.runtime.objects.text.RegExpObject) OrdinaryObject(com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject) ArrayObject(com.github.anba.es6draft.runtime.types.builtins.ArrayObject)

Example 17 with OrdinaryObject

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;
}
Also used : OrdinaryObject(com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject) ScriptObject(com.github.anba.es6draft.runtime.types.ScriptObject) RegExpObject(com.github.anba.es6draft.runtime.objects.text.RegExpObject) OrdinaryObject(com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject) ArrayObject(com.github.anba.es6draft.runtime.types.builtins.ArrayObject)

Example 18 with OrdinaryObject

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;
}
Also used : OrdinaryObject(com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject)

Example 19 with OrdinaryObject

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;
}
Also used : OrdinaryObject(com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject) ScriptObject(com.github.anba.es6draft.runtime.types.ScriptObject) RegExpObject(com.github.anba.es6draft.runtime.objects.text.RegExpObject) OrdinaryObject(com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject) ArrayObject(com.github.anba.es6draft.runtime.types.builtins.ArrayObject)

Example 20 with OrdinaryObject

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;
}
Also used : ArrayObject(com.github.anba.es6draft.runtime.types.builtins.ArrayObject) OrdinaryObject(com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject) ScriptObject(com.github.anba.es6draft.runtime.types.ScriptObject) RegExpObject(com.github.anba.es6draft.runtime.objects.text.RegExpObject) OrdinaryObject(com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject) ArrayObject(com.github.anba.es6draft.runtime.types.builtins.ArrayObject)

Aggregations

OrdinaryObject (com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject)141 ArrayObject (com.github.anba.es6draft.runtime.types.builtins.ArrayObject)102 ScriptObject (com.github.anba.es6draft.runtime.types.ScriptObject)98 RegExpObject (com.github.anba.es6draft.runtime.objects.text.RegExpObject)84 Intrinsics (com.github.anba.es6draft.runtime.types.Intrinsics)14 Property (com.github.anba.es6draft.runtime.types.Property)5 CompilationException (com.github.anba.es6draft.compiler.CompilationException)3 ParserException (com.github.anba.es6draft.parser.ParserException)3 GlobalEnvironmentRecord (com.github.anba.es6draft.runtime.GlobalEnvironmentRecord)3 RuntimeInfo (com.github.anba.es6draft.runtime.internal.RuntimeInfo)3 ScriptLoader (com.github.anba.es6draft.runtime.internal.ScriptLoader)3 Source (com.github.anba.es6draft.runtime.internal.Source)3 FunctionConstructor.functionSource (com.github.anba.es6draft.runtime.objects.FunctionConstructor.functionSource)3 AsyncGeneratorFunctionConstructor (com.github.anba.es6draft.runtime.objects.async.iteration.AsyncGeneratorFunctionConstructor)3 AsyncGeneratorFunctionPrototype (com.github.anba.es6draft.runtime.objects.async.iteration.AsyncGeneratorFunctionPrototype)3 AtomicsObject (com.github.anba.es6draft.runtime.objects.atomics.AtomicsObject)3 IntlObject (com.github.anba.es6draft.runtime.objects.intl.IntlObject)3 ArrayList (java.util.ArrayList)3 MethodCode (com.github.anba.es6draft.compiler.assembler.Code.MethodCode)2 MethodName (com.github.anba.es6draft.compiler.assembler.MethodName)2