MCPcopy Create free account
hub / github.com/chibash/stone / typeCheck

Method typeCheck

src/chap14/TypeChecker.java:65–82  ·  view source on GitHub ↗
(TypeEnv tenv)

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 7

typeCheckForAssignMethod · 0.95
operatorMethod · 0.80
leftMethod · 0.80
rightMethod · 0.80
typeCheckMethod · 0.45
plusMethod · 0.45
assertSubtypeOfMethod · 0.45

Tested by

no test coverage detected