Search in sources :

Example 1 with SLStatementNode

use of com.oracle.truffle.sl.nodes.SLStatementNode in project graal by oracle.

the class FatalError method Block.

SLStatementNode Block(boolean inLoop) {
    SLStatementNode result;
    factory.startBlock();
    List<SLStatementNode> body = new ArrayList<>();
    Expect(8);
    int start = t.charPos;
    while (StartOf(1)) {
        SLStatementNode s = Statement(inLoop);
        body.add(s);
    }
    Expect(9);
    int length = (t.charPos + t.val.length()) - start;
    result = factory.finishBlock(body, start, length);
    return result;
}
Also used : ArrayList(java.util.ArrayList) SLStatementNode(com.oracle.truffle.sl.nodes.SLStatementNode)

Example 2 with SLStatementNode

use of com.oracle.truffle.sl.nodes.SLStatementNode in project graal by oracle.

the class FatalError method ReturnStatement.

SLStatementNode ReturnStatement() {
    SLStatementNode result;
    Expect(17);
    Token returnToken = t;
    SLExpressionNode value = null;
    if (StartOf(2)) {
        value = Expression();
    }
    result = factory.createReturn(returnToken, value);
    Expect(11);
    return result;
}
Also used : SLExpressionNode(com.oracle.truffle.sl.nodes.SLExpressionNode) SLStatementNode(com.oracle.truffle.sl.nodes.SLStatementNode)

Example 3 with SLStatementNode

use of com.oracle.truffle.sl.nodes.SLStatementNode in project graal by oracle.

the class FatalError method Function.

void Function() {
    Expect(4);
    Expect(1);
    Token identifierToken = t;
    Expect(5);
    int bodyStartPos = t.charPos;
    factory.startFunction(identifierToken, bodyStartPos);
    if (la.kind == 1) {
        Get();
        factory.addFormalParameter(t);
        while (la.kind == 6) {
            Get();
            Expect(1);
            factory.addFormalParameter(t);
        }
    }
    Expect(7);
    SLStatementNode body = Block(false);
    factory.finishFunction(body);
}
Also used : SLStatementNode(com.oracle.truffle.sl.nodes.SLStatementNode)

Example 4 with SLStatementNode

use of com.oracle.truffle.sl.nodes.SLStatementNode in project graal by oracle.

the class FatalError method IfStatement.

SLStatementNode IfStatement(boolean inLoop) {
    SLStatementNode result;
    Expect(15);
    Token ifToken = t;
    Expect(5);
    SLExpressionNode condition = Expression();
    Expect(7);
    SLStatementNode thenPart = Block(inLoop);
    SLStatementNode elsePart = null;
    if (la.kind == 16) {
        Get();
        elsePart = Block(inLoop);
    }
    result = factory.createIf(ifToken, condition, thenPart, elsePart);
    return result;
}
Also used : SLExpressionNode(com.oracle.truffle.sl.nodes.SLExpressionNode) SLStatementNode(com.oracle.truffle.sl.nodes.SLStatementNode)

Example 5 with SLStatementNode

use of com.oracle.truffle.sl.nodes.SLStatementNode in project graal by oracle.

the class SLNodeFactory method finishBlock.

public SLStatementNode finishBlock(List<SLStatementNode> bodyNodes, int startPos, int length) {
    lexicalScope = lexicalScope.outer;
    if (containsNull(bodyNodes)) {
        return null;
    }
    List<SLStatementNode> flattenedNodes = new ArrayList<>(bodyNodes.size());
    flattenBlocks(bodyNodes, flattenedNodes);
    for (SLStatementNode statement : flattenedNodes) {
        if (statement.hasSource() && !isHaltInCondition(statement)) {
            statement.addStatementTag();
        }
    }
    SLBlockNode blockNode = new SLBlockNode(flattenedNodes.toArray(new SLStatementNode[flattenedNodes.size()]));
    blockNode.setSourceSection(startPos, length);
    return blockNode;
}
Also used : SLBlockNode(com.oracle.truffle.sl.nodes.controlflow.SLBlockNode) ArrayList(java.util.ArrayList) SLStatementNode(com.oracle.truffle.sl.nodes.SLStatementNode)

Aggregations

SLStatementNode (com.oracle.truffle.sl.nodes.SLStatementNode)9 SLExpressionNode (com.oracle.truffle.sl.nodes.SLExpressionNode)3 SLBlockNode (com.oracle.truffle.sl.nodes.controlflow.SLBlockNode)2 ArrayList (java.util.ArrayList)2 FrameSlot (com.oracle.truffle.api.frame.FrameSlot)1 Node (com.oracle.truffle.api.nodes.Node)1 NodeVisitor (com.oracle.truffle.api.nodes.NodeVisitor)1 RootNode (com.oracle.truffle.api.nodes.RootNode)1 SourceSection (com.oracle.truffle.api.source.SourceSection)1 SLEvalRootNode (com.oracle.truffle.sl.nodes.SLEvalRootNode)1 SLRootNode (com.oracle.truffle.sl.nodes.SLRootNode)1 SLFunctionBodyNode (com.oracle.truffle.sl.nodes.controlflow.SLFunctionBodyNode)1 LinkedHashMap (java.util.LinkedHashMap)1