summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2007-10-08 14:55:19 +0000
committerIulian Dragos <jaguarul@gmail.com>2007-10-08 14:55:19 +0000
commit3ef75fa07a6d3d64b50650856e9340142bdfcefe (patch)
tree214cc4e84942580af319df0f42da29bac8aef0e6
parentdd8fbb7c36b6b93e97e10978a71f6fe2cd0faf43 (diff)
downloadscala-3ef75fa07a6d3d64b50650856e9340142bdfcefe.tar.gz
scala-3ef75fa07a6d3d64b50650856e9340142bdfcefe.tar.bz2
scala-3ef75fa07a6d3d64b50650856e9340142bdfcefe.zip
One last file missing..
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/Repository.scala40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/Repository.scala b/src/compiler/scala/tools/nsc/backend/icode/Repository.scala
new file mode 100644
index 0000000000..9a60f671ef
--- /dev/null
+++ b/src/compiler/scala/tools/nsc/backend/icode/Repository.scala
@@ -0,0 +1,40 @@
+package scala.tools.nsc.backend.icode;
+
+import scala.collection._
+
+trait Repository {
+ val global: Global
+ import global._
+ import icodes._
+
+ val loaded: mutable.Map[Symbol, IClass] = new mutable.HashMap
+
+ /** Is the given class available as icode? */
+ def available(sym: Symbol) = classes.contains(sym) || loaded.contains(sym)
+
+ /** The icode of the given class, if available */
+ def icode(sym: Symbol): Option[IClass] =
+ if (classes.contains(sym)) Some(classes(sym))
+ else if (loaded.contains(sym)) Some(loaded(sym))
+ else None
+
+ /** The icode of the given class. If not available, it loads
+ * its bytecode.
+ */
+ def icode(sym: Symbol, force: Boolean): IClass =
+ if (available(sym)) icode(sym).get
+ else {
+ load(sym)
+ assert(available(sym))
+ loaded(sym)
+ }
+
+ /** Load bytecode for given symbol. */
+ private def load(sym: Symbol) {
+ val (c1, c2) = icodeReader.readClass(sym)
+
+ assert(c1.symbol == sym || c2.symbol == sym)
+ loaded += c1.symbol -> c1
+ loaded += c2.symbol -> c2
+ }
+}