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.662 2008/04/14 13:18:09 grubba Exp $ + || $Id: program.c,v 1.663 2008/04/14 16:34:54 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:1585:    return resolve_identifier(ident);   }      /*! @decl constant UNDEFINED    *!    *! The undefined value; ie a zero for which @[zero_type()] returns 1.    */      struct node_s *resolve_identifier(struct pike_string *ident)   { +  struct compilation *c = THIS_COMPILATION; +  node *ret = NULL; +     /* Handle UNDEFINED */    if (ident == UNDEFINED_string) {    struct svalue s;    s.type = T_INT;    s.subtype = NUMBER_UNDEFINED;    s.u.integer = 0;    return mkconstantsvaluenode(&s);    }       if(resolve_cache)
pike.git/src/program.c:1606:    struct svalue *tmp=low_mapping_string_lookup(resolve_cache,ident);    if(tmp)    {    if(!IS_UNDEFINED (tmp))    return mkconstantsvaluenode(tmp);       return 0;    }    }    -  if(get_master()) -  { -  struct compilation *c = THIS_COMPILATION; -  DECLARE_CYCLIC(); -  node *ret=0; -  if(BEGIN_CYCLIC(ident, c->lex.current_file)) -  { -  my_yyerror("Recursive module dependency in %S.", ident); -  }else{ -  SET_CYCLIC_RET(1); +  CHECK_COMPILER();       ref_push_string(ident);    ref_push_string(c->lex.current_file);    if (c->handler) {    ref_push_object(c->handler);    } else {    push_int(0);    } -  -  if (safe_apply_handler("resolv", c->handler, c->compat_handler, 3, 0)) { -  if (Pike_compiler->compiler_pass == 2 && -  ((Pike_sp[-1].type == T_OBJECT && -  Pike_sp[-1].u.object == placeholder_object) || -  (Pike_sp[-1].type == T_PROGRAM && -  Pike_sp[-1].u.program == placeholder_program))) { -  my_yyerror("Got placeholder %s (resolver problem) " -  "when resolving %S.", -  get_name_of_type (Pike_sp[-1].type), ident->str); -  } -  else { -  if(!resolve_cache) -  resolve_cache=dmalloc_touch(struct mapping *, allocate_mapping(10)); -  mapping_string_insert(resolve_cache,ident,Pike_sp-1); -  -  if(!IS_UNDEFINED (Pike_sp-1)) -  { -  ret=mkconstantsvaluenode(Pike_sp-1); -  } -  } -  pop_stack(); -  } -  else { +  if (!safe_apply_current(CE_RESOLV_FUN_NUM, 3)) {    if(Pike_compiler->compiler_pass==2) {    if (throw_value.type == T_STRING) {    my_yyerror("%S", throw_value.u.string);    free_svalue(&throw_value);    mark_free_svalue (&throw_value);    }    else {    handle_compile_exception ("Error resolving %S.", ident);    } -  } -  else { +  } else {    /* FIXME: Error goes to /dev/null. Now we get a warning at    * least in rtldebug mode, but this borken, borken, boRKen. :P */    struct svalue thrown;    move_svalue (&thrown, &throw_value);    mark_free_svalue (&throw_value);   #ifdef PIKE_DEBUG    {    struct pike_string *msg = format_exception_for_error_msg (&thrown);    if (msg) { -  yywarning ("Ignoring resolv() exception in pass %d:", +  yywarning("Ignoring resolv() exception in pass %d:",    Pike_compiler->compiler_pass);    yywarning ("%S", msg);    free_string (msg);    }    else -  yywarning ("Ignoring resolv() exception in pass %d", +  yywarning("Ignoring resolv() exception in pass %d",    Pike_compiler->compiler_pass);    }   #endif    free_svalue (&thrown);    }    } -  +  +  if (Pike_compiler->compiler_pass == 2 && +  ((Pike_sp[-1].type == T_OBJECT && +  Pike_sp[-1].u.object == placeholder_object) || +  (Pike_sp[-1].type == T_PROGRAM && +  Pike_sp[-1].u.program == placeholder_program))) { +  my_yyerror("Got placeholder %s (resolver problem) " +  "when resolving %S.", +  get_name_of_type (Pike_sp[-1].type), ident->str); +  } else { +  if(!resolve_cache) +  resolve_cache=dmalloc_touch(struct mapping *, allocate_mapping(10)); +  mapping_string_insert(resolve_cache,ident,Pike_sp-1); +  +  if(!IS_UNDEFINED (Pike_sp-1)) +  { +  ret=mkconstantsvaluenode(Pike_sp-1);    } -  END_CYCLIC(); +  } +  pop_stack();       return ret;   }    -  return 0; - } -  +    /*! @decl constant this    *!    *! Builtin read only variable that evaluates to the current object.    *!    *! @seealso    *! @[this_program], @[this_object()]    */      /*! @decl constant this_program    *!
pike.git/src/program.c:7754:    verify_supporters();    }    STACK_LEVEL_DONE(args);    pop_n_elems(args);    if (ret)    push_program(ret);    else    push_int(0);   }    + static void f_compilation_resolv(INT32 args) + { +  struct pike_string *ident; +  struct pike_string *filename; +  struct object *handler; +  +  get_all_args("resolv", args, "%W%W%O", &ident, &filename, &handler); +  +  if(get_master()) +  { +  struct compilation *c = THIS_COMPILATION; +  DECLARE_CYCLIC(); +  if(BEGIN_CYCLIC(ident, filename)) +  { +  my_yyerror("Recursive module dependency in %S.", ident); +  }else{ +  SET_CYCLIC_RET(1); +  +  low_unsafe_apply_handler("resolv", handler, c->compat_handler, args); +  } +  END_CYCLIC(); +  } else { +  pop_n_elems(args); +  push_undefined(); +  } + } +    /* Fake being called via CompilationEnvironment()->compile()    *    * This function is used to set up the environment for    * compiling C efuns and modules.    *    * Note: Since this is a stack frame, it will be cleaned up    * automatically on error, so no need to use ONERROR().    *    * Note: Steals a reference from ce.    */
pike.git/src/program.c:7892:    struct identifier *i, *i2;    struct inherit *inh, *inh2;    unsigned INT16 *ix, *ix2;    int e;       p->parent_info_storage = -1;    p->event_handler = compilation_event_handler;    p->flags |= PROGRAM_HAS_C_METHODS;       p->inherits = inh = xalloc(sizeof(struct inherit)); -  p->identifier_references = ref = xalloc(sizeof(struct reference) * 3); -  p->identifiers = i = xalloc(sizeof(struct identifier) * 3); -  p->identifier_index = ix = xalloc(sizeof(unsigned INT16) * 3); +  p->identifier_references = ref = xalloc(sizeof(struct reference) * 4); +  p->identifiers = i = xalloc(sizeof(struct identifier) * 4); +  p->identifier_index = ix = xalloc(sizeof(unsigned INT16) * 4);    p->constants = pc = xalloc(sizeof(struct program_constant) * 1);       inh->prog = p;    inh->inherit_level = 0;    inh->identifier_level = 0;    inh->parent_identifier = -1;    inh->parent_offset = OBJECT_PARENT;    inh->identifier_ref_offset = 0;    inh->storage_offset = 0;    inh->parent = NULL;
pike.git/src/program.c:7994:    p2->inherits->storage_offset = p2->xstorage;    p2->storage_needed = p2->xstorage + sizeof(struct program_state);       /* low_define_alias(NULL, NULL, 0, 1, 0); */    i2->name = make_shared_string("report");    i2->type = make_pike_type(tFuncV(tName("SeverityLevel", tInt03) tStr tIntPos    tStr tStr, tMix, tVoid));    i2->run_time_type = T_FUNCTION;    i2->identifier_flags = IDENTIFIER_C_FUNCTION | IDENTIFIER_ALIAS;    i2->func.ext_ref.depth = 1; -  i2->func.ext_ref.id = 0; +  i2->func.ext_ref.id = CE_REPORT_FUN_NUM;    i2->opt_flags = 0;   #ifdef PROFILING    i2->self_time = 0;    i2->num_calls = 0;    i2->total_time = 0;   #endif    i2++;    *(ix2++) = ref2->identifier_offset = p2->num_identifiers++;    p2->num_identifier_index++;    ref2->id_flags = 0;
pike.git/src/program.c:8044:    i->total_time = 0;   #endif    i++;    *(ix++) = ref->identifier_offset = compilation_program->num_identifiers++;    p->num_identifier_index++;    ref->id_flags = 0;    ref->inherit_offset = 0;    ref++;    p->num_identifier_references++;    +  /* ADD_FUNCTION("resolv", f_compilation_resolv, ...); */ +  i->name = make_shared_string("resolv"); +  i->type = make_pike_type(tFunc(tStr tStr tObj, tMix)); +  i->run_time_type = T_FUNCTION; +  i->identifier_flags = IDENTIFIER_C_FUNCTION; +  i->func.c_fun = f_compilation_resolv; +  i->opt_flags = 0; + #ifdef PROFILING +  i->self_time = 0; +  i->num_calls = 0; +  i->total_time = 0; + #endif +  i++; +  *(ix++) = ref->identifier_offset = compilation_program->num_identifiers++; +  p->num_identifier_index++; +  ref->id_flags = 0; +  ref->inherit_offset = 0; +  ref++; +  p->num_identifier_references++; +  +     p->flags |= PROGRAM_PASS_1_DONE;       fsort_program_identifier_index(p->identifier_index, ix-1, p);    p->flags |= PROGRAM_FIXED;       /* Yes, it is supposed to start at 0 /Grubba */    for(e=0;e<NUM_LFUNS;e++) {    int id = p->lfuns[e] = low_find_lfun(p, e);    }