Beispiel #1
0
ll_define_primitive_end


/*
** Compile into code to generate a value for an exports vector.
*/
ll_define_primitive(pair, _ir_compile2_export, _2(self, ir), _0())
{
  ll_v x = ll_SELF;
  ll_v var = ll_car(x);
  ll_v type = var_type(x);
  ll_v index = var_index(x);

  ll_assert_ref(IR);

  /* slot ref */
  if ( ll_EQ(type, ll_s(slot)) ) {
    /* Create a const containing the global var name */
    index = ll_call(ll_o(_ir_const_index), _2(IR, var));
  } else
  if ( ll_EQ(type, ll_s(glo)) ) {
    ll_abort("<pair>:%ir-compile2-export");
  }

  /* undef export is a local from a car-pos sub lambda */
  if ( ll_EQ(type, ll_undef) ) {
    ll_call_tail(ll_o(_ir_compile2), _3(ll_undef, IR, ll_f));
  } else {
    ll_v emit_type = type;

    /* env_loc is an environment slot containing a locative */
    if ( ll_EQ(type, ll_s(env_loc)) ) {
      emit_type = ll_s(env);
    }

    if ( ll_unbox_boolean(index) ) {
      ll_call(ll_o(_ir_emit_with_int), _3(IR, emit_type, index));
    } else {
      ll_call(ll_o(_ir_emit), _2(IR, emit_type));
    }

    /*
    ** arg and local values are stored directly into the exports vector.
    ** so put the value, not a locative to the arg or local in the exports vector.
    */
    if ( ll_EQ(type, ll_s(arg)) 
	 || ll_EQ(type, ll_s(local)) 
	 || ll_EQ(type, ll_s(env_loc))
      ) {
      ll_call_tail(ll_o(_ir_emit), _2(IR, ll_s(contents)));
    }
  }
}
Beispiel #2
0
/*
** Compiles a symbol into an instruction that generates a get,
** locative, or set operation.
** to the variable.
*/
ll_define_primitive(symbol, _ir_compile2_gen, _4(self, ir, tail_posQ, mode), _0())
{
  ll_v x = ll_call(ll_o(_ir_var_scope), _2(IR, SELF));
  ll_v mode = ll_ARG_3;
  ll_v var = SELF;
  ll_v type = var_type(x);
  ll_v index = var_index(x);
  ll_v co = var_closed_overQ(x);
  ll_v isn = ll_nil;

  _ll_gdb_stop_at();

  if ( ll_DEBUG(compile_emit) ) {
    ll_format(ll_undef, "  ~O: compile2-gen: ~S ~S\n", 3, IR, mode, x);
  }

  ll_assert_ref(IR);

  /* If it's closed over and environment has been exported.
   *
   * The environment has not been exported until 
   * the rest args creation
   * and other preambles have been emited.
   */
  if ( ll_unbox_boolean(co) 
       && ! in_preamble 
       /* && ll_unbox_boolean(ll_THIS_ISA(_ir, IR)->_env_exportedQ) */
       ) {
    /* Get the locative to the exports[slots] value */
    ll_call(ll_o(_ir_emit_with_int), _3(IR, ll_s(export), co));

    /*
    ** If the closed-over variable is an argument or a local
    ** the value is stored directly in the exported environment
    ** vector.
    **
    ** Otherwise the environment slot contains a locative
    ** to the actual value, probably an object slot.
    */
    if ( ! (ll_EQ(type, ll_s(arg)) || ll_EQ(type, ll_s(local))) ) {
      ll_call(ll_o(_ir_emit), _2(IR, ll_s(contents)));
    }
  }
Beispiel #3
0
Uint CField::var_index ( const std::string& vname ) const
{
  const Uint var_nb = var_number(vname);
  return var_index(var_nb);
}
//===================================================================
void CLitPoolElement::dump(ostream & os)
{
    os << (var_sign()?" -":" +") << var_index();
    if (is_watched())
        os << "*";
}