Ejemplo n.º 1
0
Variant f_exit(CVarRef status /* = null_variant */) {
  if (status.isString()) {
    echo(status.toString());
    throw ExitException(0);
  }
  throw ExitException(status.toInt32());
}
Ejemplo n.º 2
0
void Sys::Error(Str::StringRef message)
{
	// Only try sending an ErrorMsg once
	static std::atomic_flag errorEntered;
	if (!errorEntered.test_and_set()) {
		// Disable checks for sending sync messages when handling async messages.
		// At this point we don't really care since this is an error.
		VM::rootChannel.canSendSyncMsg = true;

		// Try to tell the engine about the error, but ignore errors doing so.
		try {
			VM::SendMsg<VM::ErrorMsg>(message);
		} catch (...) {}
	}

#ifdef BUILD_VM_IN_PROCESS
	// Then engine will close the root socket when it wants us to exit, which
	// will trigger an error in the IPC functions. If we reached this point then
	// we try to exit the thread semi-cleanly by throwing an exception.
	throw ExitException();
#else
	// The SendMsg should never return since the engine should kill our process.
	// Just in case it doesn't, exit here.
	_exit(255);
#endif
}
Ejemplo n.º 3
0
void Coroutine::swap() {
// Swaps control to this coroutine, causing the current coroutine to suspend.
// This function returns when another coroutine swaps back to this coroutine.
// If a coroutine dies it is asleep, then it throws an ExitException, which
// will cause the coroutine to exit.
    Coroutine* current = coroCurrent;
    switch (status_) {
    case Coroutine::DELETED: break;
    case Coroutine::RUNNABLE: status_ = Coroutine::RUNNING; break;
    case Coroutine::NEW: status_ = Coroutine::RUNNING; break;
    case Coroutine::BLOCKED: status_ = Coroutine::RUNNING; break;
    case Coroutine::RUNNING: return; // already running
    case Coroutine::EXITED: assert(!"coroutine is dead"); break;
    default: assert(!"illegal state"); break;
    }
    coroCurrent = this;
    coroSwapContext(current, this);
    switch (coroCurrent->status_) {
    case Coroutine::DELETED: if (!coroCurrent->isMain()) { throw ExitException(); } break;
    case Coroutine::RUNNING: break; 
    case Coroutine::RUNNABLE: // fallthrough
    case Coroutine::BLOCKED: // fallthrough
    case Coroutine::NEW: // fallthrough
    case Coroutine::EXITED: // fallthrough
    default: assert(!"illegal state"); break;
    }
}
Ejemplo n.º 4
0
bool ExitIterator::nextImpl(store::Item_t& result, PlanState& planState) const 
{
  PlanIteratorState* state;
  DEFAULT_STACK_INIT(PlanIteratorState, state, planState);

  throw ExitException(new PlanIteratorWrapper(theChild, planState));
    
  STACK_END(state);
}
Ejemplo n.º 5
0
static Variant HHVM_FUNCTION(assert, const Variant& assertion,
                             const Variant& message /* = null */) {
  if (!s_option_data->assertActive) return true;

  CallerFrame cf;
  Offset callerOffset;
  auto const fp = cf(&callerOffset);

  auto const passed = [&]() -> bool {
    if (assertion.isString()) {
      if (RuntimeOption::EvalAuthoritativeMode) {
        // We could support this with compile-time string literals,
        // but it's not yet implemented.
        throw_not_supported("assert()",
          "assert with strings argument in RepoAuthoritative mode");
      }
      return eval_for_assert(fp, assertion.toString()).toBoolean();
    }
    return assertion.toBoolean();
  }();
  if (passed) return true;

  if (!s_option_data->assertCallback.isNull()) {
    auto const unit = fp->m_func->unit();

    PackedArrayInit ai(3);
    ai.append(String(const_cast<StringData*>(unit->filepath())));
    ai.append(Variant(unit->getLineNumber(callerOffset)));
    ai.append(assertion.isString() ? assertion : empty_string_variant_ref);
    HHVM_FN(call_user_func)(s_option_data->assertCallback, ai.toArray());
  }
  if (s_option_data->assertException) {
    if (message.isObject()) {
      Object exn = message.toObject();
      if (exn.instanceof(SystemLib::s_AssertionErrorClass)) {
        throw_object(exn);
      }
    }

    SystemLib::throwExceptionObject(message.toString());
  }
  if (s_option_data->assertWarning) {
    String name(message.isNull() ? "Assertion" : message.toString());
    auto const str = !assertion.isString()
      ? " failed"
      : concat3(" \"",  assertion.toString(), "\" failed");
    raise_warning("assert(): %s%s", name.data(),  str.data());
  }
  if (s_option_data->assertBail) {
    throw ExitException(1);
  }

  return init_null();
}
Ejemplo n.º 6
0
 bool
 Exit::operator()(std::pair<IOperand *, IOperand *> &, bool const)
 {
   throw ExitException();
   return ("Dymethy" && "Lamine");
 }
Ejemplo n.º 7
0
void ExitCommand::execute(long time)
{
	throw ExitException();
}
Ejemplo n.º 8
0
boost::uint32_t Player::getControllerState(const Uint8 *keyboardState) const throw (ExitException)
{
	boost::uint32_t state(0);

	if (kmap)
	{
		if (keyboardState[kmap->getSDLKey(KEY_L)] == SDL_PRESSED) state |= SNES_TL_MASK;
		if (keyboardState[kmap->getSDLKey(KEY_R)] == SDL_PRESSED) state |= SNES_TR_MASK;

		if (keyboardState[kmap->getSDLKey(KEY_X)] == SDL_PRESSED) state |= SNES_X_MASK;
		if (keyboardState[kmap->getSDLKey(KEY_Y)] == SDL_PRESSED) state |= SNES_Y_MASK;
		if (keyboardState[kmap->getSDLKey(KEY_B)] == SDL_PRESSED) state |= SNES_B_MASK;
		if (keyboardState[kmap->getSDLKey(KEY_A)] == SDL_PRESSED) state |= SNES_A_MASK;

		if (keyboardState[kmap->getSDLKey(KEY_START)] == SDL_PRESSED)  state |= SNES_START_MASK;
		if (keyboardState[kmap->getSDLKey(KEY_SELECT)] == SDL_PRESSED) state |= SNES_SELECT_MASK;

		if (keyboardState[kmap->getSDLKey(KEY_UP)] == SDL_PRESSED)    state |= SNES_UP_MASK;
		if (keyboardState[kmap->getSDLKey(KEY_DOWN)] == SDL_PRESSED)  state |= SNES_DOWN_MASK;
		if (keyboardState[kmap->getSDLKey(KEY_LEFT)] == SDL_PRESSED)  state |= SNES_LEFT_MASK;
		if (keyboardState[kmap->getSDLKey(KEY_RIGHT)] == SDL_PRESSED) state |= SNES_RIGHT_MASK;
	}
	else
	{
		PluggedJoystick &j = *joystick;
		static bool turbo(false);
		static int OldSkipFrame(0);

		if (j[JB_L]) state |= SNES_TL_MASK;
		if (j[JB_R]) state |= SNES_TR_MASK;

		if (j[JB_X]) state |= SNES_X_MASK;
		if (j[JB_Y]) state |= SNES_Y_MASK;
		if (j[JB_B]) state |= SNES_B_MASK;
		if (j[JB_A]) state |= SNES_A_MASK;

		if (j[JB_START]) state |= SNES_START_MASK;
		if (j[JB_SELECT]) state |= SNES_SELECT_MASK;

		if (j[JA_LR] == LEFT)  state |= SNES_LEFT_MASK;
		if (j[JA_LR] == RIGHT) state |= SNES_RIGHT_MASK;
		if (j[JA_UD] == UP)    state |= SNES_UP_MASK;
		if (j[JA_UD] == DOWN)  state |= SNES_DOWN_MASK;

		if (j[JB_QUIT])
			throw ExitException();

		if (!j[JB_ACCEL])
		{
			if (turbo)
			{
				turbo = false;
				Settings.SkipFrames = OldSkipFrame;
			}
		}
		else
		{
			if (!turbo)
			{
				turbo = true;
				OldSkipFrame = Settings.SkipFrames;
				Settings.SkipFrames = 10;
			}
		}
	}

	return state;
}