本文整理汇总了C++中ThreadState::clear_return方法的典型用法代码示例。如果您正苦于以下问题:C++ ThreadState::clear_return方法的具体用法?C++ ThreadState::clear_return怎么用?C++ ThreadState::clear_return使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ThreadState
的用法示例。
在下文中一共展示了ThreadState::clear_return方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: interpreter
//.........这里部分代码省略.........
#define cache_ip(which) ip_ptr = vmm->addresses + which
#define flush_ip() call_frame->calculate_ip(ip_ptr)
#include "vm/gen/instruction_implementations.hpp"
} catch(TypeError& e) {
flush_ip();
Exception* exc =
Exception::make_type_error(state, e.type, e.object, e.reason);
exc->locations(state, Location::from_call_stack(state, call_frame));
state->raise_exception(exc);
call_frame->scope->flush_to_heap(state);
return NULL;
} catch(const RubyException& exc) {
exc.exception->locations(state,
Location::from_call_stack(state, call_frame));
state->raise_exception(exc.exception);
return NULL;
}
// There is no reason to be here. Either the bytecode loop exits,
// or it jumps to exception;
rubinius::bug("Control flow error in interpreter");
// If control finds it's way down here, there is an exception.
exception:
ThreadState* th = state->vm()->thread_state();
//
switch(th->raise_reason()) {
case cException:
if(current_unwind > 0) {
UnwindInfo* info = &unwinds[--current_unwind];
stack_position(info->stack_depth);
call_frame->set_ip(info->target_ip);
cache_ip(info->target_ip);
goto continue_to_run;
} else {
call_frame->scope->flush_to_heap(state);
return NULL;
}
case cBreak:
// If we're trying to break to here, we're done!
if(th->destination_scope() == call_frame->scope->on_heap()) {
stack_push(th->raise_value());
th->clear_break();
goto continue_to_run;
// Don't return here, because we want to loop back to the top
// and keep running this method.
}
// Otherwise, fall through and run the unwinds
case cReturn:
case cCatchThrow:
// Otherwise, we're doing a long return/break unwind through
// here. We need to run ensure blocks.
while(current_unwind > 0) {
UnwindInfo* info = &unwinds[--current_unwind];
if(info->for_ensure()) {
stack_position(info->stack_depth);
call_frame->set_ip(info->target_ip);
cache_ip(info->target_ip);
// Don't reset ep here, we're still handling the return/break.
goto continue_to_run;
}
}
// Ok, no ensures to run.
if(th->raise_reason() == cReturn) {
call_frame->scope->flush_to_heap(state);
// If we're trying to return to here, we're done!
if(th->destination_scope() == call_frame->scope->on_heap()) {
Object* val = th->raise_value();
th->clear_return();
return val;
} else {
// Give control of this exception to the caller.
return NULL;
}
} else { // Not for us!
call_frame->scope->flush_to_heap(state);
// Give control of this exception to the caller.
return NULL;
}
case cExit:
call_frame->scope->flush_to_heap(state);
return NULL;
default:
break;
} // switch
rubinius::bug("Control flow error in interpreter");
return NULL;
}
示例2: uncommon_interpreter
//.........这里部分代码省略.........
#undef flush_ip
#define next_int ((opcode)(stream[call_frame->inc_ip()]))
#define cache_ip(which)
#define flush_ip()
#include "vm/gen/instruction_implementations.hpp"
} catch(TypeError& e) {
flush_ip();
Exception* exc =
Exception::make_type_error(state, e.type, e.object, e.reason);
exc->locations(state, Location::from_call_stack(state, call_frame));
state->raise_exception(exc);
call_frame->scope->flush_to_heap(state);
return NULL;
} catch(const RubyException& exc) {
exc.exception->locations(state,
Location::from_call_stack(state, call_frame));
state->raise_exception(exc.exception);
return NULL;
}
// No reason to be here!
rubinius::bug("Control flow error in interpreter");
exception:
ThreadState* th = state->vm()->thread_state();
//
switch(th->raise_reason()) {
case cException:
if(current_unwind > 0) {
UnwindInfo* info = &unwinds[--current_unwind];
stack_position(info->stack_depth);
call_frame->set_ip(info->target_ip);
cache_ip(info->target_ip);
goto continue_to_run;
} else {
call_frame->scope->flush_to_heap(state);
return NULL;
}
case cBreak:
// If we're trying to break to here, we're done!
if(th->destination_scope() == call_frame->scope->on_heap()) {
stack_push(th->raise_value());
th->clear_break();
goto continue_to_run;
// Don't return here, because we want to loop back to the top
// and keep running this method.
}
// Otherwise, fall through and run the unwinds
case cReturn:
case cCatchThrow:
// Otherwise, we're doing a long return/break unwind through
// here. We need to run ensure blocks.
while(current_unwind > 0) {
UnwindInfo* info = &unwinds[--current_unwind];
if(info->for_ensure()) {
stack_position(info->stack_depth);
call_frame->set_ip(info->target_ip);
cache_ip(info->target_ip);
// Don't reset ep here, we're still handling the return/break.
goto continue_to_run;
}
}
// Ok, no ensures to run.
if(th->raise_reason() == cReturn) {
call_frame->scope->flush_to_heap(state);
// If we're trying to return to here, we're done!
if(th->destination_scope() == call_frame->scope->on_heap()) {
Object* val = th->raise_value();
th->clear_return();
return val;
} else {
// Give control of this exception to the caller.
return NULL;
}
} else { // It's cBreak thats not for us!
call_frame->scope->flush_to_heap(state);
// Give control of this exception to the caller.
return NULL;
}
case cExit:
call_frame->scope->flush_to_heap(state);
return NULL;
default:
break;
} // switch
rubinius::bug("Control flow error in interpreter");
return NULL;
}
示例3: debugger_interpreter_continue
//.........这里部分代码省略.........
#undef flush_ip
#define next_int ((opcode)(stream[call_frame->inc_ip()]))
#define cache_ip(which)
#define flush_ip()
#include "vm/gen/instruction_implementations.hpp"
} catch(TypeError& e) {
flush_ip();
Exception* exc =
Exception::make_type_error(state, e.type, e.object, e.reason);
exc->locations(state, Location::from_call_stack(state, call_frame));
state->raise_exception(exc);
call_frame->scope->flush_to_heap(state);
return NULL;
} catch(const RubyException& exc) {
exc.exception->locations(state,
Location::from_call_stack(state, call_frame));
state->raise_exception(exc.exception);
return NULL;
}
// No reason to be here!
rubinius::bug("Control flow error in interpreter");
exception:
ThreadState* th = state->vm()->thread_state();
//
switch(th->raise_reason()) {
case cException:
if(current_unwind > 0) {
UnwindInfo* info = &unwinds[--current_unwind];
stack_position(info->stack_depth);
call_frame->set_ip(info->target_ip);
cache_ip(info->target_ip);
goto continue_to_run;
} else {
call_frame->scope->flush_to_heap(state);
return NULL;
}
case cBreak:
// If we're trying to break to here, we're done!
if(th->destination_scope() == call_frame->scope->on_heap()) {
stack_push(th->raise_value());
th->clear_break();
goto continue_to_run;
// Don't return here, because we want to loop back to the top
// and keep running this method.
}
// Otherwise, fall through and run the unwinds
case cReturn:
case cCatchThrow:
// Otherwise, we're doing a long return/break unwind through
// here. We need to run ensure blocks.
while(current_unwind > 0) {
UnwindInfo* info = &unwinds[--current_unwind];
if(info->for_ensure()) {
stack_position(info->stack_depth);
call_frame->set_ip(info->target_ip);
cache_ip(info->target_ip);
// Don't reset ep here, we're still handling the return/break.
goto continue_to_run;
}
}
// Ok, no ensures to run.
if(th->raise_reason() == cReturn) {
call_frame->scope->flush_to_heap(state);
// If we're trying to return to here, we're done!
if(th->destination_scope() == call_frame->scope->on_heap()) {
Object* val = th->raise_value();
th->clear_return();
return val;
} else {
// Give control of this exception to the caller.
return NULL;
}
} else { // It's cBreak thats not for us!
call_frame->scope->flush_to_heap(state);
// Give control of this exception to the caller.
return NULL;
}
case cExit:
call_frame->scope->flush_to_heap(state);
return NULL;
default:
break;
} // switch
rubinius::bug("Control flow error in interpreter");
return NULL;
}
示例4: debugger_interpreter
//.........这里部分代码省略.........
#include "vm/gen/instruction_implementations.hpp"
} catch(TypeError& e) {
flush_ip();
Exception* exc =
Exception::make_type_error(state, e.type, e.object, e.reason);
exc->locations(state, Location::from_call_stack(state, call_frame));
state->thread_state()->raise_exception(exc);
call_frame->scope->flush_to_heap(state);
return NULL;
} catch(const RubyException& exc) {
exc.exception->locations(state,
Location::from_call_stack(state, call_frame));
state->thread_state()->raise_exception(exc.exception);
return NULL;
}
// no reason to be here!
abort();
// If control finds it's way down here, there is an exception.
exception:
ThreadState* th = state->thread_state();
//
switch(th->raise_reason()) {
case cException:
if(current_unwind > 0) {
UnwindInfo* info = &unwinds[--current_unwind];
stack_position(info->stack_depth);
call_frame->set_ip(info->target_ip);
cache_ip(info->target_ip);
goto continue_to_run;
} else {
call_frame->scope->flush_to_heap(state);
return NULL;
}
case cBreak:
// If we're trying to break to here, we're done!
if(th->destination_scope() == call_frame->scope->on_heap()) {
stack_push(th->raise_value());
th->clear_break();
goto continue_to_run;
// Don't return here, because we want to loop back to the top
// and keep running this method.
}
// Otherwise, fall through and run the unwinds
case cReturn:
case cCatchThrow:
// Otherwise, we're doing a long return/break unwind through
// here. We need to run ensure blocks.
while(current_unwind > 0) {
UnwindInfo* info = &unwinds[--current_unwind];
stack_position(info->stack_depth);
if(info->for_ensure()) {
stack_position(info->stack_depth);
call_frame->set_ip(info->target_ip);
cache_ip(info->target_ip);
// Don't reset ep here, we're still handling the return/break.
goto continue_to_run;
}
}
// Ok, no ensures to run.
if(th->raise_reason() == cReturn) {
call_frame->scope->flush_to_heap(state);
// If we're trying to return to here, we're done!
if(th->destination_scope() == call_frame->scope->on_heap()) {
Object* val = th->raise_value();
th->clear_return();
return val;
} else {
// Give control of this exception to the caller.
return NULL;
}
} else { // It's cBreak thats not for us!
call_frame->scope->flush_to_heap(state);
// Give control of this exception to the caller.
return NULL;
}
case cExit:
call_frame->scope->flush_to_heap(state);
return NULL;
default:
break;
} // switch
std::cout << "bug!\n";
call_frame->print_backtrace(state);
abort();
return NULL;
}