diff options
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scala/tools/scalai/Code.java | 8 | ||||
-rw-r--r-- | sources/scala/tools/scalai/Compiler.java | 28 | ||||
-rw-r--r-- | sources/scala/tools/scalai/Evaluator.java | 199 | ||||
-rw-r--r-- | sources/scala/tools/scalai/EvaluatorException.java | 120 | ||||
-rw-r--r-- | sources/scala/tools/scalai/ExpressionCompiler.java | 14 | ||||
-rw-r--r-- | sources/scala/tools/scalai/Interpreter.java | 2 | ||||
-rw-r--r-- | sources/scala/tools/scalai/ScalaObject.java | 11 | ||||
-rw-r--r-- | sources/scala/tools/scalai/Variable.java | 17 |
8 files changed, 204 insertions, 195 deletions
diff --git a/sources/scala/tools/scalai/Code.java b/sources/scala/tools/scalai/Code.java index ac917211f9..44ae45d8c3 100644 --- a/sources/scala/tools/scalai/Code.java +++ b/sources/scala/tools/scalai/Code.java @@ -22,7 +22,7 @@ public class Code { public case Label(Symbol symbol, Variable[] variables, Code expression); public case Create(ScalaTemplate template); // !!! remove ? - public case Invoke(Code target, Function function, Code[] parameters, int pos, Symbol method); + public case Invoke(Code target, Function function, Code[] arguments, int pos); public case Load(Code target, Variable variable); public case Store(Code target, Variable variable, Code expression); @@ -68,12 +68,12 @@ public class Code { case Create(ScalaTemplate template): return "Create(" + template + ")"; - case Invoke(Code target, Function function, Code[] parameters, int pos, Symbol method): + case Invoke(Code target, Function function, Code[] arguments, int pos): StringBuffer buffer = new StringBuffer(); buffer.append("Invoke(" + target + "," + function + "," + "[\n"); - for (int i = 0; i < parameters.length; i++) { + for (int i = 0; i < arguments.length; i++) { if (i > 0) buffer.append(",\n"); - buffer.append(parameters[i]); + buffer.append(arguments[i]); } buffer.append("])"); return buffer.toString(); diff --git a/sources/scala/tools/scalai/Compiler.java b/sources/scala/tools/scalai/Compiler.java index f25fe10c6e..be58832dc8 100644 --- a/sources/scala/tools/scalai/Compiler.java +++ b/sources/scala/tools/scalai/Compiler.java @@ -30,6 +30,7 @@ import scalac.symtab.Symbol; import scalac.symtab.TermSymbol; import scalac.util.Debug; import scalac.util.Name; +import scalac.util.Names; import scalac.util.Position; public class Compiler { @@ -83,22 +84,25 @@ public class Compiler { } catch (Exception exception) { throw Debug.abort("equals", exception); } + // !!! should we have a symbol Any.equals as for hashcode and toString? + Symbol equals_symbol = + definitions.JAVA_OBJECT_CLASS.lookup(Names.equals); + assert equals_symbol != Symbol.NONE; CodePromise equals_code = new CodePromise( new CodeContainer( - null, // !!! + equals_symbol, Code.Invoke( Code.Invoke( Code.Null, Function.JavaMethod(getInvocationHandler_method), new Code[] { Code.Self}, - Position.NOPOS, null // !!! - ), + Position.NOPOS), Function.JavaMethod(equals_method), new Code[] { Code.Load( - Code.Null, Variable.Context(Evaluator.Levels.ARGS, 0))}, - Position.NOPOS, null), // !!! + Code.Null, Variable.Argument(0))}, + Position.NOPOS), 0)); // !!! any_methods.put(_, equals_code); any_methods.put(equals_method, equals_code); @@ -118,7 +122,7 @@ public class Compiler { definitions.HASHCODE, Code.Invoke( Code.Self, Function.HashCode, new Code[0], - Position.NOPOS, definitions.HASHCODE), + Position.NOPOS), 0)); any_methods.put(definitions.HASHCODE, hashCode_code); any_methods.put(hashCode_method, hashCode_code); @@ -142,7 +146,7 @@ public class Compiler { definitions.TOSTRING, Code.Invoke( Code.Self, Function.ToString, new Code[0], - Position.NOPOS, definitions.TOSTRING), + Position.NOPOS), 0)); any_methods.put(definitions.TOSTRING, toString_code); any_methods.put(toString_method, toString_code); @@ -171,8 +175,8 @@ public class Compiler { Code.Self, Function.JavaMethod(equals_method), new Code[] { Code.Load( Code.Null, - Variable.Context(Evaluator.Levels.ARGS, 0)) }, - Position.NOPOS, definitions.EQEQ), + Variable.Argument(0)) }, + Position.NOPOS), 0)); any_methods.put(definitions.EQEQ, eqeq_code); environment.insertFunction(definitions.EQEQ, Function.EqEq); @@ -188,11 +192,11 @@ public class Compiler { Code.Self, Function.EqEq, new Code[] { Code.Load( Code.Null, - Variable.Context(Evaluator.Levels.ARGS, 0)) }, - Position.NOPOS, definitions.BANGEQ)), + Variable.Argument(0)) }, + Position.NOPOS)), Function.JavaMethod(bang_method), new Code[0], - Position.NOPOS, definitions.BANGEQ), + Position.NOPOS), 0)); any_methods.put(definitions.BANGEQ, bangeq_code); environment.insertFunction(definitions.BANGEQ, Function.BangEq); diff --git a/sources/scala/tools/scalai/Evaluator.java b/sources/scala/tools/scalai/Evaluator.java index cdf1288390..9e5b98f6d8 100644 --- a/sources/scala/tools/scalai/Evaluator.java +++ b/sources/scala/tools/scalai/Evaluator.java @@ -17,7 +17,6 @@ import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import scala.runtime.RunTime; -import scala.MatchError; import scalac.symtab.Symbol; import scalac.util.Debug; @@ -25,16 +24,6 @@ import scalac.util.Debug; public class Evaluator { //######################################################################## - // Public Interfaces - - // !!! remove - public static interface Levels { - public static final int CLASS = 0; - public static final int ARGS = 1; // !!! use PARAM ? - public static final int BODY = 2; - } - - //######################################################################## // Private Classes // !!! remove ? @@ -50,33 +39,44 @@ public class Evaluator { } } + public static class EvaluationStack { + + public final EvaluationStack stack; + public final Symbol symbol; + public final Object self; + public final Object[] args; + public final Object[] vars; + + public EvaluationStack(EvaluationStack stack, CodeContainer code, + Object self, Object[] args) + { + this.stack = stack; + this.symbol = code.symbol; + this.self = self; + this.args = args; + this.vars = new Object[code.stacksize]; + } + + } + //######################################################################## // Private Fields - private final Object[][] variables; - private Object self; + private EvaluationStack stack; + private EvaluatorException trace; //######################################################################## // Public Constructors public Evaluator() { - this.variables = new Object[3][]; - this.variables[Levels.CLASS] = null; - this.variables[Levels.ARGS] = null; - this.variables[Levels.BODY] = null; - this.self = null; + this.stack = null; + this.trace = null; } //######################################################################## // Public Methods public Object evaluate(CodeContainer code) { - // !!! System.out.println("!!! EVALUATE"); - // !!! System.out.println("!!! size = " + size); - // !!! System.out.println("!!! code.symbol = " +Debug.show(code.symbol)); - // !!! System.out.println("!!! code.stacksize = " + code.stacksize); - // !!! System.out.println("!!! code.code = " + code.code); - // !!! System.out.println("!!! "); return evaluate(code, null, new Object[0]); } @@ -86,37 +86,10 @@ public class Evaluator { public Object evaluate(CodeContainer code, Object object, Object[] args) { try { - // !!! System.out.println("!!! EVALUATE"); - // !!! System.out.println("!!! code.symbol = " +Debug.show(code.symbol)); - // !!! for (int i = 0; i < args.length; i++) { - // !!! System.out.println("!!! arg" + i + " = " + Debug.show(args[i])); - // !!! } - // !!! System.out.println("!!! code.stacksize = " + code.stacksize); - // !!! System.out.println("!!! code.code = " + code.code); - // !!! System.out.println("!!! "); - - Object backup_self = self; - Object[] backup_args = variables[Levels.ARGS]; - Object[] backup_body = variables[Levels.BODY]; - self = object; - variables[Levels.ARGS] = args; - variables[Levels.BODY] = new Object[code.stacksize]; - Object result = evaluate(code.code); - self = backup_self; - variables[Levels.ARGS] = backup_args; - variables[Levels.BODY] = backup_body; - - // !!! System.out.println("!!! RETURN"); - // !!! System.out.println("!!! code.symbol = " +Debug.show(code.symbol)); - // !!! System.out.println("!!! result.class = " + Debug.show(result)); - - return result; - } catch (EvaluatorException exception) { - throw exception; - } catch (Error exception) { - throw exception; - } catch (Throwable exception) { - throw Debug.abort(exception); + stack = new EvaluationStack(stack, code, object, args); + return evaluate(code.code); + } finally { + stack = stack.stack; } } @@ -157,16 +130,15 @@ public class Evaluator { store(evaluate(target), variable, evaluate(expression)); return RunTime.box(); - case Invoke(Code target, Function function, Code[] parameters, int pos, Symbol method): + case Invoke(Code target, Function function, Code[] arguments, int pos): Object object = evaluate(target); - Object[] args = new Object[parameters.length]; - for (int i = 0; i < args.length; i++) { - args[i] = evaluate(parameters[i]); - } - try { // !!! indent + Object[] args = new Object[arguments.length]; + for (int i = 0; i < args.length; i++) + args[i] = evaluate(arguments[i]); + try { return invoke(object, function, args); } catch (EvaluatorException exception) { - exception.addCall(pos, method); + if (stack.symbol != null) exception.addScalaCall(stack.symbol, pos); // !!! remove test throw exception; } @@ -205,8 +177,7 @@ public class Evaluator { return null; case Self: - // !!! System.out.println("!!! Self: " + Debug.show(self)); - return self; + return stack.self; default: throw Debug.abort("illegal code", code); @@ -223,7 +194,6 @@ public class Evaluator { return evaluate(code, object, args); case Member(Symbol symbol): - // !!! handle case where object is null return getScalaObject(object).invoke(object, symbol, args); case Label(Symbol symbol): @@ -268,7 +238,7 @@ public class Evaluator { case Throw: assert args.length == 0 : Debug.show(args); assert object instanceof Throwable : object.getClass(); - throw new EvaluatorException((Throwable)object); + return throw_((Throwable)object); case StringPlus: assert args.length == 1 : Debug.show(args); @@ -285,11 +255,11 @@ public class Evaluator { case HashCode: assert args.length == 0 : Debug.show(args); - return new Integer(getScalaObject(object).hashCode()); + return new Integer(getHandlerObject(object).hashCode()); case ToString: assert args.length == 0 : Debug.show(args); - return getScalaObject(object).toString(); + return getHandlerObject(object).toString(); default: throw Debug.abort("illegal function", function); @@ -298,16 +268,11 @@ public class Evaluator { private Object invoke(Object object, Constructor constructor,Object[]args){ try { - // !!! System.out.println("!!! object " + (object == null ? "null" : object.getClass().getName())); - // !!! System.out.println("!!! constr " + constructor); - // !!! System.out.println("!!! nbargs " + args.length); return constructor.newInstance(args); - } catch (MatchError exception) { - return exception(exception); } catch (ExceptionInInitializerError exception) { - return exception(exception.getException()); + return throw_(exception); } catch (InvocationTargetException exception) { - return exception(exception.getTargetException()); + return throw_(exception); } catch (InstantiationException exception) { String msg1 = "\n object = " + Debug.show(object); String msg2 = "\n constr = " + Debug.show(constructor); @@ -329,14 +294,12 @@ public class Evaluator { private Object invoke(Object object, Method method, Object[] args) { try { return method.invoke(object, args); - } catch (MatchError exception) { - return exception(exception); } catch (NullPointerException exception) { - return exception(exception); + return throw_(exception); } catch (ExceptionInInitializerError exception) { - return exception(exception.getException()); + return throw_(exception); } catch (InvocationTargetException exception) { - return exception(exception.getTargetException()); + return throw_(exception); } catch (IllegalAccessException exception) { String msg1 = "\n object = " + Debug.show(object); String msg2 = "\n method = " + Debug.show(method); @@ -353,25 +316,24 @@ public class Evaluator { //######################################################################## // Private Methods - store - // !!! return void ? private Object store(Object object, Variable variable, Object value) { switch (variable) { case Global(_): return ((Variable.Global)variable).value = value; - case Context(int level, int index): - // !!! System.out.println("!!! store Context: level = " + level + ", index = " + index); - return variables[level][index] = value; - case Module(_, _): return ((Variable.Module)variable).value = value; case Member(int index): - // !!! handle case where object is null - // !!! System.out.println("!!! store Member: index = " + index + ", length = " + getScalaObject(object).variables.length); return getScalaObject(object).variables[index] = value; + case Argument(int index): + return stack.args[index] = value; + + case Local(int index): + return stack.vars[index] = value; + case JavaField(Field field): return store(object, field, value); @@ -385,9 +347,9 @@ public class Evaluator { field.set(object, value); return value; } catch (NullPointerException exception) { - return exception(exception); + return throw_(exception); } catch (ExceptionInInitializerError exception) { - return exception(exception.getException()); + return throw_(exception); } catch (IllegalAccessException exception) { String msg1 = "\n object = " + Debug.show(object); String msg2 = "\n field = " + Debug.show(field); @@ -410,9 +372,6 @@ public class Evaluator { case Global(Object value): return value; - case Context(int level, int index): - return variables[level][index]; - case Module(CodePromise body, Object value): if (value != null) return value; ((Variable.Module)variable).body = null; @@ -420,11 +379,14 @@ public class Evaluator { return load(object, variable); case Member(int index): - // !!! handle case where object is null - // !!! System.out.println("!!! loadScala: self = " + Debug.show(object) + ", index = " + index); - // !!! System.out.println("!!! loadScala: value = " + Debug.show(getScalaObject(object).variables[index])); return getScalaObject(object).variables[index]; + case Argument(int index): + return stack.args[index]; + + case Local(int index): + return stack.vars[index]; + case JavaField(Field field): return load(object, field); @@ -437,9 +399,9 @@ public class Evaluator { try { return field.get(object); } catch (NullPointerException exception) { - return exception(exception); + return throw_(exception); } catch (ExceptionInInitializerError exception) { - return exception(exception.getException()); + return throw_(exception); } catch (IllegalAccessException exception) { String msg1 = "\n object = " + Debug.show(object); String msg2 = "\n field = " + Debug.show(field); @@ -452,6 +414,20 @@ public class Evaluator { } //######################################################################## + // Private Methods - throw + + private Object throw_(Throwable exception) { + if (exception.getCause() != null && ( + exception instanceof ExceptionInInitializerError || + exception instanceof InvocationTargetException)) + exception = exception.getCause(); + if (trace == null || trace.getCause() != exception) + trace = new EvaluatorException(exception); + trace.addScalaLeavePoint(); + throw trace; + } + + //######################################################################## // Private Methods - box // !!! @@ -518,30 +494,15 @@ public class Evaluator { } private ScalaObject getScalaObject(Object object) { - if (object == null) - return (ScalaObject)exception(new NullPointerException()); // !!! - assert object instanceof Proxy : object.getClass(); - return (ScalaObject)Proxy.getInvocationHandler(object); + Object handler = getHandlerObject(object); + assert handler instanceof ScalaObject : handler.getClass(); + return (ScalaObject)handler; } - private Object exception(Throwable exception) { - // !!! return an exception result - if (exception instanceof EvaluatorException) { - throw (EvaluatorException)exception; - } - if (exception instanceof MatchError) { - throw new EvaluatorException(exception, new Error()); - } - if (exception instanceof Error) { - throw (Error)exception; - } - throw new EvaluatorException(exception, new Error()); - } - - // !!! remove ? - private Error abort(Exception exception) { - // !!! return an abort result ? - return Debug.abort(exception); + private Object getHandlerObject(Object object) { + if (object == null) return throw_(new NullPointerException()); + assert object instanceof Proxy : object.getClass(); + return Proxy.getInvocationHandler(object); } //######################################################################## diff --git a/sources/scala/tools/scalai/EvaluatorException.java b/sources/scala/tools/scalai/EvaluatorException.java index 4853bbcc9f..b262eac367 100644 --- a/sources/scala/tools/scalai/EvaluatorException.java +++ b/sources/scala/tools/scalai/EvaluatorException.java @@ -8,7 +8,8 @@ package scalai; -import java.util.Stack; +import java.util.List; +import java.util.ArrayList; import scalac.Global; import scalac.ast.parser.Sourcefile; @@ -20,66 +21,101 @@ public class EvaluatorException extends RuntimeException { //######################################################################## // Private Fields - private final Throwable exception; - private final Throwable cut; - private final Stack stack; // !!! rename ? - private final Stack symbols; + private final StackTraceElement[] trace; + private final List stack; + + private int stop; //######################################################################## // Public Constructors - public EvaluatorException(Throwable exception) { - this(exception, null); - } - - public EvaluatorException(Throwable exception, Throwable cut) { - this.exception = exception; - this.cut = cut; - this.stack = new Stack(); - this.symbols = new Stack(); + public EvaluatorException(Throwable cause) { + super(cause); + this.trace = getTraceOf(cause); + this.stack = new ArrayList(); + this.stop = trace.length; } //######################################################################## // Public Methods - public void addCall(int pos, Symbol symbol) { - stack.push(new Integer(pos)); - symbols.push(symbol); + public void addScalaCall(Symbol method, int pos) { + StringBuffer buffer = new StringBuffer(); + buffer.append(method.owner().fullNameString()); + buffer.append('.'); + buffer.append(method.nameString()); + buffer.append('('); + buffer.append(Sourcefile.files[Position.file(pos)]); + buffer.append(':'); + buffer.append(Position.line(pos)); + buffer.append(")"); + stack.add(buffer.toString()); } - public String mkString(Global global) { - StringBuffer buffer = new StringBuffer(); - // !!! if (exception != null)buffer.append(Strings.stackTrace(exception)); - buffer.append(exception.toString()); - for (int i = 0; i < stack.size(); i++) { - buffer.append('\n'); - int pos = ((Integer)stack.elementAt(i)).intValue(); - buffer.append(" at " + - context(global, (Symbol)symbols.elementAt(i)) + - "(" + Sourcefile.files[Position.file(pos)] + ":" + - Position.line(pos) + ")"); - } - return buffer.toString(); + public void addScalaEntryPoint() { + StackTraceElement[] current = getCurrentTrace(); + // find entry point + int length = Math.min(trace.length, current.length); + int entry = 0; + while (entry < length && trace[entry].equals(current[entry])) entry++; + assert entry <= stop : "entry = " + entry + " > " + stop + " = stop"; + // skip calls through proxy class + while (entry > 0 && traceAtStartsWith(entry - 1, "$Proxy")) entry--; + // save new trace end + stop = entry; + } + + public void addScalaLeavePoint() { + StackTraceElement[] current = getCurrentTrace(); + // find leave point + int length = Math.min(trace.length, current.length); + int leave = 0; + while (leave < length && trace[leave].equals(current[leave])) leave++; + // skip calls through interpreter & reflection + int start = leave; + while (traceAtStartsWith(start, "scalai.")) start++; + while (traceAtStartsWith(start, "java.lang.reflect.")) start++; + while (traceAtStartsWith(start, "sun.reflect.")) start++; + // complete stack with java trace + for (int i = stop - 1; start <= i; i--) stack.add(trace[i]); + // save new trace end + stop = leave; } - // !!! remove ? modify ? - public String toString() { - return getClass().getName() + ": " + exception; + public Object[] getScalaStackTrace() { + return stack.toArray(); + } + + public String getScalaErrorMessage(boolean withTrace) { + String line = System.getProperty("line.separator", "\n"); + StringBuffer buffer = new StringBuffer(); + buffer.append(getCause().toString()); + if (withTrace) + for (int i = 0; i < stack.size(); i++) + buffer.append(line).append(" at ").append(stack.get(i)); + return buffer.toString(); } //######################################################################## // Private Methods - private String context(Global global, Symbol symbol) { - if (symbol == null) return "<top-level>"; - assert !symbol.isClass() : symbol.defString(); - Symbol owner = symbol.owner(); - if (owner == global.definitions.ROOT_CLASS - || symbol.owner() == Symbol.NONE) // !!! || ... - { - return symbol.name.toString(); + private boolean traceAtStartsWith(int index, String prefix) { + if (trace.length <= index) return false; + return trace[index].getClassName().startsWith(prefix); + } + + private StackTraceElement[] getCurrentTrace() { + return getTraceOf(new Error()); + } + + private StackTraceElement[] getTraceOf(Throwable exception) { + StackTraceElement[] trace = exception.getStackTrace(); + for (int i = 0; i < trace.length / 2; i++) { + StackTraceElement element = trace[i]; + trace[i] = trace[trace.length - i - 1]; + trace[trace.length - i - 1] = element; } - return owner.fullName() + "." + symbol.name; + return trace; } //######################################################################## diff --git a/sources/scala/tools/scalai/ExpressionCompiler.java b/sources/scala/tools/scalai/ExpressionCompiler.java index 3283f01773..e77e94a5d1 100644 --- a/sources/scala/tools/scalai/ExpressionCompiler.java +++ b/sources/scala/tools/scalai/ExpressionCompiler.java @@ -34,9 +34,8 @@ public class ExpressionCompiler { this.definitions = definitions; this.constants = constants; this.context = context; - for (int i = 0; i < params.length; i++) { - context.insertVariable(params[i], Variable.Context(Evaluator.Levels.ARGS,i)); - } + for (int i = 0; i < params.length; i++) + context.insertVariable(params[i], Variable.Argument(i)); } //######################################################################## @@ -70,7 +69,7 @@ public class ExpressionCompiler { case ValDef(_, _, _, Tree body): Symbol symbol = tree.symbol(); - Variable variable = Variable.Context(Evaluator.Levels.BODY, context.push()); + Variable variable = Variable.Local(context.push()); context.insertVariable(symbol, variable); // !!! this should be done in an earlier phase Code value = body != Tree.Empty ? @@ -102,7 +101,10 @@ public class ExpressionCompiler { for (int i = 0; i < params.length; i++) { vars[i] = context.lookupVariable(params[i].symbol()); // !!! - assert vars[i] instanceof Variable.Context:Debug.show(vars[i]); + assert + vars[i] instanceof Variable.Argument || + vars[i] instanceof Variable.Local : + Debug.show(vars[i]); } context.insertLabel(symbol); return Code.Label(symbol, vars, compute(body)); @@ -252,7 +254,7 @@ public class ExpressionCompiler { } } Code[] args = compute(trees); - return Code.Invoke(object, function, args, target.pos,context.owner()); + return Code.Invoke(object, function, args, target.pos); } //######################################################################## diff --git a/sources/scala/tools/scalai/Interpreter.java b/sources/scala/tools/scalai/Interpreter.java index df92fa362a..17f2bbeb04 100644 --- a/sources/scala/tools/scalai/Interpreter.java +++ b/sources/scala/tools/scalai/Interpreter.java @@ -287,7 +287,7 @@ public class Interpreter { if (interactive) writer.println(value + ": " + type); return; case Error(EvaluatorException exception): - writer.println(exception.mkString(global)); + writer.println(exception.getScalaErrorMessage(true)); return; } } diff --git a/sources/scala/tools/scalai/ScalaObject.java b/sources/scala/tools/scalai/ScalaObject.java index 0d9f65c7c9..21df3f6da2 100644 --- a/sources/scala/tools/scalai/ScalaObject.java +++ b/sources/scala/tools/scalai/ScalaObject.java @@ -41,8 +41,15 @@ public class ScalaObject implements InvocationHandler { //######################################################################## // Public Methods - InvocationHandler interface - public Object invoke(Object self, Method method, Object[] args) { - return template.invoke(self, method, args); + public Object invoke(Object self, Method method, Object[] args) + throws Throwable + { + try { + return template.invoke(self, method, args); + } catch (EvaluatorException exception) { + exception.addScalaEntryPoint(); + throw exception.getCause(); + } } //######################################################################## diff --git a/sources/scala/tools/scalai/Variable.java b/sources/scala/tools/scalai/Variable.java index 42e2c4d4b5..df9e6f8804 100644 --- a/sources/scala/tools/scalai/Variable.java +++ b/sources/scala/tools/scalai/Variable.java @@ -18,15 +18,11 @@ public class Variable { //######################################################################## // Public Cases - // !!! Object/Field(int index) - // !!! Frame/Local(int index) - // !!! Stack(int index) - // !!! Java(Field field) - public case Global(Object value); public case Module(CodePromise body, Object value); - public case Context(int level, int index); public case Member(int index); + public case Argument(int index); + public case Local(int index); public case JavaField(Field field); //######################################################################## @@ -41,12 +37,15 @@ public class Variable { case Module(CodePromise body, Object value): return "Module(" + body + "," + Debug.show(value) + ")"; - case Context(int level, int index): - return "Context(" + level + "," + index + ")"; - case Member(int index): return "Member(" + index + ")"; + case Argument(int index): + return "Context(" + index + ")"; + + case Local(int index): + return "Variable(" + index + ")"; + case JavaField(Field field): return "Java(" + field + ")"; |