mirror of
https://github.com/boostorg/build.git
synced 2026-02-15 13:02:11 +00:00
Reimplement the interpreter.
[SVN r75736]
This commit is contained in:
@@ -438,7 +438,7 @@ echo ###
|
||||
set YYACC_SOURCES=yyacc.c
|
||||
set MKJAMBASE_SOURCES=mkjambase.c
|
||||
set BJAM_SOURCES=
|
||||
set BJAM_SOURCES=%BJAM_SOURCES% command.c compile.c constants.c debug.c execnt.c expand.c filent.c glob.c hash.c
|
||||
set BJAM_SOURCES=%BJAM_SOURCES% command.c compile.c constants.c debug.c execnt.c expand.c filent.c function.c glob.c hash.c
|
||||
set BJAM_SOURCES=%BJAM_SOURCES% hdrmacro.c headers.c jam.c jambase.c jamgram.c lists.c make.c make1.c
|
||||
set BJAM_SOURCES=%BJAM_SOURCES% object.c option.c output.c parse.c pathunix.c regexp.c
|
||||
set BJAM_SOURCES=%BJAM_SOURCES% rules.c scan.c search.c subst.c timestamp.c variable.c modules.c
|
||||
|
||||
@@ -471,7 +471,7 @@ if --show-locate-target in $(ARGV)
|
||||
|
||||
# We have some different files for UNIX, and NT.
|
||||
jam.source =
|
||||
command.c compile.c constants.c debug.c expand.c glob.c
|
||||
command.c compile.c constants.c debug.c expand.c function.c glob.c
|
||||
hash.c hcache.c headers.c hdrmacro.c
|
||||
jam.c jambase.c jamgram.c
|
||||
lists.c make.c make1.c mem.c object.c
|
||||
|
||||
@@ -245,7 +245,7 @@ echo "###"
|
||||
YYACC_SOURCES="yyacc.c"
|
||||
MKJAMBASE_SOURCES="mkjambase.c"
|
||||
BJAM_SOURCES="\
|
||||
command.c compile.c constants.c debug.c expand.c glob.c hash.c\
|
||||
command.c compile.c constants.c debug.c expand.c function.c glob.c hash.c\
|
||||
hdrmacro.c headers.c jam.c jambase.c jamgram.c lists.c make.c make1.c\
|
||||
object.c option.c output.c parse.c pathunix.c regexp.c\
|
||||
rules.c scan.c search.c subst.c timestamp.c variable.c modules.c\
|
||||
|
||||
@@ -69,20 +69,20 @@
|
||||
#define C0 (OBJECT *)0
|
||||
|
||||
#if defined( OS_NT ) || defined( OS_CYGWIN )
|
||||
LIST * builtin_system_registry ( PARSE *, FRAME * );
|
||||
LIST * builtin_system_registry_names( PARSE *, FRAME * );
|
||||
LIST * builtin_system_registry ( FRAME *, int );
|
||||
LIST * builtin_system_registry_names( FRAME *, int );
|
||||
#endif
|
||||
|
||||
int glob( const char * s, const char * c );
|
||||
|
||||
void backtrace ( FRAME * );
|
||||
void backtrace_line ( FRAME * );
|
||||
void print_source_line( PARSE * );
|
||||
void print_source_line( FRAME * );
|
||||
|
||||
|
||||
RULE * bind_builtin( const char * name_, LIST * (* f)( PARSE *, FRAME * ), int flags, const char * * args )
|
||||
RULE * bind_builtin( const char * name_, LIST * (* f)( FRAME *, int flags ), int flags, const char * * args )
|
||||
{
|
||||
PARSE * p;
|
||||
FUNCTION * func;
|
||||
RULE * result;
|
||||
argument_list* arg_list = 0;
|
||||
OBJECT * name = object_new( name_ );
|
||||
@@ -93,11 +93,11 @@ RULE * bind_builtin( const char * name_, LIST * (* f)( PARSE *, FRAME * ), int f
|
||||
lol_build( arg_list->data, args );
|
||||
}
|
||||
|
||||
p = parse_make( f, P0, P0, P0, C0, C0, flags );
|
||||
func = function_builtin( f, flags );
|
||||
|
||||
result = new_rule_body( root_module(), name, arg_list, p, 1 );
|
||||
result = new_rule_body( root_module(), name, arg_list, func, 1 );
|
||||
|
||||
parse_free( p );
|
||||
function_free( func );
|
||||
|
||||
object_free( name );
|
||||
|
||||
@@ -434,7 +434,7 @@ void load_builtins()
|
||||
* The CALC rule performs simple mathematical operations on two arguments.
|
||||
*/
|
||||
|
||||
LIST * builtin_calc( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_calc( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * arg = lol_get( frame->args, 0 );
|
||||
|
||||
@@ -488,7 +488,7 @@ LIST * builtin_calc( PARSE * parse, FRAME * frame )
|
||||
* targets and sources as TARGETs.
|
||||
*/
|
||||
|
||||
LIST * builtin_depends( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_depends( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * targets = lol_get( frame->args, 0 );
|
||||
LIST * sources = lol_get( frame->args, 1 );
|
||||
@@ -502,7 +502,7 @@ LIST * builtin_depends( PARSE * parse, FRAME * frame )
|
||||
/* TARGET, creating it if needed. The internal include */
|
||||
/* TARGET shares the name of its parent. */
|
||||
|
||||
if ( parse->num )
|
||||
if ( flags )
|
||||
{
|
||||
if ( !t->includes )
|
||||
{
|
||||
@@ -534,7 +534,7 @@ LIST * builtin_depends( PARSE * parse, FRAME * frame )
|
||||
* argument.
|
||||
*/
|
||||
|
||||
LIST * builtin_rebuilds( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_rebuilds( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * targets = lol_get( frame->args, 0 );
|
||||
LIST * rebuilds = lol_get( frame->args, 1 );
|
||||
@@ -557,7 +557,7 @@ LIST * builtin_rebuilds( PARSE * parse, FRAME * frame )
|
||||
* taken.
|
||||
*/
|
||||
|
||||
LIST * builtin_echo( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_echo( FRAME * frame, int flags )
|
||||
{
|
||||
list_print( lol_get( frame->args, 0 ) );
|
||||
printf( "\n" );
|
||||
@@ -573,7 +573,7 @@ LIST * builtin_echo( PARSE * parse, FRAME * frame )
|
||||
* with a failure status.
|
||||
*/
|
||||
|
||||
LIST * builtin_exit( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_exit( FRAME * frame, int flags )
|
||||
{
|
||||
list_print( lol_get( frame->args, 0 ) );
|
||||
printf( "\n" );
|
||||
@@ -596,11 +596,11 @@ LIST * builtin_exit( PARSE * parse, FRAME * frame )
|
||||
* It binds each target as a TARGET.
|
||||
*/
|
||||
|
||||
LIST * builtin_flags( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_flags( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * l = lol_get( frame->args, 0 );
|
||||
for ( ; l; l = list_next( l ) )
|
||||
bindtarget( l->value )->flags |= parse->num;
|
||||
bindtarget( l->value )->flags |= flags;
|
||||
return L0;
|
||||
}
|
||||
|
||||
@@ -697,7 +697,7 @@ static LIST * downcase_list( LIST * in )
|
||||
}
|
||||
|
||||
|
||||
LIST * builtin_glob( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_glob( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * l = lol_get( frame->args, 0 );
|
||||
LIST * r = lol_get( frame->args, 1 );
|
||||
@@ -870,7 +870,7 @@ LIST * glob_recursive( const char * pattern )
|
||||
}
|
||||
|
||||
|
||||
LIST * builtin_glob_recursive( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_glob_recursive( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * result = L0;
|
||||
LIST * l = lol_get( frame->args, 0 );
|
||||
@@ -884,7 +884,7 @@ LIST * builtin_glob_recursive( PARSE * parse, FRAME * frame )
|
||||
* builtin_match() - MATCH rule, regexp matching.
|
||||
*/
|
||||
|
||||
LIST * builtin_match( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_match( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * l;
|
||||
LIST * r;
|
||||
@@ -930,7 +930,7 @@ LIST * builtin_match( PARSE * parse, FRAME * frame )
|
||||
return result;
|
||||
}
|
||||
|
||||
LIST * builtin_split_by_characters( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_split_by_characters( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * l1 = lol_get( frame->args, 0 );
|
||||
LIST * l2 = lol_get( frame->args, 1 );
|
||||
@@ -956,7 +956,7 @@ LIST * builtin_split_by_characters( PARSE * parse, FRAME * frame )
|
||||
return result;
|
||||
}
|
||||
|
||||
LIST * builtin_hdrmacro( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_hdrmacro( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * l = lol_get( frame->args, 0 );
|
||||
|
||||
@@ -992,7 +992,7 @@ static void add_rule_name( void * r_, void * result_ )
|
||||
}
|
||||
|
||||
|
||||
LIST * builtin_rulenames( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_rulenames( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * arg0 = lol_get( frame->args, 0 );
|
||||
LIST * result = L0;
|
||||
@@ -1035,7 +1035,7 @@ static struct hash * get_running_module_vars()
|
||||
}
|
||||
|
||||
|
||||
LIST * builtin_varnames( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_varnames( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * arg0 = lol_get( frame->args, 0 );
|
||||
LIST * result = L0;
|
||||
@@ -1060,7 +1060,7 @@ LIST * builtin_varnames( PARSE * parse, FRAME * frame )
|
||||
* Clears all rules and variables from the given module.
|
||||
*/
|
||||
|
||||
LIST * builtin_delete_module( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_delete_module( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * arg0 = lol_get( frame->args, 0 );
|
||||
LIST * result = L0;
|
||||
@@ -1100,7 +1100,7 @@ static void unknown_rule( FRAME * frame, const char * key, OBJECT * module_name,
|
||||
* variables.
|
||||
*/
|
||||
|
||||
LIST * builtin_import( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_import( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * source_module_list = lol_get( frame->args, 0 );
|
||||
LIST * source_rules = lol_get( frame->args, 1 );
|
||||
@@ -1164,7 +1164,7 @@ LIST * builtin_import( PARSE * parse, FRAME * frame )
|
||||
* is issued.
|
||||
*/
|
||||
|
||||
LIST * builtin_export( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_export( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * module_list = lol_get( frame->args, 0 );
|
||||
LIST * rules = lol_get( frame->args, 1 );
|
||||
@@ -1190,12 +1190,12 @@ LIST * builtin_export( PARSE * parse, FRAME * frame )
|
||||
* indicated for a given procedure in debug output or an error backtrace.
|
||||
*/
|
||||
|
||||
static void get_source_line( PARSE * procedure, const char * * file, int * line )
|
||||
static void get_source_line( FRAME * frame, const char * * file, int * line )
|
||||
{
|
||||
if ( procedure )
|
||||
if ( frame->file )
|
||||
{
|
||||
const char * f = object_str( procedure->file );
|
||||
int l = procedure->line;
|
||||
const char * f = object_str( frame->file );
|
||||
int l = frame->line;
|
||||
if ( !strcmp( f, "+" ) )
|
||||
{
|
||||
f = "jambase.c";
|
||||
@@ -1212,12 +1212,12 @@ static void get_source_line( PARSE * procedure, const char * * file, int * line
|
||||
}
|
||||
|
||||
|
||||
void print_source_line( PARSE * p )
|
||||
void print_source_line( FRAME * frame )
|
||||
{
|
||||
const char * file;
|
||||
int line;
|
||||
|
||||
get_source_line( p, &file, &line );
|
||||
get_source_line( frame, &file, &line );
|
||||
if ( line < 0 )
|
||||
printf( "(builtin):" );
|
||||
else
|
||||
@@ -1238,7 +1238,7 @@ void backtrace_line( FRAME * frame )
|
||||
}
|
||||
else
|
||||
{
|
||||
print_source_line( frame->procedure );
|
||||
print_source_line( frame );
|
||||
printf( " in %s\n", frame->rulename );
|
||||
}
|
||||
}
|
||||
@@ -1264,7 +1264,7 @@ void backtrace( FRAME * frame )
|
||||
* period.
|
||||
*/
|
||||
|
||||
LIST * builtin_backtrace( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_backtrace( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * levels_arg = lol_get( frame->args, 0 );
|
||||
int levels = levels_arg ? atoi( object_str( levels_arg->value ) ) : (int)( (unsigned int)(-1) >> 1 ) ;
|
||||
@@ -1275,7 +1275,7 @@ LIST * builtin_backtrace( PARSE * parse, FRAME * frame )
|
||||
const char * file;
|
||||
int line;
|
||||
char buf[32];
|
||||
get_source_line( frame->procedure, &file, &line );
|
||||
get_source_line( frame, &file, &line );
|
||||
sprintf( buf, "%d", line );
|
||||
result = list_new( result, object_new( file ) );
|
||||
result = list_new( result, object_new( buf ) );
|
||||
@@ -1298,7 +1298,7 @@ LIST * builtin_backtrace( PARSE * parse, FRAME * frame )
|
||||
* behavior.
|
||||
*/
|
||||
|
||||
LIST * builtin_caller_module( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_caller_module( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * levels_arg = lol_get( frame->args, 0 );
|
||||
int levels = levels_arg ? atoi( object_str( levels_arg->value ) ) : 0 ;
|
||||
@@ -1328,7 +1328,7 @@ LIST * builtin_caller_module( PARSE * parse, FRAME * frame )
|
||||
* Usage: pwd = [ PWD ] ;
|
||||
*/
|
||||
|
||||
LIST * builtin_pwd( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_pwd( FRAME * frame, int flags )
|
||||
{
|
||||
return pwd();
|
||||
}
|
||||
@@ -1338,7 +1338,7 @@ LIST * builtin_pwd( PARSE * parse, FRAME * frame )
|
||||
* Adds targets to the list of target that jam will attempt to update.
|
||||
*/
|
||||
|
||||
LIST * builtin_update( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_update( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * result = list_copy( L0, targets_to_update() );
|
||||
LIST * arg1 = lol_get( frame->args, 0 );
|
||||
@@ -1358,7 +1358,7 @@ int last_update_now_status;
|
||||
Third parameter, if non-empty, specifies that the -n option should have
|
||||
no effect -- that is, all out-of-date targets should be rebuild.
|
||||
*/
|
||||
LIST * builtin_update_now( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_update_now( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * targets = lol_get( frame->args, 0 );
|
||||
LIST * log = lol_get( frame->args, 1 );
|
||||
@@ -1437,7 +1437,7 @@ LIST * builtin_update_now( PARSE * parse, FRAME * frame )
|
||||
return L0;
|
||||
}
|
||||
|
||||
LIST * builtin_search_for_target( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_search_for_target( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * arg1 = lol_get( frame->args, 0 );
|
||||
LIST * arg2 = lol_get( frame->args, 1 );
|
||||
@@ -1446,7 +1446,7 @@ LIST * builtin_search_for_target( PARSE * parse, FRAME * frame )
|
||||
}
|
||||
|
||||
|
||||
LIST * builtin_import_module( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_import_module( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * arg1 = lol_get( frame->args, 0 );
|
||||
LIST * arg2 = lol_get( frame->args, 1 );
|
||||
@@ -1456,14 +1456,14 @@ LIST * builtin_import_module( PARSE * parse, FRAME * frame )
|
||||
}
|
||||
|
||||
|
||||
LIST * builtin_imported_modules( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_imported_modules( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * arg0 = lol_get( frame->args, 0 );
|
||||
return imported_modules( bindmodule( arg0 ? arg0->value : 0 ) );
|
||||
}
|
||||
|
||||
|
||||
LIST * builtin_instance( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_instance( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * arg1 = lol_get( frame->args, 0 );
|
||||
LIST * arg2 = lol_get( frame->args, 1 );
|
||||
@@ -1474,14 +1474,14 @@ LIST * builtin_instance( PARSE * parse, FRAME * frame )
|
||||
}
|
||||
|
||||
|
||||
LIST * builtin_sort( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_sort( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * arg1 = lol_get( frame->args, 0 );
|
||||
return list_sort( arg1 );
|
||||
}
|
||||
|
||||
|
||||
LIST * builtin_normalize_path( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_normalize_path( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * arg = lol_get( frame->args, 0 );
|
||||
|
||||
@@ -1603,7 +1603,7 @@ LIST * builtin_normalize_path( PARSE * parse, FRAME * frame )
|
||||
}
|
||||
|
||||
|
||||
LIST * builtin_native_rule( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_native_rule( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * module_name = lol_get( frame->args, 0 );
|
||||
LIST * rule_name = lol_get( frame->args, 1 );
|
||||
@@ -1630,7 +1630,7 @@ LIST * builtin_native_rule( PARSE * parse, FRAME * frame )
|
||||
}
|
||||
|
||||
|
||||
LIST * builtin_has_native_rule( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_has_native_rule( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * module_name = lol_get( frame->args, 0 );
|
||||
LIST * rule_name = lol_get( frame->args, 1 );
|
||||
@@ -1651,7 +1651,7 @@ LIST * builtin_has_native_rule( PARSE * parse, FRAME * frame )
|
||||
}
|
||||
|
||||
|
||||
LIST * builtin_user_module( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_user_module( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * module_name = lol_get( frame->args, 0 );
|
||||
for ( ; module_name; module_name = module_name->next )
|
||||
@@ -1663,7 +1663,7 @@ LIST * builtin_user_module( PARSE * parse, FRAME * frame )
|
||||
}
|
||||
|
||||
|
||||
LIST * builtin_nearest_user_location( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_nearest_user_location( FRAME * frame, int flags )
|
||||
{
|
||||
FRAME * nearest_user_frame =
|
||||
frame->module->user_module ? frame : frame->prev_user;
|
||||
@@ -1676,7 +1676,7 @@ LIST * builtin_nearest_user_location( PARSE * parse, FRAME * frame )
|
||||
int line;
|
||||
char buf[32];
|
||||
|
||||
get_source_line( nearest_user_frame->procedure, &file, &line );
|
||||
get_source_line( nearest_user_frame, &file, &line );
|
||||
sprintf( buf, "%d", line );
|
||||
result = list_new( result, object_new( file ) );
|
||||
result = list_new( result, object_new( buf ) );
|
||||
@@ -1685,7 +1685,7 @@ LIST * builtin_nearest_user_location( PARSE * parse, FRAME * frame )
|
||||
}
|
||||
|
||||
|
||||
LIST * builtin_check_if_file( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_check_if_file( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * name = lol_get( frame->args, 0 );
|
||||
return file_is_file( name->value ) == 1
|
||||
@@ -1694,7 +1694,7 @@ LIST * builtin_check_if_file( PARSE * parse, FRAME * frame )
|
||||
}
|
||||
|
||||
|
||||
LIST * builtin_md5( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_md5( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * l = lol_get( frame->args, 0 );
|
||||
const char* s = object_str( l->value );
|
||||
@@ -1715,7 +1715,7 @@ LIST * builtin_md5( PARSE * parse, FRAME * frame )
|
||||
return list_new( L0, object_new( hex_output ) );
|
||||
}
|
||||
|
||||
LIST *builtin_file_open( PARSE * parse, FRAME * frame )
|
||||
LIST *builtin_file_open( FRAME * frame, int flags )
|
||||
{
|
||||
const char * name = object_str( lol_get( frame->args, 0 )->value );
|
||||
const char * mode = object_str( lol_get( frame->args, 1 )->value );
|
||||
@@ -1742,7 +1742,7 @@ LIST *builtin_file_open( PARSE * parse, FRAME * frame )
|
||||
}
|
||||
}
|
||||
|
||||
LIST *builtin_pad( PARSE *parse, FRAME *frame )
|
||||
LIST *builtin_pad( FRAME * frame, int flags )
|
||||
{
|
||||
OBJECT * string = lol_get( frame->args, 0 )->value;
|
||||
const char * width_s = object_str( lol_get( frame->args, 1 )->value );
|
||||
@@ -1767,7 +1767,7 @@ LIST *builtin_pad( PARSE *parse, FRAME *frame )
|
||||
}
|
||||
}
|
||||
|
||||
LIST *builtin_precious( PARSE * parse, FRAME * frame )
|
||||
LIST *builtin_precious( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * targets = lol_get(frame->args, 0);
|
||||
|
||||
@@ -1780,7 +1780,7 @@ LIST *builtin_precious( PARSE * parse, FRAME * frame )
|
||||
return L0;
|
||||
}
|
||||
|
||||
LIST *builtin_self_path( PARSE * parse, FRAME * frame )
|
||||
LIST *builtin_self_path( FRAME * frame, int flags )
|
||||
{
|
||||
extern const char * saved_argv0;
|
||||
char * p = executable_path( saved_argv0 );
|
||||
@@ -1796,7 +1796,7 @@ LIST *builtin_self_path( PARSE * parse, FRAME * frame )
|
||||
}
|
||||
}
|
||||
|
||||
LIST *builtin_makedir( PARSE * parse, FRAME * frame )
|
||||
LIST *builtin_makedir( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * path = lol_get( frame->args, 0 );
|
||||
|
||||
@@ -1813,7 +1813,7 @@ LIST *builtin_makedir( PARSE * parse, FRAME * frame )
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
|
||||
LIST * builtin_python_import_rule( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_python_import_rule( FRAME * frame, int flags )
|
||||
{
|
||||
static int first_time = 1;
|
||||
const char * python_module = object_str( lol_get( frame->args, 0 )->value );
|
||||
@@ -1944,7 +1944,6 @@ PyObject* bjam_call( PyObject * self, PyObject * args )
|
||||
inner->prev = 0;
|
||||
inner->prev_user = 0;
|
||||
inner->module = bindmodule( constant_python_interface );
|
||||
inner->procedure = 0;
|
||||
|
||||
/* Extract the rule name and arguments from 'args'. */
|
||||
|
||||
@@ -2164,7 +2163,7 @@ PyObject * bjam_backtrace( PyObject * self, PyObject * args )
|
||||
int line;
|
||||
char buf[ 32 ];
|
||||
|
||||
get_source_line( f->procedure, &file, &line );
|
||||
get_source_line( f, &file, &line );
|
||||
sprintf( buf, "%d", line );
|
||||
|
||||
/* PyTuple_SetItem steals reference. */
|
||||
@@ -2277,7 +2276,7 @@ static char * rtrim( char * s )
|
||||
return s;
|
||||
}
|
||||
|
||||
LIST * builtin_shell( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_shell( FRAME * frame, int flags )
|
||||
{
|
||||
LIST * command = lol_get( frame->args, 0 );
|
||||
LIST * result = 0;
|
||||
@@ -2357,7 +2356,7 @@ LIST * builtin_shell( PARSE * parse, FRAME * frame )
|
||||
|
||||
#else /* #ifdef HAVE_POPEN */
|
||||
|
||||
LIST * builtin_shell( PARSE * parse, FRAME * frame )
|
||||
LIST * builtin_shell( FRAME * frame, int flags )
|
||||
{
|
||||
return L0;
|
||||
}
|
||||
|
||||
@@ -21,47 +21,47 @@ void init_property_set();
|
||||
void init_sequence();
|
||||
void init_order();
|
||||
|
||||
LIST *builtin_calc( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_depends( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_rebuilds( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_echo( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_exit( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_flags( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_glob( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_glob_recursive( PARSE *parse, FRAME *frame );
|
||||
LIST *builtin_subst( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_match( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_split_by_characters( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_hdrmacro( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_rulenames( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_varnames( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_delete_module( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_import( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_export( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_caller_module( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_backtrace( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_pwd( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_update( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_update_now( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_search_for_target( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_import_module( PARSE *parse, FRAME *args );
|
||||
LIST *builtin_imported_modules( PARSE *parse, FRAME *frame );
|
||||
LIST *builtin_instance( PARSE *parse, FRAME *frame );
|
||||
LIST *builtin_sort( PARSE *parse, FRAME *frame );
|
||||
LIST *builtin_normalize_path( PARSE *parse, FRAME *frame );
|
||||
LIST *builtin_native_rule( PARSE *parse, FRAME *frame );
|
||||
LIST *builtin_has_native_rule( PARSE *parse, FRAME *frame );
|
||||
LIST *builtin_user_module( PARSE *parse, FRAME *frame );
|
||||
LIST *builtin_nearest_user_location( PARSE *parse, FRAME *frame );
|
||||
LIST *builtin_check_if_file( PARSE *parse, FRAME *frame );
|
||||
LIST *builtin_python_import_rule( PARSE *parse, FRAME *frame );
|
||||
LIST *builtin_shell( PARSE *parse, FRAME *frame );
|
||||
LIST *builtin_md5( PARSE *parse, FRAME *frame );
|
||||
LIST *builtin_file_open( PARSE *parse, FRAME *frame );
|
||||
LIST *builtin_pad( PARSE *parse, FRAME *frame );
|
||||
LIST *builtin_precious( PARSE *parse, FRAME *frame );
|
||||
LIST *builtin_self_path( PARSE *parse, FRAME *frame );
|
||||
LIST *builtin_makedir( PARSE *parse, FRAME *frame );
|
||||
LIST *builtin_calc( FRAME * frame, int flags );
|
||||
LIST *builtin_depends( FRAME * frame, int flags );
|
||||
LIST *builtin_rebuilds( FRAME * frame, int flags );
|
||||
LIST *builtin_echo( FRAME * frame, int flags );
|
||||
LIST *builtin_exit( FRAME * frame, int flags );
|
||||
LIST *builtin_flags( FRAME * frame, int flags );
|
||||
LIST *builtin_glob( FRAME * frame, int flags );
|
||||
LIST *builtin_glob_recursive( FRAME * frame, int flags );
|
||||
LIST *builtin_subst( FRAME * frame, int flags );
|
||||
LIST *builtin_match( FRAME * frame, int flags );
|
||||
LIST *builtin_split_by_characters( FRAME * frame, int flags );
|
||||
LIST *builtin_hdrmacro( FRAME * frame, int flags );
|
||||
LIST *builtin_rulenames( FRAME * frame, int flags );
|
||||
LIST *builtin_varnames( FRAME * frame, int flags );
|
||||
LIST *builtin_delete_module( FRAME * frame, int flags );
|
||||
LIST *builtin_import( FRAME * frame, int flags );
|
||||
LIST *builtin_export( FRAME * frame, int flags );
|
||||
LIST *builtin_caller_module( FRAME * frame, int flags );
|
||||
LIST *builtin_backtrace( FRAME * frame, int flags );
|
||||
LIST *builtin_pwd( FRAME * frame, int flags );
|
||||
LIST *builtin_update( FRAME * frame, int flags );
|
||||
LIST *builtin_update_now( FRAME * frame, int flags );
|
||||
LIST *builtin_search_for_target( FRAME * frame, int flags );
|
||||
LIST *builtin_import_module( FRAME * frame, int flags );
|
||||
LIST *builtin_imported_modules( FRAME * frame, int flags );
|
||||
LIST *builtin_instance( FRAME * frame, int flags );
|
||||
LIST *builtin_sort( FRAME * frame, int flags );
|
||||
LIST *builtin_normalize_path( FRAME * frame, int flags );
|
||||
LIST *builtin_native_rule( FRAME * frame, int flags );
|
||||
LIST *builtin_has_native_rule( FRAME * frame, int flags );
|
||||
LIST *builtin_user_module( FRAME * frame, int flags );
|
||||
LIST *builtin_nearest_user_location( FRAME * frame, int flags );
|
||||
LIST *builtin_check_if_file( FRAME * frame, int flags );
|
||||
LIST *builtin_python_import_rule( FRAME * frame, int flags );
|
||||
LIST *builtin_shell( FRAME * frame, int flags );
|
||||
LIST *builtin_md5( FRAME * frame, int flags );
|
||||
LIST *builtin_file_open( FRAME * frame, int flags );
|
||||
LIST *builtin_pad( FRAME * frame, int flags );
|
||||
LIST *builtin_precious( FRAME * frame, int flags );
|
||||
LIST *builtin_self_path( FRAME * frame, int flags );
|
||||
LIST *builtin_makedir( FRAME * frame, int flags );
|
||||
|
||||
void backtrace( FRAME *frame );
|
||||
extern int last_update_now_status;
|
||||
|
||||
@@ -92,7 +92,7 @@ int glob( const char * s, const char * c );
|
||||
/* Internal functions from builtins.c */
|
||||
void backtrace( FRAME * frame );
|
||||
void backtrace_line( FRAME * frame );
|
||||
void print_source_line( PARSE * p );
|
||||
void print_source_line( FRAME * frame );
|
||||
|
||||
struct frame * frame_before_python_call;
|
||||
|
||||
@@ -105,7 +105,8 @@ void frame_init( FRAME* frame )
|
||||
lol_init(frame->args);
|
||||
frame->module = root_module();
|
||||
frame->rulename = "module scope";
|
||||
frame->procedure = 0;
|
||||
frame->file = 0;
|
||||
frame->line = -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -115,459 +116,18 @@ void frame_free( FRAME* frame )
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* compile_append() - append list results of two statements
|
||||
*
|
||||
* parse->left more compile_append() by left-recursion
|
||||
* parse->right single rule
|
||||
*/
|
||||
|
||||
LIST * compile_append( PARSE * parse, FRAME * frame )
|
||||
{
|
||||
/* Append right to left. */
|
||||
return list_append(
|
||||
parse_evaluate( parse->left, frame ),
|
||||
parse_evaluate( parse->right, frame ) );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* compile_eval() - evaluate if to determine which leg to compile
|
||||
*
|
||||
* Returns:
|
||||
* list if expression true - compile 'then' clause
|
||||
* L0 if expression false - compile 'else' clause
|
||||
*/
|
||||
|
||||
static int lcmp( LIST * t, LIST * s )
|
||||
{
|
||||
int status = 0;
|
||||
|
||||
while ( !status && ( t || s ) )
|
||||
{
|
||||
const char *st = t ? object_str( t->value ) : "";
|
||||
const char *ss = s ? object_str( s->value ) : "";
|
||||
|
||||
status = strcmp( st, ss );
|
||||
|
||||
t = t ? list_next( t ) : t;
|
||||
s = s ? list_next( s ) : s;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
LIST * compile_eval( PARSE * parse, FRAME * frame )
|
||||
{
|
||||
LIST * ll;
|
||||
LIST * lr;
|
||||
LIST * s;
|
||||
LIST * t;
|
||||
int status = 0;
|
||||
|
||||
/* Short circuit lr eval for &&, ||, and 'in'. */
|
||||
|
||||
ll = parse_evaluate( parse->left, frame );
|
||||
lr = 0;
|
||||
|
||||
switch ( parse->num )
|
||||
{
|
||||
case EXPR_AND:
|
||||
case EXPR_IN : if ( ll ) goto eval; break;
|
||||
case EXPR_OR : if ( !ll ) goto eval; break;
|
||||
default: eval: lr = parse_evaluate( parse->right, frame );
|
||||
}
|
||||
|
||||
/* Now eval. */
|
||||
switch ( parse->num )
|
||||
{
|
||||
case EXPR_NOT: if ( !ll ) status = 1; break;
|
||||
case EXPR_AND: if ( ll && lr ) status = 1; break;
|
||||
case EXPR_OR : if ( ll || lr ) status = 1; break;
|
||||
|
||||
case EXPR_IN:
|
||||
/* "a in b": make sure each of ll is equal to something in lr. */
|
||||
for ( t = ll; t; t = list_next( t ) )
|
||||
{
|
||||
for ( s = lr; s; s = list_next( s ) )
|
||||
if ( object_equal( t->value, s->value ) )
|
||||
break;
|
||||
if ( !s ) break;
|
||||
}
|
||||
/* No more ll? Success. */
|
||||
if ( !t ) status = 1;
|
||||
break;
|
||||
|
||||
case EXPR_EXISTS: if ( lcmp( ll, L0 ) != 0 ) status = 1; break;
|
||||
case EXPR_EQUALS: if ( lcmp( ll, lr ) == 0 ) status = 1; break;
|
||||
case EXPR_NOTEQ : if ( lcmp( ll, lr ) != 0 ) status = 1; break;
|
||||
case EXPR_LESS : if ( lcmp( ll, lr ) < 0 ) status = 1; break;
|
||||
case EXPR_LESSEQ: if ( lcmp( ll, lr ) <= 0 ) status = 1; break;
|
||||
case EXPR_MORE : if ( lcmp( ll, lr ) > 0 ) status = 1; break;
|
||||
case EXPR_MOREEQ: if ( lcmp( ll, lr ) >= 0 ) status = 1; break;
|
||||
}
|
||||
|
||||
if ( DEBUG_IF )
|
||||
{
|
||||
debug_compile( 0, "if", frame );
|
||||
list_print( ll );
|
||||
printf( "(%d) ", status );
|
||||
list_print( lr );
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
/* Find something to return. */
|
||||
/* In odd circumstances (like "" = "") */
|
||||
/* we'll have to return a new string. */
|
||||
|
||||
if ( !status ) t = 0;
|
||||
else if ( ll ) t = ll, ll = 0;
|
||||
else if ( lr ) t = lr, lr = 0;
|
||||
else t = list_new( L0, object_new( "1" ) );
|
||||
|
||||
if ( ll ) list_free( ll );
|
||||
if ( lr ) list_free( lr );
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* compile_foreach() - compile the "for x in y" statement
|
||||
*
|
||||
* Compile_foreach() resets the given variable name to each specified
|
||||
* value, executing the commands enclosed in braces for each iteration.
|
||||
*
|
||||
* parse->string index variable
|
||||
* parse->left variable values
|
||||
* parse->right rule to compile
|
||||
*/
|
||||
|
||||
LIST * compile_foreach( PARSE * parse, FRAME * frame )
|
||||
{
|
||||
LIST * nv = parse_evaluate( parse->left, frame );
|
||||
LIST * l;
|
||||
SETTINGS * s = 0;
|
||||
|
||||
if ( parse->num )
|
||||
{
|
||||
s = addsettings( s, VAR_SET, parse->string, L0 );
|
||||
pushsettings( s );
|
||||
}
|
||||
|
||||
/* Call var_set to reset $(parse->string) for each val. */
|
||||
|
||||
for ( l = nv; l; l = list_next( l ) )
|
||||
{
|
||||
LIST * val = list_new( L0, object_copy( l->value ) );
|
||||
var_set( parse->string, val, VAR_SET );
|
||||
list_free( parse_evaluate( parse->right, frame ) );
|
||||
}
|
||||
|
||||
if ( parse->num )
|
||||
{
|
||||
popsettings( s );
|
||||
freesettings( s );
|
||||
}
|
||||
|
||||
list_free( nv );
|
||||
|
||||
return L0;
|
||||
}
|
||||
|
||||
/*
|
||||
* compile_if() - compile 'if' rule
|
||||
*
|
||||
* parse->left condition tree
|
||||
* parse->right then tree
|
||||
* parse->third else tree
|
||||
*/
|
||||
|
||||
LIST * compile_if( PARSE * p, FRAME * frame )
|
||||
{
|
||||
LIST * l = parse_evaluate( p->left, frame );
|
||||
if ( l )
|
||||
{
|
||||
list_free( l );
|
||||
return parse_evaluate( p->right, frame );
|
||||
}
|
||||
return parse_evaluate( p->third, frame );
|
||||
}
|
||||
|
||||
|
||||
LIST * compile_while( PARSE * p, FRAME * frame )
|
||||
{
|
||||
LIST * r = 0;
|
||||
LIST * l;
|
||||
while ( ( l = parse_evaluate( p->left, frame ) ) )
|
||||
{
|
||||
list_free( l );
|
||||
if ( r ) list_free( r );
|
||||
r = parse_evaluate( p->right, frame );
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* compile_include() - support for 'include' - call include() on file
|
||||
*
|
||||
* parse->left list of files to include (can only do 1)
|
||||
*/
|
||||
|
||||
LIST * compile_include( PARSE * parse, FRAME * frame )
|
||||
{
|
||||
LIST * nt = parse_evaluate( parse->left, frame );
|
||||
|
||||
if ( DEBUG_COMPILE )
|
||||
{
|
||||
debug_compile( 0, "include", frame);
|
||||
list_print( nt );
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
if ( nt )
|
||||
{
|
||||
TARGET * t = bindtarget( nt->value );
|
||||
|
||||
/* DWA 2001/10/22 - Perforce Jam cleared the arguments here, which
|
||||
* prevents an included file from being treated as part of the body of a
|
||||
* rule. I did not see any reason to do that, so I lifted the
|
||||
* restriction.
|
||||
*/
|
||||
|
||||
/* Bind the include file under the influence of */
|
||||
/* "on-target" variables. Though they are targets, */
|
||||
/* include files are not built with make(). */
|
||||
|
||||
pushsettings( 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 );
|
||||
|
||||
parse_file( t->boundname, frame );
|
||||
}
|
||||
|
||||
list_free( nt );
|
||||
|
||||
return L0;
|
||||
}
|
||||
|
||||
static LIST* evaluate_in_module ( OBJECT * module_name, PARSE * p, FRAME* frame)
|
||||
{
|
||||
LIST* result;
|
||||
|
||||
module_t* outer_module = frame->module;
|
||||
frame->module = module_name ? bindmodule( module_name ) : root_module();
|
||||
|
||||
if ( outer_module != frame->module )
|
||||
{
|
||||
exit_module( outer_module );
|
||||
enter_module( frame->module );
|
||||
}
|
||||
|
||||
result = parse_evaluate( p, frame );
|
||||
|
||||
if ( outer_module != frame->module )
|
||||
{
|
||||
exit_module( frame->module );
|
||||
enter_module( outer_module );
|
||||
frame->module = outer_module;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
LIST * compile_module( PARSE * p, FRAME * frame )
|
||||
{
|
||||
/* Here we are entering a module declaration block. */
|
||||
LIST * module_name = parse_evaluate( p->left, frame );
|
||||
LIST * result = evaluate_in_module( module_name ? module_name->value : 0,
|
||||
p->right, frame );
|
||||
list_free( module_name );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
LIST * compile_class( PARSE * p, FRAME * frame )
|
||||
{
|
||||
/** Todo: check for empty class name.
|
||||
Check for class redeclaration. */
|
||||
|
||||
OBJECT * class_module = 0;
|
||||
|
||||
LIST * name = parse_evaluate( p->left->right, frame );
|
||||
LIST * bases = 0;
|
||||
|
||||
if ( p->left->left )
|
||||
bases = parse_evaluate( p->left->left->right, frame );
|
||||
|
||||
class_module = make_class_module( name, bases, frame );
|
||||
evaluate_in_module( class_module, p->right, frame );
|
||||
object_free( class_module );
|
||||
|
||||
return L0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* compile_list() - expand and return a list.
|
||||
*
|
||||
* parse->string - character string to expand.
|
||||
*/
|
||||
|
||||
LIST * compile_list( PARSE * parse, FRAME * frame )
|
||||
{
|
||||
/* s is a copyable string */
|
||||
OBJECT * o = parse->string;
|
||||
const char * s = object_str( o );
|
||||
return var_expand( L0, s, s + strlen( s ), frame->args, o );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* compile_local() - declare (and set) local variables.
|
||||
*
|
||||
* parse->left list of variables
|
||||
* parse->right list of values
|
||||
* parse->third rules to execute
|
||||
*/
|
||||
|
||||
LIST * compile_local( PARSE * parse, FRAME * frame )
|
||||
{
|
||||
LIST * l;
|
||||
SETTINGS * s = 0;
|
||||
LIST * nt = parse_evaluate( parse->left, frame );
|
||||
LIST * ns = parse_evaluate( parse->right, frame );
|
||||
LIST * result;
|
||||
|
||||
if ( DEBUG_COMPILE )
|
||||
{
|
||||
debug_compile( 0, "local", frame );
|
||||
list_print( nt );
|
||||
printf( " = " );
|
||||
list_print( ns );
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
/* Initial value is ns. */
|
||||
for ( l = nt; l; l = list_next( l ) )
|
||||
s = addsettings( s, VAR_SET, l->value, list_copy( L0, ns ) );
|
||||
|
||||
list_free( ns );
|
||||
list_free( nt );
|
||||
|
||||
/* Note that callees of the current context get this "local" variable,
|
||||
* making it not so much local as layered.
|
||||
*/
|
||||
|
||||
pushsettings( s );
|
||||
result = parse_evaluate( parse->third, frame );
|
||||
popsettings( s );
|
||||
|
||||
freesettings( s );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* compile_null() - do nothing -- a stub for parsing.
|
||||
*/
|
||||
|
||||
LIST * compile_null( PARSE * parse, FRAME * frame )
|
||||
{
|
||||
return L0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* compile_on() - run rule under influence of on-target variables
|
||||
*
|
||||
* parse->left list of files to include (can only do 1).
|
||||
* parse->right rule to run.
|
||||
*
|
||||
* EXPERIMENTAL!
|
||||
*/
|
||||
|
||||
LIST * compile_on( PARSE * parse, FRAME * frame )
|
||||
{
|
||||
LIST * nt = parse_evaluate( parse->left, frame );
|
||||
LIST * result = 0;
|
||||
|
||||
if ( DEBUG_COMPILE )
|
||||
{
|
||||
debug_compile( 0, "on", frame );
|
||||
list_print( nt );
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
if ( nt )
|
||||
{
|
||||
TARGET * t = bindtarget( nt->value );
|
||||
pushsettings( t->settings );
|
||||
result = parse_evaluate( parse->right, frame );
|
||||
popsettings( t->settings );
|
||||
}
|
||||
|
||||
list_free( nt );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* compile_rule() - compile a single user defined rule.
|
||||
*
|
||||
* parse->string name of user defined rule.
|
||||
* parse->left parameters (list of lists) to rule, recursing left.
|
||||
*
|
||||
* Wrapped around evaluate_rule() so that headers() can share it.
|
||||
*/
|
||||
|
||||
LIST * compile_rule( PARSE * parse, FRAME * frame )
|
||||
{
|
||||
FRAME inner[ 1 ];
|
||||
LIST * result;
|
||||
PARSE * p;
|
||||
|
||||
/* Build up the list of arg lists. */
|
||||
frame_init( inner );
|
||||
inner->prev = frame;
|
||||
inner->prev_user = frame->module->user_module ? frame : frame->prev_user;
|
||||
inner->module = frame->module; /* This gets fixed up in evaluate_rule(), below. */
|
||||
inner->procedure = parse;
|
||||
/* Special-case LOL of length 1 where the first list is totally empty.
|
||||
This is created when calling functions with no parameters, due to
|
||||
the way jam grammar is written. This is OK when one jam function
|
||||
calls another, but really not good when Jam function calls Python. */
|
||||
if ( parse->left->left == NULL && parse->left->right->func == compile_null)
|
||||
;
|
||||
else
|
||||
for ( p = parse->left; p; p = p->left )
|
||||
lol_add( inner->args, parse_evaluate( p->right, frame ) );
|
||||
|
||||
/* And invoke the rule. */
|
||||
result = evaluate_rule( parse->string, inner );
|
||||
frame_free( inner );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static void argument_error( const char * message, RULE * rule, FRAME * frame, LIST * arg )
|
||||
{
|
||||
LOL * actual = frame->args;
|
||||
assert( frame->procedure != 0 );
|
||||
assert( rule->procedure != 0 );
|
||||
backtrace_line( frame->prev );
|
||||
printf( "*** argument error\n* rule %s ( ", frame->rulename );
|
||||
lol_print( rule->arguments->data );
|
||||
printf( " )\n* called with: ( " );
|
||||
lol_print( actual );
|
||||
printf( " )\n* %s %s\n", message, arg ? object_str ( arg->value ) : "" );
|
||||
print_source_line( rule->procedure );
|
||||
function_location( rule->procedure, &frame->file, &frame->line );
|
||||
print_source_line( frame );
|
||||
printf( "see definition of rule '%s' being called\n", object_str( rule->name ) );
|
||||
backtrace( frame->prev );
|
||||
exit( 1 );
|
||||
@@ -949,25 +509,7 @@ evaluate_rule(
|
||||
profile_frame prof[1];
|
||||
module_t * prev_module = frame->module;
|
||||
|
||||
LIST * l;
|
||||
{
|
||||
LOL arg_context_, * arg_context = &arg_context_;
|
||||
if ( !frame->prev )
|
||||
lol_init(arg_context);
|
||||
else
|
||||
arg_context = frame->prev->args;
|
||||
l = var_expand( L0, object_str( rulename ), object_str( rulename )+strlen(object_str( rulename )), arg_context, 0 );
|
||||
}
|
||||
|
||||
if ( !l )
|
||||
{
|
||||
backtrace_line( frame->prev );
|
||||
printf( "warning: rulename %s expands to empty string\n", object_str( rulename ) );
|
||||
backtrace( frame->prev );
|
||||
return result;
|
||||
}
|
||||
|
||||
rule = bindrule( l->value, frame->module );
|
||||
rule = bindrule( rulename, frame->module );
|
||||
rulename = rule->name;
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
@@ -1005,17 +547,11 @@ evaluate_rule(
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Drop the rule name. */
|
||||
l = list_pop_front( l );
|
||||
|
||||
/* Tack the rest of the expansion onto the front of the first argument. */
|
||||
frame->args->list[0] = list_append( l, lol_get( frame->args, 0 ) );
|
||||
|
||||
if ( DEBUG_COMPILE )
|
||||
{
|
||||
/* Try hard to indicate in which module the rule is going to execute. */
|
||||
if ( rule->module != frame->module
|
||||
&& rule->procedure != 0 && !object_equal( rulename, rule->procedure->rulename ) )
|
||||
&& rule->procedure != 0 && !object_equal( rulename, function_rulename( rule->procedure ) ) )
|
||||
{
|
||||
char buf[256] = "";
|
||||
strncat( buf, object_str( rule->module->name ), sizeof( buf ) - 1 );
|
||||
@@ -1047,7 +583,7 @@ evaluate_rule(
|
||||
frame->rulename = object_str( rulename );
|
||||
/* And enter record profile info. */
|
||||
if ( DEBUG_PROFILE )
|
||||
profile_enter( rule->procedure->rulename, prof );
|
||||
profile_enter( function_rulename( rule->procedure ), prof );
|
||||
}
|
||||
|
||||
/* Check traditional targets $(<) and sources $(>). */
|
||||
@@ -1126,21 +662,22 @@ evaluate_rule(
|
||||
}
|
||||
|
||||
/* Now recursively compile any parse tree associated with this rule.
|
||||
* parse_refer()/parse_free() call pair added to ensure rule not freed
|
||||
* function_refer()/function_free() call pair added to ensure rule not freed
|
||||
* during use.
|
||||
*/
|
||||
if ( rule->procedure )
|
||||
{
|
||||
SETTINGS * local_args = collect_arguments( rule, frame );
|
||||
PARSE * parse = rule->procedure;
|
||||
parse_refer( parse );
|
||||
FUNCTION * function = rule->procedure;
|
||||
|
||||
function_refer( function );
|
||||
|
||||
pushsettings( local_args );
|
||||
result = parse_evaluate( parse, frame );
|
||||
result = function_run( function, frame, stack_global() );
|
||||
popsettings( local_args );
|
||||
freesettings( local_args );
|
||||
|
||||
parse_free( parse );
|
||||
function_free( function );
|
||||
}
|
||||
|
||||
if ( frame->module != prev_module )
|
||||
@@ -1179,7 +716,6 @@ LIST * call_rule( OBJECT * rulename, FRAME * caller_frame, ... )
|
||||
inner->prev_user = caller_frame->module->user_module ?
|
||||
caller_frame : caller_frame->prev_user;
|
||||
inner->module = caller_frame->module;
|
||||
inner->procedure = 0;
|
||||
|
||||
va_start( va, caller_frame );
|
||||
for ( ; ; )
|
||||
@@ -1199,212 +735,6 @@ LIST * call_rule( OBJECT * rulename, FRAME * caller_frame, ... )
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* compile_rules() - compile a chain of rules
|
||||
*
|
||||
* parse->left single rule
|
||||
* parse->right more compile_rules() by right-recursion
|
||||
*/
|
||||
|
||||
LIST * compile_rules( PARSE * parse, FRAME * frame )
|
||||
{
|
||||
/* Ignore result from first statement; return the 2nd. */
|
||||
/* Optimize recursion on the right by looping. */
|
||||
do list_free( parse_evaluate( parse->left, frame ) );
|
||||
while ( ( parse = parse->right )->func == compile_rules );
|
||||
return parse_evaluate( parse, frame );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* assign_var_mode() - convert ASSIGN_XXX compilation flag into corresponding
|
||||
* VAR_XXX variable set flag.
|
||||
*/
|
||||
|
||||
static int assign_var_mode( int parsenum, char const * * tracetext )
|
||||
{
|
||||
char const * trace;
|
||||
int setflag;
|
||||
switch ( parsenum )
|
||||
{
|
||||
case ASSIGN_SET : setflag = VAR_SET ; trace = "=" ; break;
|
||||
case ASSIGN_APPEND : setflag = VAR_APPEND ; trace = "+="; break;
|
||||
case ASSIGN_DEFAULT: setflag = VAR_DEFAULT; trace = "?="; break;
|
||||
default: setflag = VAR_SET ; trace = "" ; break;
|
||||
}
|
||||
if ( tracetext )
|
||||
*tracetext = trace ;
|
||||
return setflag;
|
||||
}
|
||||
|
||||
/*
|
||||
* compile_set() - compile the "set variable" statement
|
||||
*
|
||||
* parse->left variable names
|
||||
* parse->right variable values
|
||||
* parse->num ASSIGN_SET/APPEND/DEFAULT
|
||||
*/
|
||||
|
||||
LIST * compile_set( PARSE * parse, FRAME * frame )
|
||||
{
|
||||
LIST * nt = parse_evaluate( parse->left, frame );
|
||||
LIST * ns = parse_evaluate( parse->right, frame );
|
||||
LIST * l;
|
||||
char const * trace;
|
||||
int setflag = assign_var_mode( parse->num, &trace );
|
||||
|
||||
if ( DEBUG_COMPILE )
|
||||
{
|
||||
debug_compile( 0, "set", frame );
|
||||
list_print( nt );
|
||||
printf( " %s ", trace );
|
||||
list_print( ns );
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
/* Call var_set to set variable. var_set keeps ns, so need to copy it. */
|
||||
for ( l = nt; l; l = list_next( l ) )
|
||||
var_set( l->value, list_copy( L0, ns ), setflag );
|
||||
list_free( nt );
|
||||
return ns;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* compile_setcomp() - support for `rule` - save parse tree.
|
||||
*
|
||||
* parse->string rule name
|
||||
* parse->left rules for rule
|
||||
* parse->right optional list-of-lists describing arguments
|
||||
*/
|
||||
|
||||
LIST * compile_setcomp( PARSE * parse, FRAME * frame )
|
||||
{
|
||||
argument_list * arg_list = 0;
|
||||
|
||||
/* Create new LOL describing argument requirements if supplied. */
|
||||
if ( parse->right )
|
||||
{
|
||||
PARSE * p;
|
||||
arg_list = args_new();
|
||||
for ( p = parse->right; p; p = p->left )
|
||||
lol_add( arg_list->data, parse_evaluate( p->right, frame ) );
|
||||
}
|
||||
|
||||
new_rule_body( frame->module, parse->string, arg_list, parse->left, !parse->num );
|
||||
return L0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* compile_setexec() - support for `actions` - save execution string.
|
||||
*
|
||||
* parse->string rule name
|
||||
* parse->string1 OS command string
|
||||
* parse->num flags
|
||||
* parse->left `bind` variables
|
||||
*
|
||||
* Note that the parse flags (as defined in compile.h) are transferred directly
|
||||
* to the rule flags (as defined in rules.h).
|
||||
*/
|
||||
|
||||
LIST * compile_setexec( PARSE * parse, FRAME * frame )
|
||||
{
|
||||
LIST * bindlist = parse_evaluate( parse->left, frame );
|
||||
new_rule_actions( frame->module, parse->string, parse->string1, bindlist, parse->num );
|
||||
return L0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* compile_settings() - compile the "on =" (set variable on exec) statement.
|
||||
*
|
||||
* parse->left variable names
|
||||
* parse->right target name
|
||||
* parse->third variable value
|
||||
* parse->num ASSIGN_SET/APPEND
|
||||
*/
|
||||
|
||||
LIST * compile_settings( PARSE * parse, FRAME * frame )
|
||||
{
|
||||
LIST * nt = parse_evaluate( parse->left, frame );
|
||||
LIST * ns = parse_evaluate( parse->third, frame );
|
||||
LIST * targets = parse_evaluate( parse->right, frame );
|
||||
LIST * ts;
|
||||
char const * trace;
|
||||
int setflag = assign_var_mode( parse->num, &trace );
|
||||
|
||||
if ( DEBUG_COMPILE )
|
||||
{
|
||||
debug_compile( 0, "set", frame );
|
||||
list_print( nt );
|
||||
printf( " on " );
|
||||
list_print( targets );
|
||||
printf( " %s ", trace );
|
||||
list_print( ns );
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
/* Call addsettings() to save variable setting. addsettings() keeps ns, so
|
||||
* need to copy it. Pass append flag to addsettings().
|
||||
*/
|
||||
for ( ts = targets; ts; ts = list_next( ts ) )
|
||||
{
|
||||
TARGET * t = bindtarget( ts->value );
|
||||
LIST * l;
|
||||
|
||||
for ( l = nt; l; l = list_next( l ) )
|
||||
t->settings = addsettings( t->settings, setflag, l->value,
|
||||
list_copy( (LIST *)0, ns ) );
|
||||
}
|
||||
|
||||
list_free( nt );
|
||||
list_free( targets );
|
||||
return ns;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* compile_switch() - compile 'switch' rule.
|
||||
*
|
||||
* parse->left switch value (only 1st used)
|
||||
* parse->right cases
|
||||
*
|
||||
* cases->left 1st case
|
||||
* cases->right next cases
|
||||
*
|
||||
* case->string argument to match
|
||||
* case->left parse tree to execute
|
||||
*/
|
||||
|
||||
LIST * compile_switch( PARSE * parse, FRAME * frame )
|
||||
{
|
||||
LIST * nt = parse_evaluate( parse->left, frame );
|
||||
LIST * result = 0;
|
||||
|
||||
if ( DEBUG_COMPILE )
|
||||
{
|
||||
debug_compile( 0, "switch", frame );
|
||||
list_print( nt );
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
/* Step through cases. */
|
||||
for ( parse = parse->right; parse; parse = parse->right )
|
||||
{
|
||||
if ( !glob( object_str( parse->left->string ), nt ? object_str( nt->value ) : "" ) )
|
||||
{
|
||||
/* Get & exec parse tree for this case. */
|
||||
parse = parse->left->left;
|
||||
result = parse_evaluate( parse, frame );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
list_free( nt );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* debug_compile() - printf with indent to show rule expansion.
|
||||
@@ -1419,7 +749,7 @@ static void debug_compile( int which, const char * s, FRAME * frame )
|
||||
{
|
||||
int i;
|
||||
|
||||
print_source_line( frame->procedure );
|
||||
print_source_line( frame );
|
||||
|
||||
i = ( level + 1 ) * 2;
|
||||
while ( i > 35 )
|
||||
|
||||
@@ -24,26 +24,6 @@
|
||||
|
||||
void compile_builtins();
|
||||
|
||||
LIST *compile_append( PARSE *parse, FRAME *frame );
|
||||
LIST *compile_foreach( PARSE *parse, FRAME *frame );
|
||||
LIST *compile_if( PARSE *parse, FRAME *frame );
|
||||
LIST *compile_eval( PARSE *parse, FRAME *args );
|
||||
LIST *compile_include( PARSE *parse, FRAME *frame );
|
||||
LIST *compile_list( PARSE *parse, FRAME *frame );
|
||||
LIST *compile_local( PARSE *parse, FRAME *frame );
|
||||
LIST *compile_module( PARSE *parse, FRAME *frame );
|
||||
LIST *compile_class( PARSE *parse, FRAME *frame );
|
||||
LIST *compile_null( PARSE *parse, FRAME *frame );
|
||||
LIST *compile_on( PARSE *parse, FRAME *frame );
|
||||
LIST *compile_rule( PARSE *parse, FRAME *frame );
|
||||
LIST *compile_rules( PARSE *parse, FRAME *frame );
|
||||
LIST *compile_set( PARSE *parse, FRAME *frame );
|
||||
LIST *compile_setcomp( PARSE *parse, FRAME *frame );
|
||||
LIST *compile_setexec( PARSE *parse, FRAME *frame );
|
||||
LIST *compile_settings( PARSE *parse, FRAME *frame );
|
||||
LIST *compile_switch( PARSE *parse, FRAME *frame );
|
||||
LIST *compile_while( PARSE *parse, FRAME *frame );
|
||||
|
||||
LIST *evaluate_rule( OBJECT * rulename, FRAME * frame );
|
||||
LIST *call_rule( OBJECT * rulename, FRAME * caller_frame, ...);
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
void constants_init( void )
|
||||
{
|
||||
constant_empty = object_new( "" );
|
||||
constant_builtin = object_new( "(builtin)" );
|
||||
constant_other = object_new( "[OTHER]" );
|
||||
constant_total = object_new( "[TOTAL]" );
|
||||
@@ -40,6 +41,7 @@ void constants_init( void )
|
||||
|
||||
void constants_done( void )
|
||||
{
|
||||
object_free( constant_empty );
|
||||
object_free( constant_builtin );
|
||||
object_free( constant_other );
|
||||
object_free( constant_total );
|
||||
@@ -59,6 +61,7 @@ void constants_done( void )
|
||||
object_free( constant_MAIN_PYTHON );
|
||||
}
|
||||
|
||||
OBJECT * constant_empty;
|
||||
OBJECT * constant_builtin;
|
||||
OBJECT * constant_other;
|
||||
OBJECT * constant_total;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
void constants_init( void );
|
||||
void constants_done( void );
|
||||
|
||||
extern OBJECT * constant_empty; /* "" */
|
||||
extern OBJECT * constant_builtin; /* "(builtin)" */
|
||||
extern OBJECT * constant_other; /* "[OTHER]" */
|
||||
extern OBJECT * constant_total; /* "[TOTAL]" */
|
||||
|
||||
@@ -13,7 +13,8 @@ void frame_init( FRAME* frame )
|
||||
lol_init(frame->args);
|
||||
frame->module = root_module();
|
||||
frame->rulename = "module scope";
|
||||
frame->procedure = 0;
|
||||
frame->file = 0;
|
||||
frame->line = -1;
|
||||
}
|
||||
|
||||
void frame_free( FRAME* frame )
|
||||
|
||||
@@ -20,7 +20,8 @@ struct frame
|
||||
FRAME * prev_user;
|
||||
LOL args[ 1 ];
|
||||
module_t * module;
|
||||
PARSE * procedure;
|
||||
OBJECT * file;
|
||||
int line;
|
||||
const char * rulename;
|
||||
};
|
||||
|
||||
|
||||
3019
v2/engine/function.c
Normal file
3019
v2/engine/function.c
Normal file
File diff suppressed because it is too large
Load Diff
33
v2/engine/function.h
Normal file
33
v2/engine/function.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2011 Steven Watanabe
|
||||
* 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)
|
||||
*/
|
||||
|
||||
#ifndef FUNCTION_SW20111123_H
|
||||
#define FUNCTION_SW20111123_H
|
||||
|
||||
#include "object.h"
|
||||
#include "frames.h"
|
||||
#include "lists.h"
|
||||
#include "parse.h"
|
||||
|
||||
typedef struct _function FUNCTION;
|
||||
typedef struct _stack STACK;
|
||||
|
||||
STACK * stack_global( void );
|
||||
void stack_push( STACK * s, LIST * l );
|
||||
LIST * stack_pop( STACK * s );
|
||||
|
||||
FUNCTION * function_compile( PARSE * parse );
|
||||
FUNCTION * function_builtin( LIST * ( * func )( FRAME * frame, int flags ), int flags );
|
||||
void function_refer( FUNCTION * );
|
||||
void function_free( FUNCTION * );
|
||||
OBJECT * function_rulename( FUNCTION * );
|
||||
void function_set_rulename( FUNCTION *, OBJECT * );
|
||||
void function_location( FUNCTION *, OBJECT * *, int * );
|
||||
LIST * function_run( FUNCTION * function, FRAME * frame, STACK * s );
|
||||
|
||||
void function_done( void );
|
||||
|
||||
#endif
|
||||
@@ -126,6 +126,7 @@
|
||||
#include "class.h"
|
||||
#include "execcmd.h"
|
||||
#include "constants.h"
|
||||
#include "function.h"
|
||||
|
||||
/* Macintosh is "special" */
|
||||
#ifdef OS_MAC
|
||||
@@ -619,6 +620,7 @@ int main( int argc, char * * argv, char * * arg_environ )
|
||||
regex_done();
|
||||
exec_done();
|
||||
pwd_done();
|
||||
function_done();
|
||||
list_done();
|
||||
constants_done();
|
||||
object_done();
|
||||
|
||||
@@ -80,29 +80,29 @@
|
||||
|
||||
# define YYMAXDEPTH 10000 /* for OSF and other less endowed yaccs */
|
||||
|
||||
# define F0 (LIST *(*)(PARSE *, FRAME *))0
|
||||
# define F0 -1
|
||||
# define P0 (PARSE *)0
|
||||
# define S0 (OBJECT *)0
|
||||
|
||||
# define pappend( l,r ) parse_make( compile_append,l,r,P0,S0,S0,0 )
|
||||
# define peval( c,l,r ) parse_make( compile_eval,l,r,P0,S0,S0,c )
|
||||
# define pfor( s,l,r,x ) parse_make( compile_foreach,l,r,P0,s,S0,x )
|
||||
# define pif( l,r,t ) parse_make( compile_if,l,r,t,S0,S0,0 )
|
||||
# define pincl( l ) parse_make( compile_include,l,P0,P0,S0,S0,0 )
|
||||
# define plist( s ) parse_make( compile_list,P0,P0,P0,s,S0,0 )
|
||||
# define plocal( l,r,t ) parse_make( compile_local,l,r,t,S0,S0,0 )
|
||||
# define pmodule( l,r ) parse_make( compile_module,l,r,P0,S0,S0,0 )
|
||||
# define pclass( l,r ) parse_make( compile_class,l,r,P0,S0,S0,0 )
|
||||
# define pnull() parse_make( compile_null,P0,P0,P0,S0,S0,0 )
|
||||
# define pon( l,r ) parse_make( compile_on,l,r,P0,S0,S0,0 )
|
||||
# define prule( s,p ) parse_make( compile_rule,p,P0,P0,s,S0,0 )
|
||||
# define prules( l,r ) parse_make( compile_rules,l,r,P0,S0,S0,0 )
|
||||
# define pset( l,r,a ) parse_make( compile_set,l,r,P0,S0,S0,a )
|
||||
# define pset1( l,r,t,a ) parse_make( compile_settings,l,r,t,S0,S0,a )
|
||||
# define psetc( s,p,a,l ) parse_make( compile_setcomp,p,a,P0,s,S0,l )
|
||||
# define psete( s,l,s1,f ) parse_make( compile_setexec,l,P0,P0,s,s1,f )
|
||||
# define pswitch( l,r ) parse_make( compile_switch,l,r,P0,S0,S0,0 )
|
||||
# define pwhile( l,r ) parse_make( compile_while,l,r,P0,S0,S0,0 )
|
||||
# define pappend( l,r ) parse_make( PARSE_APPEND,l,r,P0,S0,S0,0 )
|
||||
# define peval( c,l,r ) parse_make( PARSE_EVAL,l,r,P0,S0,S0,c )
|
||||
# define pfor( s,l,r,x ) parse_make( PARSE_FOREACH,l,r,P0,s,S0,x )
|
||||
# define pif( l,r,t ) parse_make( PARSE_IF,l,r,t,S0,S0,0 )
|
||||
# define pincl( l ) parse_make( PARSE_INCLUDE,l,P0,P0,S0,S0,0 )
|
||||
# define plist( s ) parse_make( PARSE_LIST,P0,P0,P0,s,S0,0 )
|
||||
# define plocal( l,r,t ) parse_make( PARSE_LOCAL,l,r,t,S0,S0,0 )
|
||||
# define pmodule( l,r ) parse_make( PARSE_MODULE,l,r,P0,S0,S0,0 )
|
||||
# define pclass( l,r ) parse_make( PARSE_CLASS,l,r,P0,S0,S0,0 )
|
||||
# define pnull() parse_make( PARSE_NULL,P0,P0,P0,S0,S0,0 )
|
||||
# define pon( l,r ) parse_make( PARSE_ON,l,r,P0,S0,S0,0 )
|
||||
# define prule( s,p ) parse_make( PARSE_RULE,p,P0,P0,s,S0,0 )
|
||||
# define prules( l,r ) parse_make( PARSE_RULES,l,r,P0,S0,S0,0 )
|
||||
# define pset( l,r,a ) parse_make( PARSE_SET,l,r,P0,S0,S0,a )
|
||||
# define pset1( l,r,t,a ) parse_make( PARSE_SETTINGS,l,r,t,S0,S0,a )
|
||||
# define psetc( s,p,a,l ) parse_make( PARSE_SETCOMP,p,a,P0,s,S0,l )
|
||||
# define psete( s,l,s1,f ) parse_make( PARSE_SETEXEC,l,P0,P0,s,s1,f )
|
||||
# define pswitch( l,r ) parse_make( PARSE_SWITCH,l,r,P0,S0,S0,0 )
|
||||
# define pwhile( l,r ) parse_make( PARSE_WHILE,l,r,P0,S0,S0,0 )
|
||||
|
||||
# define pnode( l,r ) parse_make( F0,l,r,P0,S0,S0,0 )
|
||||
# define psnode( s,l ) parse_make( F0,l,P0,P0,s,S0,0 )
|
||||
|
||||
@@ -105,29 +105,29 @@
|
||||
|
||||
# define YYMAXDEPTH 10000 /* for OSF and other less endowed yaccs */
|
||||
|
||||
# define F0 (LIST *(*)(PARSE *, FRAME *))0
|
||||
# define F0 -1
|
||||
# define P0 (PARSE *)0
|
||||
# define S0 (OBJECT *)0
|
||||
|
||||
# define pappend( l,r ) parse_make( compile_append,l,r,P0,S0,S0,0 )
|
||||
# define peval( c,l,r ) parse_make( compile_eval,l,r,P0,S0,S0,c )
|
||||
# define pfor( s,l,r,x ) parse_make( compile_foreach,l,r,P0,s,S0,x )
|
||||
# define pif( l,r,t ) parse_make( compile_if,l,r,t,S0,S0,0 )
|
||||
# define pincl( l ) parse_make( compile_include,l,P0,P0,S0,S0,0 )
|
||||
# define plist( s ) parse_make( compile_list,P0,P0,P0,s,S0,0 )
|
||||
# define plocal( l,r,t ) parse_make( compile_local,l,r,t,S0,S0,0 )
|
||||
# define pmodule( l,r ) parse_make( compile_module,l,r,P0,S0,S0,0 )
|
||||
# define pclass( l,r ) parse_make( compile_class,l,r,P0,S0,S0,0 )
|
||||
# define pnull() parse_make( compile_null,P0,P0,P0,S0,S0,0 )
|
||||
# define pon( l,r ) parse_make( compile_on,l,r,P0,S0,S0,0 )
|
||||
# define prule( s,p ) parse_make( compile_rule,p,P0,P0,s,S0,0 )
|
||||
# define prules( l,r ) parse_make( compile_rules,l,r,P0,S0,S0,0 )
|
||||
# define pset( l,r,a ) parse_make( compile_set,l,r,P0,S0,S0,a )
|
||||
# define pset1( l,r,t,a ) parse_make( compile_settings,l,r,t,S0,S0,a )
|
||||
# define psetc( s,p,a,l ) parse_make( compile_setcomp,p,a,P0,s,S0,l )
|
||||
# define psete( s,l,s1,f ) parse_make( compile_setexec,l,P0,P0,s,s1,f )
|
||||
# define pswitch( l,r ) parse_make( compile_switch,l,r,P0,S0,S0,0 )
|
||||
# define pwhile( l,r ) parse_make( compile_while,l,r,P0,S0,S0,0 )
|
||||
# define pappend( l,r ) parse_make( PARSE_APPEND,l,r,P0,S0,S0,0 )
|
||||
# define peval( c,l,r ) parse_make( PARSE_EVAL,l,r,P0,S0,S0,c )
|
||||
# define pfor( s,l,r,x ) parse_make( PARSE_FOREACH,l,r,P0,s,S0,x )
|
||||
# define pif( l,r,t ) parse_make( PARSE_IF,l,r,t,S0,S0,0 )
|
||||
# define pincl( l ) parse_make( PARSE_INCLUDE,l,P0,P0,S0,S0,0 )
|
||||
# define plist( s ) parse_make( PARSE_LIST,P0,P0,P0,s,S0,0 )
|
||||
# define plocal( l,r,t ) parse_make( PARSE_LOCAL,l,r,t,S0,S0,0 )
|
||||
# define pmodule( l,r ) parse_make( PARSE_MODULE,l,r,P0,S0,S0,0 )
|
||||
# define pclass( l,r ) parse_make( PARSE_CLASS,l,r,P0,S0,S0,0 )
|
||||
# define pnull() parse_make( PARSE_NULL,P0,P0,P0,S0,S0,0 )
|
||||
# define pon( l,r ) parse_make( PARSE_ON,l,r,P0,S0,S0,0 )
|
||||
# define prule( s,p ) parse_make( PARSE_RULE,p,P0,P0,s,S0,0 )
|
||||
# define prules( l,r ) parse_make( PARSE_RULES,l,r,P0,S0,S0,0 )
|
||||
# define pset( l,r,a ) parse_make( PARSE_SET,l,r,P0,S0,S0,a )
|
||||
# define pset1( l,r,t,a ) parse_make( PARSE_SETTINGS,l,r,t,S0,S0,a )
|
||||
# define psetc( s,p,a,l ) parse_make( PARSE_SETCOMP,p,a,P0,s,S0,l )
|
||||
# define psete( s,l,s1,f ) parse_make( PARSE_SETEXEC,l,P0,P0,s,s1,f )
|
||||
# define pswitch( l,r ) parse_make( PARSE_SWITCH,l,r,P0,S0,S0,0 )
|
||||
# define pwhile( l,r ) parse_make( PARSE_WHILE,l,r,P0,S0,S0,0 )
|
||||
|
||||
# define pnode( l,r ) parse_make( F0,l,r,P0,S0,S0,0 )
|
||||
# define psnode( s,l ) parse_make( F0,l,P0,P0,s,S0,0 )
|
||||
|
||||
@@ -61,29 +61,29 @@
|
||||
|
||||
# define YYMAXDEPTH 10000 /* for OSF and other less endowed yaccs */
|
||||
|
||||
# define F0 (LIST *(*)(PARSE *, FRAME *))0
|
||||
# define F0 -1
|
||||
# define P0 (PARSE *)0
|
||||
# define S0 (OBJECT *)0
|
||||
|
||||
# define pappend( l,r ) parse_make( compile_append,l,r,P0,S0,S0,0 )
|
||||
# define peval( c,l,r ) parse_make( compile_eval,l,r,P0,S0,S0,c )
|
||||
# define pfor( s,l,r,x ) parse_make( compile_foreach,l,r,P0,s,S0,x )
|
||||
# define pif( l,r,t ) parse_make( compile_if,l,r,t,S0,S0,0 )
|
||||
# define pincl( l ) parse_make( compile_include,l,P0,P0,S0,S0,0 )
|
||||
# define plist( s ) parse_make( compile_list,P0,P0,P0,s,S0,0 )
|
||||
# define plocal( l,r,t ) parse_make( compile_local,l,r,t,S0,S0,0 )
|
||||
# define pmodule( l,r ) parse_make( compile_module,l,r,P0,S0,S0,0 )
|
||||
# define pclass( l,r ) parse_make( compile_class,l,r,P0,S0,S0,0 )
|
||||
# define pnull() parse_make( compile_null,P0,P0,P0,S0,S0,0 )
|
||||
# define pon( l,r ) parse_make( compile_on,l,r,P0,S0,S0,0 )
|
||||
# define prule( s,p ) parse_make( compile_rule,p,P0,P0,s,S0,0 )
|
||||
# define prules( l,r ) parse_make( compile_rules,l,r,P0,S0,S0,0 )
|
||||
# define pset( l,r,a ) parse_make( compile_set,l,r,P0,S0,S0,a )
|
||||
# define pset1( l,r,t,a ) parse_make( compile_settings,l,r,t,S0,S0,a )
|
||||
# define psetc( s,p,a,l ) parse_make( compile_setcomp,p,a,P0,s,S0,l )
|
||||
# define psete( s,l,s1,f ) parse_make( compile_setexec,l,P0,P0,s,s1,f )
|
||||
# define pswitch( l,r ) parse_make( compile_switch,l,r,P0,S0,S0,0 )
|
||||
# define pwhile( l,r ) parse_make( compile_while,l,r,P0,S0,S0,0 )
|
||||
# define pappend( l,r ) parse_make( PARSE_APPEND,l,r,P0,S0,S0,0 )
|
||||
# define peval( c,l,r ) parse_make( PARSE_EVAL,l,r,P0,S0,S0,c )
|
||||
# define pfor( s,l,r,x ) parse_make( PARSE_FOREACH,l,r,P0,s,S0,x )
|
||||
# define pif( l,r,t ) parse_make( PARSE_IF,l,r,t,S0,S0,0 )
|
||||
# define pincl( l ) parse_make( PARSE_INCLUDE,l,P0,P0,S0,S0,0 )
|
||||
# define plist( s ) parse_make( PARSE_LIST,P0,P0,P0,s,S0,0 )
|
||||
# define plocal( l,r,t ) parse_make( PARSE_LOCAL,l,r,t,S0,S0,0 )
|
||||
# define pmodule( l,r ) parse_make( PARSE_MODULE,l,r,P0,S0,S0,0 )
|
||||
# define pclass( l,r ) parse_make( PARSE_CLASS,l,r,P0,S0,S0,0 )
|
||||
# define pnull() parse_make( PARSE_NULL,P0,P0,P0,S0,S0,0 )
|
||||
# define pon( l,r ) parse_make( PARSE_ON,l,r,P0,S0,S0,0 )
|
||||
# define prule( s,p ) parse_make( PARSE_RULE,p,P0,P0,s,S0,0 )
|
||||
# define prules( l,r ) parse_make( PARSE_RULES,l,r,P0,S0,S0,0 )
|
||||
# define pset( l,r,a ) parse_make( PARSE_SET,l,r,P0,S0,S0,a )
|
||||
# define pset1( l,r,t,a ) parse_make( PARSE_SETTINGS,l,r,t,S0,S0,a )
|
||||
# define psetc( s,p,a,l ) parse_make( PARSE_SETCOMP,p,a,P0,s,S0,l )
|
||||
# define psete( s,l,s1,f ) parse_make( PARSE_SETEXEC,l,P0,P0,s,s1,f )
|
||||
# define pswitch( l,r ) parse_make( PARSE_SWITCH,l,r,P0,S0,S0,0 )
|
||||
# define pwhile( l,r ) parse_make( PARSE_WHILE,l,r,P0,S0,S0,0 )
|
||||
|
||||
# define pnode( l,r ) parse_make( F0,l,r,P0,S0,S0,0 )
|
||||
# define psnode( s,l ) parse_make( F0,l,P0,P0,s,S0,0 )
|
||||
|
||||
@@ -202,6 +202,43 @@ LIST * list_pop_front( LIST * l )
|
||||
return result;
|
||||
}
|
||||
|
||||
LIST * list_reverse( LIST * l )
|
||||
{
|
||||
LIST * result = L0;
|
||||
for ( ; l; l = l->next )
|
||||
{
|
||||
result = list_append( list_new(L0, object_copy( l->value ) ), result );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int list_cmp( LIST * t, LIST * s )
|
||||
{
|
||||
int status = 0;
|
||||
|
||||
while ( !status && ( t || s ) )
|
||||
{
|
||||
const char *st = t ? object_str( t->value ) : "";
|
||||
const char *ss = s ? object_str( s->value ) : "";
|
||||
|
||||
status = strcmp( st, ss );
|
||||
|
||||
t = t ? list_next( t ) : t;
|
||||
s = s ? list_next( s ) : s;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int list_is_sublist( LIST * sub, LIST * l )
|
||||
{
|
||||
for ( ; sub; sub = sub->next )
|
||||
{
|
||||
if ( !list_in( l, sub->value ) )
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* list_print() - print a list of strings to stdout
|
||||
|
||||
@@ -87,6 +87,9 @@ LIST * list_pop_front( LIST *l );
|
||||
LIST * list_sort( LIST *l);
|
||||
LIST * list_unique( LIST *sorted_list);
|
||||
int list_in(LIST* l, OBJECT* value);
|
||||
LIST * list_reverse( LIST * );
|
||||
int list_cmp( LIST * lhs, LIST * rhs );
|
||||
int list_is_sublist( LIST * sub, LIST * l );
|
||||
void list_done();
|
||||
|
||||
# define list_next( l ) ((l)->next)
|
||||
|
||||
@@ -89,7 +89,7 @@ static void delete_native_rule( void * xrule, void * data )
|
||||
args_free( rule->arguments );
|
||||
object_free( rule->name );
|
||||
if ( rule->procedure )
|
||||
parse_free( rule->procedure );
|
||||
function_free( rule->procedure );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
/* Use quite klugy approach: when we add order dependency from 'a' to 'b',
|
||||
just append 'b' to of value of variable 'a'.
|
||||
*/
|
||||
LIST *add_pair( PARSE *parse, FRAME *frame )
|
||||
LIST *add_pair( FRAME *frame, int flags )
|
||||
{
|
||||
LIST* arg = lol_get( frame->args, 0 );
|
||||
|
||||
@@ -74,7 +74,7 @@ void topological_sort(int** graph, int num_vertices, int* result)
|
||||
BJAM_FREE(colors);
|
||||
}
|
||||
|
||||
LIST *order( PARSE *parse, FRAME *frame )
|
||||
LIST *order( FRAME *frame, int flags )
|
||||
{
|
||||
LIST* arg = lol_get( frame->args, 0 );
|
||||
LIST* tmp;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "../timestamp.h"
|
||||
#include "../object.h"
|
||||
|
||||
LIST *path_exists( PARSE *parse, FRAME *frame )
|
||||
LIST *path_exists( FRAME *frame, int flags )
|
||||
{
|
||||
LIST* l = lol_get( frame->args, 0 );
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ rule create ( raw-properties * )
|
||||
}
|
||||
*/
|
||||
|
||||
LIST *property_set_create( PARSE *parse, FRAME *frame )
|
||||
LIST *property_set_create( FRAME *frame, int flags )
|
||||
{
|
||||
LIST* properties = lol_get( frame->args, 0 );
|
||||
LIST* sorted = 0;
|
||||
|
||||
@@ -25,7 +25,7 @@ rule transform ( list * : pattern : indices * )
|
||||
return $(result) ;
|
||||
}
|
||||
*/
|
||||
LIST *regex_transform( PARSE *parse, FRAME *frame )
|
||||
LIST *regex_transform( FRAME *frame, int flags )
|
||||
{
|
||||
LIST* l = lol_get( frame->args, 0 );
|
||||
LIST* pattern = lol_get( frame->args, 1 );
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
# endif
|
||||
|
||||
|
||||
LIST *sequence_select_highest_ranked( PARSE *parse, FRAME *frame )
|
||||
LIST *sequence_select_highest_ranked( FRAME *frame, int flags )
|
||||
{
|
||||
/* Returns all of 'elements' for which corresponding element in parallel */
|
||||
/* list 'rank' is equal to the maximum value in 'rank'. */
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
}
|
||||
return $(result) ;
|
||||
*/
|
||||
LIST *set_difference( PARSE *parse, FRAME *frame )
|
||||
LIST *set_difference( FRAME *frame, int flags )
|
||||
{
|
||||
|
||||
LIST* b = lol_get( frame->args, 0 );
|
||||
|
||||
@@ -6,12 +6,8 @@
|
||||
#include "hash.h"
|
||||
#include "object.h"
|
||||
|
||||
# define P0 (PARSE *)0
|
||||
# define C0 (OBJECT *)0
|
||||
|
||||
|
||||
void declare_native_rule( const char * module, const char * rule, const char * * args,
|
||||
LIST * (*f)( PARSE *, FRAME * ), int version )
|
||||
LIST * (*f)( FRAME *, int ), int version )
|
||||
{
|
||||
OBJECT * module_obj = 0;
|
||||
module_t * m;
|
||||
@@ -40,7 +36,7 @@ void declare_native_rule( const char * module, const char * rule, const char * *
|
||||
{
|
||||
n.arguments = 0;
|
||||
}
|
||||
n.procedure = parse_make( f, P0, P0, P0, C0, C0, 0 );
|
||||
n.procedure = function_builtin( f, 0 );
|
||||
n.version = version;
|
||||
hashenter(m->native_rules, (HASHDATA**)&np);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ struct native_rule_t
|
||||
{
|
||||
OBJECT * name;
|
||||
argument_list * arguments;
|
||||
PARSE * procedure;
|
||||
FUNCTION * procedure;
|
||||
/* Version of the interface that the native rule provides.
|
||||
It's possible that we want to change the set parameter
|
||||
for existing native rule. In that case, version number
|
||||
@@ -27,7 +27,7 @@ struct native_rule_t
|
||||
typedef struct native_rule_t native_rule_t ;
|
||||
|
||||
void declare_native_rule( const char * module, const char * rule, const char * * args,
|
||||
LIST * (*f)( PARSE *, FRAME * ), int version );
|
||||
LIST * (*f)( FRAME *, int ), int version );
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "object.h"
|
||||
#include "modules.h"
|
||||
#include "frames.h"
|
||||
#include "function.h"
|
||||
|
||||
/*
|
||||
* parse.c - make and destroy parse trees as driven by the parser
|
||||
@@ -41,6 +42,7 @@ void parse_file( OBJECT * f, FRAME * frame )
|
||||
for ( ; ; )
|
||||
{
|
||||
PARSE * p;
|
||||
FUNCTION * func;
|
||||
|
||||
/* Filled by yyparse() calling parse_save(). */
|
||||
yypsave = 0;
|
||||
@@ -50,8 +52,10 @@ void parse_file( OBJECT * f, FRAME * frame )
|
||||
break;
|
||||
|
||||
/* Run the parse tree. */
|
||||
list_free( parse_evaluate( p, frame ) );
|
||||
func = function_compile( p );
|
||||
parse_free( p );
|
||||
list_free( function_run( func, frame, stack_global() ) );
|
||||
function_free( func );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +67,7 @@ void parse_save( PARSE * p )
|
||||
|
||||
|
||||
PARSE * parse_make(
|
||||
LIST * (* func)( PARSE *, FRAME * ),
|
||||
int type,
|
||||
PARSE * left,
|
||||
PARSE * right,
|
||||
PARSE * third,
|
||||
@@ -73,7 +77,7 @@ PARSE * parse_make(
|
||||
{
|
||||
PARSE * p = (PARSE *)BJAM_MALLOC( sizeof( PARSE ) );
|
||||
|
||||
p->func = func;
|
||||
p->type = type;
|
||||
p->left = left;
|
||||
p->right = right;
|
||||
p->third = third;
|
||||
@@ -126,10 +130,3 @@ void parse_free( PARSE * p )
|
||||
|
||||
BJAM_FREE( (char *)p );
|
||||
}
|
||||
|
||||
|
||||
LIST * parse_evaluate( PARSE * p, FRAME * frame )
|
||||
{
|
||||
frame->procedure = p;
|
||||
return (*p->func)( p, frame );
|
||||
}
|
||||
|
||||
@@ -21,12 +21,32 @@
|
||||
* parse.h - make and destroy parse trees as driven by the parser.
|
||||
*/
|
||||
|
||||
#define PARSE_APPEND 0
|
||||
#define PARSE_FOREACH 1
|
||||
#define PARSE_IF 2
|
||||
#define PARSE_EVAL 3
|
||||
#define PARSE_INCLUDE 4
|
||||
#define PARSE_LIST 5
|
||||
#define PARSE_LOCAL 6
|
||||
#define PARSE_MODULE 7
|
||||
#define PARSE_CLASS 8
|
||||
#define PARSE_NULL 9
|
||||
#define PARSE_ON 10
|
||||
#define PARSE_RULE 11
|
||||
#define PARSE_RULES 12
|
||||
#define PARSE_SET 13
|
||||
#define PARSE_SETCOMP 14
|
||||
#define PARSE_SETEXEC 15
|
||||
#define PARSE_SETTINGS 16
|
||||
#define PARSE_SWITCH 17
|
||||
#define PARSE_WHILE 18
|
||||
|
||||
/*
|
||||
* Parse tree node.
|
||||
*/
|
||||
|
||||
struct _PARSE {
|
||||
LIST * (* func)( PARSE *, FRAME * );
|
||||
int type;
|
||||
PARSE * left;
|
||||
PARSE * right;
|
||||
PARSE * third;
|
||||
@@ -34,7 +54,6 @@ struct _PARSE {
|
||||
OBJECT * string1;
|
||||
int num;
|
||||
int refs;
|
||||
/* module * module; */
|
||||
OBJECT * rulename;
|
||||
OBJECT * file;
|
||||
int line;
|
||||
@@ -44,7 +63,7 @@ void parse_file( OBJECT *, FRAME * );
|
||||
void parse_save( PARSE * );
|
||||
|
||||
PARSE * parse_make(
|
||||
LIST * (* func)( PARSE *, FRAME * ),
|
||||
int type,
|
||||
PARSE * left,
|
||||
PARSE * right,
|
||||
PARSE * third,
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
*/
|
||||
|
||||
static void set_rule_actions( RULE *, rule_actions * );
|
||||
static void set_rule_body ( RULE *, argument_list *, PARSE * procedure );
|
||||
static void set_rule_body ( RULE *, argument_list *, FUNCTION * procedure );
|
||||
|
||||
static struct hash * targethash = 0;
|
||||
|
||||
@@ -93,7 +93,7 @@ static RULE * enter_rule( OBJECT * rulename, module_t * target_module )
|
||||
if ( hashenter( demand_rules( target_module ), (HASHDATA * *)&r ) )
|
||||
{
|
||||
r->name = object_copy( rulename );
|
||||
r->procedure = (PARSE *)0;
|
||||
r->procedure = 0;
|
||||
r->module = 0;
|
||||
r->actions = 0;
|
||||
r->arguments = 0;
|
||||
@@ -136,7 +136,7 @@ void rule_free( RULE * r )
|
||||
object_free( r->name );
|
||||
r->name = 0;
|
||||
if ( r->procedure )
|
||||
parse_free( r->procedure );
|
||||
function_free( r->procedure );
|
||||
r->procedure = 0;
|
||||
if ( r->arguments )
|
||||
args_free( r->arguments );
|
||||
@@ -659,7 +659,7 @@ 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, PARSE * procedure )
|
||||
static void set_rule_body( RULE * rule, argument_list * args, FUNCTION * procedure )
|
||||
{
|
||||
if ( args )
|
||||
args_refer( args );
|
||||
@@ -668,9 +668,9 @@ static void set_rule_body( RULE * rule, argument_list * args, PARSE * procedure
|
||||
rule->arguments = args;
|
||||
|
||||
if ( procedure )
|
||||
parse_refer( procedure );
|
||||
function_refer( procedure );
|
||||
if ( rule->procedure )
|
||||
parse_free( rule->procedure );
|
||||
function_free( rule->procedure );
|
||||
rule->procedure = procedure;
|
||||
}
|
||||
|
||||
@@ -719,7 +719,7 @@ 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, PARSE * procedure, int exported )
|
||||
RULE * new_rule_body( module_t * m, OBJECT * rulename, argument_list * args, FUNCTION * procedure, int exported )
|
||||
{
|
||||
RULE * local = define_rule( m, rulename, m );
|
||||
local->exported = exported;
|
||||
@@ -730,8 +730,8 @@ RULE * new_rule_body( module_t * m, OBJECT * rulename, argument_list * args, PAR
|
||||
* can use, e.g. in profiling output. Only do this once, since this could be
|
||||
* called multiple times with the same procedure.
|
||||
*/
|
||||
if ( procedure->rulename == 0 )
|
||||
procedure->rulename = global_rule_name( local );
|
||||
if ( function_rulename( procedure ) == 0 )
|
||||
function_set_rulename( procedure, global_rule_name( local ) );
|
||||
|
||||
return local;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "modules.h"
|
||||
#include "jam.h"
|
||||
#include "parse.h"
|
||||
#include "function.h"
|
||||
|
||||
|
||||
/*
|
||||
@@ -81,7 +81,7 @@ typedef struct argument_list argument_list;
|
||||
struct _rule
|
||||
{
|
||||
OBJECT * name;
|
||||
PARSE * procedure; /* parse tree from RULE */
|
||||
FUNCTION * procedure;
|
||||
argument_list * arguments; /* argument checking info, or NULL for unchecked
|
||||
*/
|
||||
rule_actions * actions; /* build actions, or NULL for no actions */
|
||||
@@ -260,7 +260,7 @@ void args_refer( argument_list * );
|
||||
/* Rule related functions. */
|
||||
RULE * bindrule ( OBJECT * rulename, module_t * );
|
||||
RULE * import_rule ( RULE * source, module_t *, OBJECT * name );
|
||||
RULE * new_rule_body ( module_t *, OBJECT * rulename, argument_list *, PARSE * procedure, int exprt );
|
||||
RULE * new_rule_body ( module_t *, OBJECT * rulename, argument_list *, FUNCTION * func, int exprt );
|
||||
RULE * new_rule_actions( module_t *, OBJECT * rulename, OBJECT * command, LIST * bindlist, int flags );
|
||||
void rule_free ( RULE * );
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
#include "object.h"
|
||||
#include "lists.h"
|
||||
#include "parse.h"
|
||||
#include "compile.h"
|
||||
#include "frames.h"
|
||||
#include "builtins.h"
|
||||
|
||||
struct regex_entry
|
||||
{
|
||||
@@ -35,10 +35,7 @@ regexp* regex_compile( OBJECT* pattern )
|
||||
return e->regex;
|
||||
}
|
||||
|
||||
LIST*
|
||||
builtin_subst(
|
||||
PARSE *parse,
|
||||
FRAME *frame )
|
||||
LIST * builtin_subst( FRAME * frame, int flags )
|
||||
{
|
||||
LIST* result = L0;
|
||||
LIST* arg1 = lol_get( frame->args, 0 );
|
||||
|
||||
@@ -57,10 +57,7 @@ static HKEY get_key(char const** path)
|
||||
return p->value;
|
||||
}
|
||||
|
||||
LIST*
|
||||
builtin_system_registry(
|
||||
PARSE *parse,
|
||||
FRAME *frame )
|
||||
LIST * builtin_system_registry( FRAME * frame, int flags )
|
||||
{
|
||||
char const* path = object_str( lol_get(frame->args, 0)->value );
|
||||
LIST* result = L0;
|
||||
@@ -187,10 +184,7 @@ static LIST* get_value_names(HKEY key, char const* path)
|
||||
return result;
|
||||
}
|
||||
|
||||
LIST*
|
||||
builtin_system_registry_names(
|
||||
PARSE *parse,
|
||||
FRAME *frame )
|
||||
LIST * builtin_system_registry_names( FRAME * frame, int flags )
|
||||
{
|
||||
char const* path = object_str( lol_get(frame->args, 0)->value );
|
||||
char const* result_type = object_str( lol_get(frame->args, 1)->value );
|
||||
|
||||
Reference in New Issue
Block a user