- maybe we should always use `const char *' in function declarations
[cacao.git] / loader.h
index 43ad783804acd9524f3a7a14b5744e338e627489..56341ea76fa8afc9f74cb4096d09a0817b1a080b 100644 (file)
--- a/loader.h
+++ b/loader.h
@@ -26,7 +26,7 @@
 
    Authors: Reinhard Grafl
 
-   $Id: loader.h 1008 2004-03-31 20:13:14Z edwin $
+   $Id: loader.h 1557 2004-11-22 12:01:16Z carolyn $
 */
 
 
 #include "unzip.h"
 #endif
 
-/* export variables */
 
-extern list unloadedclasses;     /* list of all referenced but not loaded classes */
-extern list unlinkedclasses;     /* List containing all unlinked classes */
-extern list linkedclasses;       /* List containing all linked classes */
+/* datastruture from a classfile */
+
+typedef struct classbuffer {
+       classinfo *class;                   /* pointer to classinfo structure     */
+       u1 *data;                           /* pointer to byte code               */
+       s4 size;                            /* size of the byte code              */
+       u1 *pos;                            /* current read position              */
+} classbuffer;
+
+
+/* export variables */
 
 #ifdef USE_THREADS
 extern int blockInts;
 #endif
 
 
+/* references to some system classes ******************************************/
+
+extern classinfo *class_java_lang_Object;
+extern classinfo *class_java_lang_String;
+extern classinfo *class_java_lang_Cloneable;
+extern classinfo *class_java_io_Serializable;
+extern utf *utf_fillInStackTrace_name;
+extern utf *utf_fillInStackTrace_desc;
+
+/* pseudo classes for the type checker ****************************************/
+
+/*
+ * pseudo_class_Arraystub
+ *     (extends Object implements Cloneable, java.io.Serializable)
+ *
+ *     If two arrays of incompatible component types are merged,
+ *     the resulting reference has no accessible components.
+ *     The result does, however, implement the interfaces Cloneable
+ *     and java.io.Serializable. This pseudo class is used internally
+ *     to represent such results. (They are *not* considered arrays!)
+ *
+ * pseudo_class_Null
+ *
+ *     This pseudo class is used internally to represent the
+ *     null type.
+ *
+ * pseudo_class_New
+ *
+ *     This pseudo class is used internally to represent the
+ *     the 'uninitialized object' type.
+ */
+
+extern classinfo *pseudo_class_Arraystub;
+extern classinfo *pseudo_class_Null;
+extern classinfo *pseudo_class_New;
+extern vftbl_t *pseudo_class_Arraystub_vftbl;
+
+extern utf *array_packagename;
+
+
 /************************ prototypes ******************************************/
 
 /* initialize laoder, load important systemclasses */
 void loader_init();
 
 void suck_init(char *cpath);
+void create_all_classes();
+void suck_stop(classbuffer *cb);
 
 /* free resources */
 void loader_close();
 
-/* load a class and all referenced classes */
-classinfo *loader_load(utf *topname);
-
-/* initializes all loaded classes */
-void loader_initclasses();
-
 void loader_compute_subclasses();
 
 /* retrieve constantpool element */
@@ -95,7 +138,7 @@ methodinfo *class_resolvemethod_approx(classinfo *c, utf *name, utf *dest);
 bool class_issubclass(classinfo *sub, classinfo *super);
 
 /* call initializer of class */
-void class_init(classinfo *c);
+classinfo *class_init(classinfo *c);
 
 void class_showconstanti(classinfo *c, int ii);
 
@@ -104,12 +147,6 @@ void class_showmethods(classinfo *c);
 void class_showconstantpool(classinfo *c);
 void print_arraydescriptor(FILE *file, arraydescriptor *desc);
 
-classinfo *loader_load(utf *topname);
-classinfo *loader_load_sysclass(classinfo **top,utf *topname);
-
-/* set buffer for reading classdata */
-void classload_buffer(u1 *buf, int len);
-
 /* return the primitive class inidicated by the given signature character */
 classinfo *class_primitive_from_sig(char sig);
 
@@ -134,11 +171,24 @@ int type_from_descriptor(classinfo **cls,char *utf_ptr,char *end_ptr,char **next
 /* (used by class_new, don't use directly) */
 void class_new_array(classinfo *c);
 
-void class_link(classinfo *c);
+#define LAZYLOADING(class) { \
+        if (!class->loaded) \
+            if (!class_load(class)) \
+                return 0; \
+        if (!class->linked) \
+            if (!class_link(class)) \
+                return 0; }
+
+
+classinfo *class_load(classinfo *c);
+classinfo *class_load_intern(classbuffer *cb);
+classinfo *class_link(classinfo *c);
+void class_free(classinfo *c);
 
 void field_display(fieldinfo *f);
 
 void method_display(methodinfo *m);
+void method_display_w_class(methodinfo *m);
 
 utf* clinit_desc();
 utf* clinit_name();
@@ -151,15 +201,16 @@ utf* clinit_name();
 
 typedef union classpath_info {
        struct {
-               int type;
+               s4                    type;
                union classpath_info *next;
-               char *filename;
-               int pathlen; } filepath;
-#ifdef USE_ZLIB
+               char                 *path;
+               s4                    pathlen;
+       } filepath;
+#if defined(USE_ZLIB)
        struct {
-               int type;
+               s4                    type;
                union classpath_info *next;
-               unzFile uf;
+               unzFile               uf;
        } archive;
 #endif 
 } classpath_info;