From e5709fbc956d3395e7b401fd5198524e02542e81 Mon Sep 17 00:00:00 2001 From: bd-912 Date: Sun, 12 May 2024 13:30:35 -0600 Subject: Make (classinstance).send typecheck in HeatVisitor --- heat/HeatVisitor.java | 3 ++- output/ex16.java | 22 ++++++++++++++++++++++ output/negative/DumbBracketSend-error.java | 22 ++++++++++++++++++++++ output/negative/DumbSend-error.java | 22 ++++++++++++++++++++++ 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 output/ex16.java create mode 100644 output/negative/DumbBracketSend-error.java create mode 100644 output/negative/DumbSend-error.java diff --git a/heat/HeatVisitor.java b/heat/HeatVisitor.java index 41fd3fe..e02f0d2 100644 --- a/heat/HeatVisitor.java +++ b/heat/HeatVisitor.java @@ -784,7 +784,7 @@ public class HeatVisitor extends GJDepthFirst> t = new TypeInstance("null",null,null,null); ClassInstance c = this.recentClass; MinimalLogger.info(String.format("Setting class to the most recent return: %s", - c.toString())); + c)); t.addClassInstance(c); break; default: @@ -951,6 +951,7 @@ public class HeatVisitor extends GJDepthFirst> n.getClass().getSimpleName())); /////////////////////////////////////////////////////////////// TypeInstance t = this.symt.getType(n.f0.tokenImage); + this.recentClass = t.getClassInstance(); _ret = new TypeBundle(t.getType(), t.getClassInstance()); /////////////////////////////////////////////////////////////// MinimalLogger.info(String.format("<- %s with %s", diff --git a/output/ex16.java b/output/ex16.java new file mode 100644 index 0000000..71dcede --- /dev/null +++ b/output/ex16.java @@ -0,0 +1,22 @@ +class ex16 { + public static void main(String[] a){ + System.out.println(new Test().start()); + } +} + +class Test { + + Test test; + int[] i; + + public int start() { + i = new int[10]; + test = (test).next(); + return 0; + } + + public Test next() { + System.out.println(1); + return test; + } +} diff --git a/output/negative/DumbBracketSend-error.java b/output/negative/DumbBracketSend-error.java new file mode 100644 index 0000000..263f66f --- /dev/null +++ b/output/negative/DumbBracketSend-error.java @@ -0,0 +1,22 @@ +class ex19 { + public static void main(String[] a){ + System.out.println(new Test().start()); + } +} + +class Test { + + Test test; + int[] i; + + public int start() { + i = new int[10]; + test = (i).next(); + return 0; + } + + public Test next() { + System.out.println(1); + return test; + } +} diff --git a/output/negative/DumbSend-error.java b/output/negative/DumbSend-error.java new file mode 100644 index 0000000..529ad39 --- /dev/null +++ b/output/negative/DumbSend-error.java @@ -0,0 +1,22 @@ +class DumbSend { + public static void main(String[] a){ + System.out.println(new Test().start()); + } +} + +class Test { + + Test test; + int[] i; + + public int start() { + i = new int[10]; + test = i.next(); + return 0; + } + + public Test next() { + System.out.println(1); + return test; + } +} -- cgit v1.2.3