Search in sources :

Example 1 with PointerDescriptor

use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.PointerDescriptor in project TrufflePascal by Aspect26.

the class StringBuiltinUnit method importTo.

@Override
public void importTo(UnitLexicalScope scope) {
    super.importTo(scope);
    try {
        scope.registerType("pchar", new PointerDescriptor(PCharDesriptor.getInstance()));
    } catch (LexicalException e) {
        throw new PascalRuntimeException("Could not import string unit: " + e.getMessage());
    }
    scope.markAllIdentifiersPublic();
}
Also used : LexicalException(cz.cuni.mff.d3s.trupple.parser.exceptions.LexicalException) PascalRuntimeException(cz.cuni.mff.d3s.trupple.language.runtime.exceptions.PascalRuntimeException) PointerDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.PointerDescriptor)

Example 2 with PointerDescriptor

use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.PointerDescriptor in project TrufflePascal by Aspect26.

the class BinaryExpressionNode method verifyBothCompatiblePointerTypes.

protected boolean verifyBothCompatiblePointerTypes(TypeDescriptor leftType, TypeDescriptor rightType) {
    if (!(leftType instanceof PointerDescriptor && rightType instanceof PointerDescriptor)) {
        return false;
    }
    TypeDescriptor leftInnerType = ((PointerDescriptor) leftType).getInnerTypeDescriptor();
    TypeDescriptor rightInnerType = ((PointerDescriptor) rightType).getInnerTypeDescriptor();
    return (leftInnerType == null) || (rightInnerType == null) || (rightInnerType.equals(leftInnerType));
}
Also used : TypeDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor) PointerDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.PointerDescriptor)

Example 3 with PointerDescriptor

use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.PointerDescriptor 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);
}
Also used : TypeDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor) PointerDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.PointerDescriptor)

Aggregations

PointerDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.PointerDescriptor)3 TypeDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor)2 PascalRuntimeException (cz.cuni.mff.d3s.trupple.language.runtime.exceptions.PascalRuntimeException)1 LexicalException (cz.cuni.mff.d3s.trupple.parser.exceptions.LexicalException)1