The Machine Perception Toolbox

[Introduction]- [News]- [Download]- [Screenshots]- [Manual (pdf)]- [Forums]- [API Reference]- [Repository ]

 

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

rules.c File Reference

#include "jam.h"
#include "lists.h"
#include "parse.h"
#include "variable.h"
#include "rules.h"
#include "newstr.h"
#include "hash.h"
#include "modules.h"
#include "search.h"
#include "pathsys.h"
#include "timestamp.h"

Include dependency graph for rules.c:

Include dependency graph

Go to the source code of this file.

Classes

struct  _located_target

Typedefs

typedef _located_target LOCATED_TARGET

Functions

ACTIONSactionlist (ACTIONS *chain, ACTION *action)
void actions_free (rule_actions *a)
rule_actionsactions_new (char *command, LIST *bindlist, int flags)
void actions_refer (rule_actions *a)
SETTINGSaddsettings (SETTINGS *head, int append, char *symbol, LIST *value)
void args_free (argument_list *a)
argument_listargs_new ()
void args_refer (argument_list *a)
void bind_explicitly_located_target (void *xtarget, void *data)
void bind_explicitly_located_targets ()
RULEbindrule (char *rulename, module_t *m)
TARGETbindtarget (const char *targetname)
void call_bind_rule (char *target, char *boundname)
SETTINGScopysettings (SETTINGS *head)
TARGETcopytarget (const TARGET *ot)
RULEdefine_rule (module_t *src_module, char *rulename, module_t *target_module)
void donerules ()
RULEenter_rule (char *rulename, module_t *target_module)
void freeactions (ACTIONS *chain)
void freesettings (SETTINGS *v)
void freetarget (void *xt, void *data)
void freetargets (TARGETS *chain)
RULEglobal_rule (RULE *r)
char * global_rule_name (RULE *r)
RULEimport_rule (RULE *source, module_t *m, char *name)
RULElookup_rule (char *rulename, module_t *m, int local_only)
RULEnew_rule_actions (module_t *m, char *rulename, char *command, LIST *bindlist, int flags)
RULEnew_rule_body (module_t *m, char *rulename, argument_list *args, PARSE *procedure, int exported)
void popsettings (SETTINGS *v)
void pushsettings (SETTINGS *v)
void rule_free (RULE *r)
TARGETsearch_for_target (char *name, LIST *search_path)
void set_rule_actions (RULE *rule, rule_actions *actions)
void set_rule_body (RULE *rule, argument_list *args, PARSE *procedure)
TARGETStargetchain (TARGETS *chain, TARGETS *targets)
TARGETStargetentry (TARGETS *chain, TARGET *target)
TARGETStargetlist (TARGETS *chain, LIST *targets)
void touchtarget (char *t)

Variables

hashlocated_targets = 0
SETTINGSsettings_freelist
hashtargethash = 0


Typedef Documentation

typedef struct _located_target LOCATED_TARGET
 

Definition at line 56 of file rules.c.

Referenced by search_for_target().


Function Documentation

ACTIONS* actionlist ACTIONS chain,
ACTION action
 

Definition at line 362 of file rules.c.

References ACTION, _actions::action, ACTIONS, _actions::next, and _actions::tail.

Referenced by evaluate_rule().

00365 {
00366         ACTIONS *actions = (ACTIONS *)malloc( sizeof( ACTIONS ) );
00367 
00368         actions->action = action;
00369 
00370         if( !chain ) chain = actions;
00371         else chain->tail->next = actions;
00372         chain->tail = actions;
00373         actions->next = 0;
00374 
00375         return chain;
00376 }

void actions_free rule_actions a  ) 
 

Definition at line 591 of file rules.c.

References rule_actions::bindlist, rule_actions::command, hash::free, freestr(), list_free(), and rule_actions::reference_count.

Referenced by rule_free(), and set_rule_actions().

00592 {
00593     if (--a->reference_count <= 0)
00594     {
00595         freestr(a->command);
00596         list_free(a->bindlist);
00597         free(a);
00598     }
00599 }

Here is the call graph for this function:

rule_actions* actions_new char *  command,
LIST bindlist,
int  flags
[static]
 

Definition at line 689 of file rules.c.

References rule_actions::bindlist, rule_actions::command, copystr(), rule_actions::flags, LIST, and rule_actions::reference_count.

Referenced by new_rule_actions().

00690 {
00691     rule_actions* result = (rule_actions*)malloc(sizeof(rule_actions));
00692     result->command = copystr( command );
00693     result->bindlist = bindlist;
00694     result->flags = flags;
00695     result->reference_count = 0;
00696     return result;
00697 }

Here is the call graph for this function:

void actions_refer rule_actions a  ) 
 

Definition at line 583 of file rules.c.

References rule_actions::reference_count.

Referenced by set_rule_actions().

00584 {
00585     ++a->reference_count;
00586 }

SETTINGS* addsettings SETTINGS head,
int  append,
char *  symbol,
LIST value
 

Definition at line 390 of file rules.c.

References LIST, list_append(), list_free(), newstr(), _settings::next, _list::next, SETTINGS, settings_freelist, _settings::symbol, v, and _settings::value.

Referenced by collect_arguments(), compile_foreach(), compile_local(), compile_settings(), copysettings(), and make1settings().

00395 {
00396         SETTINGS *v;
00397         
00398         /* Look for previous setting */
00399 
00400         for( v = head; v; v = v->next )
00401             if( !strcmp( v->symbol, symbol ) )
00402                 break;
00403 
00404         /* If not previously set, alloc a new. */
00405         /* If appending, do so. */
00406         /* Else free old and set new. */
00407 
00408         if( !v )
00409         {
00410         v = settings_freelist;
00411         
00412         if ( v )
00413             settings_freelist = v->next;
00414         else
00415             v = (SETTINGS *)malloc( sizeof( *v ) );
00416         
00417             v->symbol = newstr( symbol );
00418             v->value = value;
00419             v->next = head;
00420             head = v;
00421         }
00422         else if( append )
00423         {
00424             v->value = list_append( v->value, value );
00425         }
00426         else
00427         {
00428             list_free( v->value );
00429             v->value = value;
00430         } 
00431 
00432         /* Return (new) head of list. */
00433 
00434         return head;
00435 }

Here is the call graph for this function:

void args_free argument_list a  ) 
 

Definition at line 571 of file rules.c.

References argument_list::data, hash::free, lol_free(), and argument_list::reference_count.

Referenced by rule_free(), and set_rule_body().

00572 {
00573     if (--a->reference_count <= 0)
00574     {
00575         lol_free(a->data);
00576         free(a);
00577     }
00578 }

Here is the call graph for this function:

argument_list* args_new  ) 
 

Definition at line 552 of file rules.c.

References argument_list::data, lol_init(), r, and argument_list::reference_count.

Referenced by bind_builtin(), and compile_setcomp().

00553 {
00554     argument_list* r = (argument_list*)malloc( sizeof(argument_list) );
00555     r->reference_count = 0;
00556     lol_init(r->data);
00557     return r;
00558 }

Here is the call graph for this function:

void args_refer argument_list a  ) 
 

Definition at line 563 of file rules.c.

References argument_list::reference_count.

Referenced by set_rule_body().

00564 {
00565     ++a->reference_count;
00566 }

void bind_explicitly_located_target void *  xtarget,
void *  data
[static]
 

Definition at line 152 of file rules.c.

References _target::boundname, _target::flags, _target::name, _settings::next, popsettings(), pushsettings(), s, search(), _target::settings, SETTINGS, _settings::symbol, TARGET, and _target::time.

Referenced by bind_explicitly_located_targets().

00153 {
00154     TARGET* t = (TARGET*)xtarget;
00155     if (! (t->flags & T_FLAG_NOTFILE) )
00156     {
00157         /* Check if there's a setting for LOCATE */
00158         SETTINGS* s = t->settings;
00159         for(; s ; s = s->next)
00160         {            
00161             if (strcmp(s->symbol, "LOCATE") == 0) 
00162             {
00163                 pushsettings(t->settings);
00164                 /* We're binding a target with explicit LOCATE. So
00165                    third argument is of now use: nothing will be returned
00166                    through it. */
00167                 t->boundname = search( t->name, &t->time, 0 );
00168                 popsettings(t->settings);
00169                 break;
00170             }
00171         }
00172     }
00173 }

Here is the call graph for this function:

void bind_explicitly_located_targets  ) 
 

Definition at line 175 of file rules.c.

References bind_explicitly_located_target(), hashenumerate(), and targethash.

Referenced by make().

00176 {
00177     if (targethash)
00178         hashenumerate(targethash, bind_explicitly_located_target, (void*)0);
00179 }

Here is the call graph for this function:

RULE* bindrule char *  rulename,
module_t m
 

Definition at line 761 of file rules.c.

References enter_rule(), lookup_rule(), m, root_module(), and RULE.

Referenced by evaluate_rule().

00762 {
00763     RULE *result;
00764 
00765     result = lookup_rule(rulename, m, 0);
00766     if (!result)
00767         result = lookup_rule(rulename, root_module(), 0);
00768     /* We've only one caller, 'evaluate_rule', which will complain about 
00769        calling underfined rule. We could issue the error
00770        here, but we don't have necessary information, such as frame.
00771     */
00772     if (!result)
00773         result = enter_rule( rulename, root_module() );
00774 
00775     return result;
00776 }

Here is the call graph for this function:

TARGET* bindtarget const char *  targetname  ) 
 

Definition at line 131 of file rules.c.

References _target::boundname, HASHDATA, hashenter, hashinit(), _target::name, newstr(), TARGET, and targethash.

Referenced by builtin_depends(), builtin_flags(), builtin_hdrmacro(), compile_include(), compile_on(), compile_settings(), make(), make0(), make1settings(), search_for_target(), targetlist(), and touchtarget().

00132 {
00133         TARGET target, *t = &target;
00134 
00135         if( !targethash )
00136             targethash = hashinit( sizeof( TARGET ), "targets" );
00137 
00138     /* Perforce added const everywhere. No time to merge that change. */
00139         t->name = (char*)targetname;
00140 
00141         if( hashenter( targethash, (HASHDATA **)&t ) )
00142         {
00143             memset( (char *)t, '\0', sizeof( *t ) );
00144             t->name = newstr( (char*)targetname );      /* never freed */
00145             t->boundname = t->name;             /* default for T_FLAG_NOTFILE */
00146         }
00147 
00148         return t;
00149 }

Here is the call graph for this function:

void call_bind_rule char *  target,
char *  boundname
 

Definition at line 34 of file search.c.

References frame::args, copystr(), evaluate_rule(), FRAME, frame_free(), frame_init(), freestr(), L0, LIST, list_new(), lol_add(), lol_get(), _list::string, and var_get().

Referenced by search(), and search_for_target().

00037 {
00038     LIST* bind_rule = var_get( "BINDRULE" );
00039     if( bind_rule )
00040     {
00041         /* No guarantee that target is an allocated string, so be on the
00042          * safe side */
00043         char* target = copystr( target_ );
00044         
00045         /* Likewise, don't rely on implementation details of newstr.c: allocate
00046          * a copy of boundname */
00047         char* boundname = copystr( boundname_ );
00048         if( boundname && target )
00049         {
00050             /* Prepare the argument list */
00051             FRAME frame[1];
00052             frame_init( frame );
00053                     
00054             /* First argument is the target name */
00055             lol_add( frame->args, list_new( L0, target ) );
00056                     
00057             lol_add( frame->args, list_new( L0, boundname ) );
00058             if( lol_get( frame->args, 1 ) )
00059                 evaluate_rule( bind_rule->string, frame );
00060             
00061             /* Clean up */
00062             frame_free( frame );
00063         }
00064         else
00065         {
00066             if( boundname )
00067                 freestr( boundname );
00068             if( target )
00069                 freestr( target );
00070         }
00071     }
00072 }

Here is the call graph for this function:

SETTINGS* copysettings SETTINGS head  ) 
 

Definition at line 462 of file rules.c.

References addsettings(), list_copy(), _settings::next, SETTINGS, _settings::symbol, and v.

Referenced by make0(), and make1c().

00463 {
00464     SETTINGS *copy = 0, *v;
00465 
00466     for (v = head; v; v = v->next)
00467         copy = addsettings(copy, 0, v->symbol, list_copy(0, v->value));
00468 
00469     return copy;
00470 }

Here is the call graph for this function:

TARGET* copytarget const TARGET ot  ) 
 

Definition at line 262 of file rules.c.

References _target::boundname, copystr(), _target::flags, _target::name, T_FLAG_NOTFILE, and TARGET.

Referenced by builtin_depends(), and make0().

00263 {
00264         TARGET *t;
00265 
00266         t = (TARGET *)malloc( sizeof( *t ) );
00267         memset( (char *)t, '\0', sizeof( *t ) );
00268         t->name = copystr( ot->name );
00269         t->boundname = t->name;
00270 
00271         t->flags |= T_FLAG_NOTFILE | T_FLAG_INTERNAL;
00272 
00273         return t;
00274 }

Here is the call graph for this function:

RULE* define_rule module_t src_module,
char *  rulename,
module_t target_module
[static]
 

Definition at line 97 of file rules.c.

References enter_rule(), _rule::module, r, RULE, set_rule_actions(), and set_rule_body().

Referenced by global_rule(), import_rule(), new_rule_actions(), and new_rule_body().

00098 {
00099     RULE *r = enter_rule( rulename, target_module );
00100 
00101     if ( r->module != src_module ) /* if the rule was imported from elsewhere, clear it now */
00102     {
00103         set_rule_body( r, 0, 0 ); 
00104         set_rule_actions( r, 0 );
00105         r->module = src_module; /* r will be executed in the source module */
00106     }
00107 
00108     return r;
00109 }

Here is the call graph for this function:

void donerules  ) 
 

Definition at line 537 of file rules.c.

References hash::free, freetarget(), hashdone(), hashenumerate(), n, _settings::next, SETTINGS, settings_freelist, and targethash.

Referenced by main().

00538 {
00539      hashenumerate( targethash, freetarget, 0 );
00540         hashdone( targethash );
00541     while ( settings_freelist )
00542     {
00543         SETTINGS* n = settings_freelist->next;
00544         free( settings_freelist );
00545         settings_freelist = n;
00546     }
00547 }

Here is the call graph for this function:

RULE* enter_rule char *  rulename,
module_t target_module
[static]
 

Definition at line 72 of file rules.c.

References demand_rules(), HASHDATA, hashenter, _rule::name, newstr(), PARSE, r, and RULE.

Referenced by bindrule(), and define_rule().

00073 {
00074     RULE rule, *r = &rule;
00075 
00076     r->name = rulename;
00077 
00078     if ( hashenter( demand_rules( target_module ), (HASHDATA **)&r ) )
00079     {
00080         r->name = newstr( rulename );   /* never freed */
00081         r->procedure = (PARSE *)0;
00082         r->module = 0;
00083         r->actions = 0;
00084         r->arguments = 0;
00085         r->exported = 0;
00086         r->module = target_module;
00087     }
00088     return r;
00089 }

Here is the call graph for this function:

void freeactions ACTIONS chain  ) 
 

Definition at line 488 of file rules.c.

References ACTIONS, hash::free, n, and _actions::next.

Referenced by freetarget().

00489 {
00490     while( chain )
00491     {
00492         ACTIONS* n = chain->next;
00493         free( chain );
00494         chain = n;
00495     }
00496 }

void freesettings SETTINGS v  ) 
 

Definition at line 504 of file rules.c.

References freestr(), list_free(), n, _settings::next, SETTINGS, settings_freelist, _settings::symbol, v, and _settings::value.

Referenced by compile_foreach(), compile_local(), evaluate_rule(), freetarget(), make0(), make1c(), and make1cmds().

00505 {
00506         while( v )
00507         {
00508             SETTINGS *n = v->next;
00509 
00510             freestr( v->symbol );
00511             list_free( v->value );
00512         v->next = settings_freelist;
00513         settings_freelist = v;
00514 
00515             v = n;
00516         }
00517 }

Here is the call graph for this function:

void freetarget void *  xt,
void *  data
[static]
 

Definition at line 519 of file rules.c.

References _target::actions, _target::depends, freeactions(), freesettings(), freetargets(), _target::includes, _target::settings, and TARGET.

Referenced by donerules().

00520 {
00521     TARGET* t = (TARGET *)xt;
00522     if ( t->settings )
00523         freesettings( t->settings );
00524     if ( t->depends )
00525         freetargets( t->depends );
00526     if ( t->includes )
00527         freetarget( t->includes, (void*)0);
00528     if ( t->actions )
00529         freeactions( t->actions );
00530 }

Here is the call graph for this function:

void freetargets TARGETS chain  ) 
 

Definition at line 475 of file rules.c.

References hash::free, n, _targets::next, and TARGETS.

Referenced by freetarget().

00476 {
00477     while( chain )
00478     {
00479         TARGETS* n = chain->next;
00480         free( chain );
00481         chain = n;
00482     }
00483 }

RULE* global_rule RULE r  )  [static]
 

Definition at line 640 of file rules.c.

References define_rule(), freestr(), global_rule_name(), _rule::module, r, root_module(), and RULE.

Referenced by new_rule_actions().

00641 {
00642     if ( r->module == root_module() )
00643     {
00644         return r;
00645     }
00646     else
00647     {
00648         char* name = global_rule_name( r );
00649         RULE* result = define_rule( r->module, name, root_module() );
00650         freestr(name);
00651         return result;
00652     }
00653 }

Here is the call graph for this function:

char* global_rule_name RULE r  )  [static]
 

Definition at line 622 of file rules.c.

References _rule::module, module_t::name, _rule::name, newstr(), r, root_module(), and RULE.

Referenced by global_rule(), and new_rule_body().

00623 {
00624     if ( r->module == root_module() )
00625     {
00626         return r->name;
00627     }
00628     else
00629     {
00630         char name[4096] = "";
00631         strncat(name, r->module->name, sizeof(name) - 1);
00632         strncat(name, r->name, sizeof(name) - 1 );
00633         return newstr(name);
00634     }
00635 }

Here is the call graph for this function:

RULE* import_rule RULE source,
module_t m,
char *  name
 

Definition at line 778 of file rules.c.

References _rule::actions, _rule::arguments, define_rule(), m, _rule::module, _rule::procedure, RULE, set_rule_actions(), and set_rule_body().

Referenced by builtin_import(), duplicate_rule(), and import_base_rule().

00779 {
00780     RULE* dest = define_rule( source->module, name, m );
00781     set_rule_body( dest, source->arguments, source->procedure );
00782     set_rule_actions( dest, source->actions );
00783     return dest;
00784 }

Here is the call graph for this function:

RULE* lookup_rule char *  rulename,
module_t m,
int  local_only
 

Definition at line 713 of file rules.c.

References bindmodule(), module_t::class_module, hashcheck, HASHDATA, module_t::imported_modules, m, _rule::module, _rule::name, p, r, RULE, and module_t::rules.

Referenced by bindrule().

00714 {
00715     RULE rule, *r = &rule, *result = 0;
00716     module_t* original_module = m;
00717     r->name = rulename;
00718 
00719     if (m->class_module)
00720         m = m->class_module;
00721 
00722     if (m->rules && hashcheck( m->rules, (HASHDATA **)&r ) )
00723         result = r;
00724     else if (!local_only && m->imported_modules) {
00725         /* Try splitting the name into module and rule. */
00726         char *p = strchr(r->name, '.') ;
00727         if (p) {
00728             *p = '\0';
00729             /* Now, r->name keeps the module name, and p+1 keeps the rule name. */
00730             if (hashcheck( m->imported_modules, (HASHDATA **)&r))
00731             {
00732                 result = lookup_rule(p+1, bindmodule(rulename), 1);
00733             }
00734             *p = '.';
00735         }        
00736     }
00737 
00738     if (result)
00739     {
00740         if (local_only && !result->exported)
00741             result = 0;
00742         else
00743         {
00744             /* Lookup started in class module. We've found a rule in class module,
00745                which is marked for execution in that module, or in some instances.
00746                Mark it for execution in the instance where we've started lookup.
00747             */
00748             int execute_in_class = (result->module == m);
00749             int execute_in_some_instance = 
00750             (result->module->class_module && result->module->class_module == m);
00751             if (original_module != m && (execute_in_class || execute_in_some_instance))
00752                 result->module = original_module;            
00753         }
00754     }
00755 
00756     return result;
00757         
00758 }

Here is the call graph for this function:

RULE* new_rule_actions module_t m,
char *  rulename,
char *  command,
LIST bindlist,
int  flags
 

Definition at line 699 of file rules.c.

References _rule::actions, actions_new(), define_rule(), global_rule(), LIST, m, RULE, and set_rule_actions().

Referenced by compile_setexec().

00700 {
00701     RULE* local = define_rule( m, rulename, m );
00702     RULE* global = global_rule( local );
00703     set_rule_actions( local, actions_new( command, bindlist, flags ) );
00704     set_rule_actions( global, local->actions );
00705     return local;
00706 }

Here is the call graph for this function:

RULE* new_rule_body module_t m,
char *  rulename,
argument_list args,
PARSE procedure,
int  exported
 

Definition at line 661 of file rules.c.

References define_rule(), _rule::exported, global_rule_name(), m, PARSE, RULE, _PARSE::rulename, and set_rule_body().

Referenced by bind_builtin(), and compile_setcomp().

00662 {
00663     RULE* local = define_rule( m, rulename, m );
00664     local->exported = exported;
00665     set_rule_body( local, args, procedure );
00666     
00667     /* Mark the procedure with the global rule name, regardless of
00668      * whether the rule is exported. That gives us something
00669      * reasonably identifiable that we can use, e.g. in profiling
00670      * output. Only do this once, since this could be called multiple
00671      * times with the same procedure.
00672      */
00673     if ( procedure->rulename == 0 )
00674         procedure->rulename = global_rule_name( local );
00675 
00676     return local;
00677 }

Here is the call graph for this function:

void popsettings SETTINGS v  ) 
 

Definition at line 453 of file rules.c.

References pushsettings(), SETTINGS, and v.

Referenced by bind_explicitly_located_target(), compile_foreach(), compile_include(), compile_local(), compile_on(), evaluate_rule(), make0(), make1bind(), make1c(), make1cmds(), and swap_settings().

00454 {
00455         pushsettings( v );      /* just swap again */
00456 }

Here is the call graph for this function:

void pushsettings SETTINGS v  ) 
 

Definition at line 442 of file rules.c.

References _settings::next, SETTINGS, _settings::symbol, v, _settings::value, and var_swap().

Referenced by bind_explicitly_located_target(), compile_foreach(), compile_include(), compile_local(), compile_on(), evaluate_rule(), make0(), make1bind(), make1c(), make1cmds(), popsettings(), and swap_settings().

00443 {
00444         for( ; v; v = v->next )
00445             v->value = var_swap( v->symbol, v->value );
00446 }

Here is the call graph for this function:

void rule_free RULE r  ) 
 

Definition at line 112 of file rules.c.

References _rule::actions, actions_free(), args_free(), _rule::arguments, freestr(), _rule::name, parse_free(), _rule::procedure, r, and RULE.

Referenced by delete_rule_().

00113 {
00114     freestr( r->name );
00115     r->name = "";
00116     parse_free( r->procedure );
00117     r->procedure = 0;
00118         if ( r->arguments )
00119             args_free( r->arguments );
00120     r->arguments = 0;
00121     if ( r->actions )
00122                 actions_free( r->actions );
00123     r->actions = 0;
00124 }

Here is the call graph for this function:

TARGET* search_for_target char *  name,
LIST search_path
 

Definition at line 185 of file rules.c.

References _target::binding, bindtarget(), _target::boundname, call_bind_rule(), f(), _located_target::file_name, hashcheck, HASHDATA, hashinit(), LIST, list_next, LOCATED_TARGET, located_targets, _target::name, newstr(), path_build(), path_parse(), PATHNAME, _list::string, string_free(), string_new(), string_truncate(), T_BIND_EXISTS, TARGET, _target::time, timestamp(), and string::value.

Referenced by builtin_search_for_target().

00186 {
00187     PATHNAME f[1];
00188     string buf[1];
00189     LOCATED_TARGET lt, *lta = &lt;
00190     time_t time;
00191     int found = 0;
00192     TARGET* result;
00193 
00194     string_new( buf );
00195 
00196         path_parse( name, f );
00197 
00198     f->f_grist.ptr = 0;
00199     f->f_grist.len = 0;
00200 
00201     while( search_path )
00202     {
00203         f->f_root.ptr = search_path->string;
00204         f->f_root.len = strlen( search_path->string );
00205 
00206         string_truncate( buf, 0 );
00207         path_build( f, buf, 1 );
00208 
00209         lt.file_name = buf->value ;
00210 
00211         if (! located_targets )
00212             located_targets = hashinit( sizeof(LOCATED_TARGET),
00213                                         "located targets" );
00214 
00215 
00216         if ( hashcheck( located_targets, (HASHDATA **)&lta ) )
00217         {
00218             return lta->target;
00219         }
00220 
00221         timestamp( buf->value, &time );
00222         if (time)
00223         {
00224             found = 1;
00225             break;
00226         }
00227 
00228         search_path = list_next( search_path );
00229     }
00230 
00231     if ( ! found )
00232     {
00233         f->f_root.ptr = 0;
00234         f->f_root.len = 0;
00235 
00236         string_truncate( buf, 0 );
00237         path_build( f, buf, 1 );
00238 
00239         timestamp( buf->value, &time );        
00240     }
00241 
00242     result = bindtarget( name );
00243     result->boundname = newstr( buf->value );
00244     result->time = time;
00245     result->binding = time ? T_BIND_EXISTS : T_BIND_MISSING;
00246 
00247     call_bind_rule( result->name, result->boundname );
00248     
00249     string_free( buf );
00250 
00251     return result;
00252 
00253 }

Here is the call graph for this function:

void set_rule_actions RULE rule,
rule_actions actions
[static]
 

Definition at line 679 of file rules.c.

References _rule::actions, actions_free(), actions_refer(), and RULE.

Referenced by define_rule(), import_rule(), and new_rule_actions().

00680 {
00681     if ( actions )
00682         actions_refer( actions );
00683     if ( rule->actions )
00684         actions_free( rule->actions );
00685     rule->actions = actions;
00686     
00687 }

Here is the call graph for this function:

void set_rule_body RULE rule,
argument_list args,
PARSE procedure
[static]
 

Definition at line 604 of file rules.c.

References args_free(), args_refer(), _rule::arguments, PARSE, parse_free(), parse_refer(), _rule::procedure, and RULE.

Referenced by define_rule(), import_rule(), and new_rule_body().

00605 {
00606     if ( args )
00607         args_refer( args );
00608     if ( rule->arguments )
00609         args_free( rule->arguments );
00610     rule->arguments = args;
00611     
00612     if ( procedure )
00613         parse_refer( procedure );
00614     if ( rule->procedure )
00615         parse_free( rule->procedure );
00616     rule->procedure = procedure;
00617 }

Here is the call graph for this function:

TARGETS* targetchain TARGETS chain,
TARGETS targets
 

Definition at line 340 of file rules.c.

References _targets::next, _targets::tail, and TARGETS.

Referenced by make0(), and make1a().

00343 {
00344         TARGETS *c;
00345 
00346         if( !targets )
00347             return chain;
00348         else if( !chain )
00349             return targets;
00350 
00351         chain->tail->next = targets;
00352         chain->tail = targets->tail;
00353 
00354         return chain;
00355 }

TARGETS* targetentry TARGETS chain,
TARGET target
 

Definition at line 314 of file rules.c.

References c, _targets::next, _targets::tail, TARGET, _targets::target, and TARGETS.

Referenced by make0(), make1a(), make1b(), make1c(), and targetlist().

00317 {
00318         TARGETS *c;
00319 
00320         c = (TARGETS *)malloc( sizeof( TARGETS ) );
00321         c->target = target;
00322 
00323         if( !chain ) chain = c;
00324         else chain->tail->next = c;
00325         chain->tail = c;
00326         c->next = 0;
00327 
00328         return chain;
00329 }

TARGETS* targetlist TARGETS chain,
LIST targets
 

Definition at line 295 of file rules.c.

References bindtarget(), LIST, list_next, _list::string, targetentry(), and TARGETS.

Referenced by builtin_depends(), evaluate_rule(), and make0().

00298 {
00299         for( ; targets; targets = list_next( targets ) )
00300             chain = targetentry( chain, bindtarget( targets->string ) );
00301 
00302         return chain;
00303 }

Here is the call graph for this function:

void touchtarget char *  t  ) 
 

Definition at line 281 of file rules.c.

References bindtarget(), and _target::flags.

Referenced by main().

00282 {
00283         bindtarget( t )->flags |= T_FLAG_TOUCHED;
00284 }

Here is the call graph for this function:


Variable Documentation

struct hash* located_targets = 0 [static]
 

Definition at line 62 of file rules.c.

Referenced by search_for_target().

SETTINGS* settings_freelist [static]
 

Definition at line 378 of file rules.c.

Referenced by addsettings(), donerules(), and freesettings().

struct hash* targethash = 0 [static]
 

Definition at line 54 of file rules.c.

Referenced by bind_explicitly_located_targets(), bindtarget(), and donerules().


Generated on Mon Nov 8 17:08:23 2004 for MPT by  doxygen 1.3.9.1