1 /* src/vm/package.c - Java boot-package functions
3 Copyright (C) 2007, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
30 #include "toolbox/list.h"
32 #include "mm/memory.h"
34 #include "native/jni.h"
36 #include "native/include/java_lang_String.h"
38 #include "vm/package.h"
39 #include "vm/stringlocal.h"
41 #include "vmcore/options.h"
42 #include "vmcore/utf8.h"
45 /* internal property structure ************************************************/
47 typedef struct list_package_entry_t list_package_entry_t;
49 struct list_package_entry_t {
50 /* java_string_t *packagename; */
56 /* global variables ***********************************************************/
58 static list_t *list_package = NULL;
61 /* package_init ****************************************************************
63 Initialize the package list.
65 *******************************************************************************/
67 void package_init(void)
69 TRACESUBSYSTEMINITIALIZATION("package_init");
71 /* create the properties list */
73 list_package = list_create(OFFSET(list_package_entry_t, linkage));
77 /* package_add *****************************************************************
79 Add a package to the boot-package list.
82 packagename....package name as Java string
84 *******************************************************************************/
86 /* void package_add(java_handle_t *packagename) */
87 void package_add(utf *packagename)
89 /* java_string_t *s; */
90 list_package_entry_t *lpe;
92 /* Intern the Java string to get a unique address. */
94 /* s = javastring_intern(packagename); */
96 /* Check if the package is already stored. */
98 if (package_find(packagename) != NULL)
101 /* Add the package. */
104 if (opt_DebugPackage) {
106 log_print("[package_add: packagename=");
107 utf_display_printable_ascii(packagename);
113 lpe = NEW(list_package_entry_t);
115 lpe->packagename = packagename;
117 list_add_last(list_package, lpe);
121 /* package_find ****************************************************************
123 Find a package in the list.
126 packagename....package name as Java string
129 package name as Java string
131 *******************************************************************************/
133 /* java_handle_t *package_find(java_handle_t *packagename) */
134 utf *package_find(utf *packagename)
136 /* java_string_t *s; */
138 list_package_entry_t *lpe;
140 /* Intern the Java string to get a unique address. */
142 /* s = javastring_intern(packagename); */
144 /* For convenience. */
148 for (lpe = list_first(l); lpe != NULL; lpe = list_next(l, lpe)) {
149 /* if (lpe->packagename == s) */
150 if (lpe->packagename == packagename)
151 return lpe->packagename;
159 * These are local overrides for various environment variables in Emacs.
160 * Please do not remove this and leave it at the end of the file, where
161 * Emacs will automagically detect them.
162 * ---------------------------------------------------------------------
165 * indent-tabs-mode: t
169 * vim:noexpandtab:sw=4:ts=4: