(TypeEnv tenv)
| 63 | protected TypeInfo leftType, rightType; |
| 64 | public BinaryEx(List<ASTree> c) { super(c); } |
| 65 | public TypeInfo typeCheck(TypeEnv tenv) throws TypeException { |
| 66 | String op = operator(); |
| 67 | if ("=".equals(op)) |
| 68 | return typeCheckForAssign(tenv); |
| 69 | else { |
| 70 | leftType = ((ASTreeTypeEx)left()).typeCheck(tenv); |
| 71 | rightType = ((ASTreeTypeEx)right()).typeCheck(tenv); |
| 72 | if ("+".equals(op)) |
| 73 | return leftType.plus(rightType, tenv); |
| 74 | else if ("==".equals(op)) |
| 75 | return TypeInfo.INT; |
| 76 | else { |
| 77 | leftType.assertSubtypeOf(TypeInfo.INT, tenv, this); |
| 78 | rightType.assertSubtypeOf(TypeInfo.INT, tenv, this); |
| 79 | return TypeInfo.INT; |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | protected TypeInfo typeCheckForAssign(TypeEnv tenv) |
| 84 | throws TypeException |
| 85 | { |
nothing calls this directly
no test coverage detected