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