1 /* src/vm/package.cpp - 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 "vm/options.h"
35 #include "vm/package.hpp"
36 #include "vm/string.hpp"
40 /* internal property structure ************************************************/
42 typedef struct list_package_entry_t list_package_entry_t;
44 struct list_package_entry_t {
45 /* java_string_t *packagename; */
51 /* global variables ***********************************************************/
53 static list_t *list_package = NULL;
57 * Initialize the package list.
59 void Package::initialize(void)
61 TRACESUBSYSTEMINITIALIZATION("package_init");
63 /* create the properties list */
65 list_package = list_create(OFFSET(list_package_entry_t, linkage));
70 * Add a package to the boot-package list.
72 * @param packagename Package name as Java string.
74 /* void package_add(java_handle_t *packagename) */
75 void Package::add(utf *packagename)
77 /* java_string_t *s; */
78 list_package_entry_t *lpe;
80 /* Intern the Java string to get a unique address. */
82 /* s = javastring_intern(packagename); */
84 /* Check if the package is already stored. */
86 if (Package::find(packagename) != NULL)
89 /* Add the package. */
92 if (opt_DebugPackage) {
94 log_print("[package_add: packagename=");
95 utf_display_printable_ascii(packagename);
101 lpe = NEW(list_package_entry_t);
103 lpe->packagename = packagename;
105 list_add_last(list_package, lpe);
110 * Find a package in the list.
112 * @param packagename Package name as Java string.
114 * @return Package name as Java string.
116 /* java_handle_t *package_find(java_handle_t *packagename) */
117 utf* Package::find(utf *packagename)
119 /* java_string_t *s; */
121 list_package_entry_t *lpe;
123 /* Intern the Java string to get a unique address. */
125 /* s = javastring_intern(packagename); */
127 /* For convenience. */
131 for (lpe = (list_package_entry_t*) list_first(l); lpe != NULL; lpe = (list_package_entry_t*) list_next(l, lpe)) {
132 /* if (lpe->packagename == s) */
133 if (lpe->packagename == packagename)
134 return lpe->packagename;
141 /* Legacy C interface *********************************************************/
145 utf* Package_find(utf *packagename) { return Package::find(packagename); }
151 * These are local overrides for various environment variables in Emacs.
152 * Please do not remove this and leave it at the end of the file, where
153 * Emacs will automagically detect them.
154 * ---------------------------------------------------------------------
157 * indent-tabs-mode: t
161 * vim:noexpandtab:sw=4:ts=4: