+ panic("Initial exec has no follow block in %+F", irg);
+}
+
+/**
+ * Update the entity of Sels to the outer value parameters.
+ */
+static void update_outer_frame_sels(ir_node *irn, void *env)
+{
+ lower_frame_sels_env_t *ctx = env;
+ ir_node *ptr;
+ ir_entity *ent;
+ int pos = 0;
+
+ if (! is_Sel(irn))
+ return;
+ ptr = get_Sel_ptr(irn);
+ if (! is_arg_Proj(ptr))
+ return;
+ if (get_Proj_proj(ptr) != ctx->static_link_pos)
+ return;
+ ent = get_Sel_entity(irn);
+
+ if (get_entity_owner(ent) == ctx->value_tp) {
+ /* replace by its copy from the argument type */
+ pos = get_struct_member_index(ctx->value_tp, ent);
+ ent = get_argument_entity(ent, ctx);
+ set_Sel_entity(irn, ent);
+
+ /* check, if we have not seen this entity before */
+ if (get_entity_link(ent) == NULL) {
+ ent_pos_pair pair;
+
+ pair.ent = ent;
+ pair.pos = pos;
+ pair.next = NULL;
+ ARR_APP1(ent_pos_pair, ctx->value_param_list, pair);
+ /* just a mark */
+ set_entity_link(ent, ctx->value_param_list);
+ }
+ }
+}
+
+/**
+ * Fix access to outer local variables.
+ */
+static void fix_outer_variable_access(be_abi_irg_t *env,
+ lower_frame_sels_env_t *ctx)
+{
+ int i;
+ ir_graph *irg;
+ (void) env;
+
+ for (i = get_class_n_members(ctx->frame_tp) - 1; i >= 0; --i) {
+ ir_entity *ent = get_class_member(ctx->frame_tp, i);
+
+ if (! is_method_entity(ent))
+ continue;
+
+ irg = get_entity_irg(ent);
+ if (irg == NULL)
+ continue;
+
+ /*
+ * FIXME: find the number of the static link parameter
+ * for now we assume 0 here
+ */
+ ctx->static_link_pos = 0;
+
+ irg_walk_graph(irg, NULL, update_outer_frame_sels, ctx);
+ }