Search in sources :

Example 1 with SLFunctionBodyNode

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

the class SLNodeFactory method finishFunction.

public void finishFunction(SLStatementNode bodyNode) {
    if (bodyNode == null) {
        // a state update that would otherwise be performed by finishBlock
        lexicalScope = lexicalScope.outer;
    } else {
        methodNodes.add(bodyNode);
        final int bodyEndPos = bodyNode.getSourceEndIndex();
        final SourceSection functionSrc = source.createSection(functionStartPos, bodyEndPos - functionStartPos);
        final SLStatementNode methodBlock = finishBlock(methodNodes, functionBodyStartPos, bodyEndPos - functionBodyStartPos);
        assert lexicalScope == null : "Wrong scoping of blocks in parser";
        final SLFunctionBodyNode functionBodyNode = new SLFunctionBodyNode(methodBlock);
        functionBodyNode.setSourceSection(functionSrc.getCharIndex(), functionSrc.getCharLength());
        final SLRootNode rootNode = new SLRootNode(language, frameDescriptor, functionBodyNode, functionSrc, functionName);
        allFunctions.put(functionName, Truffle.getRuntime().createCallTarget(rootNode));
    }
    functionStartPos = 0;
    functionName = null;
    functionBodyStartPos = 0;
    parameterCount = 0;
    frameDescriptor = null;
    lexicalScope = null;
}
Also used : SLFunctionBodyNode(com.oracle.truffle.sl.nodes.controlflow.SLFunctionBodyNode) SourceSection(com.oracle.truffle.api.source.SourceSection) SLRootNode(com.oracle.truffle.sl.nodes.SLRootNode) SLStatementNode(com.oracle.truffle.sl.nodes.SLStatementNode)

Aggregations

SourceSection (com.oracle.truffle.api.source.SourceSection)1 SLRootNode (com.oracle.truffle.sl.nodes.SLRootNode)1 SLStatementNode (com.oracle.truffle.sl.nodes.SLStatementNode)1 SLFunctionBodyNode (com.oracle.truffle.sl.nodes.controlflow.SLFunctionBodyNode)1