Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * A structural type for an expression that has a getFirst and a getSecond method
- * which both return a Symbols.Type.
- */
- type TwoPartExpression = {
- def getFirst : Symbols.Type
- def getSecond : Symbols.Type
- }
- /**
- * Determines the type of the given two part expression's operands.
- *
- * If the types are divergent, throws an exception.
- */
- def expressionType(expression:TwoPartExpression) : Symbols.Type = {
- val (firstType, secondType) = (expression.getFirst, expression.getSecond)
- if (firstType == secondType)
- firstType
- else
- throw new Exception(...)
- }
Add Comment
Please, Sign In to add comment