1 /* src/vm/package.c - Java boot-package functions
3 Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
32 #include "toolbox/list.h"
34 #include "mm/memory.h"
36 #include "native/jni.h"
38 #include "native/include/java_lang_String.h"
40 #include "vm/package.h"
41 #include "vm/stringlocal.h"
43 #include "vmcore/options.h"
44 #include "vmcore/utf8.h"
47 /* internal property structure ************************************************/
49 typedef struct list_package_entry_t list_package_entry_t;
51 struct list_package_entry_t {
52 /* java_string_t *packagename; */
58 /* global variables ***********************************************************/
60 static list_t *list_package = NULL;
63 /* package_init ****************************************************************
65 Initialize the package list.
67 *******************************************************************************/
69 void package_init(void)
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: