LCOV - code coverage report
Current view: top level - vm - package.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 19 24 79.2 %
Date: 2017-07-14 10:03:36 Functions: 6 6 100.0 %

          Line data    Source code
       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             : 
      38         165 : Mutex Package::_mutex;
      39             : 
      40       35416 : static std::set<Utf8String>& packages() {
      41       35416 :         static std::set<Utf8String> _packages;
      42             : 
      43       35416 :         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       35146 : void Package::add(Utf8String packagename)
      52             : {
      53       35146 :         MutexLocker lock(_mutex);
      54             : 
      55             : #if !defined(NDEBUG)
      56       35146 :         if (opt_DebugPackage) {
      57           0 :                 log_start();
      58           0 :                 log_print("[package_add: packagename=");
      59           0 :                 utf_display_printable_ascii(packagename);
      60           0 :                 log_print("]");
      61           0 :                 log_finish();
      62             :         }
      63             : #endif
      64             : 
      65             :         // Add the package name.
      66       35146 :         ::packages().insert(packagename);
      67       35146 : }
      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             :  */
      77         269 : Utf8String Package::find(Utf8String packagename)
      78             : {
      79         269 :         MutexLocker lock(_mutex);
      80             : 
      81         269 :         std::set<Utf8String>&          pkgs = ::packages();
      82         269 :         std::set<Utf8String>::iterator it   = pkgs.find(packagename);
      83             : 
      84         269 :         if (it == pkgs.end())
      85         268 :                 return NULL;
      86             : 
      87           1 :         return *it;
      88             : }
      89             : 
      90           1 : const std::set<Utf8String> &Package::packages()
      91             : {
      92           1 :         return ::packages();
      93         495 : }
      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             :  */

Generated by: LCOV version 1.11