Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77515 - trunk/tools/build/v2/engine
From: steven_at_[hidden]
Date: 2012-03-24 14:53:23


Author: steven_watanabe
Date: 2012-03-24 14:53:21 EDT (Sat, 24 Mar 2012)
New Revision: 77515
URL: http://svn.boost.org/trac/boost/changeset/77515

Log:
Start cleaning up the arg_list hacks. Make the argument list part of the function instead of part of the rule. Don't var expand formal arguments.
Text files modified:
   trunk/tools/build/v2/engine/builtins.c | 11
   trunk/tools/build/v2/engine/compile.c | 10
   trunk/tools/build/v2/engine/function.c | 461 ++++++++++++++++++++++++++++-----------
   trunk/tools/build/v2/engine/function.h | 2
   trunk/tools/build/v2/engine/modules.c | 2
   trunk/tools/build/v2/engine/native.c | 11
   trunk/tools/build/v2/engine/native.h | 5
   trunk/tools/build/v2/engine/rules.c | 5
   8 files changed, 337 insertions(+), 170 deletions(-)

Modified: trunk/tools/build/v2/engine/builtins.c
==============================================================================
--- trunk/tools/build/v2/engine/builtins.c (original)
+++ trunk/tools/build/v2/engine/builtins.c 2012-03-24 14:53:21 EDT (Sat, 24 Mar 2012)
@@ -87,13 +87,7 @@
     argument_list* arg_list = 0;
     OBJECT * name = object_new( name_ );
 
- if ( args )
- {
- arg_list = args_new();
- lol_build( arg_list->data, args );
- }
-
- func = function_builtin( f, flags );
+ func = function_builtin( f, flags, args );
 
     result = new_rule_body( root_module(), name, arg_list, func, 1 );
 
@@ -1599,8 +1593,7 @@
     native_rule_t * np;
     if ( module->native_rules && (np = (native_rule_t *)hash_find( module->native_rules, list_front( rule_name ) ) ) )
     {
- args_refer( np->arguments );
- new_rule_body( module, np->name, np->arguments, np->procedure, 1 );
+ new_rule_body( module, np->name, 0, np->procedure, 1 );
     }
     else
     {

Modified: trunk/tools/build/v2/engine/compile.c
==============================================================================
--- trunk/tools/build/v2/engine/compile.c (original)
+++ trunk/tools/build/v2/engine/compile.c 2012-03-24 14:53:21 EDT (Sat, 24 Mar 2012)
@@ -115,7 +115,7 @@
 }
 
 
-void argument_error( const char * message, RULE * rule, FRAME * frame, OBJECT * arg )
+static void argument_error( const char * message, RULE * rule, FRAME * frame, OBJECT * arg )
 {
     LOL * actual = frame->args;
     assert( rule->procedure != 0 );
@@ -183,7 +183,7 @@
  * checked
  */
 
-void type_check_range
+static void type_check_range
 (
     OBJECT * type_name,
     LISTITER iter,
@@ -228,7 +228,7 @@
     }
 }
 
-void type_check
+static void type_check
 (
     OBJECT * type_name,
     LIST * values,
@@ -498,7 +498,7 @@
 
 #endif
 
-LIST * function_run_with_args( FUNCTION * function_, FRAME * frame, STACK * s, RULE * rule );
+LIST * function_run_with_args( FUNCTION * function_, FRAME * frame, STACK * s );
 
 /*
  * evaluate_rule() - execute a rule invocation.
@@ -654,7 +654,7 @@
         FUNCTION * function = rule->procedure;
 
         function_refer( function );
- result = function_run_with_args( function, frame, stack_global(), rule );
+ result = function_run_with_args( function, frame, stack_global() );
         function_free( function );
     }
 

Modified: trunk/tools/build/v2/engine/function.c
==============================================================================
--- trunk/tools/build/v2/engine/function.c (original)
+++ trunk/tools/build/v2/engine/function.c 2012-03-24 14:53:21 EDT (Sat, 24 Mar 2012)
@@ -120,7 +120,6 @@
 {
     OBJECT * name;
     FUNCTION * code;
- int arguments;
     int local;
 } SUBFUNCTION;
 
@@ -282,22 +281,6 @@
 {
     SUBFUNCTION * sub = function->functions + idx;
     argument_list * args = 0;
-
- if ( sub->arguments )
- {
- int i;
- args = args_new();
- for ( i = sub->arguments; i > 0; --i )
- {
- lol_add( args->data, stack_at( s, i - 1 ) );
- }
-
- for ( i = 0; i < sub->arguments; ++i )
- {
- stack_pop( s );
- }
- }
-
     new_rule_body( frame->module, sub->name, args, sub->code, !sub->local );
 }
 
@@ -1078,7 +1061,8 @@
 {
     OBJECT * name;
     PARSE * parse;
- int arguments;
+ int num_arguments;
+ struct arg_list * arguments;
     int local;
 };
 
@@ -1177,11 +1161,12 @@
     return c->constants->size - 1;
 }
 
-static int compile_emit_rule( compiler * c, OBJECT * name, PARSE * parse, int arguments, int local )
+static int compile_emit_rule( compiler * c, OBJECT * name, PARSE * parse, int num_arguments, struct arg_list * arguments, int local )
 {
     struct stored_rule rule;
     rule.name = object_copy( name );
     rule.parse = parse;
+ rule.num_arguments = num_arguments;
     rule.arguments = arguments;
     rule.local = local;
     dynamic_array_push( c->rules, rule );
@@ -1224,7 +1209,8 @@
         struct stored_rule * rule = &dynamic_array_at( struct stored_rule, c->rules, i );
         result->functions[i].name = rule->name;
         result->functions[i].code = function_compile( rule->parse );
- result->functions[i].arguments = rule->arguments;
+ result->functions[i].code->num_formal_arguments = rule->num_arguments;
+ result->functions[i].code->formal_arguments = rule->arguments;
         result->functions[i].local = rule->local;
     }
 
@@ -1967,6 +1953,7 @@
 #define RESULT_NONE 2
 
 static void compile_parse( PARSE * parse, compiler * c, int result_location );
+static struct arg_list * arg_list_compile( PARSE * parse, int * num_arguments );
 
 static void compile_condition( PARSE * parse, compiler * c, int branch_true, int label )
 {
@@ -2451,19 +2438,10 @@
     }
     else if ( parse->type == PARSE_SETCOMP )
     {
- int n_args = 0;
- int rule_id;
- if ( parse->right )
- {
- PARSE * p;
- for ( p = parse->right; p; p = p->left )
- {
- compile_parse( p->right, c, RESULT_STACK );
- ++n_args;
- }
- }
+ int n_args;
+ struct arg_list * args = arg_list_compile( parse->right, &n_args );
 
- rule_id = compile_emit_rule( c, parse->string, parse->left, n_args, parse->num );
+ int rule_id = compile_emit_rule( c, parse->string, parse->left, n_args, args, parse->num );
 
         compile_emit( c, INSTR_RULE, rule_id );
         adjust_result( c, RESULT_NONE, result_location );
@@ -2546,7 +2524,7 @@
     }
 }
 
-FUNCTION * function_builtin( LIST * ( * func )( FRAME * frame, int flags ), int flags )
+FUNCTION * function_builtin( LIST * ( * func )( FRAME * frame, int flags ), int flags, const char * * args )
 {
     BUILTIN_FUNCTION * result = BJAM_MALLOC( sizeof( BUILTIN_FUNCTION ) );
     result->base.type = FUNCTION_BUILTIN;
@@ -2592,27 +2570,81 @@
     return (FUNCTION *)result;
 }
 
-void argument_error( const char * message, RULE * rule, FRAME * frame, OBJECT * arg );
 int is_type_name( const char * s );
+static void argument_list_print( struct arg_list * args, int num_args );
 
-void type_check_range
+static void argument_error( const char * message, FUNCTION * procedure, FRAME * frame, OBJECT * arg )
+{
+ LOL * actual = frame->args;
+ backtrace_line( frame->prev );
+ printf( "*** argument error\n* rule %s ( ", frame->rulename );
+ argument_list_print( procedure->formal_arguments, procedure->num_formal_arguments );
+ printf( " )\n* called with: ( " );
+ lol_print( actual );
+ printf( " )\n* %s %s\n", message, arg ? object_str ( arg ) : "" );
+ function_location( procedure, &frame->file, &frame->line );
+ print_source_line( frame );
+ printf( "see definition of rule '%s' being called\n", frame->rulename );
+ backtrace( frame->prev );
+ exit( 1 );
+}
+
+static void type_check_range
 (
- OBJECT * type_name,
- LISTITER iter,
- LISTITER end,
- FRAME * caller,
- RULE * called,
- OBJECT * arg_name
-);
+ OBJECT * type_name,
+ LISTITER iter,
+ LISTITER end,
+ FRAME * caller,
+ FUNCTION * called,
+ OBJECT * arg_name
+)
+{
+ static module_t * typecheck = 0;
+
+ /* If nothing to check, bail now. */
+ if ( iter == end || !type_name )
+ return;
 
-void type_check
+ if ( !typecheck )
+ {
+ typecheck = bindmodule( constant_typecheck );
+ }
+
+ /* If the checking rule can not be found, also bail. */
+ if ( !typecheck->rules || !hash_find( typecheck->rules, type_name ) )
+ return;
+
+ for ( ; iter != end; iter = list_next( iter ) )
+ {
+ LIST *error;
+ FRAME frame[1];
+ frame_init( frame );
+ frame->module = typecheck;
+ frame->prev = caller;
+ frame->prev_user = caller->module->user_module ? caller : caller->prev_user;
+
+ /* Prepare the argument list */
+ lol_add( frame->args, list_new( L0, object_copy( list_item( iter ) ) ) );
+ error = evaluate_rule( type_name, frame );
+
+ if ( !list_empty( error ) )
+ argument_error( object_str( list_front( error ) ), called, caller, arg_name );
+
+ frame_free( frame );
+ }
+}
+
+static void type_check
 (
- OBJECT * type_name,
- LIST * values,
- FRAME * caller,
- RULE * called,
- OBJECT * arg_name
-);
+ OBJECT * type_name,
+ LIST * values,
+ FRAME * caller,
+ FUNCTION * called,
+ OBJECT * arg_name
+)
+{
+ type_check_range( type_name, list_begin( values ), list_end( values ), caller, called, arg_name );
+}
 
 struct argument {
     int flags;
@@ -2631,7 +2663,7 @@
     struct argument * args;
 };
 
-void argument_list_check( struct arg_list * formal, int formal_count, RULE * rule, FRAME * frame )
+void argument_list_check( struct arg_list * formal, int formal_count, FUNCTION * function, FRAME * frame )
 {
     LOL * all_actual = frame->args;
     int i, j;
@@ -2649,8 +2681,8 @@
             {
             case ARG_ONE:
                 if ( actual_iter == actual_end )
- argument_error( "missing argument", rule, frame, formal_arg->arg_name );
- type_check_range( formal_arg->type_name, actual_iter, list_next( actual_iter ), frame, rule, formal_arg->arg_name );
+ argument_error( "missing argument", function, frame, formal_arg->arg_name );
+ type_check_range( formal_arg->type_name, actual_iter, list_next( actual_iter ), frame, function, formal_arg->arg_name );
                 actual_iter = list_next( actual_iter );
                 break;
             case ARG_OPTIONAL:
@@ -2658,16 +2690,16 @@
                     value = L0;
                 else
                 {
- type_check_range( formal_arg->type_name, actual_iter, list_next( actual_iter ), frame, rule, formal_arg->arg_name );
+ type_check_range( formal_arg->type_name, actual_iter, list_next( actual_iter ), frame, function, formal_arg->arg_name );
                     actual_iter = list_next( actual_iter );
                 }
                 break;
             case ARG_PLUS:
                 if ( actual_iter == actual_end )
- argument_error( "missing argument", rule, frame, formal_arg->arg_name );
+ argument_error( "missing argument", function, frame, formal_arg->arg_name );
                 /* fallthrough */
             case ARG_STAR:
- type_check_range( formal_arg->type_name, actual_iter, actual_end, frame, rule, formal_arg->arg_name );
+ type_check_range( formal_arg->type_name, actual_iter, actual_end, frame, function, formal_arg->arg_name );
                 actual_iter = actual_end;
             case ARG_VARIADIC:
                 return;
@@ -2676,7 +2708,7 @@
 
         if ( actual_iter != actual_end )
         {
- argument_error( "extra argument", rule, frame, list_item( actual_iter ) );
+ argument_error( "extra argument", function, frame, list_item( actual_iter ) );
         }
     }
 
@@ -2685,12 +2717,12 @@
         LIST * actual = lol_get( all_actual, i );
         if ( !list_empty( actual ) )
         {
- argument_error( "extra argument", rule, frame, list_front( actual ) );
+ argument_error( "extra argument", function, frame, list_front( actual ) );
         }
     }
 }
 
-void argument_list_push( struct arg_list * formal, int formal_count, RULE * rule, FRAME * frame, STACK * s )
+void argument_list_push( struct arg_list * formal, int formal_count, FUNCTION * function, FRAME * frame, STACK * s )
 {
     LOL * all_actual = frame->args;
     int i, j;
@@ -2708,7 +2740,7 @@
             {
             case ARG_ONE:
                 if ( actual_iter == actual_end )
- argument_error( "missing argument", rule, frame, formal_arg->arg_name );
+ argument_error( "missing argument", function, frame, formal_arg->arg_name );
                 value = list_new( L0, object_copy( list_item( actual_iter ) ) );
                 actual_iter = list_next( actual_iter );
                 break;
@@ -2723,7 +2755,7 @@
                 break;
             case ARG_PLUS:
                 if ( actual_iter == actual_end )
- argument_error( "missing argument", rule, frame, formal_arg->arg_name );
+ argument_error( "missing argument", function, frame, formal_arg->arg_name );
                 /* fallthrough */
             case ARG_STAR:
                 value = list_copy_range( actual, actual_iter, actual_end );
@@ -2733,7 +2765,7 @@
                 return;
             }
 
- type_check( formal_arg->type_name, value, frame, rule, formal_arg->arg_name );
+ type_check( formal_arg->type_name, value, frame, function, formal_arg->arg_name );
 
             if ( formal_arg->index != -1 )
             {
@@ -2749,7 +2781,7 @@
 
         if ( actual_iter != actual_end )
         {
- argument_error( "extra argument", rule, frame, list_item( actual_iter ) );
+ argument_error( "extra argument", function, frame, list_item( actual_iter ) );
         }
     }
 
@@ -2758,7 +2790,7 @@
         LIST * actual = lol_get( all_actual, i );
         if ( !list_empty( actual ) )
         {
- argument_error( "extra argument", rule, frame, list_front( actual ) );
+ argument_error( "extra argument", function, frame, list_front( actual ) );
         }
     }
 }
@@ -2793,85 +2825,250 @@
 }
 
 
-struct arg_list * argument_list_compile( LOL * all_formal, RULE * rule )
+struct argument_compiler
 {
- struct arg_list * result = (struct arg_list *)BJAM_MALLOC( sizeof( struct arg_list ) * all_formal->count );
+ struct dynamic_array args[ 1 ];
+ struct argument arg;
+ int state;
+#define ARGUMENT_COMPILER_START 0
+#define ARGUMENT_COMPILER_FOUND_TYPE 1
+#define ARGUMENT_COMPILER_FOUND_OBJECT 2
+#define ARGUMENT_COMPILER_DONE 3
+};
+
+
+static void argument_compiler_init( struct argument_compiler * c )
+{
+ dynamic_array_init( c->args );
+ c->state = ARGUMENT_COMPILER_START;
+}
 
- int n;
- struct dynamic_array args[1];
- dynamic_array_init( args );
- for ( n = 0; n < all_formal->count ; ++n )
+static void argument_compiler_free( struct argument_compiler * c )
+{
+ dynamic_array_free( c->args );
+}
+
+static void argument_compiler_add( struct argument_compiler * c, OBJECT * arg, OBJECT * file, int line )
+{
+ switch ( c->state )
     {
- LIST *formal;
- LISTITER formal_iter, formal_end;
- for ( formal = lol_get( all_formal, n ),
- formal_iter = list_begin( formal ), formal_end = list_end( formal );
- formal_iter != formal_end; )
+ case ARGUMENT_COMPILER_FOUND_OBJECT:
+
+ if ( object_equal( arg, constant_question_mark ) )
+ {
+ c->arg.flags = ARG_OPTIONAL;
+ }
+ else if ( object_equal( arg, constant_plus ) )
+ {
+ c->arg.flags = ARG_PLUS;
+ }
+ else if ( object_equal( arg, constant_star ) )
         {
- struct argument arg;
- arg.type_name = 0;
- arg.arg_name = list_item( formal_iter );
- arg.index = -1;
+ c->arg.flags = ARG_STAR;
+ }
 
- if ( is_type_name( object_str( arg.arg_name ) ) )
- {
+ dynamic_array_push( c->args, c->arg );
+ c->state = ARGUMENT_COMPILER_START;
 
- formal_iter = list_next( formal_iter );
+ if ( c->arg.flags != ARG_ONE )
+ break;
+ /* fall-through */
 
- if ( formal_iter == formal_end )
- argument_error( "missing argument name after type name:", rule, 0, arg.arg_name );
+ case ARGUMENT_COMPILER_START:
 
- arg.type_name = arg.arg_name;
- arg.arg_name = list_item( formal_iter );
+ c->arg.type_name = 0;
+ c->arg.index = -1;
+ c->arg.flags = ARG_ONE;
 
- if ( is_type_name( object_str( arg.arg_name ) ) )
- argument_error( "missing argument name before type name:", rule, 0, arg.arg_name );
- }
+ if ( is_type_name( object_str( arg ) ) )
+ {
+ c->arg.type_name = arg;
+ c->state = ARGUMENT_COMPILER_FOUND_TYPE;
+ break;
+ }
+ /* fall-through */
 
- formal_iter = list_next( formal_iter );
+ case ARGUMENT_COMPILER_FOUND_TYPE:
+
+ if ( is_type_name( object_str( arg ) ) )
+ {
+ printf( "%s:%d: missing argument name before type name: %s\n", object_str( file ), line, object_str( arg ) );
+ exit( 1 );
+ }
+
+ c->arg.arg_name = arg;
+ if ( object_equal( arg, constant_star ) )
+ {
+ c->arg.flags = ARG_VARIADIC;
+ dynamic_array_push( c->args, c->arg );
+ c->state = ARGUMENT_COMPILER_DONE;
+ }
+ else
+ {
+ c->state = ARGUMENT_COMPILER_FOUND_OBJECT;
+ }
+ break;
 
- if ( object_equal( arg.arg_name, constant_star ) )
- {
- arg.flags = ARG_VARIADIC;
- }
- else if ( formal_iter != formal_end )
- {
- if ( object_equal( list_item( formal_iter ), constant_question_mark ) )
- {
- arg.flags = ARG_OPTIONAL;
- formal_iter = list_next( formal_iter );
- }
- else if ( object_equal( list_item( formal_iter ), constant_plus ) )
- {
- arg.flags = ARG_PLUS;
- formal_iter = list_next( formal_iter );
- }
- else if ( object_equal( list_item( formal_iter ), constant_star ) )
- {
- arg.flags = ARG_STAR;
- formal_iter = list_next( formal_iter );
- }
- else
- arg.flags = ARG_ONE;
- }
- else
- {
- arg.flags = ARG_ONE;
- }
+ case ARGUMENT_COMPILER_DONE:
+ break;
+ }
+}
 
- dynamic_array_push( args, arg );
- }
+static void argument_compiler_recurse( struct argument_compiler * c, PARSE * parse )
+{
+ if ( parse->type == PARSE_APPEND )
+ {
+ argument_compiler_recurse( c, parse->left );
+ argument_compiler_recurse( c, parse->right );
+ }
+ else if ( parse->type != PARSE_NULL )
+ {
+ assert( parse->type == PARSE_LIST );
+ argument_compiler_add( c, parse->string, parse->file, parse->line );
+ }
+}
 
- result[ n ].args = BJAM_MALLOC( args[ 0 ].size * sizeof( struct argument ) );
- result[ n ].size = args[ 0 ].size;
- memcpy( result[n].args, args[ 0 ].data, args[ 0 ].size * sizeof( struct argument ) );
- args[ 0 ].size = 0;
+static struct arg_list arg_compile_impl( struct argument_compiler * c, OBJECT * file, int line )
+{
+ struct arg_list result;
+ switch ( c->state )
+ {
+ case ARGUMENT_COMPILER_START:
+ case ARGUMENT_COMPILER_DONE:
+ break;
+ case ARGUMENT_COMPILER_FOUND_TYPE:
+ printf( "%s:%d: missing argument name after type name: %s\n", object_str( file ), line, object_str( c->arg.type_name ) );
+ exit( 1 );
+ case ARGUMENT_COMPILER_FOUND_OBJECT:
+ dynamic_array_push( c->args, c->arg );
+ break;
     }
- dynamic_array_free( args );
+ result.size = c->args->size;
+ result.args = BJAM_MALLOC( c->args->size * sizeof( struct argument ) );
+ memcpy( result.args, c->args->data, c->args->size * sizeof( struct argument ) );
+ return result;
+}
 
+static struct arg_list arg_compile( PARSE * parse )
+{
+ struct argument_compiler c[ 1 ];
+ struct arg_list result;
+ argument_compiler_init( c );
+ argument_compiler_recurse( c, parse );
+ result = arg_compile_impl( c, parse->file, parse->line );
+ argument_compiler_free( c );
     return result;
 }
 
+struct argument_list_compiler
+{
+ struct dynamic_array args[ 1 ];
+};
+
+static void argument_list_compiler_init( struct argument_list_compiler * c )
+{
+ dynamic_array_init( c->args );
+}
+
+static void argument_list_compiler_free( struct argument_list_compiler * c )
+{
+ dynamic_array_free( c->args );
+}
+
+static void argument_list_compiler_add( struct argument_list_compiler * c, PARSE * parse )
+{
+ struct arg_list args = arg_compile( parse );
+ dynamic_array_push( c->args, args );
+}
+
+static void argument_list_compiler_recurse( struct argument_list_compiler * c, PARSE * parse )
+{
+ if ( parse )
+ {
+ argument_list_compiler_add( c, parse->right );
+ argument_list_compiler_recurse( c, parse->left );
+ }
+}
+
+static struct arg_list * arg_list_compile( PARSE * parse, int * num_arguments )
+{
+ if ( parse )
+ {
+ struct argument_list_compiler c[ 1 ];
+ struct arg_list * result;
+ argument_list_compiler_init( c );
+ argument_list_compiler_recurse( c, parse );
+ *num_arguments = c->args->size;
+ result = BJAM_MALLOC( c->args->size * sizeof( struct arg_list ) );
+ memcpy( result, c->args->data, c->args->size * sizeof( struct arg_list ) );
+ argument_list_compiler_free( c );
+ return result;
+ }
+ else
+ {
+ *num_arguments = 0;
+ return 0;
+ }
+}
+
+static struct arg_list * arg_list_compile_builtin( const char * * args, int * num_arguments )
+{
+ if ( args )
+ {
+ struct argument_list_compiler c[ 1 ];
+ struct arg_list * result;
+ argument_list_compiler_init( c );
+ while ( *args )
+ {
+ struct argument_compiler arg_comp[ 1 ];
+ struct arg_list arg;
+ argument_compiler_init( arg_comp );
+ for ( ; *args && !strcmp( *args, ":" ); ++args )
+ {
+ argument_compiler_add( arg_comp, object_new( *args ), constant_builtin, -1 );
+ }
+ arg = arg_compile_impl( arg_comp, constant_builtin, -1 );
+ dynamic_array_push( c->args, arg );
+ argument_compiler_free( arg_comp );
+ }
+ *num_arguments = c->args->size;
+ result = BJAM_MALLOC( c->args->size * sizeof( struct arg_list ) );
+ memcpy( result, c->args->data, c->args->size * sizeof( struct arg_list ) );
+ argument_list_compiler_free( c );
+ return result;
+ }
+ else
+ {
+ *num_arguments = 0;
+ return 0;
+ }
+}
+
+static void argument_list_print( struct arg_list * args, int num_args )
+{
+ if ( args )
+ {
+ int i, j;
+ for ( i = 0; i < num_args; ++i )
+ {
+ if ( i ) printf(" : ");
+ for ( j = 0; j < args[ i ].size; ++j )
+ {
+ struct argument * formal_arg = &args[ i ].args[ j ];
+ if ( j ) printf( " " );
+ if ( formal_arg->type_name ) printf( "%s ", object_str( formal_arg->type_name ) );
+ printf( "%s", formal_arg->arg_name );
+ switch( formal_arg->flags )
+ {
+ case ARG_OPTIONAL: printf( " ?" ); break;
+ case ARG_PLUS: printf( " +" ); break;
+ case ARG_STAR: printf( " *" ); break;
+ }
+ }
+ }
+ }
+}
+
 
 struct arg_list * argument_list_bind_variables( struct arg_list * formal, int formal_count, module_t * module, int * counter )
 {
@@ -2915,16 +3112,6 @@
 }
 
 
-void function_set_argument_list( FUNCTION * f, LOL * formal, RULE * rule )
-{
- if ( !f->formal_arguments && formal )
- {
- f->formal_arguments = argument_list_compile( formal, rule );
- f->num_formal_arguments = formal->count;
- }
-}
-
-
 FUNCTION * function_unbind_variables( FUNCTION * f )
 {
     if ( f->type == FUNCTION_JAM )
@@ -3099,19 +3286,19 @@
     stack_deallocate( s, sizeof( string * ) );
 }
 
-LIST * function_run_with_args( FUNCTION * function_, FRAME * frame, STACK * s, RULE * rule )
+LIST * function_run_with_args( FUNCTION * function_, FRAME * frame, STACK * s )
 {
     LIST * result;
     if ( function_->type == FUNCTION_BUILTIN )
     {
         BUILTIN_FUNCTION * f = (BUILTIN_FUNCTION *)function_;
         if ( function_->formal_arguments )
- argument_list_check( function_->formal_arguments, function_->num_formal_arguments, rule, frame );
+ argument_list_check( function_->formal_arguments, function_->num_formal_arguments, function_, frame );
         return f->func( frame, f->flags );
     }
     
     if ( function_->formal_arguments )
- argument_list_push( function_->formal_arguments, function_->num_formal_arguments, rule, frame, s );
+ argument_list_push( function_->formal_arguments, function_->num_formal_arguments, function_, frame, s );
     
     result = function_run( function_, frame, s );
 

Modified: trunk/tools/build/v2/engine/function.h
==============================================================================
--- trunk/tools/build/v2/engine/function.h (original)
+++ trunk/tools/build/v2/engine/function.h 2012-03-24 14:53:21 EDT (Sat, 24 Mar 2012)
@@ -21,7 +21,7 @@
 LIST * stack_pop( STACK * s );
 
 FUNCTION * function_compile( PARSE * parse );
-FUNCTION * function_builtin( LIST * ( * func )( FRAME * frame, int flags ), int flags );
+FUNCTION * function_builtin( LIST * ( * func )( FRAME * frame, int flags ), int flags, const char * * args );
 void function_refer( FUNCTION * );
 void function_free( FUNCTION * );
 OBJECT * function_rulename( FUNCTION * );

Modified: trunk/tools/build/v2/engine/modules.c
==============================================================================
--- trunk/tools/build/v2/engine/modules.c (original)
+++ trunk/tools/build/v2/engine/modules.c 2012-03-24 14:53:21 EDT (Sat, 24 Mar 2012)
@@ -82,8 +82,6 @@
 static void delete_native_rule( void * xrule, void * data )
 {
     native_rule_t * rule = (native_rule_t *)xrule;
- if ( rule->arguments )
- args_free( rule->arguments );
     object_free( rule->name );
     if ( rule->procedure )
         function_free( rule->procedure );

Modified: trunk/tools/build/v2/engine/native.c
==============================================================================
--- trunk/tools/build/v2/engine/native.c (original)
+++ trunk/tools/build/v2/engine/native.c 2012-03-24 14:53:21 EDT (Sat, 24 Mar 2012)
@@ -33,16 +33,7 @@
         np = (native_rule_t *)hash_insert( m->native_rules, name, &found );
         np->name = name;
         assert( !found );
- if ( args )
- {
- np->arguments = args_new();
- lol_build( np->arguments->data, args );
- }
- else
- {
- np->arguments = 0;
- }
- np->procedure = function_builtin( f, 0 );
+ np->procedure = function_builtin( f, 0, args );
         np->version = version;
     }
 }

Modified: trunk/tools/build/v2/engine/native.h
==============================================================================
--- trunk/tools/build/v2/engine/native.h (original)
+++ trunk/tools/build/v2/engine/native.h 2012-03-24 14:53:21 EDT (Sat, 24 Mar 2012)
@@ -5,12 +5,15 @@
 #ifndef NATIVE_H_VP_2003_12_09
 #define NATIVE_H_VP_2003_12_09
 
+#include "lists.h"
+#include "object.h"
+#include "frames.h"
+#include "function.h"
 #include "rules.h"
 
 struct native_rule_t
 {
     OBJECT * name;
- argument_list * arguments;
     FUNCTION * procedure;
     /* Version of the interface that the native rule provides.
        It's possible that we want to change the set parameter

Modified: trunk/tools/build/v2/engine/rules.c
==============================================================================
--- trunk/tools/build/v2/engine/rules.c (original)
+++ trunk/tools/build/v2/engine/rules.c 2012-03-24 14:53:21 EDT (Sat, 24 Mar 2012)
@@ -556,8 +556,6 @@
     }
 }
 
-void function_set_argument_list( FUNCTION * f, LOL * formal, RULE * rule );
-
 /*
  * set_rule_body() - set the argument list and procedure of the given rule.
  */
@@ -570,9 +568,6 @@
         args_free( rule->arguments );
     rule->arguments = args;
 
- if ( procedure && args )
- function_set_argument_list( procedure, args->data, rule );
-
     if ( procedure )
         function_refer( procedure );
     if ( rule->procedure )


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