当前位置: 首页>>代码示例>>C++>>正文


C++ Exception::locations方法代码示例

本文整理汇总了C++中Exception::locations方法的典型用法代码示例。如果您正苦于以下问题:C++ Exception::locations方法的具体用法?C++ Exception::locations怎么用?C++ Exception::locations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Exception的用法示例。


在下文中一共展示了Exception::locations方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: call_on_object

  Object* Proc::call_on_object(STATE, CallFrame* call_frame,
                               Executable* exec, Module* mod, Arguments& args) {
    bool lambda_style = !lambda_->nil_p();
    int flags = 0;

    // Check the arity in lambda mode
    if(lambda_style) {
      flags = CallFrame::cIsLambda;
      int required = block_->code()->required_args()->to_native();

      if(args.total() < 1 || (required >= 0 && (size_t)required != args.total() - 1)) {
        Exception* exc =
          Exception::make_argument_error(state, required, args.total(), state->symbol("__block__"));
        exc->locations(state, Location::from_call_stack(state, call_frame));
        state->thread_state()->raise_exception(exc);
        return NULL;
      }
    }

    // Since we allow Proc's to be created without setting block_, we need to check
    // it.
    if(block_->nil_p()) {
      Exception* exc =
        Exception::make_type_error(state, BlockEnvironment::type, block_, "Invalid proc style");
      exc->locations(state, Location::from_call_stack(state, call_frame));
      state->thread_state()->raise_exception(exc);
      return NULL;
    }

    return block_->call_on_object(state, call_frame, args, flags);
  }
开发者ID:AndrewVos,项目名称:rubinius,代码行数:31,代码来源:proc.cpp

示例2: process_async

  bool State::process_async(CallFrame* call_frame) {
    set_call_frame(call_frame);
    vm_->clear_check_local_interrupts();

    if(vm_->run_signals_) {
      if(!vm_->shared.signal_handler()->deliver_signals(this, call_frame)) {
        return false;
      }
    }

    Exception* exc = vm_->interrupted_exception_.get();
    if(!exc->nil_p()) {
      vm_->interrupted_exception_.set(nil<Exception>());

      // Only write the locations if there are none.
      if(exc->locations()->nil_p() || exc->locations()->size() == 0) {
        exc->locations(this, Location::from_call_stack(this, call_frame));
      }

      vm_->thread_state_.raise_exception(exc);
      return false;
    }
    if(vm_->interrupt_by_kill()) {
      vm_->clear_interrupt_by_kill();
      vm_->thread_state_.raise_thread_kill();
      return false;
    }

    return true;
  }
开发者ID:Energy0124,项目名称:rubinius,代码行数:30,代码来源:state.cpp

示例3: execute

  /* Run when a NativeFunction is executed.  Executes the related C function.
   */
  Object* NativeFunction::execute(STATE, Executable* exec, Module* mod, Arguments& args) {
    NativeFunction* nfunc = as<NativeFunction>(exec);

    try {
      OnStack<2> os(state, exec, mod);
#ifdef RBX_PROFILER
      if(unlikely(state->vm()->tooling())) {
        tooling::MethodEntry method(state, exec, mod, args);
        RUBINIUS_METHOD_FFI_ENTRY_HOOK(state, mod, args.name());
        Object* ret = nfunc->call(state, args);
        RUBINIUS_METHOD_FFI_RETURN_HOOK(state, mod, args.name());
        return ret;
      } else {
        RUBINIUS_METHOD_FFI_ENTRY_HOOK(state, mod, args.name());
        Object* ret = nfunc->call(state, args);
        RUBINIUS_METHOD_FFI_RETURN_HOOK(state, mod, args.name());
        return ret;
      }
#else
      RUBINIUS_METHOD_FFI_ENTRY_HOOK(state, mod, args.name());
      Object* ret = nfunc->call(state, args);
      RUBINIUS_METHOD_FFI_RETURN_HOOK(state, mod, args.name());
      return ret;
#endif

    } catch(TypeError &e) {
      Exception* exc =
        Exception::make_type_error(state, e.type, e.object, e.reason);
      exc->locations(state, Location::from_call_stack(state));

      state->raise_exception(exc);
      RUBINIUS_METHOD_FFI_RETURN_HOOK(state, mod, args.name());
      return NULL;
    }
  }
开发者ID:Omosofe,项目名称:rubinius,代码行数:37,代码来源:native_function.cpp

示例4: execute

  /* Run when a NativeFunction is executed.  Executes the related C function.
   */
  Object* NativeFunction::execute(STATE, CallFrame* call_frame, Dispatch& msg,
                                  Arguments& args) {
    NativeFunction* nfunc = as<NativeFunction>(msg.method);

    state->set_call_frame(call_frame);

    try {

#ifdef RBX_PROFILER
      if(unlikely(state->tooling())) {
        tooling::MethodEntry method(state, msg, args);
        return nfunc->call(state, args, msg, call_frame);
      } else {
        return nfunc->call(state, args, msg, call_frame);
      }
#else
      return nfunc->call(state, args, msg, call_frame);
#endif

    } catch(TypeError &e) {
      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);
      return NULL;
    }
  }
开发者ID:AndreMeira,项目名称:rubinius,代码行数:30,代码来源:nativefunction.cpp

示例5:

  void Exception::Info::show(STATE, Object* self, int level) {
    Exception* exc = as<Exception>(self);

    class_header(state, self);
    indent_attribute(++level, "message"); exc->message()->show(state, level);
    indent_attribute(level, "locations"); exc->locations()->show_simple(state, level);
    close_body(level);
  }
开发者ID:stormbrew,项目名称:rubinius,代码行数:8,代码来源:exception.cpp

示例6: rbx_arg_error

  Object* rbx_arg_error(STATE, CallFrame* call_frame, Arguments& args, int required) {
    Exception* exc =
        Exception::make_argument_error(state, required, args.total(), args.name());
    exc->locations(state, Location::from_call_stack(state, call_frame));
    state->raise_exception(exc);

    return NULL;
  }
开发者ID:markburns,项目名称:rubinius,代码行数:8,代码来源:jit_util.cpp

示例7: rbx_arg_error

  Object* rbx_arg_error(STATE, CallFrame* call_frame, Dispatch& msg, Arguments& args,
                        int required) {
    Exception* exc =
        Exception::make_argument_error(state, required, args.total(), msg.name);
    exc->locations(state, System::vm_backtrace(state, Fixnum::from(0), call_frame));
    state->thread_state()->raise_exception(exc);

    return NULL;
  }
开发者ID:vasco,项目名称:rubinius,代码行数:9,代码来源:jit_util.cpp

示例8: call_on_object

  Object* Proc::call_on_object(STATE, Executable* exec, CallFrame* call_frame,
                               Dispatch& msg, Arguments& args) {
    bool lambda_style = !lambda_->nil_p();
    int flags = 0;

    // Check the arity in lambda mode
    if(lambda_style) {
      flags = CallFrame::cIsLambda;
      int required = block_->method()->required_args()->to_native();

      if(args.total() < 1 || (required >= 0 && (size_t)required != args.total() - 1)) {
        Exception* exc =
          Exception::make_argument_error(state, required, args.total(), state->symbol("__block__"));
        exc->locations(state, System::vm_backtrace(state, Fixnum::from(0), call_frame));
        state->thread_state()->raise_exception(exc);
        return NULL;
      }
    }

    // Since we allow Proc's to be created without setting block_, we need to check
    // it.
    if(block_->nil_p()) {
      Exception* exc =
        Exception::make_type_error(state, BlockEnvironment::type, block_, "Invalid proc style");
      exc->locations(state, System::vm_backtrace(state, Fixnum::from(0), call_frame));
      state->thread_state()->raise_exception(exc);
      return NULL;
    }

    Object* ret = block_->call_on_object(state, call_frame, args, flags);

    if(lambda_style && !ret) {
      RaiseReason reason = state->thread_state()->raise_reason();
      if(reason == cReturn || reason == cBreak) {
        // TODO investigate if we should check the destination_scope here.
        // It doesn't appear that MRI checks anything similar.
        ret = state->thread_state()->raise_value();
        state->thread_state()->clear_exception(true);
      }
    }

    return ret;
  }
开发者ID:vasco,项目名称:rubinius,代码行数:43,代码来源:proc.cpp

示例9: rbx_string_dup

  Object* rbx_string_dup(STATE, CallFrame* call_frame, Object* obj) {
    try {
      return as<String>(obj)->string_dup(state);
    } catch(TypeError& e) {
      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);
      return NULL;
    }
  }
开发者ID:jefflembeck,项目名称:rubinius,代码行数:12,代码来源:jit_util.cpp

示例10: call_prim

  Object* Proc::call_prim(STATE, Executable* exec, CallFrame* call_frame, Dispatch& msg,
                          Arguments& args) {
    bool lambda_style = RTEST(lambda_);
    int flags = 0;

    // Check the arity in lambda mode
    if(lambda_style) {
      flags = CallFrame::cIsLambda;
      int required = block_->method()->required_args()->to_native();

      bool arity_ok = false;
      if(Fixnum* fix = try_as<Fixnum>(block_->method()->splat())) {
        if(fix->to_native() == -2) {
          arity_ok = true;
        } else if(args.total() >= (size_t)required) {
          arity_ok = true;
        }

      // Bug-to-bug compatibility: when required is 1, we accept any number of
      // args. Why? No fucking clue. I guess perhaps you then get all the arguments
      // as an array?
      } else if(required == 1) {
        arity_ok = true;
      } else {
        arity_ok = ((size_t)required == args.total());
      }

      if(!arity_ok) {
        Exception* exc =
          Exception::make_argument_error(state, required, args.total(), state->symbol("__block__"));
        exc->locations(state, Location::from_call_stack(state, call_frame));
        state->thread_state()->raise_exception(exc);
        return NULL;
      }
    }

    Object* ret;
    if(bound_method_->nil_p()) {
      ret = block_->call(state, call_frame, args, flags);
    } else if(NativeMethod* nm = try_as<NativeMethod>(bound_method_)) {
      Dispatch dis(state->symbol("call"));
      dis.method = nm;
      dis.module = G(rubinius);
      ret = nm->execute(state, call_frame, dis, args);
    } else {
      Dispatch dis(state->symbol("__yield__"));
      ret = dis.send(state, call_frame, args);
    }

    return ret;
  }
开发者ID:MarkusQ,项目名称:rubinius,代码行数:51,代码来源:proc.cpp

示例11: check_thread_raise_or_kill

  bool VM::check_thread_raise_or_kill(STATE) {
    Exception* exc = interrupted_exception();

    if(!exc->nil_p()) {
      clear_interrupted_exception();

      // Only write the locations if there are none.
      if(exc->locations()->nil_p() || exc->locations()->size() == 0) {
        exc->locations(this, Location::from_call_stack(state));
      }

      thread_state_.raise_exception(exc);

      return true;
    }

    if(interrupt_by_kill()) {
      Fiber* fib = current_fiber.get();

      if(fib->nil_p() || fib->root_p()) {
        clear_interrupt_by_kill();
      } else {
        set_check_local_interrupts();
      }

      thread_state_.raise_thread_kill();

      return true;
    }

    // If the current thread is trying to step, debugger wise, then assist!
    if(thread_step()) {
      clear_thread_step();
      if(!Helpers::yield_debugger(state, cNil)) return true;
    }

    return false;
  }
开发者ID:clockmaker002,项目名称:rubinius,代码行数:38,代码来源:vm.cpp

示例12: execute

  intptr_t Interpreter::execute(STATE, MachineCode* const machine_code) {
    InterpreterState is;
    Exception* exception = 0;
    intptr_t* opcodes = (intptr_t*)machine_code->opcodes;

    CallFrame* call_frame = state->vm()->call_frame();
    call_frame->stack_ptr_ = call_frame->stk - 1;
    call_frame->machine_code = machine_code;
    call_frame->is = &is;

    try {
      return ((instructions::Instruction)opcodes[call_frame->ip()])(state, call_frame, opcodes);
    } catch(TypeError& e) {
      exception = Exception::make_type_error(state, e.type, e.object, e.reason);
      exception->locations(state, Location::from_call_stack(state));

      call_frame->scope->flush_to_heap(state);
    } catch(RubyException& exc) {
      if(exc.exception->locations()->nil_p()) {
        exc.exception->locations(state, Location::from_call_stack(state));
      }
      exception = exc.exception;
    } catch(std::exception& e) {
      exception = Exception::make_interpreter_error(state, e.what());
      exception->locations(state, Location::from_call_stack(state));

      call_frame->scope->flush_to_heap(state);
    } catch(...) {
      exception = Exception::make_interpreter_error(state, "unknown C++ exception thrown");
      exception->locations(state, Location::from_call_stack(state));

      call_frame->scope->flush_to_heap(state);
    }

    state->raise_exception(exception);
    return 0;
  }
开发者ID:chuckremes,项目名称:rubinius,代码行数:37,代码来源:interpreter.cpp

示例13: thunk_executor

  Object* Thunk::thunk_executor(STATE, CallFrame* call_frame, Dispatch& msg,
                                       Arguments& args)
  {
    Thunk* thunk = as<Thunk>(msg.method);

    if(args.total() != 0) {
      Exception* exc =
        Exception::make_argument_error(state, 0, args.total(), msg.name);
      exc->locations(state, Location::from_call_stack(state, call_frame));
      state->thread_state()->raise_exception(exc);
      return NULL;
    }

    return thunk->value();
  }
开发者ID:AndreMeira,项目名称:rubinius,代码行数:15,代码来源:thunk.cpp

示例14: thunk_executor

  Object* Thunk::thunk_executor(STATE, CallFrame* call_frame, Executable* exec, Module* mod,
                                       Arguments& args)
  {
    Thunk* thunk = as<Thunk>(exec);

    if(args.total() != 0) {
      Exception* exc =
        Exception::make_argument_error(state, 0, args.total(), args.name());
      exc->locations(state, Location::from_call_stack(state, call_frame));
      state->raise_exception(exc);
      return NULL;
    }

    return thunk->value();
  }
开发者ID:Energy0124,项目名称:rubinius,代码行数:15,代码来源:thunk.cpp

示例15: call_on_object

  Object* BlockEnvironment::call_on_object(STATE, CallFrame* call_frame,
                                           Arguments& args, int flags)
  {
    if(args.total() < 1) {
      Exception* exc =
        Exception::make_argument_error(state, 1, args.total(), state->symbol("__block__"));
      exc->locations(state, Location::from_call_stack(state, call_frame));
      state->thread_state()->raise_exception(exc);
      return NULL;
    }

    Object* recv = args.shift(state);

    BlockInvocation invocation(recv, code_->scope(), flags);
    return invoke(state, call_frame, this, args, invocation);
  }
开发者ID:BRIMIL01,项目名称:rubinius,代码行数:16,代码来源:block_environment.cpp


注:本文中的Exception::locations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。