To compile routines capable of being passed as arguments to the I6 library routine for looping over parser scope at run-time, and so to provide an implementation for conditions such as "in the presence of Mrs Dalloway".
typedef struct loop_over_scope { struct parse_node *what_to_find; struct inter_name *los_iname; CLASS_DEFINITION } loop_over_scope;
- The structure loop_over_scope is accessed in 4/ap and here.
loop_over_scope *PL::Actions::ScopeLoops::new(parse_node *what) { loop_over_scope *los = CREATE(loop_over_scope); los->what_to_find = Node::duplicate(what); if (Specifications::is_description(what)) { los->what_to_find->down = Node::duplicate(los->what_to_find->down); Descriptions::clear_calling(los->what_to_find); } package_request *PR = Hierarchy::local_package(LOOP_OVER_SCOPES_HAP); los->los_iname = Hierarchy::make_iname_in(LOOP_OVER_SCOPE_FN_HL, PR); return los; } loop_over_scope *latest_los = NULL; int PL::Actions::ScopeLoops::compilation_coroutine(void) { int N = 0; while (TRUE) { loop_over_scope *los; if (latest_los == NULL) los = FIRST_OBJECT(loop_over_scope); else los = NEXT_OBJECT(latest_los, loop_over_scope); if (los == NULL) break; latest_los = los; Compile an individual loop-over-scope2.1; N++; } return N; }
§2.1. Compile an individual loop-over-scope2.1 =
packaging_state save = Routines::begin(los->los_iname); ph_stack_frame *phsf = Frames::current_stack_frame(); local_variable *it_lv = LocalVariables::add_pronoun(phsf, EMPTY_WORDING, K_object); inter_symbol *it_s = LocalVariables::declare_this(it_lv, FALSE, 8); Produce::inv_primitive(Emit::tree(), IF_BIP); Produce::down(Emit::tree()); LocalVariables::begin_condition_emit(); value_holster VH = Holsters::new(INTER_VAL_VHMODE); if (los->what_to_find) { parse_node *lv_sp = Lvalues::new_LOCAL_VARIABLE(EMPTY_WORDING, it_lv); PL::Actions::Patterns::compile_pattern_match_clause_inner(FALSE, &VH, lv_sp, FALSE, los->what_to_find, K_object, FALSE); } else Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 0); LocalVariables::end_condition_emit(); Produce::code(Emit::tree()); Produce::down(Emit::tree()); Produce::inv_primitive(Emit::tree(), STORE_BIP); Produce::down(Emit::tree()); Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(LOS_RV_HL)); Produce::val_symbol(Emit::tree(), K_value, it_s); Produce::up(Emit::tree()); Produce::up(Emit::tree()); Produce::up(Emit::tree()); Routines::end(save);
- This code is used in §2.