use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.ReferenceDescriptor 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 cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.ReferenceDescriptor in project TrufflePascal by Aspect26.
the class NodeFactory method createSimpleAssignment.
private StatementNode createSimpleAssignment(Token identifierToken, ExpressionNode valueNode) {
String variableIdentifier = this.getIdentifierFromToken(identifierToken);
FrameSlot frameSlot = this.doLookup(variableIdentifier, LexicalScope::getLocalSlot, true);
TypeDescriptor targetType = this.doLookup(variableIdentifier, LexicalScope::getIdentifierDescriptor, true);
this.checkTypesAreCompatible(valueNode.getType(), targetType);
return (targetType instanceof ReferenceDescriptor) ? AssignReferenceNodeGen.create(valueNode, frameSlot) : SimpleAssignmentNodeGen.create(valueNode, frameSlot);
}
Aggregations