diff options
author | Patrick Simianer <simianer@cl.uni-heidelberg.de> | 2012-11-05 15:29:46 +0100 |
---|---|---|
committer | Patrick Simianer <simianer@cl.uni-heidelberg.de> | 2012-11-05 15:29:46 +0100 |
commit | 1db70a45d59946560fbd5db6487b55a8674ef973 (patch) | |
tree | 172585dafe4d1462f22d8200e733d52dddb55b1e /jam-files/engine/modules.c | |
parent | 4dd5216d3afa9ab72b150e250a3c30a5f223ce53 (diff) | |
parent | 6bbf03ac46bd57400aa9e65a321a304a234af935 (diff) |
merge upstream/master
Diffstat (limited to 'jam-files/engine/modules.c')
-rw-r--r-- | jam-files/engine/modules.c | 168 |
1 files changed, 0 insertions, 168 deletions
diff --git a/jam-files/engine/modules.c b/jam-files/engine/modules.c deleted file mode 100644 index 72952594..00000000 --- a/jam-files/engine/modules.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright 2001-2004 David Abrahams. - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) - */ -#include "jam.h" - -#include "modules.h" -#include "string.h" -#include "hash.h" -#include "newstr.h" -#include "lists.h" -#include "parse.h" -#include "rules.h" -#include "variable.h" -#include "strings.h" -#include <assert.h> - -static struct hash * module_hash = 0; - - -static char * new_module_str( module_t * m, char * suffix ) -{ - char * result; - string s; - string_copy( &s, m->name ); - string_append( &s, suffix ); - result = newstr( s.value ); - string_free( &s ); - return result; -} - - -module_t * bindmodule( char * name ) -{ - PROFILE_ENTER( BINDMODULE ); - - string s; - module_t m_; - module_t * m = &m_; - - if ( !module_hash ) - module_hash = hashinit( sizeof( module_t ), "modules" ); - - string_new( &s ); - if ( name ) - { - string_append( &s, name ); - string_push_back( &s, '.' ); - } - - m->name = s.value; - - if ( hashenter( module_hash, (HASHDATA * *)&m ) ) - { - m->name = newstr( m->name ); - m->variables = 0; - m->rules = 0; - m->imported_modules = 0; - m->class_module = 0; - m->native_rules = 0; - m->user_module = 0; - } - string_free( &s ); - - PROFILE_EXIT( BINDMODULE ); - - return m; -} - -/* - * demand_rules() - Get the module's "rules" hash on demand. - */ -struct hash * demand_rules( module_t * m ) -{ - if ( !m->rules ) - m->rules = hashinit( sizeof( RULE ), new_module_str( m, "rules" ) ); - return m->rules; -} - - -/* - * delete_module() - wipe out the module's rules and variables. - */ - -static void delete_rule_( void * xrule, void * data ) -{ - rule_free( (RULE *)xrule ); -} - - -void delete_module( module_t * m ) -{ - /* Clear out all the rules. */ - if ( m->rules ) - { - hashenumerate( m->rules, delete_rule_, (void *)0 ); - hashdone( m->rules ); - m->rules = 0; - } - - if ( m->variables ) - { - var_hash_swap( &m->variables ); - var_done(); - var_hash_swap( &m->variables ); - m->variables = 0; - } -} - - -module_t * root_module() -{ - static module_t * root = 0; - if ( !root ) - root = bindmodule( 0 ); - return root; -} - -void enter_module( module_t * m ) -{ - var_hash_swap( &m->variables ); -} - - -void exit_module( module_t * m ) -{ - var_hash_swap( &m->variables ); -} - - -void import_module( LIST * module_names, module_t * target_module ) -{ - PROFILE_ENTER( IMPORT_MODULE ); - - struct hash * h; - - if ( !target_module->imported_modules ) - target_module->imported_modules = hashinit( sizeof( char * ), "imported" ); - h = target_module->imported_modules; - - for ( ; module_names; module_names = module_names->next ) - { - char * s = module_names->string; - char * * ss = &s; - hashenter( h, (HASHDATA * *)&ss ); - } - - PROFILE_EXIT( IMPORT_MODULE ); -} - - -static void add_module_name( void * r_, void * result_ ) -{ - char * * r = (char * *)r_; - LIST * * result = (LIST * *)result_; - - *result = list_new( *result, copystr( *r ) ); -} - - -LIST * imported_modules( module_t * module ) -{ - LIST * result = L0; - if ( module->imported_modules ) - hashenumerate( module->imported_modules, add_module_name, &result ); - return result; -} |