Skip to content
Snippets Groups Projects
Commit d6782d89 authored by Jan Gruteser's avatar Jan Gruteser
Browse files

replace unifications and setType in evalBoundedVariables

parent 3fc05d8a
No related branches found
No related tags found
No related merge requests found
...@@ -732,35 +732,18 @@ public class TypeChecker extends BuiltInOPs implements BBuildIns, TranslationGlo ...@@ -732,35 +732,18 @@ public class TypeChecker extends BuiltInOPs implements BBuildIns, TranslationGlo
if (params[i].length == 1) { if (params[i].length == 1) {
FormalParamNode p = params[i][0]; FormalParamNode p = params[i][0];
FunctionType expected = new FunctionType(IntType.getInstance(), new UntypedType()); FunctionType expected = new FunctionType(IntType.getInstance(), new UntypedType());
try { expected = (FunctionType) unify(expected, subType, "parameter " + p.getName(), bounds[i]);
expected = (FunctionType) expected.unify(subType);
} catch (UnificationException e) {
throw new TypeErrorException(String.format("Expected %s, found %s at parameter %s,%n%s",
expected, subType, p.getName().toString(), bounds[i].getLocation()));
}
domList.add(expected); domList.add(expected);
symbolNodeList.add(p); symbolNodeList.add(p);
p.setToolObject(TYPE_ID, expected.getRange()); setTypeAndFollowers(p, expected.getRange());
if (expected.getRange() instanceof AbstractHasFollowers) {
((AbstractHasFollowers) expected.getRange()).addFollower(p);
}
} else { } else {
TupleType tuple = new TupleType(params[i].length); TupleType tuple = new TupleType(params[i].length);
try { tuple = (TupleType) unify(tuple, subType, "tuple", bounds[i]);
tuple = (TupleType) tuple.unify(subType);
} catch (UnificationException e) {
throw new TypeErrorException(String.format("Expected %s, found %s at tuple,%n%s", tuple,
subType, bounds[i].getLocation()));
}
domList.add(tuple); domList.add(tuple);
for (int j = 0; j < params[i].length; j++) { for (int j = 0; j < params[i].length; j++) {
FormalParamNode p = params[i][j]; FormalParamNode p = params[i][j];
symbolNodeList.add(p); symbolNodeList.add(p);
TLAType paramType = tuple.getTypes().get(j); setTypeAndFollowers(p, tuple.getTypes().get(j));
p.setToolObject(TYPE_ID, paramType);
if (paramType instanceof AbstractHasFollowers) {
((AbstractHasFollowers) paramType).addFollower(p);
}
} }
} }
...@@ -771,10 +754,7 @@ public class TypeChecker extends BuiltInOPs implements BBuildIns, TranslationGlo ...@@ -771,10 +754,7 @@ public class TypeChecker extends BuiltInOPs implements BBuildIns, TranslationGlo
domList.add(subType); domList.add(subType);
FormalParamNode p = params[i][j]; FormalParamNode p = params[i][j];
symbolNodeList.add(p); symbolNodeList.add(p);
p.setToolObject(TYPE_ID, subType); setTypeAndFollowers(p, subType);
if (subType instanceof AbstractHasFollowers) {
((AbstractHasFollowers) subType).addFollower(p);
}
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment