RULE* import_rule( RULE* source, module_t* m, char* name ) { RULE* dest = define_rule( source->module, name, m ); set_rule_body( dest, source->arguments, source->procedure ); set_rule_actions( dest, source->actions ); return dest; }
/* * define_rule() - return pointer to RULE, creating it if necessary in * target_module. Prepare it to accept a body or action originating in * src_module. */ static RULE * define_rule( module_t *src_module, char *rulename, module_t *target_module ) { RULE *r = enter_rule( rulename, target_module ); if ( r->module != src_module ) /* if the rule was imported from elsewhere, clear it now */ { set_rule_body( r, 0, 0 ); set_rule_actions( r, 0 ); r->module = src_module; /* r will be executed in the source module */ } return r; }
/* * new_rule_body() - make a new rule named rulename in the given * module, with the given argument list and procedure. If exported is * true, the rule is exported to the global module as * modulename.rulename. */ RULE* new_rule_body( module* m, char* rulename, argument_list* args, PARSE* procedure, int exported ) { RULE* local = define_rule( m, rulename, m ); local->exported = exported; set_rule_body( local, args, procedure ); /* Mark the procedure with the global rule name, regardless of * whether the rule is exported. That gives us something * reasonably identifiable that we 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 ); /* export the rule to the global module if neccessary */ if ( exported ) { RULE* global = global_rule( local ); set_rule_body( global, args, procedure ); } return local; }
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; set_rule_body( local, args, procedure ); /* Mark the procedure with the global rule name, regardless of whether the * rule is exported. That gives us something reasonably identifiable that we * can use, e.g. in profiling output. Only do this once, since this could be * called multiple times with the same procedure. */ if ( function_rulename( procedure ) == 0 ) function_set_rulename( procedure, global_rule_name( local ) ); return local; }