Package compilation.analysis.semantic
Class TypeBinder
- java.lang.Object
-
- compilation.analysis.semantic.TypeBinder
-
public final class TypeBinder extends java.lang.ObjectThe TypeBinder class is used to identify if an operator and operand(s) are compatible with one another.Using pre-defined operator combinations, the class takes an operator and operand(s) and compares them against the corresponding pre-defined set. For example, to check whether an addition operator is valid to use between an integer and double. If true, an AnnotatedOperator object is returned. If false, null is returned.
- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description TypeBinder()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static @Nullable AnnotatedAssignmentOperatorbindAssignmentOperators(TokenType operatorType, ObjectType symbolType, ObjectType assignmentType)Attempts to bind an assignment operator to a symbol and assignment, returning an AnnotatedAssignmentOperator object if they are compatible.static @Nullable AnnotatedBinaryOperatorbindBinaryOperators(TokenType operatorType, ObjectType leftOperandType, ObjectType rightOperandType)Attempts to bind a two operands with an operator, returning an AnnotatedBinaryOperator object if they are compatible.static @Nullable AnnotatedUnaryOperatorbindUnaryOperators(TokenType operatorType, ObjectType operandType)Attempts to bind an operator to an operand, returning an AnnotatedUnaryOperator object if they are compatible.
-
-
-
Method Detail
-
bindUnaryOperators
@Nullable public static @Nullable AnnotatedUnaryOperator bindUnaryOperators(TokenType operatorType, ObjectType operandType)
Attempts to bind an operator to an operand, returning an AnnotatedUnaryOperator object if they are compatible.If the operator and operand are not compatible, null is returned.
- Parameters:
operatorType- The TokenType of the operatoroperandType- The ObjectType of the operand- Returns:
- An AnnotatedUnaryOperator object containing the expressions type enums
-
bindBinaryOperators
@Nullable public static @Nullable AnnotatedBinaryOperator bindBinaryOperators(TokenType operatorType, ObjectType leftOperandType, ObjectType rightOperandType)
Attempts to bind a two operands with an operator, returning an AnnotatedBinaryOperator object if they are compatible.If the operator and operands are not compatible, null is returned.
- Parameters:
operatorType- The TokenType of the operatorleftOperandType- The ObjectType of the left operandrightOperandType- The ObjectType of the right operand- Returns:
- An AnnotatedBinaryOperator object containing the expressions type enums
-
bindAssignmentOperators
@Nullable public static @Nullable AnnotatedAssignmentOperator bindAssignmentOperators(TokenType operatorType, ObjectType symbolType, ObjectType assignmentType)
Attempts to bind an assignment operator to a symbol and assignment, returning an AnnotatedAssignmentOperator object if they are compatible.If the operator, symbol, and assignment are not compatible, null is returned.
- Parameters:
operatorType- The TokenType of the operatorsymbolType- The ObjectType of the symbolassignmentType- The ObjectType of the assignment- Returns:
- An AnnotatedAssignmentOperator object containing the expressions type enums
-
-