pike.git / src / program.c

version» Context lines:

pike.git/src/program.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: program.c,v 1.676 2008/04/26 11:17:38 grubba Exp $ + || $Id: program.c,v 1.677 2008/04/26 14:27:08 grubba Exp $   */      #include "global.h"   #include "program.h"   #include "object.h"   #include "dynamic_buffer.h"   #include "pike_types.h"   #include "stralloc.h"   #include "las.h"   #include "lex.h"
pike.git/src/program.c:1220:   struct program *null_program=0;      struct program *compilation_program = 0;   struct program *compilation_env_program = 0;   struct object *compilation_environment = NULL;      struct program *gc_internal_program = 0;   static struct program *gc_mark_program_pos = 0;      int compilation_depth=-1; - dynamic_buffer used_modules; +    static struct mapping *resolve_cache=0;      #ifdef PIKE_DEBUG   #define CHECK_FILE_ENTRY(PROG, POS, LEN, SHIFT) \    do { \    if (SHIFT < 0 || SHIFT > 2 || \    POS + (LEN << SHIFT) > PROG->linenumbers + PROG->num_linenumbers) \    Pike_fatal ("Invalid file entry in linenumber info.\n"); \    } while (0)   #else
pike.git/src/program.c:1424:   #endif      void add_relocated_int_to_program(INT32 i)   {    add_to_relocations(Pike_compiler->new_program->num_program);    ins_int(i, (void (*)(char))add_to_program);   }      void use_module(struct svalue *s)   { +  struct compilation *c = THIS_COMPILATION;    if( (1<<s->type) & (BIT_MAPPING | BIT_OBJECT | BIT_PROGRAM))    { -  +  c->num_used_modules++;    Pike_compiler->num_used_modules++;    assign_svalue_no_free((struct svalue *)    low_make_buf_space(sizeof(struct svalue), -  &used_modules), s); +  &c->used_modules), s);    if(Pike_compiler->module_index_cache)    {    free_mapping(Pike_compiler->module_index_cache);    Pike_compiler->module_index_cache=0;    }    }else{    yyerror("Module is neither mapping nor object");    }   }      void unuse_modules(INT32 howmany)   { -  +  struct compilation *c = THIS_COMPILATION;    if(!howmany) return;   #ifdef PIKE_DEBUG -  if(howmany *sizeof(struct svalue) > used_modules.s.len) +  if(howmany *sizeof(struct svalue) > c->used_modules.s.len)    Pike_fatal("Unusing too many modules.\n");   #endif -  +  c->num_used_modules -= howmany;    Pike_compiler->num_used_modules-=howmany; -  low_make_buf_space(-sizeof(struct svalue)*howmany, &used_modules); -  free_svalues((struct svalue *)low_make_buf_space(0, &used_modules), +  low_make_buf_space(-sizeof(struct svalue)*howmany, &c->used_modules); +  free_svalues((struct svalue *)low_make_buf_space(0, &c->used_modules),    howmany,    BIT_MAPPING | BIT_OBJECT | BIT_PROGRAM);    if(Pike_compiler->module_index_cache)    {    free_mapping(Pike_compiler->module_index_cache);    Pike_compiler->module_index_cache=0;    }   }      int low_find_shared_string_identifier(struct pike_string *name,
pike.git/src/program.c:1542:   /* fprintf(stderr,"***Undefined.\n"); */       return 0;   }      struct node_s *resolve_identifier(struct pike_string *ident);      struct node_s *find_module_identifier(struct pike_string *ident,    int see_inherit)   { +  struct compilation *c = THIS_COMPILATION;    struct node_s *ret;       struct svalue *modules=(struct svalue *) -  (used_modules.s.str + used_modules.s.len); +  (c->used_modules.s.str + c->used_modules.s.len);       {    struct program_state *p=Pike_compiler;    int n;    for(n=0;n<=compilation_depth;n++,p=p->previous)    {    int i;    if(see_inherit)    {    i=really_low_find_shared_string_identifier(ident,
pike.git/src/program.c:1572:    mkexternalnode(p->new_program, i);    }    }       if((ret=index_modules(ident,    &p->module_index_cache,    p->num_used_modules,    modules))) return ret;    modules-=p->num_used_modules;   #ifdef PIKE_DEBUG -  if( ((char *)modules ) < used_modules.s.str) +  if( ((char *)modules ) < c->used_modules.s.str)    Pike_fatal("Modules out of whack!\n");   #endif    }    }       return resolve_identifier(ident);   }      /*! @decl constant UNDEFINED    *!
pike.git/src/program.c:2416:    threads_disabled, compilation_depth));       init_type_stack();      #define PUSH   #include "compilation.h"       Pike_compiler->parent_identifier=id;    Pike_compiler->compiler_pass = pass;    -  Pike_compiler->num_used_modules=0; +  Pike_compiler->num_used_modules=0; /* FIXME: Duplicate? */       if(p->flags & PROGRAM_FINISHED)    {    yyerror("Pass2: Program already done");    }       Pike_compiler->malloc_size_program = ALLOC_STRUCT(program);    Pike_compiler->fake_object=alloc_object();      #ifdef PIKE_DEBUG
pike.git/src/program.c:7383:      static void run_init(struct compilation *c)   {    debug_malloc_touch(c);    c->save_depth=compilation_depth;    compilation_depth=-1;       if (c->compat_handler) free_object(c->compat_handler);    c->compat_handler=0;    -  c->used_modules_save = used_modules; -  c->num_used_modules_save = Pike_compiler->num_used_modules; -  Pike_compiler->num_used_modules=0; -  +     c->resolve_cache_save = resolve_cache;    resolve_cache = 0;       c->lex.current_line=1;    free_string(c->lex.current_file);    c->lex.current_file=make_shared_string("-");       if (runtime_options & RUNTIME_STRICT_TYPES)    {    c->lex.pragmas = ID_STRICT_TYPES;
pike.git/src/program.c:7421:    }       c->lex.pos=c->prog->str;   }      static void run_init2(struct compilation *c)   {    debug_malloc_touch(c);    Pike_compiler->compiler = c;    -  initialize_buf(&used_modules); -  +     /* Get the proper default module. */    safe_apply_current2(PC_GET_DEFAULT_MODULE_FUN_NUM, 0, NULL);    if(Pike_sp[-1].type == T_INT)    {    pop_stack();    ref_push_mapping(get_builtin_constants());    }    assign_svalue(&c->default_module, Pike_sp-1);    pop_stack();   
pike.git/src/program.c:7445:    Pike_compiler->compat_major=PIKE_MAJOR_VERSION;    Pike_compiler->compat_minor=PIKE_MINOR_VERSION;       if(c->major>=0)    change_compiler_compatibility(c->major, c->minor);   }      static void run_exit(struct compilation *c)   {    debug_malloc_touch(c); -  toss_buffer(&used_modules); -  used_modules = c->used_modules_save; +       #ifdef PIKE_DEBUG -  if(Pike_compiler->num_used_modules) +  if(c->num_used_modules)    Pike_fatal("Failed to pop modules properly.\n");   #endif -  Pike_compiler->num_used_modules = c->num_used_modules_save ; +       #ifdef PIKE_DEBUG    if (compilation_depth != -1) {    fprintf(stderr, "compile(): compilation_depth is %d\n",    compilation_depth);    }   #endif /* PIKE_DEBUG */    compilation_depth=c->save_depth;       if (resolve_cache)
pike.git/src/program.c:7781:    struct compilation *c = THIS_COMPILATION;       switch (e) {    case PROG_EVENT_INIT:    CDFPRINTF((stderr, "th(%ld) compilation: INIT(%p).\n",    (long) th_self(), c));    MEMSET(c, 0, sizeof(*c));    c->supporter.self = Pike_fp->current_object; /* NOTE: Not ref-counted! */    c->compilation_inherit =    Pike_fp->context - Pike_fp->current_object->prog->inherits; +  initialize_buf(&c->used_modules);    add_ref(c->default_module.u.mapping = get_builtin_constants());    c->default_module.type = T_MAPPING;    c->major = -1;    c->minor = -1;    c->lex.current_line = 1;    c->lex.current_file = make_shared_string("-");    break;    case PROG_EVENT_EXIT:    CDFPRINTF((stderr, "th(%ld) compilation: EXIT(%p).\n",    (long) th_self(), c)); -  +  toss_buffer(&c->used_modules);    free_compilation(c);    break;    }   }      /*! @decl void report(SeverityLevel severity, @    *! string filename, int linenumber, @    *! string subsystem, @    *! string message, mixed ... extra_args)    *!
pike.git/src/program.c:8258:    ref_push_mapping(get_builtin_constants());    }       STACK_LEVEL_CHECK(1);       assign_svalue(&c->default_module, Pike_sp-1);       /* Replace the implicit import of all_constants() with    * the new value.    */ -  if(Pike_compiler->num_used_modules) +  if(c->num_used_modules)    { -  free_svalue( (struct svalue *)used_modules.s.str ); -  ((struct svalue *)used_modules.s.str)[0]=sp[-1]; +  free_svalue( (struct svalue *)c->used_modules.s.str ); +  ((struct svalue *)c->used_modules.s.str)[0]=sp[-1];    sp--;    dmalloc_touch_svalue(sp);    if(Pike_compiler->module_index_cache)    {    free_mapping(Pike_compiler->module_index_cache);    Pike_compiler->module_index_cache=0;    }    }else{    use_module(sp-1);    pop_stack();