pike.git / src / dynamic_load.c

version» Context lines:

pike.git/src/dynamic_load.c:7:   #ifndef NO_PIKE_INCLUDES   # include "global.h"   # include "interpret.h"   # include "constants.h"   # include "pike_error.h"   # include "module.h"   # include "stralloc.h"   # include "pike_macros.h"   # include "main.h"   # include "constants.h" + # include "language.h" + # include "lex.h"    - RCSID("$Id: dynamic_load.c,v 1.58 2002/01/30 22:06:04 marcus Exp $"); + RCSID("$Id: dynamic_load.c,v 1.59 2002/01/31 17:52:14 marcus Exp $");      #else /* TESTING */      #include <stdio.h>      #endif /* !TESTING */      #ifdef HAVE_ERRNO_H   #include <errno.h>   #endif /* HAVE_ERRNO_H */
pike.git/src/dynamic_load.c:325: Inside #if defined(USE_DYNAMIC_MODULES) and #if defined(NO_CAST_TO_FUN)
   void *ptr;    modfun fun;    } u;    u.ptr = ptr;    return u.fun;   }   #else /* !NO_CAST_TO_FUN */   #define CAST_TO_FUN(X) ((modfun)X)   #endif /* NO_CAST_TO_FUN */    - static void cleanup_compilation_depth(int *save_depth_p) + struct compilation_save   { -  +  struct lex lex; +  int compilation_depth; + }; +  + static void cleanup_compilation(struct compilation_save *save) + {    free_program(end_program()); -  compilation_depth=*save_depth_p; +  free_string(lex.current_file); +  compilation_depth = save->compilation_depth; +  lex = save->lex;   }      /*! @decl int load_module(string module_name)    *!    *! Load a binary module.    *!    *! This function loads a module written in C or some other language    *! into Pike. The module is initialized and any programs or constants    *! defined will immediately be available.    *!
pike.git/src/dynamic_load.c:360:    extern int compilation_depth;    extern int global_callable_flags;       void *module;    modfun init, exit;    struct module_list *new_module;    const char *module_name;       ONERROR err;    -  int save_depth=compilation_depth; +  struct compilation_save save;       if(sp[-args].type != T_STRING)    Pike_error("Bad argument 1 to load_module()\n");       module_name = sp[-args].u.string->str;       /* Removing RTLD_GLOBAL breaks some PiGTK themes - Hubbe */    /* Using RTLD_LAZY is faster, but makes it impossible to    * detect linking problems at runtime..    */
pike.git/src/dynamic_load.c:413:    }    }       new_module=ALLOC_STRUCT(module_list);    new_module->next=dynamic_module_list;    dynamic_module_list=new_module;    new_module->module=module;    new_module->init=init;    new_module->exit=exit;    +  save.lex = lex; +  lex.current_line=1; +  lex.current_file=make_shared_string("-"); +  save.compilation_depth=compilation_depth;    compilation_depth=-1;    start_new_program();       global_callable_flags|=CALLABLE_DYNAMIC;      #ifdef PIKE_DEBUG    { struct svalue *save_sp=sp;   #endif -  SET_ONERROR(err, cleanup_compilation_depth, &save_depth); +  SET_ONERROR(err, cleanup_compilation, &save);    (*(modfun)init)();    UNSET_ONERROR(err);   #ifdef PIKE_DEBUG    if(sp != save_sp)    fatal("load_module(%s) left %ld droppings on stack!\n",    module_name,    PTRDIFF_T_TO_LONG(sp - save_sp));    }   #endif       pop_n_elems(args);    push_program(end_program()); -  compilation_depth=save_depth; +  free_string(lex.current_file); +  compilation_depth = save.compilation_depth; +  lex = save.lex;   }      #endif /* USE_DYNAMIC_MODULES */         void init_dynamic_load(void)   {   #ifdef USE_DYNAMIC_MODULES    if (dlinit()) {