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;
}
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;
}
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);
}
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;
}
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;
}
Aggregations