use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor 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);
}
use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor in project TrufflePascal by Aspect26.
the class NodeFactory method startUnitFunctionImplementation.
public void startUnitFunctionImplementation(FunctionHeading heading) {
String identifier = this.getIdentifierFromToken(heading.identifierToken);
TypeDescriptor returnTypeDescriptor = heading.returnTypeDescriptor;
try {
if (currentLexicalScope.containsLocalIdentifier(identifier) && !currentLexicalScope.isSubroutine(identifier)) {
parser.SemErr("Cannot implement. Not a function: " + identifier);
} else if (!currentLexicalScope.containsLocalIdentifier(identifier)) {
currentLexicalScope.forwardFunction(identifier, heading.formalParameters, returnTypeDescriptor);
}
currentLexicalScope = new LexicalScope(currentLexicalScope, identifier, parser.isUsingTPExtension());
currentLexicalScope.registerReturnVariable(currentLexicalScope.getName(), returnTypeDescriptor);
this.addParameterIdentifiersToLexicalScope(heading.formalParameters);
} catch (LexicalException e) {
parser.SemErr(e.getMessage());
}
}
use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor in project TrufflePascal by Aspect26.
the class NodeFactory method createReadDereferenceNode.
public ReadDereferenceNode createReadDereferenceNode(ExpressionNode pointerExpression) {
PointerDescriptor pointerDescriptor = null;
TypeDescriptor actualType = this.getActualType(pointerExpression.getType());
if (actualType instanceof PointerDescriptor) {
pointerDescriptor = (PointerDescriptor) actualType;
} else {
parser.SemErr("Can not dereference this type");
}
TypeDescriptor returnType = (pointerDescriptor != null) ? pointerDescriptor.getInnerTypeDescriptor() : null;
return ReadDereferenceNodeGen.create(pointerExpression, returnType);
}
use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor in project TrufflePascal by Aspect26.
the class FatalError method EnumDefinition.
TypeDescriptor EnumDefinition() {
TypeDescriptor typeDescriptor;
List<String> enumIdentifiers = new ArrayList<>();
Expect(6);
Expect(1);
enumIdentifiers.add(factory.getIdentifierFromToken(t));
while (la.kind == 10) {
Get();
Expect(1);
enumIdentifiers.add(factory.getIdentifierFromToken(t));
}
Expect(7);
typeDescriptor = factory.registerEnum(enumIdentifiers);
return typeDescriptor;
}
use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor in project TrufflePascal by Aspect26.
the class FatalError method Type.
TypeDescriptor Type() {
TypeDescriptor typeDescriptor;
typeDescriptor = null;
if (isSubrange()) {
typeDescriptor = SubrangeType();
} else if (la.kind == 1) {
Get();
typeDescriptor = factory.getTypeDescriptor(t);
} else if (la.kind == 6) {
typeDescriptor = EnumDefinition();
} else if (la.kind == 16 || la.kind == 17) {
List<OrdinalDescriptor> ordinalDimensions = ArrayDefinition();
while (continuesArray()) {
Expect(14);
List<OrdinalDescriptor> additionalDimensions = ArrayDefinition();
ordinalDimensions.addAll(additionalDimensions);
}
Expect(14);
Expect(1);
typeDescriptor = factory.createArray(ordinalDimensions, t);
} else if (la.kind == 15) {
Get();
Expect(14);
OrdinalDescriptor ordinal = Ordinal();
typeDescriptor = factory.createSetType(ordinal);
} else if (la.kind == 20) {
typeDescriptor = FileType();
} else if (la.kind == 21) {
typeDescriptor = RecordType();
} else if (la.kind == 23) {
typeDescriptor = PointerType();
} else
SynErr(73);
return typeDescriptor;
}
Aggregations