a112aca2f7d95045bea1a33d1acd41fabc8d4a81
[cacao.git] / src / vm / package.cpp
1 /* src/vm/package.cpp - Java boot-package functions
2
3    Copyright (C) 2007, 2008
4    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5
6    This file is part of CACAO.
7
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.
12
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.
17
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
21    02110-1301, USA.
22
23 */
24
25
26 #include "config.h"
27
28 #include <stdint.h>
29
30 #include "mm/memory.h"
31
32 #include "vm/options.h"
33 #include "vm/package.hpp"
34 #include "vm/string.hpp"
35 #include "vm/utf8.h"
36
37
38 // Package list.
39
40 std::set<utf*> Package::_packages;
41
42
43 /**
44  * Add a package to the boot-package list.
45  *
46  * @param packagename Package name as Java string.
47  */
48 void Package::add(utf* packagename)
49 {
50         // Intern the Java string to get a unique address.
51 /*      s = javastring_intern(packagename); */
52
53 #if !defined(NDEBUG)
54         if (opt_DebugPackage) {
55                 log_start();
56                 log_print("[package_add: packagename=");
57                 utf_display_printable_ascii(packagename);
58                 log_print("]");
59                 log_finish();
60         }
61 #endif
62
63         // Add the package name.
64         _packages.insert(packagename);
65 }
66
67
68 /**
69  * Find a package in the list.
70  *
71  * @param packagename Package name as Java string.
72  *
73  * @return Package name as Java string.
74  */
75 utf* Package::find(utf* packagename)
76 {
77         std::set<utf*>::iterator it = _packages.find(packagename);
78
79         if (it == _packages.end())
80                 return NULL;
81
82         return *it;
83 }
84
85
86 /*
87  * These are local overrides for various environment variables in Emacs.
88  * Please do not remove this and leave it at the end of the file, where
89  * Emacs will automagically detect them.
90  * ---------------------------------------------------------------------
91  * Local variables:
92  * mode: c++
93  * indent-tabs-mode: t
94  * c-basic-offset: 4
95  * tab-width: 4
96  * End:
97  * vim:noexpandtab:sw=4:ts=4:
98  */