void factor_vm::primitive_callback() { cell return_rewind = to_cell(ctx->pop()); tagged<word> w(ctx->pop()); w.untag_check(this); ctx->push(allot_alien(callbacks->add(w.value(),return_rewind)->entry_point())); }
void Editor::processKeyPress(const ivec4 & keys) { if (keys == kKeyGraveAccent) { mIsActive = !mIsActive; broadcast_message(HASH::editor_activate__, kMessageFlag_Editor, mTask.id(), to_cell(mIsActive)); } }
/* 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)); }
void factor_vm::primitive_fwrite() { FILE* file = pop_file_handle(); cell length = to_cell(ctx->pop()); char* text = alien_offset(ctx->pop()); if (length == 0) return; size_t written = safe_fwrite(text, 1, length, file); if (written != length) io_error_if_not_EINTR(); }
/* make an alien pointing at an offset of another alien */ inline void factorvm::vmprim_displaced_alien() { cell alien = dpop(); cell displacement = to_cell(dpop()); if(alien == F && displacement == 0) dpush(F); else { switch(tagged<object>(alien).type()) { case BYTE_ARRAY_TYPE: case ALIEN_TYPE: case F_TYPE: dpush(allot_alien(alien,displacement)); break; default: type_error(ALIEN_TYPE,alien); break; } } }
void factor_vm::primitive_string() { cell initial = to_cell(ctx->pop()); cell length = unbox_array_size(); ctx->push(tag<string>(allot_string(length,initial))); }
static level_max_core const & to_max_core(level const & l) { lean_assert(is_max(l) || is_imax(l)); return static_cast<level_max_core const &>(to_cell(l)); }
level_succ const & to_level_succ(level const & l) { lean_assert(is_succ(l)); return static_cast<level_succ const &>(to_cell(l)); }
static level_param_core const & to_param_core(level const & l) { lean_assert(is_param_core(l)); return static_cast<level_param_core const &>(to_cell(l)); }
void sprite_stage_remove(i32 stageHash, Entity * pCaller) { MessageQueueWriter msgw(HASH::sprite_stage_remove, kMessageFlag_None, pCaller->task().id(), kRendererTaskId, to_cell(stageHash), 0); }