diff --git a/v2/engine/builtins.c b/v2/engine/builtins.c index 38a091066..402025289 100644 --- a/v2/engine/builtins.c +++ b/v2/engine/builtins.c @@ -84,12 +84,11 @@ RULE * bind_builtin( const char * name_, LIST * (* f)( FRAME *, int flags ), int { FUNCTION * func; RULE * result; - argument_list* arg_list = 0; OBJECT * name = object_new( name_ ); func = function_builtin( f, flags, args ); - result = new_rule_body( root_module(), name, arg_list, func, 1 ); + result = new_rule_body( root_module(), name, func, 1 ); function_free( func ); @@ -1593,7 +1592,7 @@ LIST * builtin_native_rule( FRAME * frame, int flags ) native_rule_t * np; if ( module->native_rules && (np = (native_rule_t *)hash_find( module->native_rules, list_front( rule_name ) ) ) ) { - new_rule_body( module, np->name, 0, np->procedure, 1 ); + new_rule_body( module, np->name, np->procedure, 1 ); } else { @@ -1841,7 +1840,7 @@ LIST * builtin_python_import_rule( FRAME * frame, int flags ) if ( pFunc && PyCallable_Check( pFunc ) ) { module_t * m = bindmodule( jam_module ); - new_rule_body( m, jam_rule, 0, function_python( pFunc, 0 ), 0 ); + new_rule_body( m, jam_rule, function_python( pFunc, 0 ), 0 ); } else { @@ -2005,12 +2004,9 @@ PyObject * bjam_import_rule( PyObject * self, PyObject * args ) object_free( module_name ); } rule_name = object_new( rule ); - r = bindrule( rule_name, m ); + new_rule_body( m, rule_name, function_python( func, bjam_signature ), 0 ); object_free( rule_name ); - /* Make pFunc owned. */ - r->procedure = function_python( func, bjam_signature ); - Py_INCREF( Py_None ); return Py_None; } diff --git a/v2/engine/function.c b/v2/engine/function.c index b9ecf0cba..b70013ebf 100644 --- a/v2/engine/function.c +++ b/v2/engine/function.c @@ -295,8 +295,7 @@ static void function_default_variable( JAM_FUNCTION * function, FRAME * frame, i static void function_set_rule( JAM_FUNCTION * function, FRAME * frame, STACK * s, int idx ) { SUBFUNCTION * sub = function->functions + idx; - argument_list * args = 0; - new_rule_body( frame->module, sub->name, args, sub->code, !sub->local ); + new_rule_body( frame->module, sub->name, sub->code, !sub->local ); } static void function_set_actions( JAM_FUNCTION * function, FRAME * frame, STACK * s, int idx ) diff --git a/v2/engine/rules.c b/v2/engine/rules.c index 8ee034720..8276e6ba0 100644 --- a/v2/engine/rules.c +++ b/v2/engine/rules.c @@ -45,7 +45,7 @@ */ static void set_rule_actions( RULE *, rule_actions * ); -static void set_rule_body ( RULE *, argument_list *, FUNCTION * procedure ); +static void set_rule_body ( RULE *, FUNCTION * procedure ); static struct hash * targethash = 0; @@ -86,7 +86,6 @@ static RULE * enter_rule( OBJECT * rulename, module_t * target_module ) r->procedure = 0; r->module = 0; r->actions = 0; - r->arguments = 0; r->exported = 0; r->module = target_module; } @@ -110,7 +109,7 @@ static RULE * define_rule RULE * r = enter_rule( rulename, target_module ); if ( r->module != src_module ) /* if the rule was imported from elsewhere, clear it now */ { - set_rule_body( r, 0, 0 ); + set_rule_body( r, 0 ); set_rule_actions( r, 0 ); r->module = src_module; /* r will be executed in the source module */ } @@ -125,9 +124,6 @@ void rule_free( RULE * r ) if ( r->procedure ) function_free( r->procedure ); r->procedure = 0; - if ( r->arguments ) - args_free( r->arguments ); - r->arguments = 0; if ( r->actions ) actions_free( r->actions ); r->actions = 0; @@ -487,43 +483,6 @@ void rules_done() } -/* - * args_new() - make a new reference-counted argument list. - */ - -argument_list * args_new() -{ - argument_list * r = (argument_list *)BJAM_MALLOC( sizeof(argument_list) ); - r->reference_count = 0; - lol_init( r->data ); - return r; -} - - -/* - * args_refer() - add a new reference to the given argument list. - */ - -void args_refer( argument_list * a ) -{ - ++a->reference_count; -} - - -/* - * args_free() - release a reference to the given argument list. - */ - -void args_free( argument_list * a ) -{ - if ( --a->reference_count <= 0 ) - { - lol_free( a->data ); - BJAM_FREE( a ); - } -} - - /* * actions_refer() - add a new reference to the given actions. */ @@ -552,14 +511,8 @@ void actions_free( rule_actions * a ) * set_rule_body() - set the argument list and procedure of the given rule. */ -static void set_rule_body( RULE * rule, argument_list * args, FUNCTION * procedure ) +static void set_rule_body( RULE * rule, FUNCTION * procedure ) { - if ( args ) - args_refer( args ); - if ( rule->arguments ) - args_free( rule->arguments ); - rule->arguments = args; - if ( procedure ) function_refer( procedure ); if ( rule->procedure ) @@ -616,11 +569,11 @@ static RULE * global_rule( RULE * r ) * exported to the global module as modulename.rulename. */ -RULE * new_rule_body( module_t * m, OBJECT * rulename, argument_list * args, FUNCTION * procedure, int exported ) +RULE * new_rule_body( module_t * m, OBJECT * rulename, FUNCTION * procedure, int exported ) { RULE * local = define_rule( m, rulename, m ); local->exported = exported; - set_rule_body( local, args, procedure ); + set_rule_body( local, procedure ); /* Mark the procedure with the global rule name, regardless of whether the * rule is exported. That gives us something reasonably identifiable that we @@ -749,7 +702,7 @@ RULE * bindrule( OBJECT * rulename, module_t * m ) RULE * import_rule( RULE * source, module_t * m, OBJECT * name ) { RULE * dest = define_rule( source->module, name, m ); - set_rule_body( dest, source->arguments, source->procedure ); + set_rule_body( dest, source->procedure ); set_rule_actions( dest, source->actions ); return dest; } diff --git a/v2/engine/rules.h b/v2/engine/rules.h index 74cc4873b..0cc476044 100644 --- a/v2/engine/rules.h +++ b/v2/engine/rules.h @@ -52,13 +52,6 @@ typedef struct _settings SETTINGS ; /* RULE - a generic jam rule, the product of RULE and ACTIONS. */ -/* A rule's argument list. */ -struct argument_list -{ - int reference_count; - LOL data[1]; -}; - /* Build actions corresponding to a rule. */ struct rule_actions { @@ -82,8 +75,6 @@ struct _rule { OBJECT * name; FUNCTION * procedure; - argument_list * arguments; /* argument checking info, or NULL for unchecked - */ rule_actions * actions; /* build actions, or NULL for no actions */ module_t * module; /* module in which this rule is executed */ int exported; /* nonzero if this rule is supposed to appear in @@ -253,16 +244,11 @@ void freesettings ( SETTINGS * ); void actions_refer( rule_actions * ); void actions_free ( rule_actions * ); -/* Argument list related functions. */ -void args_free ( argument_list * ); -argument_list * args_new (); -void args_refer( argument_list * ); - /* Rule related functions. */ RULE * bindrule ( OBJECT * rulename, module_t * ); RULE * import_rule ( RULE * source, module_t *, OBJECT * name ); void rule_localize ( RULE * rule, module_t * module ); -RULE * new_rule_body ( module_t *, OBJECT * rulename, argument_list *, FUNCTION * func, int exprt ); +RULE * new_rule_body ( module_t *, OBJECT * rulename, FUNCTION * func, int exprt ); RULE * new_rule_actions( module_t *, OBJECT * rulename, FUNCTION * command, LIST * bindlist, int flags ); void rule_free ( RULE * );