added Context.java
authoradam <adam@megacz.com>
Sun, 3 Jul 2005 21:57:19 +0000 (21:57 +0000)
committeradam <adam@megacz.com>
Sun, 3 Jul 2005 21:57:19 +0000 (21:57 +0000)
darcs-hash:20050703215719-5007d-a726caa366b23bf9ba1b5f4ae6d20f2ab24e3b05.gz

src/org/ibex/classgen/Context.java [new file with mode: 0644]

diff --git a/src/org/ibex/classgen/Context.java b/src/org/ibex/classgen/Context.java
new file mode 100644 (file)
index 0000000..99d9819
--- /dev/null
@@ -0,0 +1,20 @@
+package org.ibex.classgen;
+import java.util.*;
+
+/**
+ *  a Context is like a ClassLoader in that it maps from class names
+ *  to bytecode-implementations of classes, except that it doesn't
+ *  actually load the resolved class -- it simply creates a (cached)
+ *  ClassFile for it.
+ */
+public class Context {
+
+    private Hashtable cache = new Hashtable();
+
+    public Context() { }
+
+    public void add(ClassFile cf) { cache.put(cf.getType().getName(), cf); }
+    public Collection enumerateClassFiles() { return cache.values(); }
+    public ClassFile resolve(String classname) { return (ClassFile)cache.get(classname); }
+
+}