diff options
author | paltherr <paltherr@epfl.ch> | 2004-02-04 20:46:56 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2004-02-04 20:46:56 +0000 |
commit | 0e15eaa854b3e86cd5427a3589c5a6aacc4ae303 (patch) | |
tree | 923e25f9f63d8713fc159622edad7f9535ca3d6b /sources | |
parent | 49b2a7e6b9ccc148fe38fc4c553f7423b40e0597 (diff) | |
download | scala-0e15eaa854b3e86cd5427a3589c5a6aacc4ae303.tar.gz scala-0e15eaa854b3e86cd5427a3589c5a6aacc4ae303.tar.bz2 scala-0e15eaa854b3e86cd5427a3589c5a6aacc4ae303.zip |
- Added getClass methods
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scala/tools/scalai/Environment.java | 29 | ||||
-rw-r--r-- | sources/scala/tools/scalai/ExpressionContext.java | 12 |
2 files changed, 41 insertions, 0 deletions
diff --git a/sources/scala/tools/scalai/Environment.java b/sources/scala/tools/scalai/Environment.java index 68750cf873..f9a883d0a0 100644 --- a/sources/scala/tools/scalai/Environment.java +++ b/sources/scala/tools/scalai/Environment.java @@ -47,6 +47,35 @@ public class Environment { } //######################################################################## + // Public Methods - translate + + public Class getClass(Symbol symbol) { + assert symbol.isClass(): Debug.show(symbol); + Template value = lookupTemplate(symbol); + switch (value) { + case Global(ScalaTemplate template): + return template.getProxy(); + case JavaClass(Class clasz): + return clasz; + default: + throw Debug.abort("illegal case", value); + } + } + + public Class getClass(Type type) { + switch (type) { + case TypeRef(_, Symbol symbol, _): + return getClass(symbol); + case UnboxedType(int kind): + return mirror.getClass(kind); + case UnboxedArrayType(Type element): + return mirror.getArray(getClass(element)); + default: + throw Debug.abort("illegal case", type); + } + } + + //######################################################################## // Public Methods - insert public ClassDef insertClassDef(Symbol symbol, ClassDef classdef) { diff --git a/sources/scala/tools/scalai/ExpressionContext.java b/sources/scala/tools/scalai/ExpressionContext.java index 0ee1382cac..2d64b2dfec 100644 --- a/sources/scala/tools/scalai/ExpressionContext.java +++ b/sources/scala/tools/scalai/ExpressionContext.java @@ -15,6 +15,7 @@ import java.util.HashMap; import ch.epfl.lamp.util.SourceFile; import scalac.symtab.Symbol; +import scalac.symtab.Type; import scalac.util.Debug; public class ExpressionContext { @@ -47,6 +48,17 @@ public class ExpressionContext { } //######################################################################## + // Public Methods - translate + + public Class getClass(Symbol symbol) { + return environment.getClass(symbol); + } + + public Class getClass(Type type) { + return environment.getClass(type); + } + + //######################################################################## // Public Methods - insert public Function insertLabel(Symbol symbol) { |