示例#1
0
文件: compile.c 项目: 4ukuta/core
static void debug_compile( int which, char * s, FRAME * frame )
{
    static int level = 0;
    static char indent[36] = ">>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|";

    if ( which >= 0 )
    {
        int i;

        print_source_line( frame->procedure );

        i = ( level + 1 ) * 2;
        while ( i > 35 )
        {
            fputs( indent, stdout );
            i -= 35;
        }

        printf( "%*.*s ", i, i, indent );
    }

    if ( s )
        printf( "%s ", s );

    level += which;
}
示例#2
0
文件: compile.c 项目: 4ukuta/core
static void argument_error( char * message, RULE * rule, FRAME * frame, LIST* arg )
{
    LOL * actual = frame->args;
    assert( frame->procedure != 0 );
    backtrace_line( frame->prev );
    printf( "*** argument error\n* rule %s ( ", frame->rulename );
    lol_print( rule->arguments->data );
    printf( " )\n* called with: ( " );
    lol_print( actual );
    printf( " )\n* %s %s\n", message, arg ? arg->string : "" );
    print_source_line( rule->procedure );
    printf( "see definition of rule '%s' being called\n", rule->name );
    backtrace( frame->prev );
    exit( 1 );
}
示例#3
0
文件: error.c 项目: optixx/vasm
static void error(int n,va_list vl,struct err_out *errlist,int offset)
{
  static source *last_err_source = NULL;
  static int last_err_no;
  static int last_err_line;
  FILE *f;
  const char *msgkind;
  int lineno;
  int msgno;
  int flags=errlist[n].flags;

  if ((flags&DONTWARN) || ((flags&WARNING) && no_warn))
    return;

  if (last_err_source) {
    /* avoid printing the same error again and again, which might happen
       when a line is evaluated in multiple passes */
    if (cur_src!=NULL && cur_src==last_err_source &&
       cur_src->line==last_err_line &&
       n+offset==last_err_no)
      return;
  }

  if ((flags&MESSAGE) && !(flags&(WARNING|ERROR|FATAL)))
    f = stdout;  /* print messages to stdout */
  else
    f = stderr;  /* otherwise stderr */

  if (cur_src) {
    last_err_source = cur_src;
    last_err_line = cur_src->line;
    last_err_no = n + offset;
  }
  fprintf(f,"\n");

  if (cur_listing)
    cur_listing->error = n + offset;

  if (flags & ERROR) {
    ++errors;
    if(max_errors!=0 && errors>max_errors){
      fprintf(f,"***maximum number of errors reached!***\n");
      leave();
    }
    msgkind = "error";
  }
  else if (flags & WARNING)
    msgkind = "warning";
  else if (flags & MESSAGE)
    msgkind = "message";
  else
	msgkind = "info";

  msgno = n+offset;

  if (!(flags & NOLINE) && cur_src!=NULL)
	  fprintf(f,"%s(%d): ", cur_src->name, cur_src->line);

  fprintf(f,"%s%s %d: ", (flags & FATAL) ? "fatal " : "", msgkind, msgno);

  vfprintf(f,errlist[n].text,vl);
  fprintf(f,"\n");

  if (!(flags & NOLINE) && cur_src!=NULL) {
    if (cur_src->parent != NULL) {
      source *parent,*child;
    
      child = cur_src;
      while (parent = child->parent) {
        if (child->num_params >= 0)
          fprintf(f,"\tcalled");    /* macro called from */
        else
          fprintf(f,"\tincluded");  /* included from */
        fprintf(f," from line %d of \"%s\"\n",child->parent_line,parent->name);
        child = parent;
      }
    }
    print_source_line(f);
  }

  if (flags & FATAL) {
    fprintf(f,"aborting...\n");
    leave();
  }
}