summaryrefslogtreecommitdiff
path: root/heat/HeatVisitor.java
diff options
context:
space:
mode:
authorbd-912 <bdunahu@colostate.edu>2024-04-26 19:36:16 -0600
committerbd-912 <bdunahu@colostate.edu>2024-04-26 19:36:16 -0600
commite2d7b563cd22b92604e07dad9bf6bcf0393a46ca (patch)
tree539f081c254d31afe9574fa42f5629971d8a9eb5 /heat/HeatVisitor.java
parent42512ab2cfd16422909263475b044f40b3829707 (diff)
HeatVisitor MessageSend anonymous, observe Factorial + others pass
Diffstat (limited to 'heat/HeatVisitor.java')
-rw-r--r--heat/HeatVisitor.java33
1 files changed, 19 insertions, 14 deletions
diff --git a/heat/HeatVisitor.java b/heat/HeatVisitor.java
index ba739c9..584eaec 100644
--- a/heat/HeatVisitor.java
+++ b/heat/HeatVisitor.java
@@ -208,7 +208,7 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> {
n.getClass().getSimpleName(),
id));
///////////////////////////////////////////////////////////////
- _ret = n.f0.accept(this, argu);
+ // f0.accept(this, argu);
///////////////////////////////////////////////////////////////
MinimalLogger.info(String.format("<- %s (%s)",
n.getClass().getSimpleName(),
@@ -428,10 +428,13 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> {
MinimalLogger.info(String.format("-> %s",
n.getClass().getSimpleName()));
///////////////////////////////////////////////////////////////
- TypeBundle tb = new TypeBundle(this.symt.getType(id).getType(), null);
- if (tb.getType() == null)
+ TypeInstance t = this.symt.getType(id);
+ if (t == null)
+ t = this.symt.getTypeAttr(id);
+ if (t.getType() == null)
throw new TypecheckException(String.format("%s glowers at symbol table!",
n.getClass().getSimpleName()));
+ TypeBundle tb = new TypeBundle(t.getType(), null);
// Fixme---add subtyping?
_ret = n.f2.accept(this, argu);
@@ -587,7 +590,7 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> {
///////////////////////////////////////////////////////////////
TypeBundle tb = n.f0.accept(this, argu);
_ret = n.f2.accept(this, argu);
- if (!tb.isBool() || _ret.isBool())
+ if (!tb.isBool() || !_ret.isBool())
throw new TypecheckException(String.format("%s tried with something other than an Boolean!",
n.getClass().getSimpleName()));
///////////////////////////////////////////////////////////////
@@ -609,7 +612,7 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> {
///////////////////////////////////////////////////////////////
TypeBundle tb = n.f0.accept(this, argu);
_ret = n.f2.accept(this, argu);
- if (!tb.isInt() || _ret.isInt())
+ if (!tb.isInt() || !_ret.isInt())
throw new TypecheckException(String.format("%s tried with something other than an integer!",
n.getClass().getSimpleName()));
_ret = new TypeBundle(TypeEnum.bool, null);
@@ -632,7 +635,7 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> {
///////////////////////////////////////////////////////////////
TypeBundle tb = n.f0.accept(this, argu);
_ret = n.f2.accept(this, argu);
- if (!tb.isInt() || _ret.isInt())
+ if (!tb.isInt() || !_ret.isInt())
throw new TypecheckException(String.format("%s tried with something other than an integer!",
n.getClass().getSimpleName()));
///////////////////////////////////////////////////////////////
@@ -654,7 +657,7 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> {
///////////////////////////////////////////////////////////////
TypeBundle tb = n.f0.accept(this, argu);
_ret = n.f2.accept(this, argu);
- if (!tb.isInt() || _ret.isInt())
+ if (!tb.isInt() || !_ret.isInt())
throw new TypecheckException(String.format("%s tried with something other than an integer!",
n.getClass().getSimpleName()));
///////////////////////////////////////////////////////////////
@@ -676,7 +679,7 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> {
///////////////////////////////////////////////////////////////
TypeBundle tb = n.f0.accept(this, argu);
_ret = n.f2.accept(this, argu);
- if (!tb.isInt() || _ret.isInt())
+ if (!tb.isInt() || !_ret.isInt())
throw new TypecheckException(String.format("%s tried with something other than an integer!",
n.getClass().getSimpleName()));
///////////////////////////////////////////////////////////////
@@ -759,6 +762,7 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> {
case 6:
MinimalLogger.info(String.format("Message send found ANONYMOUS"));
t = new TypeInstance("null",null,null,null);
+ t.addClassInstance((ClassInstance) this.symt.getClass(((AllocationExpression) (n.f0.f0.choice)).f1.f0.tokenImage));
break;
case 8:
MinimalLogger.info(String.format("Message send found BRACKET"));
@@ -914,9 +918,8 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> {
MinimalLogger.info(String.format("-> %s",
n.getClass().getSimpleName()));
///////////////////////////////////////////////////////////////
- if (true)
- throw new TypecheckException("Identifier says: stop calling me!");
- n.f0.accept(this, argu);
+ TypeInstance t = this.symt.getType(n.f0.tokenImage);
+ _ret = new TypeBundle(t.getType(), t.getClassInstance());
///////////////////////////////////////////////////////////////
MinimalLogger.info(String.format("<- %s with %s",
n.getClass().getSimpleName(),
@@ -972,10 +975,12 @@ public class HeatVisitor extends GJDepthFirst<TypeBundle,String> {
*/
public TypeBundle visit(AllocationExpression n, String argu) {
TypeBundle _ret=null;
- MinimalLogger.info(String.format("-> %s",
- n.getClass().getSimpleName()));
+ String id = n.f1.f0.tokenImage;
+ MinimalLogger.info(String.format("-> %s (%s)",
+ n.getClass().getSimpleName(),
+ id));
///////////////////////////////////////////////////////////////
- n.f1.accept(this, argu);
+ _ret = new TypeBundle(TypeEnum.classname, this.symt.getClass(id));
///////////////////////////////////////////////////////////////
MinimalLogger.info(String.format("<- %s with %s",
n.getClass().getSimpleName(),