CACAO
package.cpp
Go to the documentation of this file.
1 /* src/vm/package.cpp - Java boot-package functions
2 
3  Copyright (C) 1996-2013
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 "mm/dumpmemory.hpp"
29 #include "toolbox/logging.hpp"
30 #include "vm/options.hpp"
31 #include "vm/package.hpp"
32 #include "vm/utf8.hpp"
33 
34 #include <set>
35 
36 // Package list.
37 
39 
40 static std::set<Utf8String>& packages() {
41  static std::set<Utf8String> _packages;
42 
43  return _packages;
44 }
45 
46 /**
47  * Add a package to the boot-package list.
48  *
49  * @param packagename Package name as Java string.
50  */
51 void Package::add(Utf8String packagename)
52 {
54 
55 #if !defined(NDEBUG)
56  if (opt_DebugPackage) {
57  log_start();
58  log_print("[package_add: packagename=");
59  utf_display_printable_ascii(packagename);
60  log_print("]");
61  log_finish();
62  }
63 #endif
64 
65  // Add the package name.
66  ::packages().insert(packagename);
67 }
68 
69 
70 /**
71  * Find a package in the list.
72  *
73  * @param packagename Package name as Java string.
74  *
75  * @return Package name as Java string.
76  */
78 {
80 
81  std::set<Utf8String>& pkgs = ::packages();
82  std::set<Utf8String>::iterator it = pkgs.find(packagename);
83 
84  if (it == pkgs.end())
85  return NULL;
86 
87  return *it;
88 }
89 
90 const std::set<Utf8String> &Package::packages()
91 {
93 }
94 
95 /*
96  * These are local overrides for various environment variables in Emacs.
97  * Please do not remove this and leave it at the end of the file, where
98  * Emacs will automagically detect them.
99  * ---------------------------------------------------------------------
100  * Local variables:
101  * mode: c++
102  * indent-tabs-mode: t
103  * c-basic-offset: 4
104  * tab-width: 4
105  * End:
106  * vim:noexpandtab:sw=4:ts=4:
107  */
Dummy implementation of a mutex.
Definition: mutex-none.hpp:33
void log_finish(void)
Definition: logging.cpp:117
int opt_DebugPackage
Definition: options.cpp:170
static std::set< Utf8String > & packages()
Definition: package.cpp:40
void log_print(const char *text,...)
Definition: logging.cpp:149
static Mutex _mutex
Definition: package.hpp:49
void log_start(void)
Definition: logging.cpp:106
static Utf8String find(Utf8String packagename)
Find a package in the list.
Definition: package.cpp:77
Helper class used to implicitly acquire and release a mutex within a method scope.
Definition: mutex.hpp:42
void utf_display_printable_ascii(Utf8String u)
Definition: utf8.cpp:532
static void lock()
Definition: package.hpp:40
static const std::set< Utf8String > & packages()
Definition: package.cpp:90
static void add(Utf8String packagename)
Add a package to the boot-package list.
Definition: package.cpp:51