这篇教程C++ EXEC_TAG函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中EXEC_TAG函数的典型用法代码示例。如果您正苦于以下问题:C++ EXEC_TAG函数的具体用法?C++ EXEC_TAG怎么用?C++ EXEC_TAG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了EXEC_TAG函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: ruby_setup/* Initializes the Ruby VM and builtin libraries. * @retval 0 if succeeded. * @retval non-zero an error occurred. */intruby_setup(void){ static int initialized = 0; int state; if (initialized) return 0; initialized = 1; ruby_init_stack((void *)&state); Init_BareVM(); Init_heap(); Init_vm_objects(); PUSH_TAG(); if ((state = EXEC_TAG()) == 0) { rb_call_inits(); ruby_prog_init(); GET_VM()->running = 1; } POP_TAG(); return state;}
开发者ID:betacraft,项目名称:ruby-vernac,代码行数:29,
示例2: ruby_initvoidruby_init(void){ int state; if (ruby_initialized) return; ruby_initialized = 1;#ifdef __MACOS__ rb_origenviron = 0;#else rb_origenviron = environ;#endif#if WITH_OBJC char *s; s = getenv("MACRUBY_DEBUG"); ruby_dlog_enabled = !(s == NULL || *s == '0'); s = getenv("MACRUBY_DEBUG_FILE"); if (s == NULL) { ruby_dlog_file = stderr; } else { ruby_dlog_file = fopen(s, "w"); if (ruby_dlog_file == NULL) { fprintf(stderr, "cannot open macruby debug file `%s'", strerror(errno)); ruby_dlog_file = stderr; } }#endif Init_stack((void *)&state); Init_PreGC(); Init_BareVM(); Init_heap(); PUSH_TAG(); if ((state = EXEC_TAG()) == 0) { rb_call_inits();#ifdef __MACOS__ _macruby_init();#elif defined(__VMS) _vmsruby_init();#endif ruby_prog_init(); ALLOW_INTS; } POP_TAG(); if (state) { error_print(); exit(EXIT_FAILURE); } GET_VM()->running = 1;}
开发者ID:yangjuchan,项目名称:homework,代码行数:60,
示例3: signal_execstatic voidsignal_exec(VALUE cmd, int safe, int sig){ rb_thread_t *cur_th = GET_THREAD(); volatile unsigned long old_interrupt_mask = cur_th->interrupt_mask; int state; /* * workaround the following race: * 1. signal_enque queues signal for execution * 2. user calls trap(sig, "IGNORE"), setting SIG_IGN * 3. rb_signal_exec runs on queued signal */ if (IMMEDIATE_P(cmd)) return; cur_th->interrupt_mask |= TRAP_INTERRUPT_MASK; TH_PUSH_TAG(cur_th); if ((state = EXEC_TAG()) == 0) { VALUE signum = INT2NUM(sig); rb_eval_cmd(cmd, rb_ary_new3(1, signum), safe); } TH_POP_TAG(); cur_th = GET_THREAD(); cur_th->interrupt_mask = old_interrupt_mask; if (state) { /* XXX: should be replaced with rb_threadptr_pending_interrupt_enque() */ JUMP_TAG(state); }}
开发者ID:yugui,项目名称:ruby,代码行数:31,
示例4: rb_debug_inspector_openVALUErb_debug_inspector_open(rb_debug_inspector_func_t func, void *data){ rb_debug_inspector_t dbg_context; rb_thread_t *th = GET_THREAD(); int state; volatile VALUE UNINITIALIZED_VAR(result); dbg_context.th = th; dbg_context.cfp = dbg_context.th->cfp; dbg_context.backtrace = rb_vm_backtrace_location_ary(th, 0, 0); dbg_context.backtrace_size = RARRAY_LEN(dbg_context.backtrace); dbg_context.contexts = collect_caller_bindings(th); TH_PUSH_TAG(th); if ((state = EXEC_TAG()) == 0) { result = (*func)(&dbg_context, data); } TH_POP_TAG(); /* invalidate bindings? */ if (state) { JUMP_TAG(state); } return result;}
开发者ID:sho-h,项目名称:ruby,代码行数:28,
示例5: rb_f_catchstatic VALUErb_f_catch(int argc, VALUE *argv){ VALUE tag; int state; VALUE val = Qnil; /* OK */ rb_thread_t *th = GET_THREAD(); rb_control_frame_t *saved_cfp = th->cfp; if (argc == 0) { tag = rb_obj_alloc(rb_cObject); } else { rb_scan_args(argc, argv, "01", &tag); } PUSH_TAG(); th->tag->tag = tag; if ((state = EXEC_TAG()) == 0) { val = rb_yield_0(1, &tag); } else if (state == TAG_THROW && RNODE(th->errinfo)->u1.value == tag) { th->cfp = saved_cfp; val = th->tag->retval; th->errinfo = Qnil; state = 0; } POP_TAG(); if (state) JUMP_TAG(state); return val;}
开发者ID:3runo5ouza,项目名称:rhodes,代码行数:34,
示例6: rb_method_callVALUErb_method_call(int argc, VALUE *argv, VALUE method){ VALUE result = Qnil; /* OK */ struct METHOD *data; int state; volatile int safe = -1; Data_Get_Struct(method, struct METHOD, data); if (data->recv == Qundef) { rb_raise(rb_eTypeError, "can't call unbound method; bind first"); } PUSH_TAG(); if (OBJ_TAINTED(method)) { safe = rb_safe_level(); if (rb_safe_level() < 4) { rb_set_safe_level_force(4); } } if ((state = EXEC_TAG()) == 0) { rb_thread_t *th = GET_THREAD(); VALUE rb_vm_call(rb_thread_t * th, VALUE klass, VALUE recv, VALUE id, ID oid, int argc, const VALUE *argv, const NODE *body, int nosuper); PASS_PASSED_BLOCK_TH(th); result = rb_vm_call(th, data->oclass, data->recv, data->id, data->oid, argc, argv, data->body, 0); } POP_TAG(); if (safe >= 0) rb_set_safe_level_force(safe); if (state) JUMP_TAG(state); return result;}
开发者ID:srirammca53,项目名称:update_status,代码行数:35,
示例7: rb_method_callVALUErb_method_call(int argc, VALUE *argv, VALUE method){ VALUE result = Qnil; /* OK */ struct METHOD *data; int state; volatile int safe = -1; Data_Get_Struct(method, struct METHOD, data); if (data->recv == Qundef) { rb_raise(rb_eTypeError, "can't call unbound method; bind first"); } PUSH_TAG(PROT_NONE); if (OBJ_TAINTED(method)) { safe = rb_safe_level(); if (rb_safe_level() < 4) { rb_set_safe_level_force(4); } } if ((state = EXEC_TAG()) == 0) { PASS_PASSED_BLOCK(); result = th_call0(GET_THREAD(), data->klass, data->recv, data->id, data->oid, argc, argv, data->body, 0); } POP_TAG(); if (safe >= 0) rb_set_safe_level_force(safe); if (state) JUMP_TAG(state); return result;}
开发者ID:RWB01,项目名称:Code-Translator,代码行数:32,
示例8: rb_require_safeVALUErb_require_safe(VALUE fname, int safe){ volatile VALUE result = Qnil; rb_thread_t *th = GET_THREAD(); volatile VALUE errinfo = th->errinfo; int state; struct { int safe; } volatile saved; char *volatile ftptr = 0; PUSH_TAG(); saved.safe = rb_safe_level(); if ((state = EXEC_TAG()) == 0) { VALUE path; long handle; int found; rb_set_safe_level_force(safe); FilePathValue(fname); rb_set_safe_level_force(0); found = search_required(fname, &path, safe); if (found) { if (!path || !(ftptr = load_lock(RSTRING_PTR(path)))) { result = Qfalse; } else { switch (found) { case 'r': rb_load_internal(path, 0); break; case 's': handle = (long)rb_vm_call_cfunc(rb_vm_top_self(), load_ext, path, 0, path); rb_ary_push(ruby_dln_librefs, LONG2NUM(handle)); break; } rb_provide_feature(path); result = Qtrue; } } } POP_TAG(); load_unlock(ftptr, !state); rb_set_safe_level_force(saved.safe); if (state) { JUMP_TAG(state); } if (NIL_P(result)) { load_failed(fname); } th->errinfo = errinfo; return result;}
开发者ID:Subv,项目名称:Ruby-Impl,代码行数:60,
示例9: rb_vm_invoke_procVALUErb_vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, VALUE self, int argc, const VALUE *argv, const rb_block_t * blockptr){ VALUE val = Qundef; int state; volatile int stored_safe = th->safe_level; TH_PUSH_TAG(th); if ((state = EXEC_TAG()) == 0) { if (!proc->is_from_method) { th->safe_level = proc->safe_level; } val = invoke_block_from_c(th, &proc->block, self, argc, argv, blockptr, 0); } TH_POP_TAG(); if (!proc->is_from_method) { th->safe_level = stored_safe; } if (state) { JUMP_TAG(state); } return val;}
开发者ID:qnighy,项目名称:ruby-1.9.2p0,代码行数:26,
示例10: rb_postponed_job_flushvoidrb_postponed_job_flush(rb_vm_t *vm){ rb_thread_t *th = GET_THREAD(); unsigned long saved_postponed_job_interrupt_mask = th->interrupt_mask & POSTPONED_JOB_INTERRUPT_MASK; VALUE saved_errno = th->errinfo; th->errinfo = Qnil; /* mask POSTPONED_JOB dispatch */ th->interrupt_mask |= POSTPONED_JOB_INTERRUPT_MASK; { TH_PUSH_TAG(th); EXEC_TAG(); { int index; while ((index = vm->postponed_job_index) > 0) { if (ATOMIC_CAS(vm->postponed_job_index, index, index-1) == index) { rb_postponed_job_t *pjob = &vm->postponed_job_buffer[index-1]; (*pjob->func)(pjob->data); } } } TH_POP_TAG(); } /* restore POSTPONED_JOB mask */ th->interrupt_mask &= ~(saved_postponed_job_interrupt_mask ^ POSTPONED_JOB_INTERRUPT_MASK); th->errinfo = saved_errno;}
开发者ID:ksperling,项目名称:ruby,代码行数:28,
示例11: ruby_finalize_0static voidruby_finalize_0(void){ PUSH_TAG(); if (EXEC_TAG() == 0) { rb_trap_exit(); } POP_TAG(); rb_exec_end_proc(); rb_clear_trace_func();}
开发者ID:betacraft,项目名称:ruby-vernac,代码行数:11,
示例12: ruby_cleanup/** Destructs the VM. * * Runs the VM finalization processes as well as ruby_finalize(), and frees * resources used by the VM. * * @param ex Default value to the return value. * @return If an error occurred returns a non-zero. If otherwise, returns the * given ex. * @note This function does not raise any exception. */intruby_cleanup(volatile int ex){ int state; volatile VALUE errs[2]; rb_thread_t *th = GET_THREAD(); int nerr; rb_threadptr_interrupt(th); rb_threadptr_check_signal(th); PUSH_TAG(); if ((state = EXEC_TAG()) == 0) { SAVE_ROOT_JMPBUF(th, { RUBY_VM_CHECK_INTS(th); });
开发者ID:betacraft,项目名称:ruby-vernac,代码行数:23,
示例13: rb_eval_cmdVALUErb_eval_cmd(VALUE cmd, VALUE arg, int level){ int state; VALUE val = Qnil; /* OK */ volatile int safe = rb_safe_level(); if (OBJ_TAINTED(cmd)) { level = 4; } if (TYPE(cmd) != T_STRING) { PUSH_TAG(); rb_set_safe_level_force(level); if ((state = EXEC_TAG()) == 0) { val = rb_funcall2(cmd, rb_intern("call"), RARRAY_LEN(arg), RARRAY_PTR(arg)); } POP_TAG(); rb_set_safe_level_force(safe); if (state) JUMP_TAG(state); return val; } PUSH_TAG(); if ((state = EXEC_TAG()) == 0) { val = eval_string(rb_vm_top_self(), cmd, Qnil, 0, 0); } POP_TAG(); rb_set_safe_level_force(safe); if (state) rb_vm_jump_tag_but_local_jump(state, val); return val;}
开发者ID:3runo5ouza,项目名称:rhodes,代码行数:37,
示例14: rb_load_protectvoidrb_load_protect(VALUE fname, int wrap, int *state){ int status; volatile VALUE path = 0; PUSH_TAG(); if ((status = EXEC_TAG()) == 0) { path = file_to_load(fname); } POP_TAG(); if (!status) status = rb_load_internal0(GET_THREAD(), path, wrap); if (state) *state = status;}
开发者ID:scorpion007,项目名称:ruby,代码行数:15,
示例15: rb_fiber_startvoidrb_fiber_start(void){ rb_thread_t *th = GET_THREAD(); rb_fiber_t *fib; rb_context_t *cont; rb_proc_t *proc; int state; GetFiberPtr(th->fiber, fib); cont = &fib->cont; TH_PUSH_TAG(th); if ((state = EXEC_TAG()) == 0) { int argc; VALUE *argv, args; GetProcPtr(cont->saved_thread.first_proc, proc); args = cont->value; argv = (argc = cont->argc) > 1 ? RARRAY_PTR(args) : &args; cont->value = Qnil; th->errinfo = Qnil; th->local_lfp = proc->block.lfp; th->local_svar = Qnil; fib->status = RUNNING; cont->value = rb_vm_invoke_proc(th, proc, proc->block.self, argc, argv, 0); } TH_POP_TAG(); if (state) { if (TAG_RAISE) { th->thrown_errinfo = th->errinfo; } else { th->thrown_errinfo = rb_vm_make_jump_tag_but_local_jump(state, th->errinfo); } RUBY_VM_SET_INTERRUPT(th); } rb_fiber_terminate(fib); rb_bug("rb_fiber_start: unreachable");}
开发者ID:srirammca53,项目名称:update_status,代码行数:43,
示例16: ruby_options/*! Processes command line arguments and compiles the Ruby source to execute. * * This function does: * /li Processes the given command line flags and arguments for ruby(1) * /li compiles the source code from the given argument, -e or stdin, and * /li returns the compiled source as an opaque pointer to an internal data structure * * @return an opaque pointer to the compiled source or an internal special value. * @sa ruby_executable_node(). */void *ruby_options(int argc, char **argv){ int state; void *volatile iseq = 0; ruby_init_stack((void *)&iseq); PUSH_TAG(); if ((state = EXEC_TAG()) == 0) { SAVE_ROOT_JMPBUF(GET_THREAD(), iseq = ruby_process_options(argc, argv)); } else { rb_clear_trace_func(); state = error_handle(state); iseq = (void *)INT2FIX(state); } POP_TAG(); return iseq;}
开发者ID:betacraft,项目名称:ruby-vernac,代码行数:29,
示例17: ruby_initvoidruby_init(void){ static int initialized = 0; int state; if (initialized) return; initialized = 1;#ifdef __MACOS__ rb_origenviron = 0;#else rb_origenviron = environ;#endif Init_stack((void *)&state); Init_BareVM(); Init_heap(); PUSH_TAG(); if ((state = EXEC_TAG()) == 0) { rb_call_inits();#ifdef __MACOS__ _macruby_init();#elif defined(__VMS) _vmsruby_init();#endif ruby_prog_init(); ALLOW_INTS; } POP_TAG(); if (state) { error_print(); exit(EXIT_FAILURE); } GET_VM()->running = 1;}
开发者ID:genki,项目名称:ruby,代码行数:41,
示例18: signal_execstatic voidsignal_exec(VALUE cmd, int safe, int sig){ rb_thread_t *cur_th = GET_THREAD(); volatile unsigned long old_interrupt_mask = cur_th->interrupt_mask; int state; cur_th->interrupt_mask |= TRAP_INTERRUPT_MASK; TH_PUSH_TAG(cur_th); if ((state = EXEC_TAG()) == 0) { VALUE signum = INT2NUM(sig); rb_eval_cmd(cmd, rb_ary_new3(1, signum), safe); } TH_POP_TAG(); cur_th = GET_THREAD(); cur_th->interrupt_mask = old_interrupt_mask; if (state) { /* XXX: should be replaced with rb_threadptr_pending_interrupt_enque() */ JUMP_TAG(state); }}
开发者ID:Danylyuk,项目名称:first_app,代码行数:22,
示例19: rb_fiber_startvoidrb_fiber_start(void){ rb_thread_t *th = GET_THREAD(); rb_context_t *cont; rb_proc_t *proc; VALUE args; int state; GetContPtr(th->fiber, cont); TH_PUSH_TAG(th); if ((state = EXEC_TAG()) == 0) { GetProcPtr(cont->saved_thread.first_proc, proc); args = cont->value; cont->value = Qnil; th->errinfo = Qnil; th->local_lfp = proc->block.lfp; th->local_svar = Qnil; cont->value = vm_invoke_proc(th, proc, proc->block.self, 1, &args, 0); } TH_POP_TAG(); if (state) { if (TAG_RAISE) { th->thrown_errinfo = th->errinfo; } else { th->thrown_errinfo = vm_make_jump_tag_but_local_jump(state, th->errinfo); } RUBY_VM_SET_INTERRUPT(th); } rb_fiber_terminate(cont); rb_bug("rb_fiber_start: unreachable");}
开发者ID:genki,项目名称:ruby,代码行数:37,
示例20: rb_load_internalstatic voidrb_load_internal(VALUE fname, int wrap){ int state; rb_thread_t *th = GET_THREAD(); volatile VALUE wrapper = th->top_wrapper; volatile VALUE self = th->top_self; volatile int loaded = FALSE; volatile int mild_compile_error;#ifndef __GNUC__ rb_thread_t *volatile th0 = th;#endif th->errinfo = Qnil; /* ensure */ if (!wrap) { rb_secure(4); /* should alter global state */ th->top_wrapper = 0; } else { /* load in anonymous module as toplevel */ th->top_self = rb_obj_clone(rb_vm_top_self()); th->top_wrapper = rb_module_new(); rb_extend_object(th->top_self, th->top_wrapper); } mild_compile_error = th->mild_compile_error; PUSH_TAG(); state = EXEC_TAG(); if (state == 0) { NODE *node; VALUE iseq; th->mild_compile_error++; node = (NODE *)rb_load_file(RSTRING_PTR(fname)); loaded = TRUE; iseq = rb_iseq_new_top(node, rb_str_new2("<top (required)>"), fname, rb_realpath_internal(Qnil, fname, 1), Qfalse); th->mild_compile_error--; rb_iseq_eval(iseq); } POP_TAG();#ifndef __GNUC__ th = th0; fname = RB_GC_GUARD(fname);#endif th->mild_compile_error = mild_compile_error; th->top_self = self; th->top_wrapper = wrapper; if (!loaded) { rb_exc_raise(GET_THREAD()->errinfo); } if (state) { rb_vm_jump_tag_but_local_jump(state, Qundef); } if (!NIL_P(GET_THREAD()->errinfo)) { /* exception during load */ rb_exc_raise(th->errinfo); }}
开发者ID:Subv,项目名称:Ruby-Impl,代码行数:62,
示例21: vm_execstatic VALUEvm_exec(rb_thread_t *th){ int state; VALUE result, err; VALUE initial = 0; VALUE *escape_dfp = NULL; TH_PUSH_TAG(th); _tag.retval = Qnil; if ((state = EXEC_TAG()) == 0) { vm_loop_start: result = vm_exec_core(th, initial); if ((state = th->state) != 0) { err = result; th->state = 0; goto exception_handler; } } else { int i; struct iseq_catch_table_entry *entry; unsigned long epc, cont_pc, cont_sp; VALUE catch_iseqval; rb_control_frame_t *cfp; VALUE type; err = th->errinfo; exception_handler: cont_pc = cont_sp = catch_iseqval = 0; while (th->cfp->pc == 0 || th->cfp->iseq == 0) { if (UNLIKELY(VM_FRAME_TYPE(th->cfp) == VM_FRAME_MAGIC_CFUNC)) { const rb_method_entry_t *me = th->cfp->me; EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, th->cfp->self, me->called_id, me->klass); } th->cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp); } cfp = th->cfp; epc = cfp->pc - cfp->iseq->iseq_encoded; if (state == TAG_BREAK || state == TAG_RETURN) { escape_dfp = GET_THROWOBJ_CATCH_POINT(err); if (cfp->dfp == escape_dfp) { if (state == TAG_RETURN) { if ((cfp + 1)->pc != &finish_insn_seq[0]) { SET_THROWOBJ_CATCH_POINT(err, (VALUE)(cfp + 1)->dfp); SET_THROWOBJ_STATE(err, state = TAG_BREAK); } else { for (i = 0; i < cfp->iseq->catch_table_size; i++) { entry = &cfp->iseq->catch_table[i]; if (entry->start < epc && entry->end >= epc) { if (entry->type == CATCH_TYPE_ENSURE) { catch_iseqval = entry->iseq; cont_pc = entry->cont; cont_sp = entry->sp; break; } } } if (!catch_iseqval) { result = GET_THROWOBJ_VAL(err); th->errinfo = Qnil; th->cfp += 2; goto finish_vme; } } /* through */ } else { /* TAG_BREAK */#if OPT_STACK_CACHING initial = (GET_THROWOBJ_VAL(err));#else *th->cfp->sp++ = (GET_THROWOBJ_VAL(err));#endif th->errinfo = Qnil; goto vm_loop_start; } } } if (state == TAG_RAISE) { for (i = 0; i < cfp->iseq->catch_table_size; i++) { entry = &cfp->iseq->catch_table[i]; if (entry->start < epc && entry->end >= epc) { if (entry->type == CATCH_TYPE_RESCUE || entry->type == CATCH_TYPE_ENSURE) { catch_iseqval = entry->iseq; cont_pc = entry->cont; cont_sp = entry->sp; break; } } }//.........这里部分代码省略.........
开发者ID:qnighy,项目名称:ruby-1.9.2p0,代码行数:101,
示例22: error_printstatic voiderror_print(void){ volatile VALUE errat = Qnil; /* OK */ VALUE errinfo = GET_THREAD()->errinfo; volatile VALUE eclass, e; const char *volatile einfo; volatile long elen; if (NIL_P(errinfo)) return; PUSH_TAG(); if (EXEC_TAG() == 0) { errat = get_backtrace(errinfo); } else { errat = Qnil; } if (EXEC_TAG()) goto error; if (NIL_P(errat)) { const char *file = rb_sourcefile(); int line = rb_sourceline(); if (!file) warn_printf("%d", line); else if (!line) warn_printf("%s", file); else warn_printf("%s:%d", file, line); } else if (RARRAY_LEN(errat) == 0) { error_pos(); } else { VALUE mesg = RARRAY_PTR(errat)[0]; if (NIL_P(mesg)) error_pos(); else { warn_print2(RSTRING_PTR(mesg), RSTRING_LEN(mesg)); } } eclass = CLASS_OF(errinfo); if (EXEC_TAG() == 0) { e = rb_funcall(errinfo, rb_intern("message"), 0, 0); StringValue(e); einfo = RSTRING_PTR(e); elen = RSTRING_LEN(e); } else { einfo = ""; elen = 0; } if (EXEC_TAG()) goto error; if (eclass == rb_eRuntimeError && elen == 0) { warn_print(": unhandled exception/n"); } else { VALUE epath; epath = rb_class_name(eclass); if (elen == 0) { warn_print(": "); warn_print2(RSTRING_PTR(epath), RSTRING_LEN(epath)); warn_print("/n"); } else { char *tail = 0; long len = elen; if (RSTRING_PTR(epath)[0] == '#') epath = 0; if ((tail = memchr(einfo, '/n', elen)) != 0) { len = tail - einfo; tail++; /* skip newline */ } warn_print(": "); warn_print2(einfo, len); if (epath) { warn_print(" ("); warn_print2(RSTRING_PTR(epath), RSTRING_LEN(epath)); warn_print(")/n"); } if (tail) { warn_print2(tail, elen - len - 1); if (einfo[elen-1] != '/n') warn_print2("/n", 1); } } } if (!NIL_P(errat)) { long i; long len = RARRAY_LEN(errat); VALUE *ptr = RARRAY_PTR(errat); int skip = eclass == rb_eSysStackError;#define TRACE_MAX (TRACE_HEAD+TRACE_TAIL+5)//.........这里部分代码省略.........
开发者ID:agrimm,项目名称:ruby-benchmark-suite,代码行数:101,
示例23: rb_require_internal/* * returns * 0: if already loaded (false) * 1: successfully loaded (true) * <0: not found (LoadError) * >1: exception */intrb_require_internal(VALUE fname, int safe){ volatile int result = -1; rb_thread_t *th = GET_THREAD(); volatile VALUE errinfo = th->errinfo; int state; struct { int safe; } volatile saved; char *volatile ftptr = 0; if (RUBY_DTRACE_REQUIRE_ENTRY_ENABLED()) { RUBY_DTRACE_REQUIRE_ENTRY(StringValuePtr(fname), rb_sourcefile(), rb_sourceline()); } TH_PUSH_TAG(th); saved.safe = rb_safe_level(); if ((state = EXEC_TAG()) == 0) { VALUE path; long handle; int found; rb_set_safe_level_force(safe); FilePathValue(fname); rb_set_safe_level_force(0); if (RUBY_DTRACE_FIND_REQUIRE_ENTRY_ENABLED()) { RUBY_DTRACE_FIND_REQUIRE_ENTRY(StringValuePtr(fname), rb_sourcefile(), rb_sourceline()); } path = rb_str_encode_ospath(fname); found = search_required(path, &path, safe); if (RUBY_DTRACE_FIND_REQUIRE_RETURN_ENABLED()) { RUBY_DTRACE_FIND_REQUIRE_RETURN(StringValuePtr(fname), rb_sourcefile(), rb_sourceline()); } if (found) { if (!path || !(ftptr = load_lock(RSTRING_PTR(path)))) { result = 0; } else if (!*ftptr) { rb_provide_feature(path); result = TAG_RETURN; } else { switch (found) { case 'r': rb_load_internal(path, 0); break; case 's': handle = (long)rb_vm_call_cfunc(rb_vm_top_self(), load_ext, path, 0, path); rb_ary_push(ruby_dln_librefs, LONG2NUM(handle)); break; } rb_provide_feature(path); result = TAG_RETURN; } } } TH_POP_TAG(); load_unlock(ftptr, !state); rb_set_safe_level_force(saved.safe); if (state) { /* never TAG_RETURN */ return state; } th->errinfo = errinfo; if (RUBY_DTRACE_REQUIRE_RETURN_ENABLED()) { RUBY_DTRACE_REQUIRE_RETURN(StringValuePtr(fname), rb_sourcefile(), rb_sourceline()); } return result;}
开发者ID:scorpion007,项目名称:ruby,代码行数:94,
示例24: eval_string_with_cref/*RHO static*/ VALUEeval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *cref, const char *file, int line){ int state; VALUE result = Qundef; VALUE envval; rb_binding_t *bind = 0; rb_thread_t *th = GET_THREAD(); rb_env_t *env = NULL; rb_block_t block; volatile int parse_in_eval; volatile int mild_compile_error; if (file == 0) { file = rb_sourcefile(); line = rb_sourceline(); } parse_in_eval = th->parse_in_eval; mild_compile_error = th->mild_compile_error; PUSH_TAG(); if ((state = EXEC_TAG()) == 0) { rb_iseq_t *iseq; volatile VALUE iseqval; if (scope != Qnil) { if (rb_obj_is_kind_of(scope, rb_cBinding)) { GetBindingPtr(scope, bind); envval = bind->env; } else { rb_raise(rb_eTypeError, "wrong argument type %s (expected Binding)", rb_obj_classname(scope)); } GetEnvPtr(envval, env); th->base_block = &env->block; } else { rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp); if (cfp != 0) { block = *RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp); th->base_block = █ th->base_block->self = self; th->base_block->iseq = cfp->iseq; /* TODO */ } else { rb_raise(rb_eRuntimeError, "Can't eval on top of Fiber or Thread"); } } //RHO if ( TYPE(src) != T_STRING ){ iseqval = src; }else //RHO { /* make eval iseq */ th->parse_in_eval++; th->mild_compile_error++; iseqval = rb_iseq_compile(src, rb_str_new2(file), INT2FIX(line)); th->mild_compile_error--; th->parse_in_eval--; } vm_set_eval_stack(th, iseqval, cref); th->base_block = 0; if (0) { /* for debug */ printf("%s/n", RSTRING_PTR(rb_iseq_disasm(iseqval))); } /* save new env */ GetISeqPtr(iseqval, iseq); if (bind && iseq->local_size > 0) { bind->env = rb_vm_make_env_object(th, th->cfp); } /* kick */ CHECK_STACK_OVERFLOW(th->cfp, iseq->stack_max); result = vm_exec(th); } POP_TAG(); th->mild_compile_error = mild_compile_error; th->parse_in_eval = parse_in_eval; if (state) { if (state == TAG_RAISE) { VALUE errinfo = th->errinfo; if (strcmp(file, "(eval)") == 0) { VALUE mesg, errat, bt2; extern VALUE rb_get_backtrace(VALUE info); ID id_mesg; CONST_ID(id_mesg, "mesg"); errat = rb_get_backtrace(errinfo); mesg = rb_attr_get(errinfo, id_mesg); if (!NIL_P(errat) && TYPE(errat) == T_ARRAY && (bt2 = vm_backtrace(th, -2), RARRAY_LEN(bt2) > 0)) {//.........这里部分代码省略.........
开发者ID:3runo5ouza,项目名称:rhodes,代码行数:101,
示例25: rb_load_internal0static intrb_load_internal0(rb_thread_t *th, VALUE fname, int wrap){ int state; volatile VALUE wrapper = th->top_wrapper; volatile VALUE self = th->top_self; volatile int loaded = FALSE; volatile int mild_compile_error;#if !defined __GNUC__ rb_thread_t *volatile th0 = th;#endif th->errinfo = Qnil; /* ensure */ if (!wrap) { th->top_wrapper = 0; } else { /* load in anonymous module as toplevel */ th->top_self = rb_obj_clone(rb_vm_top_self()); th->top_wrapper = rb_module_new(); rb_extend_object(th->top_self, th->top_wrapper); } mild_compile_error = th->mild_compile_error; TH_PUSH_TAG(th); state = EXEC_TAG(); if (state == 0) { NODE *node; rb_iseq_t *iseq; th->mild_compile_error++; node = (NODE *)rb_load_file_str(fname); loaded = TRUE; iseq = rb_iseq_new_top(node, rb_str_new2("<top (required)>"), fname, rb_realpath_internal(Qnil, fname, 1), NULL); th->mild_compile_error--; rb_iseq_eval(iseq); } TH_POP_TAG();#if !defined __GNUC__ th = th0; fname = RB_GC_GUARD(fname);#endif th->mild_compile_error = mild_compile_error; th->top_self = self; th->top_wrapper = wrapper; if (!loaded && !FIXNUM_P(th->errinfo)) { /* an error on loading don't include INT2FIX(TAG_FATAL) see r35625 */ return TAG_RAISE; } if (state) { VALUE exc = rb_vm_make_jump_tag_but_local_jump(state, Qundef); if (NIL_P(exc)) return state; th->errinfo = exc; return TAG_RAISE; } if (!NIL_P(th->errinfo)) { /* exception during load */ return TAG_RAISE; } return state;}
开发者ID:scorpion007,项目名称:ruby,代码行数:65,
注:本文中的EXEC_TAG函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ EXFAT_SB函数代码示例 C++ EXECVP函数代码示例 |