Exemplo n.º 1
0
/* Allocates memory (add(), allot_alien())*/
void factor_vm::primitive_callback() {
  cell return_rewind = to_cell(ctx->pop());
  tagged<word> w(ctx->pop());

  w.untag_check(this);

  cell func = callbacks->add(w.value(), return_rewind)->entry_point();
  CODE_TO_FUNCTION_POINTER_CALLBACK(this, func);
  ctx->push(allot_alien(func));
}
Exemplo n.º 2
0
void factor_vm::c_to_factor(cell quot) {
  /* First time this is called, wrap the c-to-factor sub-primitive inside
     of a callback stub, which saves and restores non-volatile registers
     per platform ABI conventions, so that the Factor compiler can treat
     all registers as volatile */
  if (!c_to_factor_func) {
    tagged<word> c_to_factor_word(special_objects[C_TO_FACTOR_WORD]);
    code_block* c_to_factor_block = callbacks->add(c_to_factor_word.value(), 0);
    cell func = c_to_factor_block->entry_point();
    CODE_TO_FUNCTION_POINTER_CALLBACK(this, func);
    c_to_factor_func = (c_to_factor_func_type) func;
  }
  c_to_factor_func(quot);
}