Example #1
0
 public TypeInfo typeCheck(TypeEnv tenv) throws TypeException {
   if (tenv.get(0, index) != null)
     throw new TypeException("duplicate variable: " + name(), this);
   varType = TypeInfo.get(type());
   tenv.put(0, index, varType);
   valueType = ((ASTreeTypeEx) initializer()).typeCheck(tenv);
   valueType.assertSubtypeOf(varType, tenv, this);
   return varType;
 }
Example #2
0
 public TypeInfo typeCheckForAssign(TypeEnv tenv, TypeInfo valueType) throws TypeException {
   type = tenv.get(nest, index);
   if (type == null) {
     type = valueType;
     tenv.put(0, index, valueType);
     return valueType;
   } else {
     valueType.assertSubtypeOf(type, tenv, this);
     return type;
   }
 }
Example #3
0
 public TypeInfo typeCheck(TypeEnv tenv) throws TypeException {
   type = tenv.get(nest, index);
   if (type == null) throw new TypeException("undefined name: " + name(), this);
   else return type;
 }