Ejemplo n.º 1
0
Archivo: pb-io.c Proyecto: mpw/p2
static char *
pclass_string1 (PCLASS pclass, IDENT *i)
{
  char *s = (char *) xmalloc_atomic(MAX_IDENT_LEN+10);

  switch (pclass) {
  case CON:
  case GCON:
  case CUR:
  case GCUR:
  case KCUR:
  case SCH:
  case STR:
#ifndef NDEBUG
    if (i == NULL || i->ctype == NULL || i->ctype->ident == NULL
        || i->ctype->ident->name == NULL)
      assertion_failed("structure has incomplete ctype");
#endif
    sprintf(s, "struct %s", i->ctype->ident->name);
    return(s);
  case UNI:
#ifndef NDEBUG
    if (i == NULL || i->ctype == NULL || i->ctype->ident == NULL
        || i->ctype->ident->name == NULL)
      assertion_failed("union has incomplete ctype");
#endif
    sprintf(s, "union %s", i->ctype->ident->name);
    return(s);
  case VOI: return("void");
#if 0
  case CTQ: return("const");
  case VTQ: return("volatile");
#endif
  case CHA: return("char");
  case VCHA: return("char");
  case SHO: return("short");
  case ENU:
#ifndef NDEBUG
    if (i == NULL || i->ctype == NULL || i->ctype->ident == NULL
        || i->ctype->ident->name == NULL)
      assertion_failed("enumeration has incomplete ctype");
#endif
    sprintf(s, "enum %s", i->ctype->ident->name);
    return(s);
  case IN:   return("int");
  case LON:  return("long");
  case LLON: return("long long");
  case FLO:  return("float");
  case DOU:  return("double");
  case LDOU: return("long double");
  default:
#ifndef NDEBUG
    assertion_failed("nonprintable pclass, value = %d", pclass);
#endif
    return(NULL);
  }
}
Ejemplo n.º 2
0
Archivo: xform.c Proyecto: mpw/p2
static void
assert_layerdef_valid (const LAYER_DEF *layerdef)
{
  if (layerdef == NULL)
    assertion_failed("NULL layerdef");
  if (layerdef->layer_name == NULL)
    assertion_failed("NULL layer_name");
  if (((int)layerdef->layer_realm < MIN_RCLASS) || 
      layerdef->layer_realm > MAX_RCLASS) 
    assertion_failed("illegal layer_realm = %d", layerdef->layer_realm);
}
Ejemplo n.º 3
0
Archivo: pb-io.c Proyecto: mpw/p2
void
sprint_decl1 (char *s, size_t *len, IDENT *i, BOOLEAN print_semicolon)
{
  CTYPE *ctype = i->ctype;

#ifndef NDEBUG
  assert_ctype_valid(ctype);
#endif

  /* We don't want to print anything if i is a forward reference, since
  a forward reference (although creating an entry in the symbol table)
  is not a declaration. */

#ifndef NDEBUG
  if (i->forward)
    assertion_failed("tried to print forward reference %s", i->name);
  if (ctype == NULL)
    assertion_failed("identifier has null ctype");
#endif

  /* Only print something if there is anything worth printing. */
  
  if (!i->defaulted
      || i->sclass != UND
      || ctype->uclass != ERR
      || i->initializer != NULL) {
    
    char *t;

    /* Print sclass (ie storage class, eg register). */
    t = sclass_string1(i->sclass); 
    if (strcmp(t, "") != 0) {
      print1(s, len, t);
      print2(s, len, " ", 1);
    }
    
    /* Print uclass (ie signed/unsigned). */
    t = uclass_string(ctype->uclass);
    if (strcmp(t, "") != 0) {
      print1(s, len, t);
      print2(s, len, " ", 1);
    }
    
    /* Print rest of declaration. */
    sprint_decl2(s, len, i);
    if (print_semicolon)
      print2(s, len, ";", 1);
  }
}
Ejemplo n.º 4
0
Archivo: pb-xform.c Proyecto: mpw/p2
BOOLEAN
is_member_of (IDENT *s, char *f)
{
  MCURSOR *mcurs = new_mcursor(s);
  char    field[MAX_IDENT_LEN];
  char    *p;

#ifndef NDEBUG
  if (!(aggregate_ctype(s->ctype)))
    assertion_failed("arg 1 to is_member_of must be an aggregate");
#endif /* NDEBUG */

  if (s->members == NULL)
    return(FALSE);

  /* The string f is a field designator, but it also might include index
     offsets, such as in "next2[4]".  We need to strip off the string "[4]"
     in order to do the membership test comparison.  The first step is to
     strip is part of the field string off (DSB). */

  strcpy(field, f);
  p = strchr(field, '[');
  if (p)
    *p = '\0';

  /* Search the list of fields */

  FOREACH_MEMBER(mcurs) {
    if (strcmp(name_of(mcurs),field) == 0)
      return(TRUE);
  }
  return(FALSE);
}
Ejemplo n.º 5
0
Archivo: xform.c Proyecto: mpw/p2
void
assert_te_valid (const TE *te)
{
#ifndef NDEBUG
  if (te == NULL)
    assertion_failed("NULL type expression ");
  assert_layerdef_valid(te->layerdef);
#if 0
  if (te->layerno == 0) {
    char *layer_name = te->layerdef->layer_name;
    if (strcmp(layer_name, "conceptual") != 0)
      assertion_failed("Top layer %s must be conceptual", layer_name);
  }
#endif
#endif /* NDEBUG */
}
Ejemplo n.º 6
0
 void operator()(const std::string& msg_, bool v_) const
 {
   if (!v_)
   {
     throw assertion_failed(msg_, _filename, _line);
   }
 }
Ejemplo n.º 7
0
bool assert_fail(const char* expression, const char* file, const int line, const char* function)
{
	std::stringstream message;
	message << file << ":" << line << ": ";
	message << "assertion failed: ";
	message << expression;
	throw assertion_failed(message.str());
}
Ejemplo n.º 8
0
Archivo: pb-io.c Proyecto: mpw/p2
static char *
uclass_string (UCLASS uclass)
{
  switch (uclass) {
  case UND: return("");
  case SIG: return("signed");
  case UNS: return("unsigned");
  default:
#ifndef NDEBUG
    assertion_failed("nonprintable uclass, value = %d", uclass);
#endif
    return(NULL);
  }
}
Ejemplo n.º 9
0
Archivo: pb-io.c Proyecto: mpw/p2
char *
direction_string (int direction)
{
  switch (direction) {
  case -1: return("descending");
  case  0: return("");
  case  1: return("ascending");
  default:
#ifndef NDEBUG
    assertion_failed("nonprintable direction, value = %d", direction);
#endif
    return(NULL);
  }
}
Ejemplo n.º 10
0
Archivo: util.c Proyecto: mpw/p2
void machine_setup (void)
{
#if HAVE_SYS_SYSMIPS_H
  /* Disable address fixups for this process (inherited by any children).
      Where a fixup would have occured, you will get a SIGBUS.
      See comp.unix.ultrix_Common_Frequently_Asked_Questions. (JAT) */
#if ASSERTION_FAILED
  if (syscall(SYS_sysmips, MIPS_FIXADE, 0, NULL, NULL, NULL) == -1)
    assertion_failed("syscall failed");
#else
  syscall(SYS_sysmips, MIPS_FIXADE, 0, NULL, NULL, NULL);
#endif
#endif
}
Ejemplo n.º 11
0
Archivo: pb-io.c Proyecto: mpw/p2
char *
rclass_enum_const_string (RCLASS rclass)
{
  switch (rclass) {
  case DS:  return("DS");
  case TOP: return("TOP");
  case MEM: return("MEM");
  default:
#ifndef NDEBUG
    assertion_failed("nonprintable rclass, value = %d", rclass);
#endif
    return(NULL);
  }
}
Ejemplo n.º 12
0
Archivo: seen.c Proyecto: mpw/p2
void
operation_seen (SPECIAL_OP op)
{
  int q = getindxop(op); 
  if (! op_exists_in_realm(op, layer_realm)) 
    assertion_failed("op %s is not in realm %d", 
                     op_tab[q].name, layer_realm);
  q = getindxop(op);

  if (seen[op])
    parse_error("multiple %s procs", op_tab[q].name);
  else
    seen[op] = TRUE;
}
Ejemplo n.º 13
0
Archivo: pb-io.c Proyecto: mpw/p2
static char *
qclass_string (QCLASS qclass)
{
  switch (qclass)
  {
    case CTQ: return("const");
    case VTQ: return("volatile");
    case UND: return("");
    default:
#ifndef NDEBUG
      assertion_failed("nonprintable qclass, value = %d", qclass);
#endif
      return(NULL);
  }
}
Ejemplo n.º 14
0
Archivo: pb-xform.c Proyecto: mpw/p2
IDENT *
new_struct (char *name, BOOLEAN add_to_symtab)
{
  CTYPE *c = STRUCT_CTYPE;
  IDENT *i = new_ident(SUE, name, c, NULL, FALSE);
  c->ident = i;
  if (add_to_symtab)
  {
#ifndef NDEBUG
    ENTRY *e = symtab_lookup(symtab[SUE], name);
    if (e != NULL && e->ident->scope == scope)
      assertion_failed("struct %s already exists in scope", name);
#endif /* NDEBUG */
    add_ident_to_symtab1(symtab[SUE], i);
  }
  return(i);
}
Ejemplo n.º 15
0
Archivo: pb-io.c Proyecto: mpw/p2
static char *
sclass_string1 (SCLASS sclass)
{
  switch (sclass) {
  case UND: return("");
  case TDF: return("typedef");
  case EXT: return("extern");
  case STA: return("static");
  case AUT: return("auto");
  case REG: return("register");
  default:
#ifndef NDEBUG
    assertion_failed("nonprintable sclass, value = %d", sclass);
#endif
    return(NULL);
  }
}
Ejemplo n.º 16
0
Archivo: pb-xform.c Proyecto: mpw/p2
KC_STATE *
lookup_kc_state (TE *te, int id, char *expr, BOOLEAN c)
{
  KC_STATE *kc = (c) ? te->cursor_state : te->container_state;

  while (kc) {
    if (kc->id == id && kc->layerno == te->layerno)
      return(kc);
    kc = kc->next;
  }

#ifndef NDEBUG
  assertion_failed("no %s_state record found for %s = %s, id = %d, "
                   "layerno = %d, layer_name = %s",
                   (c) ? "c" : "k", (c) ? "cursor" : "container",
                   expr, id, te->layerno, te->layer_name);
#endif /* NDEBUG */

  /* Should be an error--no state record found. (DSB) */
  return(NULL);
}
Ejemplo n.º 17
0
Archivo: ref-util.c Proyecto: mpw/p2
static char *
get_realm_param (char *s)
{
  char *result = NULL;
  if (params_rlist != NULL) {
    int i = get_path_num(s);
    RLIST *p;

    for (p = params_rlist; i > 0; p = p->next, i--);

    switch (p->type) {
    case DS:
      result = "DS";
      break;
    case MEM:
      result = "MEM"; 
      break;
    case TOP:
      result = "TOP";
      break;
    case TOPLINK:
      result = "TOPLINK";
      break;
    case LINK:
      result = "LINK";
      break;
    case BOTTOM:
      result = "BOTTOM";
      break;
#ifndef NDEBUG
    default:
      assertion_failed("illegal realm param %d", p->type);
#endif
    }
  }
  return(result);
}
Ejemplo n.º 18
0
void uspi_assertion_failed (const char *pExpr, const char *pFile, unsigned nLine)
{
	assertion_failed (pExpr, pFile, nLine);
}
Ejemplo n.º 19
0
 /** @brief assertionしないか判定する。
     @param[in] in_condition assertionしないかどうか。
     @param[in] in_message   assertionしたとき、consoleに出力する文字列。
     @retval true  assertionしなかった。
     @retval false assertionした。
  */
 inline PSYQ_CONSTEXPR bool assertion_check(
     bool const in_condition,
     char const* const in_message)
 {
     return in_condition? true: assertion_failed(in_message);
 }
Ejemplo n.º 20
0
Archivo: pb-io.c Proyecto: mpw/p2
void
sprint_decl3 (char *s, size_t *len, int j, IDENT *i)
{
  char *leftp, *rightp;
  PTYPE *ptype;
  PCLASS pclass;
  QCLASS qclass;

  if (j == 0)
  {
    /* Normal cases. */

    if (i->pname != NULL)
      print1(s, len, i->pname);
    else if (i->name != NULL)
      print1(s, len, i->name);

    /* Special case for printing error messages
       where i has a ctype, but not a name. (JAT) */

    delete_trailing_space1(s, len);
  }
  else if (j > 0)
  {
    j--;
    {
      ptype = (*i->ctype->stype)[j];
      assert_ptype_valid(ptype);
      pclass = ptype->pclass;
      qclass = ptype->qclass;
      if ((j == 0)
          || (pclass == PTR)
          || (pclass == (*i->ctype->stype)[j-1]->pclass)
#if 0
          || ((*i->ctype->stype)[j-1]->pclass == CTQ)
          || ((*i->ctype->stype)[j-1]->pclass == VTQ)
#endif
         )
      {
        /* Don't print (redundant or illegal) parenthesis. */
        leftp = "";
        rightp = "";
      }
      else
      {
        /* Print (possibly redundant) parenthesis. */
        leftp = "(";
        rightp = ")";
      }
      /* Print derrived type. */
      switch (pclass)
      {
      case FUN: 
        print1(s, len, leftp);
        sprint_decl3(s, len, j, i);
        print1(s, len, rightp);
        /* Don't print redundant function declaration parenthesis. */
        if (j == i->ctype->len-2 || (*i->ctype->stype)[j+1]->pclass != FUN) {
          print2(s, len, " ( ", 3);
          print_ptree1(s, len, ptype->supp);
          print2(s, len, " )", 2);
        }
        break;
      case ARR:
        print1(s, len, leftp);
        sprint_decl3(s, len, j, i);
        print1(s, len, rightp);
        print2(s, len, "[", 1);
        print_ptree1(s, len, ptype->supp);
        print2(s, len, "]", 1);
        break;
      case PTR:
        print2(s, len, "*", 1);
        /* Print type qualifier. */
        if (qclass != UND)
        {
          print1(s, len, qclass_string(qclass));
          print2(s, len, " ", 1);
        }
        print1(s, len, leftp);
        sprint_decl3(s, len, j, i);
        print1(s, len, rightp);
        break;
#if 0
      case CTQ:
      case VTQ:
        /* Here, I assume that type qualifiers do not
           need to be parenthesized (JAT) */
        print1(s, len, pclass_string1(pclass, i));
        print2(s, len, " ", 1);
        sprint_decl3(s, len, j, i);
        break;
#endif
      default:
#ifndef NDEBUG
        assertion_failed("nonprintable derrived type pclass value = %d", pclass);
#endif
        break;
      }
    }    
  }
}
Ejemplo n.º 21
0
Archivo: pb-io.c Proyecto: mpw/p2
void
sprint_decl2 (char *s, size_t *len, IDENT *i)
{
  PTYPE *ptype;
  PCLASS pclass;
  QCLASS qclass;
  ENTRY *e;

#ifndef NDEBUG
  if (i->ctype->len == 0)
    assertion_failed("ctype len value = 0");
#endif

  ptype = base_ptype(i->ctype);
  assert_ptype_valid(ptype);
  pclass = ptype->pclass;
#if 0
  qclass = decl->qclass;
#else
  qclass = ptype->qclass;
#endif  

  /* Print type qualifier. */
  if (qclass != UND)
  {
    print1(s, len, qclass_string(qclass));
#if 0
    /* Reset decl->qclass. */
    decl->qclass = UND;
#endif
    print2(s, len, " ", 1);
  }

  /* Print base type */
  if (!i->defaulted) {
    /* Print base type. */
    print1(s, len, pclass_string1(pclass, i));
    print2(s, len, " ", 1);
  }
  
  if ((pclass == ENU) && (i->ctype->ident == i)) {
    /* Print enum declaration. */
    print2(s, len, "{ ", 2);
    print_ptree1(s, len, i->supp); /* print enumeration body */
    print2(s, len, " }", 2);
  }
  else if ((i->ctype->ident == i) && aggregate_pclass(pclass)) {
    /* Print aggregate declaration. */
    print2(s, len, "{\n", 2);
    if (i->members != NULL)
      for (e = i->members->last; e != NULL; e = e->prev) {
        sprint_decl1(s, len, e->ident, TRUE);
        print2(s, len, "\n", 1);
      }
    print2(s, len, "}", 1);
  }
  else
    /* Print derrived type. */
    sprint_decl3(s, len, (i->ctype->len)-1, i);
  
  if ((pclass != ENU) && (i->supp != NULL)) {
    /* Print bit field */
    print2(s, len, " : ", 3);
    print_ptree1(s, len, i->supp);
  }
  
  if (i->attribute != NULL) {
    /* Print GNU __attribute__ */
    print2(s, len, " ", 1);
    print_ptree1(s, len, i->attribute);
  }

  if (i->initializer != NULL) {
    /* Print initializer */
    print2(s, len, " = ", 3);
    print_ptree1(s, len, i->initializer);
  }
}
Ejemplo n.º 22
0
 utree eval (utree const& subject) const { 
   if (!predicate(subject))
     BOOST_THROW_EXCEPTION(assertion_failed());
   return utree();
 }