Search in sources :

Example 36 with ArrayObject

use of com.github.anba.es6draft.runtime.types.builtins.ArrayObject in project es6draft by anba.

the class ReflectParser method visit.

@Override
public Object visit(LetStatement node, Void value) {
    ArrayObject head = createList(node.getBindings(), value);
    Object body = node.getStatement().accept(this, value);
    if (hasBuilder(Type.LetStatement)) {
        return call(Type.LetStatement, node, head, body);
    }
    OrdinaryObject statement = createStatement(node, Type.LetStatement);
    addProperty(statement, "head", head);
    addProperty(statement, "body", body);
    return statement;
}
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 37 with ArrayObject

use of com.github.anba.es6draft.runtime.types.builtins.ArrayObject in project es6draft by anba.

the class ReflectParser method visit.

@Override
public Object visit(ArrowFunction node, Void value) {
    Object id = NULL;
    ArrayObject params = createList(getParameterBindings(node.getParameters()), value);
    ArrayObject defaults = createListWithNull(getParameterDefaults(node.getParameters()), value);
    Object rest = acceptOrNull(getRestParameter(node.getParameters()), value);
    Object body;
    if (node.getExpression() == null) {
        body = createFunctionBody(node, value);
    } else {
        body = node.getExpression().accept(this, value);
    }
    boolean generator = false;
    boolean expression = node.getExpression() != null;
    if (hasBuilder(Type.ArrowFunctionExpression)) {
        return call(Type.ArrowFunctionExpression, node, id, params, body, generator, expression);
    }
    OrdinaryObject function = createFunction(node, Type.ArrowFunctionExpression);
    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 38 with ArrayObject

use of com.github.anba.es6draft.runtime.types.builtins.ArrayObject in project es6draft by anba.

the class ReflectParser method visit.

@Override
public Object visit(ObjectAssignmentPattern node, Void value) {
    ArrayObject properties = createList(node.getProperties(), value);
    // TODO: rest property
    if (hasBuilder(Type.ObjectPattern)) {
        return call(Type.ObjectPattern, node, properties);
    }
    OrdinaryObject pattern = createPattern(node, Type.ObjectPattern);
    addProperty(pattern, "properties", properties);
    return pattern;
}
Also used : ArrayObject(com.github.anba.es6draft.runtime.types.builtins.ArrayObject) OrdinaryObject(com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject)

Example 39 with ArrayObject

use of com.github.anba.es6draft.runtime.types.builtins.ArrayObject in project es6draft by anba.

the class ReflectParser method visit.

@Override
public Object visit(SwitchClause node, Void value) {
    Object test = acceptOrNull(node.getExpression(), value);
    ArrayObject consequent = createList(node.getStatements(), value);
    if (hasBuilder(Type.SwitchCase)) {
        return call(Type.SwitchCase, node, test, consequent);
    }
    OrdinaryObject switchCase = createNode(node, Type.SwitchCase);
    addProperty(switchCase, "test", test);
    addProperty(switchCase, "consequent", consequent);
    return switchCase;
}
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 40 with ArrayObject

use of com.github.anba.es6draft.runtime.types.builtins.ArrayObject in project es6draft by anba.

the class ReflectParser method visit.

@Override
public Object visit(AsyncArrowFunction node, Void value) {
    Object id = NULL;
    ArrayObject params = createList(getParameterBindings(node.getParameters()), value);
    ArrayObject defaults = createListWithNull(getParameterDefaults(node.getParameters()), value);
    Object rest = acceptOrNull(getRestParameter(node.getParameters()), value);
    Object body;
    if (node.getExpression() == null) {
        body = createFunctionBody(node, value);
    } else {
        body = node.getExpression().accept(this, value);
    }
    // TODO: flag for async
    boolean generator = false;
    boolean expression = node.getExpression() != null;
    if (hasBuilder(Type.ArrowFunctionExpression)) {
        return call(Type.ArrowFunctionExpression, node, id, params, body, generator, expression);
    }
    OrdinaryObject function = createFunction(node, Type.ArrowFunctionExpression);
    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

ArrayObject (com.github.anba.es6draft.runtime.types.builtins.ArrayObject)50 OrdinaryObject (com.github.anba.es6draft.runtime.types.builtins.OrdinaryObject)43 ScriptObject (com.github.anba.es6draft.runtime.types.ScriptObject)32 RegExpObject (com.github.anba.es6draft.runtime.objects.text.RegExpObject)25 ArrayList (java.util.ArrayList)5 ImmutablePrototypeObject (com.github.anba.es6draft.runtime.types.builtins.ImmutablePrototypeObject)3 PropertyDescriptor (com.github.anba.es6draft.runtime.types.PropertyDescriptor)2 MethodName (com.github.anba.es6draft.compiler.assembler.MethodName)1 MatchState (com.github.anba.es6draft.regexp.MatchState)1 IsCallable (com.github.anba.es6draft.runtime.AbstractOperations.IsCallable)1 ExecutionContext (com.github.anba.es6draft.runtime.ExecutionContext)1 DateObject (com.github.anba.es6draft.runtime.objects.date.DateObject)1 Callable (com.github.anba.es6draft.runtime.types.Callable)1 Property (com.github.anba.es6draft.runtime.types.Property)1 Symbol (com.github.anba.es6draft.runtime.types.Symbol)1 AbstractMap (java.util.AbstractMap)1 Date (java.util.Date)1 Map (java.util.Map)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1