summaryrefslogtreecommitdiff
path: root/minijava/TypeCheckSimp.java
diff options
context:
space:
mode:
authorbd-912 <bdunahu@colostate.edu>2024-03-23 21:09:05 -0600
committerbd-912 <bdunahu@colostate.edu>2024-03-23 21:09:05 -0600
commit762acb336997d43e15d64ff591103614abe4806f (patch)
treef2f02cc09b4ca81f6b06bc67d2f90df4a2fc9e81 /minijava/TypeCheckSimp.java
parent7a26f1108fb412daa4495628fc5136da2bb0ee34 (diff)
Added minor classname functionality to ST
Diffstat (limited to 'minijava/TypeCheckSimp.java')
-rw-r--r--minijava/TypeCheckSimp.java231
1 files changed, 118 insertions, 113 deletions
diff --git a/minijava/TypeCheckSimp.java b/minijava/TypeCheckSimp.java
index f9e71bd..4ad0639 100644
--- a/minijava/TypeCheckSimp.java
+++ b/minijava/TypeCheckSimp.java
@@ -8,11 +8,11 @@ import java.util.*;
* Provides default methods which visit each node in the tree in depth-first
* order. Your visitors may extend this class.
*/
-public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,TypeEnum>> {
+public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,TypeInstance>> {
private int offset;
- private void printNode(Node n, HashMap<String,TypeEnum> argu, boolean enter, TypeEnum consensus) {
+ private void printNode(Node n, HashMap<String,TypeInstance> argu, boolean enter, TypeEnum consensus) {
for (int i=0; i < this.offset; ++i)
System.out.print(".");
if (enter)
@@ -32,11 +32,11 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
//
// Auto class visitors--probably don't need to be overridden.
//
- public TypeInstance visit(NodeList n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(NodeList n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
- TypeInstance ret = new TypeInstance(TypeEnum.CHECK);
+ TypeInstance ret = new TypeInstance(null, TypeEnum.CHECK);
int _count=0;
for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
TypeInstance node = e.nextElement().accept(this,argu);
@@ -51,13 +51,13 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
return ret;
}
- public TypeInstance visit(NodeListOptional n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(NodeListOptional n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
TypeInstance ret;
- if ( n.present() ) { // FIXME "present" seems to check if any nodes exist at all!
- ret = new TypeInstance(TypeEnum.CHECK);
+ if ( n.present() ) {
+ ret = new TypeInstance(null, TypeEnum.CHECK);
int _count=0;
for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
TypeInstance node = e.nextElement().accept(this,argu);
@@ -67,7 +67,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
}
}
else
- ret = new TypeInstance(TypeEnum.CHECK); // FIXME used to read 'null'
+ ret = new TypeInstance(null, TypeEnum.CHECK);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
@@ -75,7 +75,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
}
// FIXME
- public TypeInstance visit(NodeOptional n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(NodeOptional n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -84,18 +84,18 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
if ( n.present() )
ret = n.node.accept(this,argu);
else
- ret = new TypeInstance(TypeEnum.CHECK);
+ ret = new TypeInstance(null, TypeEnum.CHECK);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
return ret;
}
- public TypeInstance visit(NodeSequence n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(NodeSequence n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
- TypeInstance ret = new TypeInstance(TypeEnum.CHECK);
+ TypeInstance ret = new TypeInstance(null, TypeEnum.CHECK);
int _count=0;
for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); ) {
TypeInstance node = e.nextElement().accept(this,argu);
@@ -109,7 +109,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
return ret;
}
- public TypeInstance visit(NodeToken n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(NodeToken n, HashMap<String,TypeInstance> argu) {
// A fixed string token. '⌣'
++this.offset;
// this.printNode(n, argu, false, null);
@@ -126,7 +126,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f1 -> ( TypeDeclaration() )*
* f2 -> <EOF>
*/
- public TypeInstance visit(Goal n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(Goal n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -159,7 +159,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f16 -> "}"
* f17 -> "}"
*/
- public TypeInstance visit(MainClass n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(MainClass n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -174,7 +174,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
n.f8.accept(this, argu);
n.f9.accept(this, argu);
n.f10.accept(this, argu);
- TypeInstance args = n.f11.accept(this, argu);
+ // TypeInstance args = n.f11.accept(this, argu);
n.f12.accept(this, argu);
n.f13.accept(this, argu);
TypeInstance var_dec = n.f14.accept(this, argu);
@@ -191,7 +191,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f0 -> ClassDeclaration()
* | ClassExtendsDeclaration()
*/
- public TypeInstance visit(TypeDeclaration n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(TypeDeclaration n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -210,19 +210,25 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f4 -> ( MethodDeclaration() )*
* f5 -> "}"
*/
- public TypeInstance visit(ClassDeclaration n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(ClassDeclaration n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
- TypeInstance _ret=null;
n.f0.accept(this, argu);
- n.f1.accept(this, argu);
+ TypeInstance id = n.f1.accept(this, argu);
n.f2.accept(this, argu);
- n.f3.accept(this, argu);
- n.f4.accept(this, argu);
+ TypeInstance vars = n.f3.accept(this, argu);
+ TypeInstance mehs = n.f4.accept(this, argu);
n.f5.accept(this, argu);
+ TypeInstance ret = (id.get_type() == TypeEnum.classname &&
+ vars.has_checked() &&
+ mehs.has_checked()) ?
+ new TypeInstance(null, TypeEnum.CHECK) :
+ new TypeInstance(null, TypeEnum.ERROR);
+
+ this.printNode(n, argu, false, ret.get_type());
--this.offset;
- return _ret;
+ return ret;
}
/**
@@ -235,7 +241,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f6 -> ( MethodDeclaration() )*
* f7 -> "}"
*/
- public TypeInstance visit(ClassExtendsDeclaration n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(ClassExtendsDeclaration n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -258,7 +264,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f1 -> Identifier()
* f2 -> ";"
*/
- public TypeInstance visit(VarDeclaration n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(VarDeclaration n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -287,7 +293,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f11 -> ";"
* f12 -> "}"
*/
- public TypeInstance visit(MethodDeclaration n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(MethodDeclaration n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -305,9 +311,9 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
n.f11.accept(this, argu);
n.f12.accept(this, argu);
TypeInstance ret = (stmt.equal_type(ret_type) &&
- stmt.get_type() == TypeEnum.CHECK) ?
- new TypeInstance(TypeEnum.CHECK) :
- new TypeInstance(TypeEnum.ERROR);
+ stmt.has_checked()) ?
+ new TypeInstance(null, TypeEnum.CHECK) :
+ new TypeInstance(null, TypeEnum.ERROR);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
@@ -318,17 +324,17 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f0 -> FormalParameter()
* f1 -> ( FormalParameterRest() )*
*/
- public TypeInstance visit(FormalParameterList n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(FormalParameterList n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
TypeInstance _ret=null;
TypeInstance para1 = n.f0.accept(this, argu);
TypeInstance parar = n.f1.accept(this, argu);
- TypeInstance ret = (para1.get_type() == TypeEnum.CHECK &&
- parar.get_type() == TypeEnum.CHECK) ?
- new TypeInstance(TypeEnum.CHECK) :
- new TypeInstance(TypeEnum.ERROR);
+ TypeInstance ret = (para1.has_checked() &&
+ parar.has_checked()) ?
+ new TypeInstance(null, TypeEnum.CHECK) :
+ new TypeInstance(null, TypeEnum.ERROR);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
@@ -339,7 +345,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f0 -> Type()
* f1 -> Identifier()
*/
- public TypeInstance visit(FormalParameter n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(FormalParameter n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -355,7 +361,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f0 -> ","
* f1 -> FormalParameter()
*/
- public TypeInstance visit(FormalParameterRest n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(FormalParameterRest n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -373,7 +379,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* | IntegerType()
* | Identifier()
*/
- public TypeInstance visit(Type n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(Type n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -389,11 +395,11 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f1 -> "["
* f2 -> "]"
*/
- public TypeInstance visit(ArrayType n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(ArrayType n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
- TypeInstance ret = new TypeInstance(TypeEnum.int_array);
+ TypeInstance ret = new TypeInstance(null, TypeEnum.int_array);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
@@ -403,11 +409,11 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
/**
* f0 -> "boolean"
*/
- public TypeInstance visit(BooleanType n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(BooleanType n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
- TypeInstance ret = new TypeInstance(TypeEnum.bool);
+ TypeInstance ret = new TypeInstance(null, TypeEnum.bool);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
@@ -417,11 +423,11 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
/**
* f0 -> "int"
*/
- public TypeInstance visit(IntegerType n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(IntegerType n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
- TypeInstance ret = new TypeInstance(TypeEnum.integer);
+ TypeInstance ret = new TypeInstance(null, TypeEnum.integer);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
@@ -436,7 +442,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* | WhileStatement()
* | PrintStatement()
*/
- public TypeInstance visit(Statement n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(Statement n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -452,7 +458,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f1 -> ( Statement() )*
* f2 -> "}"
*/
- public TypeInstance visit(Block n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(Block n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -475,7 +481,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f2 -> Expression()
* f3 -> ";"
*/
- public TypeInstance visit(AssignmentStatement n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(AssignmentStatement n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -484,8 +490,8 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
TypeInstance rhs = n.f2.accept(this, argu);
n.f3.accept(this, argu);
TypeInstance ret = (lhs.equal_type(rhs)) ?
- new TypeInstance(TypeEnum.CHECK) :
- new TypeInstance(TypeEnum.ERROR);
+ new TypeInstance(null, TypeEnum.CHECK) :
+ new TypeInstance(null, TypeEnum.ERROR);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
@@ -504,12 +510,11 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f5 -> Expression()
* f6 -> ";"
*/
- public TypeInstance visit(ArrayAssignmentStatement n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(ArrayAssignmentStatement n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
- TypeInstance id = new TypeInstance(argu.get(n.f0.f0.tokenImage));
- n.f0.accept(this, argu);
+ TypeInstance id = n.f0.accept(this, argu);
n.f1.accept(this, argu);
TypeInstance index = n.f2.accept(this, argu);
n.f3.accept(this, argu);
@@ -519,8 +524,8 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
TypeInstance ret = (id.get_type() == TypeEnum.int_array &&
index.get_type() == TypeEnum.integer &&
value.get_type() == TypeEnum.integer) ?
- new TypeInstance(TypeEnum.CHECK) :
- new TypeInstance(TypeEnum.ERROR);
+ new TypeInstance(null, TypeEnum.CHECK) :
+ new TypeInstance(null, TypeEnum.ERROR);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
@@ -538,7 +543,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f5 -> "else"
* f6 -> Statement()
*/
- public TypeInstance visit(IfStatement n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(IfStatement n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -551,9 +556,9 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
TypeInstance stmt2 = n.f6.accept(this, argu);
TypeInstance ret = (expr.get_type() == TypeEnum.bool &&
stmt1.get_type() == stmt2.get_type() &&
- stmt1.get_type() == TypeEnum.CHECK) ?
- new TypeInstance(TypeEnum.CHECK) :
- new TypeInstance(TypeEnum.ERROR);
+ stmt1.has_checked()) ?
+ new TypeInstance(null, TypeEnum.CHECK) :
+ new TypeInstance(null, TypeEnum.ERROR);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
@@ -570,7 +575,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f3 -> ")"
* f4 -> Statement()
*/
- public TypeInstance visit(WhileStatement n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(WhileStatement n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -580,9 +585,9 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
n.f3.accept(this, argu);
TypeInstance stmt = n.f4.accept(this, argu);
TypeInstance ret = (expr.get_type() == TypeEnum.bool &&
- stmt.get_type() == TypeEnum.CHECK) ?
- new TypeInstance(TypeEnum.CHECK) :
- new TypeInstance(TypeEnum.ERROR);
+ stmt.has_checked()) ?
+ new TypeInstance(null, TypeEnum.CHECK) :
+ new TypeInstance(null, TypeEnum.ERROR);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
@@ -598,7 +603,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f3 -> ")"
* f4 -> ";"
*/
- public TypeInstance visit(PrintStatement n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(PrintStatement n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -608,8 +613,8 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
n.f3.accept(this, argu);
n.f4.accept(this, argu);
ret = (ret.get_type() == TypeEnum.integer) ?
- new TypeInstance(TypeEnum.CHECK) :
- new TypeInstance(TypeEnum.ERROR);
+ new TypeInstance(null, TypeEnum.CHECK) :
+ new TypeInstance(null, TypeEnum.ERROR);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
@@ -627,7 +632,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* | MessageSend()
* | PrimaryExpression()
*/
- public TypeInstance visit(Expression n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(Expression n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -645,7 +650,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f1 -> "&&"
* f2 -> PrimaryExpression()
*/
- public TypeInstance visit(AndExpression n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(AndExpression n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -654,8 +659,8 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
TypeInstance oper2 = n.f2.accept(this, argu);
TypeInstance ret = (oper1.get_type() == TypeEnum.bool &&
oper2.get_type() == TypeEnum.bool) ?
- new TypeInstance(TypeEnum.bool) :
- new TypeInstance(TypeEnum.ERROR);
+ new TypeInstance(null, TypeEnum.bool) :
+ new TypeInstance(null, TypeEnum.ERROR);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
@@ -669,7 +674,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f1 -> "<"
* f2 -> PrimaryExpression()
*/
- public TypeInstance visit(CompareExpression n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(CompareExpression n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -678,8 +683,8 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
TypeInstance oper2 = n.f2.accept(this, argu);
TypeInstance ret = (oper1.get_type() == TypeEnum.integer &&
oper2.get_type() == TypeEnum.integer) ?
- new TypeInstance(TypeEnum.bool) :
- new TypeInstance(TypeEnum.ERROR);
+ new TypeInstance(null, TypeEnum.bool) :
+ new TypeInstance(null, TypeEnum.ERROR);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
@@ -693,7 +698,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f1 -> "+"
* f2 -> PrimaryExpression()
*/
- public TypeInstance visit(PlusExpression n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(PlusExpression n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -702,8 +707,8 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
TypeInstance oper2 = n.f2.accept(this, argu);
TypeInstance ret = (oper1.get_type() == TypeEnum.integer &&
oper2.get_type() == TypeEnum.integer) ?
- new TypeInstance(TypeEnum.integer) :
- new TypeInstance(TypeEnum.ERROR);
+ new TypeInstance(null, TypeEnum.integer) :
+ new TypeInstance(null, TypeEnum.ERROR);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
@@ -717,7 +722,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f1 -> "-"
* f2 -> PrimaryExpression()
*/
- public TypeInstance visit(MinusExpression n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(MinusExpression n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -726,8 +731,8 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
TypeInstance oper2 = n.f2.accept(this, argu);
TypeInstance ret = (oper1.get_type() == TypeEnum.integer &&
oper2.get_type() == TypeEnum.integer) ?
- new TypeInstance(TypeEnum.integer) :
- new TypeInstance(TypeEnum.ERROR);
+ new TypeInstance(null, TypeEnum.integer) :
+ new TypeInstance(null, TypeEnum.ERROR);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
@@ -741,7 +746,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f1 -> "*"
* f2 -> PrimaryExpression()
*/
- public TypeInstance visit(TimesExpression n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(TimesExpression n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -750,8 +755,8 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
TypeInstance oper2 = n.f2.accept(this, argu);
TypeInstance ret = (oper1.get_type() == TypeEnum.integer &&
oper2.get_type() == TypeEnum.integer) ?
- new TypeInstance(TypeEnum.integer) :
- new TypeInstance(TypeEnum.ERROR);
+ new TypeInstance(null, TypeEnum.integer) :
+ new TypeInstance(null, TypeEnum.ERROR);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
@@ -767,7 +772,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f2 -> PrimaryExpression()
* f3 -> "]"
*/
- public TypeInstance visit(ArrayLookup n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(ArrayLookup n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -777,8 +782,8 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
n.f3.accept(this, argu);
TypeInstance ret = (array.get_type() == TypeEnum.int_array &&
index.get_type() == TypeEnum.integer) ?
- new TypeInstance(TypeEnum.integer) :
- new TypeInstance(TypeEnum.ERROR);
+ new TypeInstance(null, TypeEnum.integer) :
+ new TypeInstance(null, TypeEnum.ERROR);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
@@ -792,15 +797,15 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f1 -> "."
* f2 -> "length"
*/
- public TypeInstance visit(ArrayLength n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(ArrayLength n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
TypeInstance ret = n.f0.accept(this, argu);
n.f1.accept(this, argu);
n.f2.accept(this, argu);
- ret = (ret.get_type() == TypeEnum.int_array) ? new TypeInstance(TypeEnum.integer) :
- new TypeInstance(TypeEnum.ERROR);
+ ret = (ret.get_type() == TypeEnum.int_array) ? new TypeInstance(null, TypeEnum.integer) :
+ new TypeInstance(null, TypeEnum.ERROR);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
@@ -818,7 +823,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f4 -> ( ExpressionList() )?
* f5 -> ")"
*/
- public TypeInstance visit(MessageSend n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(MessageSend n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -838,16 +843,16 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f0 -> Expression()
* f1 -> ( ExpressionRest() )*
*/
- public TypeInstance visit(ExpressionList n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(ExpressionList n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
TypeInstance expr1 = n.f0.accept(this, argu);
TypeInstance exprr = n.f1.accept(this, argu);
- TypeInstance ret = (expr1.get_type() == TypeEnum.CHECK &&
- exprr.get_type() == TypeEnum.CHECK) ?
- new TypeInstance(TypeEnum.CHECK) :
- new TypeInstance(TypeEnum.ERROR);
+ TypeInstance ret = (expr1.has_checked() &&
+ exprr.has_checked()) ?
+ new TypeInstance(null, TypeEnum.CHECK) :
+ new TypeInstance(null, TypeEnum.ERROR);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
@@ -858,7 +863,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f0 -> ","
* f1 -> Expression()
*/
- public TypeInstance visit(ExpressionRest n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(ExpressionRest n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -881,7 +886,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* | NotExpression()
* | BracketExpression()
*/
- public TypeInstance visit(PrimaryExpression n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(PrimaryExpression n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -898,13 +903,13 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
*
* f0 -> <INTEGER_LITERAL>
*/
- public TypeInstance visit(IntegerLiteral n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(IntegerLiteral n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
this.printNode(n, argu, false, TypeEnum.integer);
--this.offset;
- return new TypeInstance(TypeEnum.integer);
+ return new TypeInstance(null, TypeEnum.integer);
}
/**
@@ -912,13 +917,13 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
*
* f0 -> "true"
*/
- public TypeInstance visit(TrueLiteral n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(TrueLiteral n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
this.printNode(n, argu, false, TypeEnum.bool);
--this.offset;
- return new TypeInstance(TypeEnum.bool);
+ return new TypeInstance(null, TypeEnum.bool);
}
/**
@@ -926,13 +931,13 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
*
* f0 -> "false"
*/
- public TypeInstance visit(FalseLiteral n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(FalseLiteral n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
this.printNode(n, argu, false, TypeEnum.bool);
--this.offset;
- return new TypeInstance(TypeEnum.bool);
+ return new TypeInstance(null, TypeEnum.bool);
}
// FIXME
@@ -941,29 +946,29 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
*
* f0 -> <IDENTIFIER>
*/
- public TypeInstance visit(Identifier n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(Identifier n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
- TypeInstance ret = new TypeInstance(argu.get(n.f0.tokenImage));
+ TypeInstance ret = argu.get(n.f0.tokenImage);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
return ret;
}
- //FIXME FIXME FIXME
+ // FIXME FIXME FIXME
/**
* [40]: method exists? but where is the token?
*
* f0 -> "this"
*/
- public TypeInstance visit(ThisExpression n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(ThisExpression n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
n.f0.accept(this, argu);
- TypeInstance ret = new TypeInstance(TypeEnum.CHECK);
+ TypeInstance ret = new TypeInstance(null, TypeEnum.CHECK);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
@@ -979,7 +984,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f3 -> Expression()
* f4 -> "]"
*/
- public TypeInstance visit(ArrayAllocationExpression n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(ArrayAllocationExpression n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -988,15 +993,15 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
n.f2.accept(this, argu);
n.f3.accept(this, argu);
n.f4.accept(this, argu);
- ret = (ret.get_type() == TypeEnum.integer) ? new TypeInstance(TypeEnum.int_array) :
- new TypeInstance(TypeEnum.ERROR);
+ ret = (ret.get_type() == TypeEnum.integer) ? new TypeInstance(null, TypeEnum.int_array) :
+ new TypeInstance(null, TypeEnum.ERROR);
this.printNode(n, argu, false, ret.get_type());
--this.offset;
return ret;
}
- // FIXME FIXME FIXME
+ // FIXME
/**
* [42]:
*
@@ -1005,7 +1010,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f2 -> "("
* f3 -> ")"
*/
- public TypeInstance visit(AllocationExpression n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(AllocationExpression n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -1025,7 +1030,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f0 -> "!"
* f1 -> Expression()
*/
- public TypeInstance visit(NotExpression n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(NotExpression n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);
@@ -1034,7 +1039,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
this.printNode(n, argu, false, ret.get_type());
--this.offset;
- return (ret.get_type() == TypeEnum.bool) ? ret : new TypeInstance(TypeEnum.ERROR);
+ return (ret.get_type() == TypeEnum.bool) ? ret : new TypeInstance(null, TypeEnum.ERROR);
}
/**
@@ -1044,7 +1049,7 @@ public class TypeCheckSimp implements GJVisitor<TypeInstance,HashMap<String,Type
* f1 -> Expression()
* f2 -> ")"
*/
- public TypeInstance visit(BracketExpression n, HashMap<String,TypeEnum> argu) {
+ public TypeInstance visit(BracketExpression n, HashMap<String,TypeInstance> argu) {
++this.offset;
this.printNode(n, argu, true, null);