|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r75912 - in trunk/tools/build/v2/engine: . modules
From: steven_at_[hidden]
Date: 2011-12-11 21:02:23
Author: steven_watanabe
Date: 2011-12-11 21:02:20 EST (Sun, 11 Dec 2011)
New Revision: 75912
URL: http://svn.boost.org/trac/boost/changeset/75912
Log:
Clean up the evil 'variables of the running module are swapped with the global variable table' hack.
Text files modified:
trunk/tools/build/v2/engine/builtins.c | 39 ++--------------------------
trunk/tools/build/v2/engine/class.c | 10 +-----
trunk/tools/build/v2/engine/compile.c | 27 +------------------
trunk/tools/build/v2/engine/function.c | 47 +++++++++++-----------------------
trunk/tools/build/v2/engine/hcache.c | 9 +++--
trunk/tools/build/v2/engine/headers.c | 7 ++--
trunk/tools/build/v2/engine/jam.c | 27 ++++++++-----------
trunk/tools/build/v2/engine/make.c | 6 ++--
trunk/tools/build/v2/engine/make1.c | 54 +++++++++++++++------------------------
trunk/tools/build/v2/engine/modules.c | 15 ----------
trunk/tools/build/v2/engine/modules.h | 2 -
trunk/tools/build/v2/engine/modules/order.c | 4 +-
trunk/tools/build/v2/engine/modules/property-set.c | 4 +-
trunk/tools/build/v2/engine/rules.c | 12 ++++----
trunk/tools/build/v2/engine/rules.h | 4 +-
trunk/tools/build/v2/engine/search.c | 6 ++--
trunk/tools/build/v2/engine/variable.c | 49 ++++++++++++-----------------------
trunk/tools/build/v2/engine/variable.h | 13 ++++-----
18 files changed, 105 insertions(+), 230 deletions(-)
Modified: trunk/tools/build/v2/engine/builtins.c
==============================================================================
--- trunk/tools/build/v2/engine/builtins.c (original)
+++ trunk/tools/build/v2/engine/builtins.c 2011-12-11 21:02:20 EST (Sun, 11 Dec 2011)
@@ -1019,32 +1019,13 @@
}
-static struct hash * get_running_module_vars()
-{
- struct hash * dummy;
- struct hash * vars = NULL;
- /* Get the global variables pointer (that of the currently running module).
- */
- var_hash_swap( &vars );
- dummy = vars;
- /* Put the global variables pointer in its right place. */
- var_hash_swap( &dummy );
- return vars;
-}
-
-
LIST * builtin_varnames( FRAME * frame, int flags )
{
LIST * arg0 = lol_get( frame->args, 0 );
LIST * result = L0;
module_t * source_module = bindmodule( arg0 ? arg0->value : 0 );
- /* The running module _always_ has its 'variables' member set to NULL due to
- * the way enter_module() and var_hash_swap() work.
- */
- struct hash * vars = source_module == frame->module
- ? get_running_module_vars()
- : source_module->variables;
+ struct hash * vars = source_module->variables;
if ( vars )
hashenumerate( vars, add_hash_key, &result );
@@ -1842,19 +1823,7 @@
first_time = 0;
- if ( outer_module != root_module() )
- {
- exit_module( outer_module );
- enter_module( root_module() );
- }
-
- extra = var_get( constant_extra_pythonpath );
-
- if ( outer_module != root_module() )
- {
- exit_module( root_module() );
- enter_module( outer_module );
- }
+ extra = var_get( root_module(), constant_extra_pythonpath );
for ( ; extra; extra = extra->next )
{
@@ -2143,11 +2112,9 @@
if ( !PyArg_ParseTuple( args, "s", &name ) )
return NULL;
- enter_module( root_module() );
varname = object_new( name );
- value = var_get( varname );
+ value = var_get( root_module(), varname );
object_free( varname );
- exit_module( root_module() );
result = PyList_New( list_length( value ) );
for ( i = 0; value; value = list_next( value ), ++i )
Modified: trunk/tools/build/v2/engine/class.c
==============================================================================
--- trunk/tools/build/v2/engine/class.c (original)
+++ trunk/tools/build/v2/engine/class.c 2011-12-11 21:02:20 EST (Sun, 11 Dec 2011)
@@ -135,14 +135,8 @@
class_module = bindmodule( name );
- exit_module( outer_module );
- enter_module( class_module );
-
- var_set( constant_name, xname, VAR_SET );
- var_set( constant_bases, bases, VAR_SET );
-
- exit_module( class_module );
- enter_module( outer_module );
+ var_set( class_module, constant_name, xname, VAR_SET );
+ var_set( class_module, constant_bases, bases, VAR_SET );
for ( ; bases; bases = bases->next )
import_base_rules( class_module, bases->value );
Modified: trunk/tools/build/v2/engine/compile.c
==============================================================================
--- trunk/tools/build/v2/engine/compile.c (original)
+++ trunk/tools/build/v2/engine/compile.c 2011-12-11 21:02:20 EST (Sun, 11 Dec 2011)
@@ -211,8 +211,6 @@
return;
}
- exit_module( caller->module );
-
while ( values != 0 )
{
LIST *error;
@@ -222,21 +220,16 @@
frame->prev = caller;
frame->prev_user = caller->module->user_module ? caller : caller->prev_user;
- enter_module( typecheck );
/* Prepare the argument list */
lol_add( frame->args, list_new( L0, object_copy( values->value ) ) );
error = evaluate_rule( type_name, frame );
- exit_module( typecheck );
-
if ( error )
argument_error( object_str( error->value ), called, caller, arg_name );
frame_free( frame );
values = values->next;
}
-
- enter_module( caller->module );
}
/*
@@ -532,14 +525,8 @@
frame->module = m;
- exit_module( prev_module );
- enter_module( m );
-
result = call_python_function( rule, frame );
- exit_module( m );
- enter_module ( prev_module );
-
return result;
}
#endif
@@ -572,10 +559,6 @@
{
/* Propagate current module to nested rule invocations. */
frame->module = rule->module;
-
- /* Swap variables. */
- exit_module( prev_module );
- enter_module( rule->module );
}
/* Record current rule name in frame. */
@@ -680,20 +663,14 @@
function_refer( function );
- pushsettings( local_args );
+ pushsettings( frame->module, local_args );
result = function_run( function, frame, stack_global() );
- popsettings( local_args );
+ popsettings( frame->module, local_args );
freesettings( local_args );
function_free( function );
}
- if ( frame->module != prev_module )
- {
- exit_module( frame->module );
- enter_module( prev_module );
- }
-
if ( DEBUG_PROFILE && rule->procedure )
profile_exit( prof );
Modified: trunk/tools/build/v2/engine/function.c
==============================================================================
--- trunk/tools/build/v2/engine/function.c (original)
+++ trunk/tools/build/v2/engine/function.c 2011-12-11 21:02:20 EST (Sun, 11 Dec 2011)
@@ -242,27 +242,27 @@
static LIST * function_get_variable( JAM_FUNCTION * function, FRAME * frame, int idx )
{
- return list_copy( L0, var_get( function->constants[idx] ) );
+ return list_copy( L0, var_get( frame->module, function->constants[idx] ) );
}
static void function_set_variable( JAM_FUNCTION * function, FRAME * frame, int idx, LIST * value )
{
- var_set( function->constants[idx], value, VAR_SET );
+ var_set( frame->module, function->constants[idx], value, VAR_SET );
}
static LIST * function_swap_variable( JAM_FUNCTION * function, FRAME * frame, int idx, LIST * value )
{
- return var_swap( function->constants[idx], value );
+ return var_swap( frame->module, function->constants[idx], value );
}
static void function_append_variable( JAM_FUNCTION * function, FRAME * frame, int idx, LIST * value )
{
- var_set( function->constants[idx], value, VAR_APPEND );
+ var_set( frame->module, function->constants[idx], value, VAR_APPEND );
}
static void function_default_variable( JAM_FUNCTION * function, FRAME * frame, int idx, LIST * value )
{
- var_set( function->constants[idx], value, VAR_DEFAULT );
+ var_set( frame->module, function->constants[idx], value, VAR_DEFAULT );
}
static void function_set_rule( JAM_FUNCTION * function, FRAME * frame, STACK * s, int idx )
@@ -354,28 +354,28 @@
}
else
{
- return list_copy( L0, var_get( name ) );
+ return list_copy( L0, var_get( frame->module, name ) );
}
}
static void function_set_named_variable( JAM_FUNCTION * function, FRAME * frame, OBJECT * name, LIST * value)
{
- var_set( name, value, VAR_SET );
+ var_set( frame->module, name, value, VAR_SET );
}
static LIST * function_swap_named_variable( JAM_FUNCTION * function, FRAME * frame, OBJECT * name, LIST * value )
{
- return var_swap( name, value );
+ return var_swap( frame->module, name, value );
}
static void function_append_named_variable( JAM_FUNCTION * function, FRAME * frame, OBJECT * name, LIST * value)
{
- var_set( name, value, VAR_APPEND );
+ var_set( frame->module, name, value, VAR_APPEND );
}
static void function_default_named_variable( JAM_FUNCTION * function, FRAME * frame, OBJECT * name, LIST * value )
{
- var_set( name, value, VAR_DEFAULT );
+ var_set( frame->module, name, value, VAR_DEFAULT );
}
static LIST * function_call_rule( JAM_FUNCTION * function, FRAME * frame, STACK * s, int n_args, const char * unexpanded, OBJECT * file, int line )
@@ -2944,7 +2944,7 @@
* using pushsettings.
*/
TARGET * t = bindtarget( targets->value );
- pushsettings( t->settings );
+ pushsettings( frame->module, t->settings );
}
else
{
@@ -2965,7 +2965,7 @@
if ( targets )
{
TARGET * t = bindtarget( targets->value );
- popsettings( t->settings );
+ popsettings( frame->module, t->settings );
}
list_free( targets );
stack_push( s, result );
@@ -3262,13 +3262,13 @@
/* "on-target" variables. Though they are targets, */
/* include files are not built with make(). */
- pushsettings( t->settings );
+ pushsettings( root_module(), t->settings );
/* We don't expect that file to be included is generated by some
action. Therefore, pass 0 as third argument.
If the name resolves to directory, let it error out. */
object_free( t->boundname );
t->boundname = search( t->name, &t->time, 0, 0 );
- popsettings( t->settings );
+ popsettings( root_module(), t->settings );
parse_file( t->boundname, frame );
}
@@ -3289,12 +3289,6 @@
list_free( module_name );
- if ( outer_module != frame->module )
- {
- exit_module( outer_module );
- enter_module( frame->module );
- }
-
*(module_t * *)stack_allocate( s, sizeof( module_t * ) ) = outer_module;
break;
@@ -3304,12 +3298,7 @@
{
module_t * outer_module = *(module_t * *)stack_get( s );
stack_deallocate( s, sizeof( module_t * ) );
- if ( outer_module != frame->module )
- {
- exit_module( frame->module );
- enter_module( outer_module );
- frame->module = outer_module;
- }
+ frame->module = outer_module;
break;
}
@@ -3322,12 +3311,6 @@
module_t * outer_module = frame->module;
frame->module = bindmodule( class_module );
object_free( class_module );
-
- if ( outer_module != frame->module )
- {
- exit_module( outer_module );
- enter_module( frame->module );
- }
*(module_t * *)stack_allocate( s, sizeof( module_t * ) ) = outer_module;
Modified: trunk/tools/build/v2/engine/hcache.c
==============================================================================
--- trunk/tools/build/v2/engine/hcache.c (original)
+++ trunk/tools/build/v2/engine/hcache.c 2011-12-11 21:02:20 EST (Sun, 11 Dec 2011)
@@ -13,6 +13,7 @@
# include "hcache.h"
# include "variable.h"
# include "search.h"
+# include "modules.h"
#ifdef OPT_HEADER_CACHE_EXT
@@ -75,20 +76,20 @@
static OBJECT * name = 0;
if ( !name )
{
- LIST * hcachevar = var_get( constant_HCACHEFILE );
+ LIST * hcachevar = var_get( root_module(), constant_HCACHEFILE );
if ( hcachevar )
{
TARGET * t = bindtarget( hcachevar->value );
- pushsettings( t->settings );
+ pushsettings( root_module(), t->settings );
/* Do not expect the cache file to be generated, so pass 0 as the
* third argument to search. Expect the location to be specified via
* LOCATE, so pass 0 as the fourth arugment.
*/
object_free( t->boundname );
t->boundname = search( t->name, &t->time, 0, 0 );
- popsettings( t->settings );
+ popsettings( root_module(), t->settings );
if ( hcachevar )
name = object_copy( t->boundname );
@@ -106,7 +107,7 @@
static int cache_maxage( void )
{
int age = 100;
- LIST * var = var_get( constant_HCACHEMAXAGE );
+ LIST * var = var_get( root_module(), constant_HCACHEMAXAGE );
if ( var )
{
age = atoi( object_str( var->value ) );
Modified: trunk/tools/build/v2/engine/headers.c
==============================================================================
--- trunk/tools/build/v2/engine/headers.c (original)
+++ trunk/tools/build/v2/engine/headers.c 2011-12-11 21:02:20 EST (Sun, 11 Dec 2011)
@@ -14,6 +14,7 @@
# include "parse.h"
# include "compile.h"
# include "rules.h"
+# include "modules.h"
# include "variable.h"
# include "regexp.h"
# include "headers.h"
@@ -56,7 +57,7 @@
# define MAXINC 10
void
-headers( TARGET *t )
+headers( TARGET * t )
{
LIST * hdrscan;
LIST * hdrrule;
@@ -66,10 +67,10 @@
regexp * re[ MAXINC ];
int rec = 0;
- if ( !( hdrscan = var_get( constant_HDRSCAN ) ) )
+ if ( !( hdrscan = var_get( root_module(), constant_HDRSCAN ) ) )
return;
- if ( !( hdrrule = var_get( constant_HDRRULE ) ) )
+ if ( !( hdrrule = var_get( root_module(), constant_HDRRULE ) ) )
return;
if ( DEBUG_HEADER )
Modified: trunk/tools/build/v2/engine/jam.c
==============================================================================
--- trunk/tools/build/v2/engine/jam.c (original)
+++ trunk/tools/build/v2/engine/jam.c 2011-12-11 21:02:20 EST (Sun, 11 Dec 2011)
@@ -385,10 +385,10 @@
#endif
/* Set JAMDATE. */
- var_set( constant_JAMDATE, list_new( L0, outf_time(time(0)) ), VAR_SET );
+ var_set( root_module(), constant_JAMDATE, list_new( L0, outf_time(time(0)) ), VAR_SET );
/* Set JAM_VERSION. */
- var_set( constant_JAM_VERSION,
+ var_set( root_module(), constant_JAM_VERSION,
list_new( list_new( list_new( L0,
object_new( VERSION_MAJOR_SYM ) ),
object_new( VERSION_MINOR_SYM ) ),
@@ -402,7 +402,7 @@
if ( uname( &u ) >= 0 )
{
- var_set( constant_JAMUNAME,
+ var_set( root_module(), constant_JAMUNAME,
list_new(
list_new(
list_new(
@@ -422,20 +422,18 @@
/* First into the global module, with splitting, for backward
* compatibility.
*/
- var_defines( use_environ, 1 );
+ var_defines( root_module(), use_environ, 1 );
environ_module = bindmodule( constant_ENVIRON );
/* Then into .ENVIRON, without splitting. */
- enter_module( environ_module );
- var_defines( use_environ, 0 );
- exit_module( environ_module );
+ var_defines( environ_module, use_environ, 0 );
/*
* Jam defined variables OS & OSPLAT. We load them after environment, so
* that setting OS in environment does not change Jam's notion of the
* current platform.
*/
- var_defines( othersyms, 1 );
+ var_defines( root_module(), othersyms, 1 );
/* Load up variables set on command line. */
for ( n = 0; ( s = getoptval( optv, 's', n ) ); ++n )
@@ -443,17 +441,15 @@
char *symv[2];
symv[ 0 ] = s;
symv[ 1 ] = 0;
- var_defines( symv, 1 );
- enter_module( environ_module );
- var_defines( symv, 0 );
- exit_module( environ_module );
+ var_defines( root_module(), symv, 1 );
+ var_defines( environ_module, symv, 0 );
}
/* Set the ARGV to reflect the complete list of arguments of invocation.
*/
for ( n = 0; n < arg_c; ++n )
{
- var_set( constant_ARGV, list_new( L0, object_new( arg_v[n] ) ), VAR_APPEND );
+ var_set( root_module(), constant_ARGV, list_new( L0, object_new( arg_v[n] ) ), VAR_APPEND );
}
/* Initialize built-in rules. */
@@ -523,7 +519,7 @@
options. */
{
LIST *p = L0;
- p = var_get ( constant_PARALLELISM );
+ p = var_get ( root_module(), constant_PARALLELISM );
if ( p )
{
int j = atoi( object_str( p->value ) );
@@ -541,7 +537,7 @@
/* KEEP_GOING overrides -q option. */
{
LIST *p = L0;
- p = var_get( constant_KEEP_GOING );
+ p = var_get( root_module(), constant_KEEP_GOING );
if ( p )
{
int v = atoi( object_str( p->value ) );
@@ -590,7 +586,6 @@
clear_targets_to_update();
/* Widely scattered cleanup. */
- var_done();
file_done();
rules_done();
stamps_done();
Modified: trunk/tools/build/v2/engine/make.c
==============================================================================
--- trunk/tools/build/v2/engine/make.c (original)
+++ trunk/tools/build/v2/engine/make.c 2011-12-11 21:02:20 EST (Sun, 11 Dec 2011)
@@ -280,7 +280,7 @@
/* Step 2a: set "on target" variables. */
s = copysettings( t->settings );
- pushsettings( s );
+ pushsettings( root_module(), s );
/* Step 2b: find and timestamp the target file (if it is a file). */
if ( ( t->binding == T_BIND_UNBOUND ) && !( t->flags & T_FLAG_NOTFILE ) )
@@ -314,7 +314,7 @@
#ifdef OPT_SEMAPHORE
{
- LIST * var = var_get( constant_JAM_SEMAPHORE );
+ LIST * var = var_get( root_module(), constant_JAM_SEMAPHORE );
if ( var )
{
TARGET * semaphore = bindtarget( var->value );
@@ -329,7 +329,7 @@
headers( t );
/* Step 2d: reset "on target" variables. */
- popsettings( s );
+ popsettings( root_module(), s );
freesettings( s );
/*
Modified: trunk/tools/build/v2/engine/make1.c
==============================================================================
--- trunk/tools/build/v2/engine/make1.c (original)
+++ trunk/tools/build/v2/engine/make1.c 2011-12-11 21:02:20 EST (Sun, 11 Dec 2011)
@@ -72,7 +72,7 @@
static CMD * make1cmds ( TARGET * );
static LIST * make1list ( LIST *, TARGETS *, int flags );
-static SETTINGS * make1settings( LIST * vars );
+static SETTINGS * make1settings( struct module_t * module, LIST * vars );
static void make1bind ( TARGET * );
/* Ugly static - it is too hard to carry it through the callbacks. */
@@ -581,9 +581,9 @@
target_to_rescan->includes = 0;
s = copysettings( target_to_rescan->settings );
- pushsettings( s );
+ pushsettings( root_module(), s );
headers( target_to_rescan );
- popsettings( s );
+ popsettings( root_module(), s );
freesettings( s );
if ( target_to_rescan->includes )
@@ -672,9 +672,9 @@
{
LIST * timing_rule;
- pushsettings( target->settings );
- timing_rule = var_get( constant_TIMING_RULE );
- popsettings( target->settings );
+ pushsettings( root_module(), target->settings );
+ timing_rule = var_get( root_module(), constant_TIMING_RULE );
+ popsettings( root_module(), target->settings );
if ( timing_rule )
{
@@ -723,9 +723,9 @@
{
LIST * action_rule;
- pushsettings( target->settings );
- action_rule = var_get( constant_ACTION_RULE );
- popsettings( target->settings );
+ pushsettings( root_module(), target->settings );
+ action_rule = var_get( root_module(), constant_ACTION_RULE );
+ popsettings( root_module(), target->settings );
if ( action_rule )
{
@@ -888,29 +888,17 @@
TARGET * new_target
)
{
- if ( new_module == root_module() )
- new_module = 0;
-
if ( ( new_target == *current_target ) && ( new_module == *current_module ) )
return;
if ( *current_target )
- popsettings( (*current_target)->settings );
-
- if ( new_module != *current_module )
- {
- if ( *current_module )
- exit_module( *current_module );
-
- *current_module = new_module;
+ popsettings( *current_module, (*current_target)->settings );
- if ( new_module )
- enter_module( new_module );
- }
+ if ( new_target )
+ pushsettings( new_module, new_target->settings );
+ *current_module = new_module;
*current_target = new_target;
- if ( new_target )
- pushsettings( new_target->settings );
}
@@ -980,12 +968,12 @@
swap_settings( &settings_module, &settings_target, rule->module, t );
if ( !shell )
{
- shell = var_get( constant_JAMSHELL ); /* shell is per-target */
+ shell = var_get( rule->module, constant_JAMSHELL ); /* shell is per-target */
}
/* If we had 'actions xxx bind vars' we bind the vars now. */
- boundvars = make1settings( actions->bindlist );
- pushsettings( boundvars );
+ boundvars = make1settings( rule->module, actions->bindlist );
+ pushsettings( rule->module, boundvars );
/*
* Build command, starting with all source args.
@@ -1050,7 +1038,7 @@
/* Free the variables whose values were bound by 'actions xxx bind
* vars'.
*/
- popsettings( boundvars );
+ popsettings( rule->module, boundvars );
freesettings( boundvars );
}
@@ -1109,13 +1097,13 @@
* make1settings() - for vars that get bound values, build up replacement lists.
*/
-static SETTINGS * make1settings( LIST * vars )
+static SETTINGS * make1settings( struct module_t * module, LIST * vars )
{
SETTINGS * settings = 0;
for ( ; vars; vars = list_next( vars ) )
{
- LIST * l = var_get( vars->value );
+ LIST * l = var_get( module, vars->value );
LIST * nl = 0;
for ( ; l; l = list_next( l ) )
@@ -1150,9 +1138,9 @@
if ( t->flags & T_FLAG_NOTFILE )
return;
- pushsettings( t->settings );
+ pushsettings( root_module(), t->settings );
object_free( t->boundname );
t->boundname = search( t->name, &t->time, 0, ( t->flags & T_FLAG_ISFILE ) );
t->binding = t->time ? T_BIND_EXISTS : T_BIND_MISSING;
- popsettings( t->settings );
+ popsettings( root_module(), t->settings );
}
Modified: trunk/tools/build/v2/engine/modules.c
==============================================================================
--- trunk/tools/build/v2/engine/modules.c (original)
+++ trunk/tools/build/v2/engine/modules.c 2011-12-11 21:02:20 EST (Sun, 11 Dec 2011)
@@ -113,9 +113,7 @@
if ( m->variables )
{
- var_hash_swap( &m->variables );
- var_done();
- var_hash_swap( &m->variables );
+ var_done( m );
m->variables = 0;
}
@@ -149,17 +147,6 @@
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 )
{
Modified: trunk/tools/build/v2/engine/modules.h
==============================================================================
--- trunk/tools/build/v2/engine/modules.h (original)
+++ trunk/tools/build/v2/engine/modules.h 2011-12-11 21:02:20 EST (Sun, 11 Dec 2011)
@@ -23,8 +23,6 @@
module_t * bindmodule( OBJECT * name );
module_t * root_module();
-void enter_module( module_t * );
-void exit_module( module_t * );
void delete_module( module_t * );
void import_module( LIST * module_names, module_t * target_module );
Modified: trunk/tools/build/v2/engine/modules/order.c
==============================================================================
--- trunk/tools/build/v2/engine/modules/order.c (original)
+++ trunk/tools/build/v2/engine/modules/order.c 2011-12-11 21:02:20 EST (Sun, 11 Dec 2011)
@@ -16,7 +16,7 @@
{
LIST* arg = lol_get( frame->args, 0 );
- var_set(arg->value, list_copy(0, arg->next), VAR_APPEND);
+ var_set(frame->module, arg->value, list_copy(0, arg->next), VAR_APPEND);
return L0;
}
@@ -92,7 +92,7 @@
for(tmp = arg, src = 0; tmp; tmp = tmp->next, ++src) {
/* For all object this one depend upon, add elements
to 'graph' */
- LIST* dependencies = var_get(tmp->value);
+ LIST* dependencies = var_get(frame->module, tmp->value);
int index = 0;
graph[src] = (int*)BJAM_CALLOC(list_length(dependencies)+1, sizeof(int));
Modified: trunk/tools/build/v2/engine/modules/property-set.c
==============================================================================
--- trunk/tools/build/v2/engine/modules/property-set.c (original)
+++ trunk/tools/build/v2/engine/modules/property-set.c 2011-12-11 21:02:20 EST (Sun, 11 Dec 2011)
@@ -82,7 +82,7 @@
string_push_back(var, '-');
}
name = object_new(var->value);
- val = var_get(name);
+ val = var_get(frame->module, name);
if (val == 0)
{
OBJECT* rulename = object_new("new");
@@ -90,7 +90,7 @@
list_append(list_new(0, object_new("property-set")), unique), 0);
object_free(rulename);
- var_set(name, list_copy(0, val), VAR_SET);
+ var_set(frame->module, name, list_copy(0, val), VAR_SET);
}
else
{
Modified: trunk/tools/build/v2/engine/rules.c
==============================================================================
--- trunk/tools/build/v2/engine/rules.c (original)
+++ trunk/tools/build/v2/engine/rules.c 2011-12-11 21:02:20 EST (Sun, 11 Dec 2011)
@@ -188,13 +188,13 @@
{
if ( strcmp( object_str( s->symbol ), "LOCATE" ) == 0 )
{
- pushsettings( t->settings );
+ pushsettings( root_module(), t->settings );
/* We are binding a target with explicit LOCATE. So third
* argument is of no use: nothing will be returned through it.
*/
object_free( t->boundname );
t->boundname = search( t->name, &t->time, 0, 0 );
- popsettings( t->settings );
+ popsettings( root_module(), t->settings );
break;
}
}
@@ -471,10 +471,10 @@
* pushsettings() - set all target specific variables.
*/
-void pushsettings( SETTINGS * v )
+void pushsettings( struct module_t * module, SETTINGS * v )
{
for ( ; v; v = v->next )
- v->value = var_swap( v->symbol, v->value );
+ v->value = var_swap( module, v->symbol, v->value );
}
@@ -482,9 +482,9 @@
* popsettings() - reset target specific variables to their pre-push values.
*/
-void popsettings( SETTINGS * v )
+void popsettings( struct module_t * module, SETTINGS * v )
{
- pushsettings( v ); /* just swap again */
+ pushsettings( module, v ); /* just swap again */
}
Modified: trunk/tools/build/v2/engine/rules.h
==============================================================================
--- trunk/tools/build/v2/engine/rules.h (original)
+++ trunk/tools/build/v2/engine/rules.h 2011-12-11 21:02:20 EST (Sun, 11 Dec 2011)
@@ -245,8 +245,8 @@
ACTIONS * actionlist ( ACTIONS *, ACTION * );
void freeactions ( ACTIONS * );
SETTINGS * addsettings ( SETTINGS *, int flag, OBJECT * symbol, LIST * value );
-void pushsettings ( SETTINGS * );
-void popsettings ( SETTINGS * );
+void pushsettings ( struct module_t * module, SETTINGS * );
+void popsettings ( struct module_t * module, SETTINGS * );
SETTINGS * copysettings ( SETTINGS * );
void freesettings ( SETTINGS * );
void actions_refer( rule_actions * );
Modified: trunk/tools/build/v2/engine/search.c
==============================================================================
--- trunk/tools/build/v2/engine/search.c (original)
+++ trunk/tools/build/v2/engine/search.c 2011-12-11 21:02:20 EST (Sun, 11 Dec 2011)
@@ -39,7 +39,7 @@
OBJECT * boundname_
)
{
- LIST * bind_rule = var_get( constant_BINDRULE );
+ LIST * bind_rule = var_get( root_module(), constant_BINDRULE );
if ( bind_rule )
{
OBJECT * target = object_copy( target_ );
@@ -117,7 +117,7 @@
f->f_grist.ptr = 0;
f->f_grist.len = 0;
- if ( ( varlist = var_get( constant_LOCATE ) ) )
+ if ( ( varlist = var_get( root_module(), constant_LOCATE ) ) )
{
OBJECT * key;
f->f_root.ptr = object_str( varlist->value );
@@ -135,7 +135,7 @@
object_free( key );
found = 1;
}
- else if ( varlist = var_get( constant_SEARCH ) )
+ else if ( varlist = var_get( root_module(), constant_SEARCH ) )
{
while ( varlist )
{
Modified: trunk/tools/build/v2/engine/variable.c
==============================================================================
--- trunk/tools/build/v2/engine/variable.c (original)
+++ trunk/tools/build/v2/engine/variable.c 2011-12-11 21:02:20 EST (Sun, 11 Dec 2011)
@@ -21,6 +21,7 @@
#include "object.h"
#include "strings.h"
#include "pathsys.h"
+#include "modules.h"
#include <stdlib.h>
#include <stdio.h>
@@ -48,8 +49,6 @@
* 09/11/00 (seiwald) - defunct var_list() removed
*/
-static struct hash *varhash = 0;
-
/*
* VARIABLE - a user defined multi-value variable
*/
@@ -62,25 +61,11 @@
LIST * value;
};
-static VARIABLE * var_enter( OBJECT * symbol );
+static VARIABLE * var_enter( struct module_t * module, OBJECT * symbol );
static void var_dump( OBJECT * symbol, LIST * value, char * what );
/*
- * var_hash_swap() - swap all variable settings with those passed
- *
- * Used to implement separate settings spaces for modules
- */
-
-void var_hash_swap( struct hash * * new_vars )
-{
- struct hash * old = varhash;
- varhash = *new_vars;
- *new_vars = old;
-}
-
-
-/*
* var_defines() - load a bunch of variable=value settings
*
* If preprocess is false, take the value verbatim.
@@ -93,7 +78,7 @@
* Otherwise, split the value at blanks.
*/
-void var_defines( char * const * e, int preprocess )
+void var_defines( struct module_t * module, char * const * e, int preprocess )
{
string buf[1];
@@ -166,7 +151,7 @@
/* Get name. */
string_append_range( buf, *e, val );
varname = object_new( buf->value );
- var_set( varname, l, VAR_SET );
+ var_set( module, varname, l, VAR_SET );
object_free( varname );
string_truncate( buf, 0 );
}
@@ -183,7 +168,7 @@
* Returns NULL if symbol unset.
*/
-LIST * var_get( OBJECT * symbol )
+LIST * var_get( struct module_t * module, OBJECT * symbol )
{
LIST * result = 0;
#ifdef OPT_AT_FILES
@@ -221,7 +206,7 @@
v->symbol = symbol;
- if ( varhash && hashcheck( varhash, (HASHDATA * *)&v ) )
+ if ( module->variables && hashcheck( module->variables, (HASHDATA * *)&v ) )
{
if ( DEBUG_VARGET )
var_dump( v->symbol, v->value, "get" );
@@ -242,9 +227,9 @@
* Copies symbol. Takes ownership of value.
*/
-void var_set( OBJECT * symbol, LIST * value, int flag )
+void var_set( struct module_t * module, OBJECT * symbol, LIST * value, int flag )
{
- VARIABLE * v = var_enter( symbol );
+ VARIABLE * v = var_enter( module, symbol );
if ( DEBUG_VARSET )
var_dump( symbol, value, "set" );
@@ -277,9 +262,9 @@
* var_swap() - swap a variable's value with the given one.
*/
-LIST * var_swap( OBJECT * symbol, LIST * value )
+LIST * var_swap( struct module_t * module, OBJECT * symbol, LIST * value )
{
- VARIABLE * v = var_enter( symbol );
+ VARIABLE * v = var_enter( module, symbol );
LIST * oldvalue = v->value;
if ( DEBUG_VARSET )
var_dump( symbol, value, "set" );
@@ -292,18 +277,18 @@
* var_enter() - make new var symbol table entry, returning var ptr.
*/
-static VARIABLE * var_enter( OBJECT * symbol )
+static VARIABLE * var_enter( struct module_t * module, OBJECT * symbol )
{
VARIABLE var;
VARIABLE * v = &var;
- if ( !varhash )
- varhash = hashinit( sizeof( VARIABLE ), "variables" );
+ if ( !module->variables )
+ module->variables = hashinit( sizeof( VARIABLE ), "variables" );
v->symbol = symbol;
v->value = 0;
- if ( hashenter( varhash, (HASHDATA * *)&v ) )
+ if ( hashenter( module->variables, (HASHDATA * *)&v ) )
v->symbol = object_copy( symbol );
return v;
@@ -334,10 +319,10 @@
}
-void var_done()
+void var_done( struct module_t * module )
{
list_free( saved_var );
saved_var = 0;
- hashenumerate( varhash, delete_var_, (void *)0 );
- hashdone( varhash );
+ hashenumerate( module->variables, delete_var_, (void *)0 );
+ hashdone( module->variables );
}
Modified: trunk/tools/build/v2/engine/variable.h
==============================================================================
--- trunk/tools/build/v2/engine/variable.h (original)
+++ trunk/tools/build/v2/engine/variable.h 2011-12-11 21:02:20 EST (Sun, 11 Dec 2011)
@@ -11,14 +11,13 @@
#ifndef VARIABLE_SW20111119_H
#define VARIABLE_SW20111119_H
-struct hash;
+struct module_t;
-void var_defines( char* const *e, int preprocess );
-LIST * var_get( OBJECT * symbol );
-void var_set( OBJECT * symbol, LIST * value, int flag );
-LIST * var_swap( OBJECT * symbol, LIST *value );
-void var_done();
-void var_hash_swap( struct hash * * );
+void var_defines( struct module_t * module, char * const * e, int preprocess );
+LIST * var_get( struct module_t * module, OBJECT * symbol );
+void var_set( struct module_t * module, OBJECT * symbol, LIST * value, int flag );
+LIST * var_swap( struct module_t * module, OBJECT * symbol, LIST * value );
+void var_done( struct module_t * module );
/*
* Defines for var_set().
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk