Esempio n. 1
0
extern "C" closure builtin_function_reapply(OperationArgs& Args)
{
  int index1 = Args.reference(0).as_index_var();
  int R1 = Args.current_closure().lookup_in_env( index1 );

  int index2 = Args.reference(1).as_index_var();
  int R2 = Args.current_closure().lookup_in_env( index2 );

  expression_ref apply_E;
  {
    expression_ref fE = index_var(1);
    expression_ref argE = index_var(0);
    apply_E = (fE, argE);
  }

  // %1 %0 {R1,R2}
  int apply_reg = Args.allocate({apply_E,{R1, R2}});

  // FIXME - aren't we trying to eliminate general evaluation of regs that aren't children?  See below:

  // Evaluate the newly create application reg - and depend upon it!
  if (Args.evaluate_changeables())
    Args.evaluate_reg_to_object(apply_reg);

  return {index_var(0),{apply_reg}};
}
Esempio n. 2
0
extern "C" closure builtin_function_new_random_modifiable(OperationArgs& Args)
{
  //  assert(not Args.evaluate_changeables());

  reg_heap& M = Args.memory();

  int R1 = Args.reg_for_slot(0);

  int R2 = Args.reg_for_slot(1);

  int V = Args.reg_for_slot(2);

  int rate = Args.reg_for_slot(3);

  // Allocate a reg, and fill it with a modifiable of the correct index
  expression_ref E(new expression(modifiable(),{index_var(2),index_var(1),index_var(0)}));
  closure C{E,{R2,R1,rate}};
  int r = Args.allocate(std::move(C));
  M.make_reg_changeable(r);
  M.set_shared_value(r,V);

  M.add_random_modifiable(r);

  // Return a reference to the new modifiable.
  return {index_var(0),{r}};
}
Esempio n. 3
0
extern "C" closure builtin_function_new_modifiable(OperationArgs& Args)
{
  assert(not Args.evaluate_changeables());

  reg_heap& M = Args.memory();

  int D = Args.reg_for_slot(0);

  // Allocate a reg, and fill it with a modifiable of the correct index
  expression_ref E(new expression(modifiable(),{index_var(0)}));
  closure C{E,{D}};
  int R1 = Args.allocate(std::move(C));
  M.make_reg_changeable(R1);

  // Return a reference to the new modifiable.
  return {index_var(0),{R1}};
}