* src/vm/Makefile.am (noinst_LTLIBRARIES): Reformatted.
[cacao.git] / src / vm / loader.h
index 8004107d0f288f9a9a14255dee68cf9a2ecceb00..412553a531f1a5754a985c7ce67a279aa7e118cd 100644 (file)
@@ -1,9 +1,9 @@
-/* loader.h - class loader header
+/* src/vm/loader.h - class loader header
 
-   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
-   R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser,
-   M. Probst, S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck,
-   P. Tomsich, J. Wenninger
+   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
 
    This file is part of CACAO.
 
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
 
-   Contact: cacao@complang.tuwien.ac.at
+   Contact: cacao@cacaojvm.org
 
    Authors: Reinhard Grafl
 
-   $Id: loader.h 705 2003-12-07 17:26:52Z twisti $
+   Changes: Christian Thalinger
+
+   $Id: loader.h 4490 2006-02-12 16:02:43Z edwin $
 */
 
 
 #ifndef _LOADER_H
 #define _LOADER_H
 
-#include <stdio.h>
-
-
-/************************* program switches ***********************************/
+#include "config.h"
 
-extern bool loadverbose;         /* Print debug messages during loading */
-extern bool linkverbose;
-extern bool initverbose;         /* Log class initialization */ 
-extern bool makeinitializations; /* Initialize classes automatically */
-
-extern bool getloadingtime;
-extern long int loadingtime;     /* CPU time for class loading */
-
-extern list unlinkedclasses;     /* List containing all unlinked classes */
-extern list linkedclasses;       /* List containing all linked classes */
-
-#ifdef USE_THREADS
-extern int blockInts;
-#endif
+#include <stdio.h>
 
+#include "vm/types.h"
 
-/************************ prototypes ******************************************/
 
-/* initialize laoder, load important systemclasses */
-void loader_init();
+/* forward typedefs ***********************************************************/
 
-void suck_init(char *cpath);
+typedef struct classbuffer classbuffer;
 
-/* free resources */
-void loader_close();
 
-/* load a class and all referenced classes */
-classinfo *loader_load(utf *topname);
+#include "vm/class.h"
+#include "vm/descriptor.h"
+#include "vm/global.h"
+#include "vm/references.h"
+#include "vm/method.h"
+#include "vm/utf8.h"
 
-/* initializes all loaded classes */
-void loader_initclasses();
 
-void loader_compute_subclasses();
+/* constant pool entries *******************************************************
 
-/* retrieve constantpool element */
-voidptr class_getconstant(classinfo *class, u4 pos, u4 ctype);
+       All constant pool entries need a data structure which contain the entrys
+       value. In some cases this structure exist already, in the remaining cases
+       this structure must be generated:
 
-/* determine type of a constantpool element */
-u4 class_constanttype(classinfo *class, u4 pos);
+               kind                      structure                     generated?
+       ----------------------------------------------------------------------
+    CONSTANT_Class               classinfo                           no   XXX this will change
+    CONSTANT_Fieldref            constant_FMIref                    yes
+    CONSTANT_Methodref           constant_FMIref                    yes
+    CONSTANT_InterfaceMethodref  constant_FMIref                    yes
+    CONSTANT_String              unicode                             no
+    CONSTANT_Integer             constant_integer                   yes
+    CONSTANT_Float               constant_float                     yes
+    CONSTANT_Long                constant_long                      yes
+    CONSTANT_Double              constant_double                    yes
+    CONSTANT_NameAndType         constant_nameandtype               yes
+    CONSTANT_Utf8                unicode                             no
+    CONSTANT_UNUSED              -
 
-s4 class_findmethodIndex(classinfo *c, utf *name, utf *desc);
+*******************************************************************************/
 
-/* search class for a field */
-fieldinfo *class_findfield(classinfo *c, utf *name, utf *desc);
+typedef struct {            /* Integer                                        */
+       s4 value;
+} constant_integer;
 
-/* search for a method with a specified name and descriptor */
-methodinfo *class_findmethod(classinfo *c, utf *name, utf *desc);
-methodinfo *class_resolvemethod(classinfo *c, utf *name, utf *dest);
+       
+typedef struct {            /* Float                                          */
+       float value;
+} constant_float;
 
-/* search for a method with specified name and arguments (returntype ignored) */
-methodinfo *class_findmethod_approx(classinfo *c, utf *name, utf *desc);
-methodinfo *class_resolvemethod_approx(classinfo *c, utf *name, utf *dest);
 
-bool class_issubclass(classinfo *sub, classinfo *super);
+typedef struct {            /* Long                                           */
+       s8 value;
+} constant_long;
+       
 
-/* call initializer of class */
-void class_init(classinfo *c);
+typedef struct {            /* Double                                         */
+       double value;
+} constant_double;
 
-void class_showconstanti(classinfo *c, int ii);
 
-/* debug purposes */
-void class_showmethods(classinfo *c);
-void class_showconstantpool(classinfo *c);
-void print_arraydescriptor(FILE *file, arraydescriptor *desc);
+typedef struct {            /* NameAndType (Field or Method)                  */
+       utf *name;              /* field/method name                              */
+       utf *descriptor;        /* field/method type descriptor string            */
+} constant_nameandtype;
 
-classinfo *loader_load(utf *topname);
 
-/* set buffer for reading classdata */
-void classload_buffer(u1 *buf, int len);
+/* classbuffer ****************************************************************/
 
-/* return the primitive class inidicated by the given signature character */
-classinfo *class_primitive_from_sig(char sig);
+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              */
+       char      *path;                    /* path to file (for debugging)       */
+};
 
 
-/* return the class indicated by the given descriptor */
-#define CLASSLOAD_SKIP  0
-#define CLASSLOAD_NEW   1
-#define CLASSLOAD_LOAD  2
+/* export variables ***********************************************************/
 
-#if 0
-#define CLASSLOAD_NEW       0x0000 /* default */
-#define CLASSLOAD_LOAD      0x0001
-#define CLASSLOAD_SKIP      0x0002
-#define CLASSLOAD_PANIC     0x0000 /* default */
-#define CLASSLOAD_NOPANIC   0x0010
-#define CLASSLOAD_PRIMITIVE 0x0000 /* default */
-#define CLASSLOAD_VOID      0x0000 /* default */
-#define CLASSLOAD_NOVOID    0x0020
+#if defined(USE_THREADS)
+extern int blockInts;
 #endif
 
-classinfo *class_from_descriptor(char *utf_ptr,char *end_ptr,char **next,int mode);
 
-/* (used by class_new, don't use directly) */
-void class_new_array(classinfo *c);
+/* function prototypes ********************************************************/
 
-void class_link(classinfo *c);
+/* initialize loader, load important systemclasses */
+bool loader_init(u1 *stackbottom);
 
-void field_display(fieldinfo *f);
+void loader_load_all_classes(void);
 
-void method_display(methodinfo *m);
+/* free resources */
+void loader_close(void);
 
-utf* clinit_desc();
-utf* clinit_name();
+/* class loading functions */
+classinfo *load_class_from_sysloader(utf *name);
+classinfo *load_class_from_classloader(utf *name, java_objectheader *cl);
+classinfo *load_class_bootstrap(utf *name);
 
-#endif /* _LOADER_H */
+/* (don't use the following directly) */
+classinfo *load_class_from_classbuffer(classbuffer *cb);
+classinfo *load_newly_created_array(classinfo *c,java_objectheader *loader);
 
+#endif /* _LOADER_H */
 
 /*
  * These are local overrides for various environment variables in Emacs.
@@ -156,4 +154,5 @@ utf* clinit_name();
  * c-basic-offset: 4
  * tab-width: 4
  * End:
+ * vim:noexpandtab:sw=4:ts=4:
  */