summaryrefslogtreecommitdiff
path: root/st
diff options
context:
space:
mode:
Diffstat (limited to 'st')
-rw-r--r--st/SymbolTable.java60
1 files changed, 30 insertions, 30 deletions
diff --git a/st/SymbolTable.java b/st/SymbolTable.java
index fa196e3..0793a6a 100644
--- a/st/SymbolTable.java
+++ b/st/SymbolTable.java
@@ -52,10 +52,6 @@ public class SymbolTable {
ClassInstance cls = (ClassInstance) this.active.get(TypeEnum.classname);
ClassInstance ext = this.getClass(arg);
- if (ext == null)
- throw new TypecheckException(String.format("There is no %s to extend!",
- arg));
-
MinimalLogger.info(String.format("%s found to extend %s",
cls.getName(),
ext.getName()));
@@ -176,37 +172,41 @@ public class SymbolTable {
}
public TypeInstance getType(String name) {
- TokenKey id = new TokenKey(name,
- TypeEnum.integer,
- (ClassInstance) this.getActive(TypeEnum.classname),
- (MethodInstance) this.getActive(TypeEnum.method));
+ /**
+ * Extracts a 'type' (non-method,class) symbol from the
+ * symbol table, with proper scoping. Throws a typecheck error if missing.
+ */
+ TokenKey id;
+ // local var
+ id = new TokenKey(name,
+ TypeEnum.integer,
+ (ClassInstance) this.getActive(TypeEnum.classname),
+ (MethodInstance) this.getActive(TypeEnum.method));
AbstractInstance symbol;
TypeInstance ret = ((symbol = this.symt.get(id)) !=
null && symbol instanceof TypeInstance) ?
(TypeInstance) symbol : null;
if (ret == null)
- MinimalLogger.severe(String.format("getType returning null for missing alias %s!",
- id));
- return ret;
- }
-
- public TypeInstance getTypeAttr(String name) {
- TokenKey id = new TokenKey(name,
- TypeEnum.integer,
- (ClassInstance) this.getActive(TypeEnum.classname),
- null);
- AbstractInstance symbol;
- TypeInstance ret = ((symbol = this.symt.get(id)) !=
- null && symbol instanceof TypeInstance) ?
+ // class var
+ id = new TokenKey(name,
+ TypeEnum.integer,
+ (ClassInstance) this.getActive(TypeEnum.classname),
+ null);
+ ret = ((symbol = this.symt.get(id)) !=
+ null && symbol instanceof TypeInstance) ?
(TypeInstance) symbol : null;
if (ret == null)
- MinimalLogger.severe(String.format("getType returning null for missing alias %s!",
- id));
+ throw new TypecheckException(String.format("No type symbol with name %s was found in %s, %s!",
+ name, this.getActive(TypeEnum.classname),
+ this.getActive(TypeEnum.method)));
return ret;
}
-
public MethodInstance getMethod(String name) {
+ /**
+ * Extracts a 'method' (non-type,class) symbol from the
+ * symbol table, with proper scoping. Throws a typecheck error if missing.
+ */
TokenKey id = new TokenKey(name,
TypeEnum.method,
(ClassInstance) this.getActive(TypeEnum.classname),
@@ -216,8 +216,8 @@ public class SymbolTable {
null && symbol instanceof MethodInstance) ?
(MethodInstance) symbol : null;
if (ret == null)
- MinimalLogger.severe(String.format("getMethod returning null for missing alias %s!",
- id));
+ throw new TypecheckException(String.format("No method symbol with name %s was found in %s!",
+ name, this.getActive(TypeEnum.classname)));
return ret;
}
@@ -231,8 +231,8 @@ public class SymbolTable {
null && symbol instanceof MethodInstance) ?
(MethodInstance) symbol : null;
if (ret == null)
- MinimalLogger.severe(String.format("getMethod returning null for missing alias %s!",
- id));
+ throw new TypecheckException(String.format("No method symbol with name %s was found in %s!",
+ name, c));
return ret;
}
@@ -246,8 +246,8 @@ public class SymbolTable {
null && symbol instanceof ClassInstance) ?
(ClassInstance) symbol : null;
if (ret == null)
- MinimalLogger.severe(String.format("getClass returning null for missing alias %s!",
- id));
+ throw new TypecheckException(String.format("No class symbol with name %s was found!",
+ name));
return ret;
}