Commit 91c03ae2 by Tianqi Yang

fix(overload): add type FuncTableType to solve the type of Ident

Add type FuncTableType and return it in FunctionTable.getType Solve the null pointer return value at TypeCheck.visitIdent
parent 1df549be
...@@ -3,6 +3,7 @@ package decaf.symbol; ...@@ -3,6 +3,7 @@ package decaf.symbol;
import java.util.*; import java.util.*;
import decaf.scope.ClassScope; import decaf.scope.ClassScope;
import decaf.type.FuncTableType;
import decaf.type.FuncType; import decaf.type.FuncType;
public class FunctionTable extends Symbol { public class FunctionTable extends Symbol {
...@@ -32,8 +33,8 @@ public class FunctionTable extends Symbol { ...@@ -32,8 +33,8 @@ public class FunctionTable extends Symbol {
} }
@Override @Override
public FuncType getType() { public FuncTableType getType() {
return null; return new FuncTableType(name);
} }
@Override @Override
......
package decaf.type;
public class FuncTableType extends Type {
String name;
public FuncTableType (String name)
{
this.name = name;
}
public boolean isFuncTableType() {
return true;
}
public boolean compatible(Type type)
{
return equal (type);
}
public boolean equal(Type type)
{
return equals (type);
}
public String toString()
{
return name + "(...)";
}
}
...@@ -17,6 +17,10 @@ public abstract class Type { ...@@ -17,6 +17,10 @@ public abstract class Type {
return false; return false;
} }
public boolean isFuncTableType() {
return false;
}
public abstract boolean compatible(Type type); public abstract boolean compatible(Type type);
public abstract boolean equal(Type type); public abstract boolean equal(Type type);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment