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

Method typeCheck

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

Source from the content-addressed store, hash-verified

131 protected TypeEnv bodyEnv;
132 public DefStmntEx2(List<ASTree> c) { super(c); }
133 public TypeInfo typeCheck(TypeEnv tenv) throws TypeException {
134 TypeInfo[] params = ((ParamListEx2)parameters()).types();
135 TypeInfo retType = TypeInfo.get(type());
136 funcType = TypeInfo.function(retType, params);
137 TypeInfo oldType = tenv.put(0, index, funcType);
138 if (oldType != null)
139 throw new TypeException("function redefinition: " + name(),
140 this);
141 bodyEnv = new TypeEnv(size, tenv);
142 for (int i = 0; i < params.length; i++)
143 bodyEnv.put(0, i, params[i]);
144 TypeInfo bodyType
145 = ((ASTreeTypeEx)revise(body())).typeCheck(bodyEnv);
146 bodyType.assertSubtypeOf(retType, tenv, this);
147 return funcType;
148 }
149 }
150 @Reviser
151 public static class ParamListEx2 extends TypedEvaluator.ParamListEx {

Callers

nothing calls this directly

Calls 10

getMethod · 0.95
functionMethod · 0.95
assertSubtypeOfMethod · 0.95
typesMethod · 0.80
putMethod · 0.65
parametersMethod · 0.45
typeMethod · 0.45
nameMethod · 0.45
typeCheckMethod · 0.45
bodyMethod · 0.45

Tested by

no test coverage detected