Search in sources :

Example 6 with FrameSlot

use of com.oracle.truffle.api.frame.FrameSlot in project TrufflePascal by Aspect26.

the class NodeFactory method createReadVariableFromScope.

private ExpressionNode createReadVariableFromScope(String identifier, LexicalScope scope) {
    // TODO: check if it is a constant or a variable
    FrameSlot variableSlot = scope.getLocalSlot(identifier);
    TypeDescriptor type = scope.getIdentifierDescriptor(identifier);
    boolean isLocal = scope == currentLexicalScope;
    boolean isReference = type instanceof ReferenceDescriptor;
    boolean isConstant = type instanceof ConstantDescriptor;
    if (isConstant) {
        ConstantDescriptor constantType = (ConstantDescriptor) type;
        return ReadConstantNodeGen.create(constantType.getValue(), constantType);
    } else if (isLocal) {
        if (isReference) {
            return ReadReferenceVariableNodeGen.create(variableSlot, type);
        } else {
            return ReadLocalVariableNodeGen.create(variableSlot, type);
        }
    } else {
        return ReadGlobalVariableNodeGen.create(variableSlot, type);
    }
}
Also used : FrameSlot(com.oracle.truffle.api.frame.FrameSlot) TypeDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor) ReferenceDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.ReferenceDescriptor)

Example 7 with FrameSlot

use of com.oracle.truffle.api.frame.FrameSlot in project TrufflePascal by Aspect26.

the class NodeFactory method addProgramArgumentsAssignmentNodes.

private void addProgramArgumentsAssignmentNodes() {
    int currentArgument = 0;
    for (String argumentIdentifier : this.mainProgramArgumentsIdentifiers) {
        FrameSlot argumentSlot = this.currentLexicalScope.getLocalSlot(argumentIdentifier);
        TypeDescriptor typeDescriptor = this.currentLexicalScope.getIdentifierDescriptor(argumentIdentifier);
        if (typeDescriptor != null) {
            if (ProgramArgumentAssignmentNode.supportsType(typeDescriptor)) {
                this.currentLexicalScope.addScopeInitializationNode(new ProgramArgumentAssignmentNode(argumentSlot, typeDescriptor, currentArgument++));
            }
        // TODO: else -> show warning
        }
    }
}
Also used : FrameSlot(com.oracle.truffle.api.frame.FrameSlot) TypeDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor)

Example 8 with FrameSlot

use of com.oracle.truffle.api.frame.FrameSlot in project TrufflePascal by Aspect26.

the class FatalError method WithStatement.

StatementNode WithStatement() {
    StatementNode statement;
    Expect(39);
    List<String> recordIdentifiers = IdentifiersList();
    LexicalScope initialScope = factory.getScope();
    List<FrameSlot> recordSlots = factory.stepIntoRecordsScope(recordIdentifiers);
    Expect(40);
    StatementNode innerStatement = Statement();
    factory.setScope(initialScope);
    statement = factory.createWithStatement(recordSlots, innerStatement);
    return statement;
}
Also used : FrameSlot(com.oracle.truffle.api.frame.FrameSlot) StatementNode(cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode)

Example 9 with FrameSlot

use of com.oracle.truffle.api.frame.FrameSlot in project graal by oracle.

the class BytecodeInterpreterPartialEvaluationTest method instArraySimpleIfProgram.

@Test
public void instArraySimpleIfProgram() {
    FrameDescriptor fd = new FrameDescriptor();
    FrameSlot valueSlot = fd.addFrameSlot("value", FrameSlotKind.Int);
    FrameSlot returnSlot = fd.addFrameSlot("return", FrameSlotKind.Int);
    Inst[] inst = new Inst[] { /* 0: */
    new Inst.Const(valueSlot, 1, 1), /* 1: */
    new Inst.IfZero(valueSlot, 2, 4), /* 2: */
    new Inst.Const(returnSlot, 41, 3), /* 3: */
    new Inst.Return(), /* 4: */
    new Inst.Const(returnSlot, 42, 5), /* 5: */
    new Inst.Return() };
    assertPartialEvalEqualsAndRunsCorrect(new InstArrayProgram("instArraySimpleIfProgram", inst, returnSlot, fd));
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) FrameSlot(com.oracle.truffle.api.frame.FrameSlot) Test(org.junit.Test)

Example 10 with FrameSlot

use of com.oracle.truffle.api.frame.FrameSlot in project graal by oracle.

the class FrameDescriptorTest method shallowCopy.

@Test
public void shallowCopy() {
    Object defaultValue = "default";
    FrameDescriptor d = new FrameDescriptor(defaultValue);
    s1 = d.addFrameSlot("v1", "i1", FrameSlotKind.Boolean);
    s2 = d.addFrameSlot("v2", "i2", FrameSlotKind.Float);
    assertEquals(2, d.getSize());
    final FrameSlot first = d.getSlots().get(1);
    assertEquals(first.getInfo(), "i2");
    assertEquals(first.getKind(), FrameSlotKind.Float);
    assertEquals(first.getIndex(), 1);
    FrameDescriptor copy = d.shallowCopy();
    assertEquals(2, copy.getSize());
    final FrameSlot firstCopy = copy.getSlots().get(1);
    assertEquals("Info is copied", firstCopy.getInfo(), "i2");
    assertEquals("Kind is copied", firstCopy.getKind(), FrameSlotKind.Float);
    assertEquals(firstCopy.getIndex(), 1);
    firstCopy.setKind(FrameSlotKind.Int);
    assertEquals("Kind is changed", firstCopy.getKind(), FrameSlotKind.Int);
    assertEquals("Kind is changed in original too!", first.getKind(), FrameSlotKind.Int);
}
Also used : FrameDescriptor(com.oracle.truffle.api.frame.FrameDescriptor) FrameSlot(com.oracle.truffle.api.frame.FrameSlot) Test(org.junit.Test)

Aggregations

FrameSlot (com.oracle.truffle.api.frame.FrameSlot)47 LLVMExpressionNode (com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode)12 PrimitiveType (com.oracle.truffle.llvm.runtime.types.PrimitiveType)11 PointerType (com.oracle.truffle.llvm.runtime.types.PointerType)10 FrameDescriptor (com.oracle.truffle.api.frame.FrameDescriptor)7 TypeDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor)7 StructureType (com.oracle.truffle.llvm.runtime.types.StructureType)6 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 Type (com.oracle.truffle.llvm.runtime.types.Type)5 CallTarget (com.oracle.truffle.api.CallTarget)4 TruffleRuntime (com.oracle.truffle.api.TruffleRuntime)3 RootNode (com.oracle.truffle.api.nodes.RootNode)3 Phi (com.oracle.truffle.llvm.parser.LLVMPhiManager.Phi)3 LLVMArithmeticInstructionType (com.oracle.truffle.llvm.parser.instructions.LLVMArithmeticInstructionType)3 LLVMConversionType (com.oracle.truffle.llvm.parser.instructions.LLVMConversionType)3 SymbolImpl (com.oracle.truffle.llvm.parser.model.SymbolImpl)3 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)2 Frame (com.oracle.truffle.api.frame.Frame)2 FrameInstance (com.oracle.truffle.api.frame.FrameInstance)2