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

compile.h File Reference

#include "frames.h"
#include "parse.h"
#include "regexp.h"

Include dependency graph for compile.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Defines

#define ASSIGN_APPEND   0x01
#define ASSIGN_DEFAULT   0x02
#define ASSIGN_SET   0x00
#define EXEC_EXISTING   0x20
#define EXEC_IGNORE   0x04
#define EXEC_PIECEMEAL   0x10
#define EXEC_QUIETLY   0x08
#define EXEC_TOGETHER   0x02
#define EXEC_UPDATED   0x01
#define EXPR_AND   1
#define EXPR_EQUALS   4
#define EXPR_EXISTS   3
#define EXPR_IN   10
#define EXPR_LESS   6
#define EXPR_LESSEQ   7
#define EXPR_MORE   8
#define EXPR_MOREEQ   9
#define EXPR_NOT   0
#define EXPR_NOTEQ   5
#define EXPR_OR   2

Functions

LISTcompile_append (PARSE *parse, FRAME *frame)
void compile_builtins ()
LISTcompile_class (PARSE *parse, FRAME *frame)
LISTcompile_eval (PARSE *parse, FRAME *args)
LISTcompile_foreach (PARSE *parse, FRAME *frame)
LISTcompile_if (PARSE *parse, FRAME *frame)
LISTcompile_include (PARSE *parse, FRAME *frame)
LISTcompile_list (PARSE *parse, FRAME *frame)
 Todo: check for empty class name.
LISTcompile_local (PARSE *parse, FRAME *frame)
LISTcompile_module (PARSE *parse, FRAME *frame)
LISTcompile_null (PARSE *parse, FRAME *frame)
LISTcompile_on (PARSE *parse, FRAME *frame)
LISTcompile_rule (PARSE *parse, FRAME *frame)
LISTcompile_rules (PARSE *parse, FRAME *frame)
LISTcompile_set (PARSE *parse, FRAME *frame)
LISTcompile_setcomp (PARSE *parse, FRAME *frame)
LISTcompile_setexec (PARSE *parse, FRAME *frame)
LISTcompile_settings (PARSE *parse, FRAME *frame)
LISTcompile_switch (PARSE *parse, FRAME *frame)
LISTcompile_while (PARSE *parse, FRAME *frame)
LISTevaluate_rule (char *rulename, FRAME *frame)
void profile_dump ()
regexpregex_compile (const char *pattern)


Define Documentation

#define ASSIGN_APPEND   0x01
 

Definition at line 57 of file compile.h.

Referenced by compile_set().

#define ASSIGN_DEFAULT   0x02
 

Definition at line 58 of file compile.h.

Referenced by compile_set().

#define ASSIGN_SET   0x00
 

Definition at line 56 of file compile.h.

Referenced by compile_set().

#define EXEC_EXISTING   0x20
 

Definition at line 67 of file compile.h.

#define EXEC_IGNORE   0x04
 

Definition at line 64 of file compile.h.

#define EXEC_PIECEMEAL   0x10
 

Definition at line 66 of file compile.h.

#define EXEC_QUIETLY   0x08
 

Definition at line 65 of file compile.h.

#define EXEC_TOGETHER   0x02
 

Definition at line 63 of file compile.h.

#define EXEC_UPDATED   0x01
 

Definition at line 62 of file compile.h.

#define EXPR_AND   1
 

Definition at line 72 of file compile.h.

Referenced by compile_eval(), and yyparse().

#define EXPR_EQUALS   4
 

Definition at line 76 of file compile.h.

Referenced by compile_eval(), and yyparse().

#define EXPR_EXISTS   3
 

Definition at line 75 of file compile.h.

Referenced by compile_eval(), and yyparse().

#define EXPR_IN   10
 

Definition at line 82 of file compile.h.

Referenced by compile_eval(), and yyparse().

#define EXPR_LESS   6
 

Definition at line 78 of file compile.h.

Referenced by compile_eval(), and yyparse().

#define EXPR_LESSEQ   7
 

Definition at line 79 of file compile.h.

Referenced by compile_eval(), and yyparse().

#define EXPR_MORE   8
 

Definition at line 80 of file compile.h.

Referenced by compile_eval(), and yyparse().

#define EXPR_MOREEQ   9
 

Definition at line 81 of file compile.h.

Referenced by compile_eval(), and yyparse().

#define EXPR_NOT   0
 

Definition at line 71 of file compile.h.

Referenced by compile_eval(), and yyparse().

#define EXPR_NOTEQ   5
 

Definition at line 77 of file compile.h.

Referenced by compile_eval(), and yyparse().

#define EXPR_OR   2
 

Definition at line 73 of file compile.h.

Referenced by compile_eval(), and yyparse().


Function Documentation

LIST* compile_append PARSE parse,
FRAME frame
 

Definition at line 121 of file compile.c.

References FRAME, _PARSE::left, list_append(), PARSE, parse_evaluate(), and _PARSE::right.

00124 {
00125     /* Append right to left. */
00126 
00127     return list_append( 
00128         parse_evaluate( parse->left, frame ),
00129         parse_evaluate( parse->right, frame ) );
00130 }

Here is the call graph for this function:

void compile_builtins  ) 
 

LIST* compile_class PARSE parse,
FRAME frame
 

Definition at line 427 of file compile.c.

References evaluate_in_module(), FRAME, _PARSE::left, LIST, make_class_module(), p, PARSE, parse_evaluate(), and _PARSE::right.

00430 {
00434     char* class_module = 0;
00435 
00436     LIST* name = parse_evaluate( p->left->right, frame );
00437     LIST* bases = 0;
00438 
00439     if (p->left->left)
00440         bases = parse_evaluate( p->left->left->right, frame );
00441 
00442     class_module = make_class_module(name, bases, frame);    
00443     evaluate_in_module( class_module, p->right, frame );
00444 
00445     return L0;    
00446 }

Here is the call graph for this function:

LIST* compile_eval PARSE parse,
FRAME args
 

Definition at line 160 of file compile.c.

References debug_compile(), eval(), EXPR_AND, EXPR_EQUALS, EXPR_EXISTS, EXPR_IN, EXPR_LESS, EXPR_LESSEQ, EXPR_MORE, EXPR_MOREEQ, EXPR_NOT, EXPR_NOTEQ, EXPR_OR, FRAME, L0, lcmp(), _PARSE::left, LIST, list_free(), list_new(), list_next, list_print(), newstr(), _PARSE::num, PARSE, parse_evaluate(), _PARSE::right, s, and _list::string.

00163 {
00164         LIST *ll, *lr, *s, *t;
00165         int status = 0;
00166 
00167         /* Short circuit lr eval for &&, ||, and 'in' */
00168 
00169         ll = parse_evaluate( parse->left, frame );
00170         lr = 0;
00171 
00172         switch( parse->num )
00173         {
00174         case EXPR_AND: 
00175         case EXPR_IN:   if( ll ) goto eval; break;
00176         case EXPR_OR:   if( !ll ) goto eval; break;
00177         default: eval:  lr = parse_evaluate( parse->right, frame );
00178         }
00179 
00180         /* Now eval */
00181 
00182         switch( parse->num )
00183         {
00184         case EXPR_NOT:  
00185                 if( !ll ) status = 1;
00186                 break;
00187 
00188         case EXPR_AND:
00189                 if( ll && lr ) status = 1;
00190                 break;
00191 
00192         case EXPR_OR:
00193                 if( ll || lr ) status = 1;
00194                 break;
00195 
00196         case EXPR_IN:
00197                 /* "a in b": make sure each of */
00198                 /* ll is equal to something in lr. */
00199 
00200                 for( t = ll; t; t = list_next( t ) )
00201                 {
00202                     for( s = lr; s; s = list_next( s ) )
00203                         if( !strcmp( t->string, s->string ) )
00204                             break;
00205                     if( !s ) break;
00206                 }
00207 
00208                 /* No more ll? Success */
00209 
00210                 if( !t ) status = 1;
00211 
00212                 break;
00213 
00214         case EXPR_EXISTS:       if( lcmp( ll, L0 ) != 0 ) status = 1; break;
00215         case EXPR_EQUALS:       if( lcmp( ll, lr ) == 0 ) status = 1; break;
00216         case EXPR_NOTEQ:        if( lcmp( ll, lr ) != 0 ) status = 1; break;
00217         case EXPR_LESS:         if( lcmp( ll, lr ) < 0  ) status = 1; break;
00218         case EXPR_LESSEQ:       if( lcmp( ll, lr ) <= 0 ) status = 1; break;
00219         case EXPR_MORE:         if( lcmp( ll, lr ) > 0  ) status = 1; break;
00220         case EXPR_MOREEQ:       if( lcmp( ll, lr ) >= 0 ) status = 1; break;
00221 
00222         }
00223 
00224         if( DEBUG_IF )
00225         {
00226             debug_compile( 0, "if", frame );
00227             list_print( ll );
00228             printf( "(%d) ", status );
00229             list_print( lr );
00230             printf( "\n" );
00231         }
00232 
00233         /* Find something to return. */
00234         /* In odd circumstances (like "" = "") */
00235         /* we'll have to return a new string. */
00236 
00237         if( !status ) t = 0;
00238         else if( ll ) t = ll, ll = 0;
00239         else if( lr ) t = lr, lr = 0;
00240         else t = list_new( L0, newstr( "1" ) );
00241 
00242         if( ll ) list_free( ll );
00243         if( lr ) list_free( lr );
00244         return t;
00245 }

Here is the call graph for this function:

LIST* compile_foreach PARSE parse,
FRAME frame
 

Definition at line 260 of file compile.c.

References addsettings(), copystr(), FRAME, freesettings(), L0, _PARSE::left, LIST, list_free(), list_new(), list_next, _PARSE::num, PARSE, parse_evaluate(), popsettings(), pushsettings(), _PARSE::right, s, SETTINGS, _list::string, _PARSE::string, VAR_SET, and var_set().

00263 {
00264     LIST    *nv = parse_evaluate( parse->left, frame );
00265     LIST    *l;
00266     SETTINGS *s = 0;
00267         
00268         if ( parse->num )
00269         {
00270             s = addsettings( s, 0, parse->string, L0 );
00271             pushsettings( s );
00272         }
00273 
00274     /* Call var_set to reset $(parse->string) for each val. */
00275 
00276     for( l = nv; l; l = list_next( l ) )
00277     {
00278         LIST *val = list_new( L0, copystr( l->string ) );
00279 
00280         var_set( parse->string, val, VAR_SET );
00281 
00282         list_free( parse_evaluate( parse->right, frame ) );
00283     }
00284 
00285         if ( parse->num )
00286         {
00287             popsettings( s );
00288             freesettings( s );
00289         }
00290 
00291     list_free( nv );
00292 
00293     return L0;
00294 }

Here is the call graph for this function:

LIST* compile_if PARSE parse,
FRAME frame
 

Definition at line 305 of file compile.c.

References FRAME, _PARSE::left, LIST, list_free(), p, PARSE, parse_evaluate(), _PARSE::right, and _PARSE::third.

00308 {
00309     LIST *l = parse_evaluate( p->left, frame );
00310     if( l )
00311     {
00312         list_free( l );
00313         return parse_evaluate( p->right, frame );
00314     }
00315     else
00316     {
00317         return parse_evaluate( p->third, frame );
00318     }
00319 }

Here is the call graph for this function:

LIST* compile_include PARSE parse,
FRAME frame
 

Definition at line 345 of file compile.c.

References bindtarget(), _target::boundname, debug_compile(), FRAME, _PARSE::left, LIST, list_free(), list_print(), _target::name, PARSE, parse_evaluate(), parse_file(), popsettings(), pushsettings(), search(), _target::settings, _list::string, TARGET, and _target::time.

00348 {
00349     LIST    *nt = parse_evaluate( parse->left, frame );
00350 
00351     if( DEBUG_COMPILE )
00352     {
00353         debug_compile( 0, "include", frame);
00354         list_print( nt );
00355         printf( "\n" );
00356     }
00357 
00358     if( nt )
00359     {
00360         TARGET *t = bindtarget( nt->string );
00361 
00362             /* DWA 2001/10/22 - Perforce Jam clears the arguments here, which
00363              * prevents an included file from being treated as part of the body
00364              * of a rule. I didn't see any reason to do that, so I lifted the
00365              * restriction.
00366              */
00367                
00368         /* Bind the include file under the influence of */
00369         /* "on-target" variables.  Though they are targets, */
00370         /* include files are not built with make(). */
00371 
00372         pushsettings( t->settings );
00373         /* We don't expect that file to be included is generated by some
00374            action. Therefore, pass 0 as third argument. */
00375         t->boundname = search( t->name, &t->time, 0 );
00376         popsettings( t->settings );
00377 
00378         parse_file( t->boundname, frame );
00379     }
00380 
00381     list_free( nt );
00382 
00383     return L0;
00384 }

Here is the call graph for this function:

LIST* compile_list PARSE parse,
FRAME frame
 

Todo: check for empty class name.

Definition at line 456 of file compile.c.

References frame::args, FRAME, L0, PARSE, s, _PARSE::string, and var_expand().

00459 {
00460     /* voodoo 1 means: s is a copyable string */
00461     char *s = parse->string;
00462     return var_expand( L0, s, s + strlen( s ), frame->args, 1 );
00463 }

Here is the call graph for this function:

LIST* compile_local PARSE parse,
FRAME frame
 

Definition at line 474 of file compile.c.

References addsettings(), debug_compile(), FRAME, freesettings(), _PARSE::left, LIST, list_copy(), list_free(), list_next, list_print(), PARSE, parse_evaluate(), popsettings(), pushsettings(), _PARSE::right, s, SETTINGS, _list::string, and _PARSE::third.

00477 {
00478     LIST *l;
00479     SETTINGS *s = 0;
00480     LIST    *nt = parse_evaluate( parse->left, frame );
00481     LIST    *ns = parse_evaluate( parse->right, frame );
00482     LIST    *result;
00483 
00484     if( DEBUG_COMPILE )
00485     {
00486         debug_compile( 0, "local", frame);
00487         list_print( nt );
00488         printf( " = " );
00489         list_print( ns );
00490         printf( "\n" );
00491     }
00492 
00493     /* Initial value is ns */
00494 
00495     for( l = nt; l; l = list_next( l ) )
00496         s = addsettings( s, 0, l->string, list_copy( (LIST*)0, ns ) );
00497 
00498     list_free( ns );
00499     list_free( nt );
00500 
00501     /* Note that callees of the current context get this "local" */
00502     /* variable, making it not so much local as layered. */
00503 
00504     pushsettings( s );
00505     result = parse_evaluate( parse->third, frame );
00506     popsettings( s );
00507 
00508     freesettings( s );
00509 
00510     return result;
00511 }

Here is the call graph for this function:

LIST* compile_module PARSE parse,
FRAME frame
 

Definition at line 412 of file compile.c.

References evaluate_in_module(), FRAME, _PARSE::left, LIST, list_free(), p, PARSE, parse_evaluate(), _PARSE::right, and _list::string.

00415 {
00416     /* Here we are entering a module declaration block. 
00417      */
00418     LIST* module_name = parse_evaluate( p->left, frame );
00419     LIST* result = evaluate_in_module( module_name ? module_name->string : 0, 
00420                                        p->right, frame );
00421     
00422     list_free( module_name );
00423     return result;
00424 }

Here is the call graph for this function:

LIST* compile_null PARSE parse,
FRAME frame
 

Definition at line 518 of file compile.c.

References FRAME, and PARSE.

00521 {
00522     return L0;
00523 }

LIST* compile_on PARSE parse,
FRAME frame
 

Definition at line 535 of file compile.c.

References bindtarget(), debug_compile(), FRAME, _PARSE::left, LIST, list_free(), list_print(), PARSE, parse_evaluate(), popsettings(), pushsettings(), _PARSE::right, _target::settings, _list::string, and TARGET.

00538 {
00539         LIST    *nt = parse_evaluate( parse->left, frame );
00540         LIST    *result = 0;
00541 
00542         if( DEBUG_COMPILE )
00543         {
00544             debug_compile( 0, "on", frame );
00545             list_print( nt );
00546             printf( "\n" );
00547         }
00548 
00549         if( nt )
00550         {
00551             TARGET *t = bindtarget( nt->string );
00552             pushsettings( t->settings );
00553 
00554             result = parse_evaluate( parse->right, frame );
00555 
00556             popsettings( t->settings );
00557         }
00558 
00559         list_free( nt );
00560 
00561         return result;
00562 }

Here is the call graph for this function:

LIST* compile_rule PARSE parse,
FRAME frame
 

Definition at line 575 of file compile.c.

References frame::args, evaluate_rule(), FRAME, frame_free(), frame_init(), _PARSE::left, LIST, lol_add(), frame::module, p, PARSE, parse_evaluate(), frame::prev, frame::procedure, _PARSE::right, and _PARSE::string.

00578 {
00579     FRAME       inner[1];
00580     LIST    *result;
00581     PARSE   *p;
00582     
00583 
00584     /* Build up the list of arg lists */
00585 
00586     frame_init( inner );
00587     inner->prev = frame;
00588     inner->module = frame->module; /* This gets fixed up in evaluate_rule(), below */
00589     inner->procedure = parse;
00590 
00591     for( p = parse->left; p; p = p->left )
00592         lol_add( inner->args, parse_evaluate( p->right, frame ) );
00593 
00594     /* And invoke rule */
00595 
00596     result = evaluate_rule( parse->string, inner );
00597 
00598     frame_free( inner );
00599 
00600     return result;
00601 }

Here is the call graph for this function:

LIST* compile_rules PARSE parse,
FRAME frame
 

Definition at line 1044 of file compile.c.

References FRAME, _PARSE::left, list_free(), PARSE, parse_evaluate(), and _PARSE::right.

01047 {
01048     /* Ignore result from first statement; return the 2nd. */
01049         /* Optimize recursion on the right by looping. */
01050 
01051     do list_free( parse_evaluate( parse->left, frame ) );
01052     while( (parse = parse->right)->func == compile_rules );
01053 
01054     return parse_evaluate( parse, frame );
01055 }

Here is the call graph for this function:

LIST* compile_set PARSE parse,
FRAME frame
 

Definition at line 1066 of file compile.c.

References ASSIGN_APPEND, ASSIGN_DEFAULT, ASSIGN_SET, debug_compile(), FRAME, L0, _PARSE::left, LIST, list_copy(), list_free(), list_next, list_print(), _PARSE::num, PARSE, parse_evaluate(), _PARSE::right, _list::string, and var_set().

01069 {
01070     LIST    *nt = parse_evaluate( parse->left, frame );
01071     LIST    *ns = parse_evaluate( parse->right, frame );
01072     LIST    *l;
01073     int     setflag;
01074     char    *trace;
01075 
01076     switch( parse->num )
01077     {
01078     case ASSIGN_SET:    setflag = VAR_SET; trace = "="; break;
01079     case ASSIGN_APPEND: setflag = VAR_APPEND; trace = "+="; break;
01080     case ASSIGN_DEFAULT:    setflag = VAR_DEFAULT; trace = "?="; break;
01081     default:        setflag = VAR_SET; trace = ""; break;
01082     }
01083 
01084     if( DEBUG_COMPILE )
01085     {
01086         debug_compile( 0, "set", frame);
01087         list_print( nt );
01088         printf( " %s ", trace );
01089         list_print( ns );
01090         printf( "\n" );
01091     }
01092 
01093     /* Call var_set to set variable */
01094     /* var_set keeps ns, so need to copy it */
01095 
01096     for( l = nt; l; l = list_next( l ) )
01097         var_set( l->string, list_copy( L0, ns ), setflag );
01098 
01099     list_free( nt );
01100 
01101     return ns;
01102 }

Here is the call graph for this function:

LIST* compile_setcomp PARSE parse,
FRAME frame
 

Definition at line 1113 of file compile.c.

References args_new(), argument_list::data, FRAME, _PARSE::left, lol_add(), frame::module, new_rule_body(), _PARSE::num, p, PARSE, parse_evaluate(), _PARSE::right, and _PARSE::string.

01116 {
01117     argument_list* arg_list = 0;
01118     
01119     /* Create new LOL describing argument requirements if supplied */
01120     if ( parse->right )
01121     {
01122         PARSE *p;
01123         arg_list = args_new();
01124         for( p = parse->right; p; p = p->left )
01125             lol_add( arg_list->data, parse_evaluate( p->right, frame ) );
01126     }
01127     
01128     new_rule_body( frame->module, parse->string, arg_list, parse->left, !parse->num );
01129     return L0;
01130 }

Here is the call graph for this function:

LIST* compile_setexec PARSE parse,
FRAME frame
 

Definition at line 1145 of file compile.c.

References FRAME, _PARSE::left, LIST, frame::module, new_rule_actions(), _PARSE::num, PARSE, parse_evaluate(), _PARSE::string, and _PARSE::string1.

01148 {
01149     LIST* bindlist = parse_evaluate( parse->left, frame );
01150 
01151     new_rule_actions( frame->module, parse->string, parse->string1, bindlist, parse->num );
01152 
01153     return L0;
01154 }

Here is the call graph for this function:

LIST* compile_settings PARSE parse,
FRAME frame
 

Definition at line 1166 of file compile.c.

References addsettings(), bindtarget(), debug_compile(), FRAME, _PARSE::left, LIST, list_copy(), list_free(), list_next, list_print(), _PARSE::num, PARSE, parse_evaluate(), _PARSE::right, _target::settings, _list::string, TARGET, and _PARSE::third.

01169 {
01170     LIST    *nt = parse_evaluate( parse->left, frame );
01171     LIST    *ns = parse_evaluate( parse->third, frame );
01172     LIST    *targets = parse_evaluate( parse->right, frame );
01173     LIST    *ts;
01174     int append = parse->num == ASSIGN_APPEND;
01175 
01176     if( DEBUG_COMPILE )
01177     {
01178         debug_compile( 0, "set", frame);
01179         list_print( nt );
01180         printf( " on " );
01181         list_print( targets );
01182         printf( " %s ", append ? "+=" : "=" );
01183         list_print( ns );
01184         printf( "\n" );
01185     }
01186 
01187     /* Call addsettings to save variable setting */
01188     /* addsettings keeps ns, so need to copy it */
01189     /* Pass append flag to addsettings() */
01190 
01191     for( ts = targets; ts; ts = list_next( ts ) )
01192     {
01193         TARGET  *t = bindtarget( ts->string );
01194         LIST    *l;
01195 
01196         for( l = nt; l; l = list_next( l ) )
01197         t->settings = addsettings( t->settings, append, 
01198                 l->string, list_copy( (LIST*)0, ns ) );
01199     }
01200 
01201     list_free( nt );
01202     list_free( targets );
01203 
01204     return ns;
01205 }

Here is the call graph for this function:

LIST* compile_switch PARSE parse,
FRAME frame
 

Definition at line 1221 of file compile.c.

References debug_compile(), FRAME, glob(), _PARSE::left, LIST, list_free(), list_print(), PARSE, parse_evaluate(), _PARSE::right, _list::string, and _PARSE::string.

01224 {
01225     LIST    *nt = parse_evaluate( parse->left, frame );
01226     LIST    *result = 0;
01227 
01228     if( DEBUG_COMPILE )
01229     {
01230         debug_compile( 0, "switch", frame);
01231         list_print( nt );
01232         printf( "\n" );
01233     }
01234 
01235     /* Step through cases */
01236 
01237     for( parse = parse->right; parse; parse = parse->right )
01238     {
01239         if( !glob( parse->left->string, nt ? nt->string : "" ) )
01240         {
01241         /* Get & exec parse tree for this case */
01242         parse = parse->left->left;
01243         result = parse_evaluate( parse, frame );
01244         break;
01245         }
01246     }
01247 
01248     list_free( nt );
01249 
01250     return result;
01251 }

Here is the call graph for this function:

LIST* compile_while PARSE parse,
FRAME frame
 

Definition at line 322 of file compile.c.

References FRAME, _PARSE::left, LIST, list_free(), p, PARSE, parse_evaluate(), r, and _PARSE::right.

00325 {
00326     LIST *r = 0;
00327     LIST *l;
00328     while ( l = parse_evaluate( p->left, frame ) )
00329     {
00330         list_free( l );
00331         if( r ) list_free( r );
00332         r = parse_evaluate( p->right, frame );
00333     }
00334     return r;
00335 }

Here is the call graph for this function:

LIST* evaluate_rule char *  rulename,
FRAME frame
 

Definition at line 895 of file compile.c.

References ACTION, actionlist(), _target::actions, _rule::actions, frame::args, backtrace(), backtrace_line(), bindrule(), collect_arguments(), debug_compile(), DEBUG_PROFILE, enter_module(), exit_module(), FRAME, freesettings(), L0, _lol::list, LIST, list_append(), list_pop_front(), LOL, lol_get(), lol_init(), lol_print(), _rule::module, frame::module, _rule::name, module_t::name, _targets::next, PARSE, parse_evaluate(), parse_free(), parse_refer(), popsettings(), frame::prev, _rule::procedure, profile_enter(), profile_exit(), profile_frame, pushsettings(), _action::rule, RULE, frame::rulename, _PARSE::rulename, SETTINGS, _list::string, _targets::target, targetlist(), TARGETS, and var_expand().

Referenced by call_bind_rule(), compile_rule(), headers(), and type_check().

00898 {
00899     LIST      *result = L0;
00900     RULE          *rule;
00901     profile_frame prof[1];
00902     module_t    *prev_module = frame->module;
00903     
00904     LIST      *l;
00905     {
00906         LOL arg_context_, *arg_context = &arg_context_;
00907         if ( !frame->prev )
00908             lol_init(arg_context);
00909         else
00910             arg_context = frame->prev->args;
00911         
00912         l = var_expand( L0, rulename, rulename+strlen(rulename), arg_context, 0 );
00913     }
00914 
00915     if ( !l )
00916     {
00917         backtrace_line( frame->prev );
00918         printf( "warning: rulename %s expands to empty string\n", rulename );
00919         backtrace( frame->prev );
00920         return result;
00921     }
00922 
00923     rulename = l->string;
00924     rule = bindrule( l->string, frame->module );
00925 
00926     /* drop the rule name */
00927     l = list_pop_front( l );
00928 
00929     /* tack the rest of the expansion onto the front of the first argument */
00930     frame->args->list[0] = list_append( l, lol_get( frame->args, 0 ) );
00931 
00932     if ( DEBUG_COMPILE )
00933     {
00934         /* Try hard to indicate in which module the rule is going to execute */
00935         if ( rule->module != frame->module
00936              && rule->procedure != 0 && strcmp(rulename, rule->procedure->rulename) )
00937         {
00938             char buf[256] = "";
00939             strncat( buf, rule->module->name, sizeof(buf) - 1 );
00940             strncat( buf, rule->name, sizeof(buf) - 1 );
00941             debug_compile( 1, buf, frame);
00942         }
00943         else
00944         {
00945             debug_compile( 1, rulename, frame);
00946         }
00947 
00948         lol_print( frame->args );
00949         printf( "\n" );
00950     }
00951     
00952     if ( rule->procedure && rule->module != prev_module )
00953     {
00954         /* propagate current module to nested rule invocations */
00955         frame->module = rule->module;
00956         
00957         /* swap variables */
00958         exit_module( prev_module );
00959         enter_module( rule->module );
00960     }
00961         
00962     /* record current rule name in frame */
00963     if ( rule->procedure )
00964     {
00965         frame->rulename = rulename;
00966         /* and enter record profile info */
00967         if ( DEBUG_PROFILE )
00968             profile_enter( rule->procedure->rulename, prof );
00969     }
00970 
00971     /* Check traditional targets $(<) and sources $(>) */
00972 
00973     if( !rule->actions && !rule->procedure )
00974     {
00975         backtrace_line( frame->prev );
00976         printf( "rule %s unknown in module %s\n", rule->name, frame->module->name );
00977         backtrace( frame->prev );
00978         exit(1);
00979     }
00980 
00981     /* If this rule will be executed for updating the targets */
00982     /* then construct the action for make(). */
00983 
00984     if( rule->actions )
00985     {
00986         TARGETS *t;
00987         ACTION  *action;
00988 
00989         /* The action is associated with this instance of this rule */
00990 
00991         action = (ACTION *)malloc( sizeof( ACTION ) );
00992         memset( (char *)action, '\0', sizeof( *action ) );
00993 
00994         action->rule = rule;
00995         action->targets = targetlist( (TARGETS *)0, lol_get( frame->args, 0 ) );
00996         action->sources = targetlist( (TARGETS *)0, lol_get( frame->args, 1 ) );
00997 
00998         /* Append this action to the actions of each target */
00999 
01000         for( t = action->targets; t; t = t->next )
01001             t->target->actions = actionlist( t->target->actions, action );
01002     }
01003 
01004     /* Now recursively compile any parse tree associated with this rule */
01005     /* refer/free to ensure rule not freed during use */
01006 
01007     if( rule->procedure )
01008     {
01009         SETTINGS *local_args = collect_arguments( rule, frame );
01010         PARSE *parse = rule->procedure;
01011         parse_refer( parse );
01012         
01013         pushsettings( local_args );
01014         result = parse_evaluate( parse, frame );
01015         popsettings( local_args );
01016         freesettings( local_args );
01017         
01018         parse_free( parse );
01019     }
01020 
01021     if ( frame->module != prev_module )
01022     {
01023         exit_module( frame->module );
01024         enter_module( prev_module );
01025     }
01026 
01027     if ( DEBUG_PROFILE && rule->procedure )
01028         profile_exit( prof );
01029 
01030     if( DEBUG_COMPILE )
01031         debug_compile( -1, 0, frame);
01032 
01033     return result;
01034 }

Here is the call graph for this function:

void profile_dump  ) 
 

Definition at line 881 of file compile.c.

References dump_profile_entry(), hashenumerate(), and profile_hash.

Referenced by main().

00882 {
00883     if ( profile_hash )
00884     {
00885         printf("%10s %10s %10s %s\n", "gross", "net", "# entries", "name");
00886         hashenumerate( profile_hash, dump_profile_entry, 0 );
00887     }
00888 }

Here is the call graph for this function:

regexp* regex_compile const char *  pattern  ) 
 

Definition at line 21 of file subst.c.

References HASHDATA, hashenter, hashinit(), regex_entry::pattern, regcomp(), regex_entry, and regex_hash.

Referenced by builtin_match(), builtin_subst(), headers(), headers1(), and macro_headers().

00022 {
00023     regex_entry entry, *e = &entry;
00024     entry.pattern = pattern;
00025     
00026     if ( !regex_hash )
00027         regex_hash = hashinit(sizeof(regex_entry), "regex");
00028         
00029     if ( hashenter( regex_hash, (HASHDATA **)&e ) )
00030         e->regex = regcomp( (char*)pattern );
00031     
00032     return e->regex;
00033 }

Here is the call graph for this function:


Generated on Mon Nov 8 17:07:58 2004 for MPT by  doxygen 1.3.9.1