コード例 #1
0
ファイル: exception.c プロジェクト: mtmiron/toi
VALUE
throw_exc(VALUE self, int argc, VALUE *argv)
{
	/* argv[0] == VALUE string descrip; argv[1] == optional
	   exception class being thrown (default `Exception') */
	int i, len;
	VALUE buf, thr, ret, exc_type;
	VALUE exc;

	thr = cur_thr;
	exc = THREAD(thr)->excobj;

	while (!TEST(exc) && TEST(thr))
	{
		thr = THREAD(thr)->up;
		if (TEST(thr))
			exc = THREAD(thr)->excobj;
		else
			exc = Qnil;
	}

	if (!TEST(exc))
	{
		if ( (argc > 0) && argv[0] && (TYPE(argv[0]) == T_STRING) )
			fail(str2cstr(argv[0]));
		else
			fail("unhandled exception");
	}

	if ((argc > 0) && (argv[0]) && TEST(argv[0]))
		EXCEPTION(exc)->strerror = argv[0];
	else
		EXCEPTION(exc)->strerror = string_new("(details of exception unspecified)");

	if (argc > 1)
		exc_type = argv[1];
	else
		exc_type = cException;

	if (!TEST(exc) || !kind_of_p(exc, exc_type))
		fail("uncaught exception");

	if (TEST(EXCEPTION(exc)->rescue_thr))
	{
		thr = cur_thr;
		cur_thr = EXCEPTION(exc)->rescue_thr;
		eval_stack( THREAD(EXCEPTION(exc)->rescue_thr)->stack );
		ret = Qbreak;
		cur_thr = thr;
	}
	else
	{
		ret = THREAD(cur_thr)->last;
		cur_thr = EXCEPTION(exc)->thr;
	}

	return ret;
}
コード例 #2
0
ファイル: compound.c プロジェクト: jhbadger/xlispstat
/* internal predicate */
int compoundp P1C(LVAL, x)
{
  switch (ntype(x)) {
  case FIXNUM:
  case FLONUM:
  case COMPLEX:
    return(FALSE);
  case CONS:
    return(TRUE);
  case DARRAY:
    x = getdarraydata(x);
    if (stringp(x))
      return(FALSE);
    /* fall through */
  case VECTOR:
  case TVEC:
    return(gettvecsize(x) > 0 ? TRUE :FALSE);
  case OBJECT:
    return(kind_of_p(x, getvalue(s_compound_data_proto)));
  default:
    return(FALSE);
  }
}
コード例 #3
0
ファイル: menus.c プロジェクト: jhbadger/xlispstat
/* is this a menu item ? */
int menu_item_p P1C(LVAL, x)
{
  return(kind_of_p(x, getvalue(s_menu_item_proto)));
}