summaryrefslogtreecommitdiff
path: root/heat/HeatVisitor.java
diff options
context:
space:
mode:
Diffstat (limited to 'heat/HeatVisitor.java')
-rw-r--r--heat/HeatVisitor.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/heat/HeatVisitor.java b/heat/HeatVisitor.java
index 9886fdc..2e830c5 100644
--- a/heat/HeatVisitor.java
+++ b/heat/HeatVisitor.java
@@ -249,10 +249,9 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,ArrayList<TypeBundle>>
// NOT
// if it is a class and the classes are equal
// or it is not a class and the types are equal
- if (!((tb.getInstance() != null && tb.getInstance().equals(_ret.getInstance())) ||
- (tb.getInstance() == null && tb.getType() == _ret.getType())))
- throw new TypecheckException(String.format("%s returns the wrong type!",
- id));
+ if (!tb.equals(_ret))
+ throw new TypecheckException(String.format("%s in %s returns the wrong type!",
+ id, symt.getActive(TypeEnum.classname)));
///////////////////////////////////////////////////////////////
this.symt.removeActive(TypeEnum.method);
MinimalLogger.info(String.format("<- %s (%s)",
@@ -327,9 +326,14 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,ArrayList<TypeBundle>>
MinimalLogger.info(String.format("-> %s",
n.getClass().getSimpleName()));
///////////////////////////////////////////////////////////////
- if (n.f0.which == 3)
- _ret = new TypeBundle(TypeEnum.classname, this.symt.getClass(((Identifier) n.f0.choice).f0.tokenImage));
- else
+ if (n.f0.which == 3) {
+ String id = ((Identifier) n.f0.choice).f0.tokenImage;
+ ClassInstance c = this.symt.getClass(id);
+ if (c == null)
+ throw new TypecheckException(String.format("%s was never declared!",
+ id));
+ _ret = new TypeBundle(TypeEnum.classname, c);
+ } else
_ret = n.f0.accept(this, argu);
///////////////////////////////////////////////////////////////
MinimalLogger.info(String.format("<- %s with %s",
@@ -820,6 +824,8 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,ArrayList<TypeBundle>>
n.getClass().getSimpleName(),
t.getName()));
+ MinimalLogger.severe(String.format("Class instance was: %s", t.getClassInstance()));
+ MinimalLogger.severe(String.format("M was: %s with args %s", m, m.getParentClass()));
ArrayList<TypeBundle> actual = new ArrayList<TypeBundle>();
ArrayList<TypeBundle> expected = new ArrayList<TypeBundle>();
n.f4.accept(this, actual);