Branch: Tag:

1999-11-04

1999-11-04 02:35:31 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Added support to specify an error handler to compile() et al.

Rev: lib/master.pike.in:1.66
Rev: src/language.yacc:1.129
Rev: src/program.c:1.170
Rev: src/program.h:1.65

5:   \*/   /**/   #include "global.h" - RCSID("$Id: program.c,v 1.169 1999/10/29 00:09:47 hubbe Exp $"); + RCSID("$Id: program.c,v 1.170 1999/11/04 02:35:28 grubba Exp $");   #include "program.h"   #include "object.h"   #include "dynamic_buffer.h"
111:   struct program *new_program=0;   struct object *fake_object=0;   struct program *malloc_size_program=0; + struct object *error_handler=0;      int compiler_pass;   int compilation_depth;
2628:    va_end(args);   }    - struct program *compile(struct pike_string *prog) + struct program *compile(struct pike_string *prog, struct object *handler)   {   #ifdef PIKE_DEBUG    JMP_BUF tmp;
2637:    struct lex save_lex;    int save_depth=compilation_depth;    int saved_threads_disabled; +  struct object *saved_handler = error_handler;    dynamic_buffer used_modules_save = used_modules;    INT32 num_used_modules_save = num_used_modules;    extern void yyparse(void);
2644:    CDFPRINTF((stderr, "th(%ld) compile() starting compilation_depth=%d\n",    (long)th_self(),compilation_depth));    +  error_handler = handler; +     low_init_threads_disable();    saved_threads_disabled = threads_disabled;   
2754:    compilation_depth=save_depth;    used_modules = used_modules_save;    num_used_modules = num_used_modules_save ; +  error_handler = saved_handler;      #ifdef PIKE_DEBUG    UNSETJMP(tmp);
3270:    if(strlen(buf)>sizeof(buf))    fatal("Buffer overfloat in yywarning!\n");    -  if(get_master()) -  { +  if ((error_handler && error_handler->prog) || get_master()) {    ref_push_string(lex.current_file);    push_int(lex.current_line);    push_text(buf); -  +  +  if (error_handler && error_handler->prog) { +  safe_apply(error_handler, "compile_warning", 3); +  } else {    SAFE_APPLY_MASTER("compile_warning",3); -  +  }    pop_stack();    }   }