use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.compound.RecordDescriptor in project TrufflePascal by Aspect26.
the class NodeFactory method createReadFromRecordNode.
public ReadFromRecordNode createReadFromRecordNode(ExpressionNode recordExpression, Token identifierToken) {
TypeDescriptor descriptor = this.getActualType(recordExpression.getType());
String identifier = this.getIdentifierFromToken(identifierToken);
TypeDescriptor returnType = null;
if (!(descriptor instanceof RecordDescriptor)) {
parser.SemErr("Can not access non record type this way");
} else {
RecordDescriptor accessedRecordDescriptor = (RecordDescriptor) descriptor;
if (!accessedRecordDescriptor.containsIdentifier(identifier)) {
parser.SemErr("The record does not contain this identifier");
} else {
returnType = accessedRecordDescriptor.getLexicalScope().getIdentifierDescriptor(identifier);
}
}
return ReadFromRecordNodeGen.create(recordExpression, returnType, identifier);
}
use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.compound.RecordDescriptor in project TrufflePascal by Aspect26.
the class NodeFactory method stepIntoRecordElementScope.
private FrameSlot stepIntoRecordElementScope(String recordIdentifier) throws LexicalException {
TypeDescriptor recordDescriptor = this.currentLexicalScope.getIdentifierDescriptor(recordIdentifier);
if (recordDescriptor == null || !(recordDescriptor instanceof RecordDescriptor)) {
throw new LexicalException("Not a record: " + recordIdentifier);
} else {
FrameSlot recordSlot = this.currentLexicalScope.getLocalSlot(recordIdentifier);
this.currentLexicalScope = ((RecordDescriptor) recordDescriptor).getLexicalScope();
return recordSlot;
}
}
use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.compound.RecordDescriptor in project TrufflePascal by Aspect26.
the class NodeFactory method createAssignmentToRecordField.
private StatementNode createAssignmentToRecordField(ExpressionNode recordExpression, Token identifierToken, ExpressionNode valueNode) {
String identifier = this.getIdentifierFromToken(identifierToken);
TypeDescriptor expressionType = getActualType(recordExpression.getType());
if (!(expressionType instanceof RecordDescriptor)) {
parser.SemErr("Not a record");
}
return AssignToRecordFieldNodeGen.create(identifier, recordExpression, valueNode);
}
Aggregations