Search in sources :

Example 1 with StatementNode

use of cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode in project TrufflePascal by Aspect26.

the class LexicalScope method generateInitializationNodes.

/**
 * Generates initialization node for each declared identifier in the current scope and returns list of these nodes.
 * @param frame frame of the scope (used in scopes of units)
 */
List<StatementNode> generateInitializationNodes(VirtualFrame frame) {
    List<StatementNode> initializationNodes = new ArrayList<>();
    for (Map.Entry<String, TypeDescriptor> entry : this.localIdentifiers.getAllIdentifiers().entrySet()) {
        String identifier = entry.getKey();
        TypeDescriptor typeDescriptor = entry.getValue();
        StatementNode initializationNode = createInitializationNode(identifier, typeDescriptor, frame);
        if (initializationNode != null) {
            initializationNodes.add(initializationNode);
        }
    }
    return initializationNodes;
}
Also used : TypeDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor) ReturnTypeDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.subroutine.ReturnTypeDescriptor) EnumTypeDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.compound.EnumTypeDescriptor) StatementNode(cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode)

Example 2 with StatementNode

use of cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode in project TrufflePascal by Aspect26.

the class FatalError method GotoStatement.

StatementNode GotoStatement() {
    StatementNode statement;
    Expect(47);
    Expect(3);
    statement = factory.createGotoStatement(t);
    return statement;
}
Also used : StatementNode(cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode)

Example 3 with StatementNode

use of cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode in project TrufflePascal by Aspect26.

the class FatalError method Assignment.

StatementNode Assignment(Token identifierToken) {
    StatementNode assignment;
    AssignmentData assignmentData;
    assignment = null;
    if (isReturnVariable(identifierToken)) {
        Expect(35);
        ExpressionNode value = Expression();
        assignment = factory.createSimpleAssignment(identifierToken, value);
    } else if (StartOf(5)) {
        assignmentData = AssignmentRoute(identifierToken);
        Expect(35);
        ExpressionNode value = Expression();
        assignment = factory.finishAssignmentNode(assignmentData, value);
    } else
        SynErr(76);
    return assignment;
}
Also used : StatementNode(cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode)

Example 4 with StatementNode

use of cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode in project TrufflePascal by Aspect26.

the class FatalError method Block.

StatementNode Block() {
    StatementNode blockNode;
    Expect(34);
    List<StatementNode> bodyNodes = new ArrayList<>();
    if (StartOf(3)) {
        StatementSequence(bodyNodes);
    }
    Expect(21);
    blockNode = factory.createBlockNode(bodyNodes, this.extendedGotoSupport);
    return blockNode;
}
Also used : ArrayList(java.util.ArrayList) StatementNode(cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode)

Example 5 with StatementNode

use of cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode in project TrufflePascal by Aspect26.

the class FatalError method MainFunction.

void MainFunction() {
    factory.startMainFunction();
    StatementNode blockNode = Block();
    mainNode = factory.finishMainFunction(blockNode);
    Expect(33);
}
Also used : StatementNode(cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode)

Aggregations

StatementNode (cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode)30 ArrayList (java.util.ArrayList)6 FrameSlot (com.oracle.truffle.api.frame.FrameSlot)2 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)1 BlockNode (cz.cuni.mff.d3s.trupple.language.nodes.statement.BlockNode)1 TypeDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor)1 EnumTypeDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.compound.EnumTypeDescriptor)1 ReturnTypeDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.subroutine.ReturnTypeDescriptor)1