pike.git / src / program.c

version» Context lines:

pike.git/src/program.c:1521:   #define RELOCATE_program(ORIG, NEW)   #endif /* !RELOCATE_program */   #define RELOCATE_identifier_cache(ORIG,NEW)   #define RELOCATE_linenumbers(ORIG,NEW)   #define RELOCATE_identifier_index(ORIG,NEW)   #define RELOCATE_variable_index(ORIG,NEW)   #define RELOCATE_identifier_references(ORIG,NEW)   #define RELOCATE_strings(ORIG,NEW)   #define RELOCATE_inherits(ORIG,NEW)   #define RELOCATE_identifiers(ORIG,NEW) + #define RELOCATE_annotations(ORIG,NEW)   #define RELOCATE_constants(ORIG,NEW)   #define RELOCATE_relocations(ORIG,NEW)      #if SIZEOF_LONG_LONG == 8   /* we have 8 byte ints, hopefully this constant works on all these systems */   #define MAXVARS(NUMTYPE) \    (NUMTYPE)(sizeof(NUMTYPE)==1?254: \    (sizeof(NUMTYPE)==2?65534: \    (sizeof(NUMTYPE)==4?4294967294U:18446744073709551614ULL)))   #else
pike.git/src/program.c:1749:    dummy.func = func;    dummy.opt_flags = opt_flags;   #ifdef PROFILING    dummy.self_time=0;    dummy.num_calls=0;    dummy.recur_depth=0;    dummy.total_time=0;   #endif    debug_add_to_identifiers(dummy);    +  if (Pike_compiler->current_annotations) { +  compiler_add_annotations(n, Pike_compiler->current_annotations); +  } +     return n;   }      static int add_identifier(struct compilation *c,    struct pike_type *type,    struct pike_string *name,    unsigned int modifier_flags,    unsigned int identifier_flags,    unsigned int opt_flags,    union idptr func,
pike.git/src/program.c:3463:    /* fprintf(stderr, "Exiting program: %p, id:%d\n", p, p->id); */       if(id_to_program_cache[p->id & (ID_TO_PROGRAM_CACHE_SIZE-1)]==p)    id_to_program_cache[p->id & (ID_TO_PROGRAM_CACHE_SIZE-1)]=0;       if(p->strings)    for(e=0; e<p->num_strings; e++)    if(p->strings[e])    free_string(p->strings[e]);    +  if (p->annotations) { +  for (e = 0; e < p->num_annotations; e++) { +  do_free_array(p->annotations[e]); +  } +  } +     if(p->identifiers)    {    for(e=0; e<p->num_identifiers; e++)    {    if(p->identifiers[e].name)    free_string(p->identifiers[e].name);    if(p->identifiers[e].type)    free_type(p->identifiers[e].type);    }    }
pike.git/src/program.c:3676:    free_string(Pike_compiler->last_identifier);    Pike_compiler->last_identifier=0;    }       if(Pike_compiler->last_file)    {    free_string(Pike_compiler->last_file);    Pike_compiler->last_file=0;    }    +  if (Pike_compiler->current_annotations) { +  free_node(Pike_compiler->current_annotations); +  Pike_compiler->current_annotations = NULL; +  } +     if (Pike_compiler->current_attributes) {    free_node(Pike_compiler->current_attributes);    Pike_compiler->current_attributes = NULL;    }       unuse_modules(Pike_compiler->num_used_modules);       free_all_nodes();       ba_destroy(&Pike_compiler->node_allocator);
pike.git/src/program.c:4194:    struct pike_type *type,    int id_flags)   {    union idptr dispatch_fun;    dispatch_fun.c_fun = f_dispatch_variant;    return define_function(name, type, id_flags & ~(ID_VARIANT|ID_LOCAL),    IDENTIFIER_C_FUNCTION, &dispatch_fun, 0);   }      /** +  * Add a single annotation for a symbol in the current program +  * being compiled. +  * +  * @param id +  * Identifier to annotate, -1 for the current program. +  * +  * @param val +  * Annotation value. Should be an object implementing +  * the Pike.Annotation interface. +  */ + static void add_annotation(int id, struct svalue *val) + { +  id += 1; +  while (Pike_compiler->new_program->num_annotations <= id) { +  add_to_annotations(NULL); +  } +  +  if (val) { +  if (Pike_compiler->new_program->annotations[id]) { +  Pike_compiler->new_program->annotations[id] = +  append_array(Pike_compiler->new_program->annotations[id], val); +  } else { +  push_svalue(val); +  Pike_compiler->new_program->annotations[id] = aggregate_array(1); +  } +  } + } +  + void compiler_add_annotations(int id, node *annotations) + { +  while(annotations) { +  node *val_node = CAR(annotations); +  annotations = CDR(annotations); +  if (val_node->token != F_CONSTANT) continue; +  add_annotation(id, &val_node->u.sval); +  } + } +  + /**    * End the current compilation pass.    *    * @param finish    * finish-state:    *    * 0: First pass.    * 1: Last pass.    * 2: Called from decode_value().    *    * Note: This function is misnamed, since it's run after all passes.