pike.git / lib / master.pike.in

version» Context lines:

pike.git/lib/master.pike.in:1:   // -*- Pike -*-   //   // Master Control Program for Pike.   //   // 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: master.pike.in,v 1.375 2005/07/12 17:22:08 nilsson Exp $ + // $Id: master.pike.in,v 1.376 2005/07/13 09:25:26 grubba Exp $      #pike __REAL_VERSION__   //#pragma strict_types      // Some programs destroys character pairs beginning with the currency   // symbol when running in chinese locale.   #if "ยค/" != "\244/"   #error "master.pike.in is corrupted."   #endif   
pike.git/lib/master.pike.in:912:    resolv_debug("unregister %s\n", fname);    if (m_delete (rev_programs, p))    m_delete (programs, fname);    else    programs[fname] = no_value;       fname = dirname (fname);    object n;    if ( fname!="" && objectp (n = fc[fname]) )    if (n->is_resolv_dirnode || n->is_resolv_joinnode) -  n[""]["delete_value"](p); +  n->delete_value (p);    }       object o = objects[p];    if (objectp (o)) {    if (m_delete (rev_objects, o))    m_delete (objects, p);    else    objects[p] = no_value;    }   
pike.git/lib/master.pike.in:1218:   static class ZERO_TYPE {};      //! Module node representing a single directory.   //!   //! @seealso   //! @[joinnode]   class dirnode   {    string dirname;    object|void compilation_handler; +  constant is_resolv_dirnode = 1;    // objectp() is intentionally not used on the module object, to    // allow a module to deny its own existence with `!.    mixed module;    mapping(string:mixed) cache=([]);    mapping(string:array(string)) file_paths = ([]);      #ifdef __NT__   #define FIX_CASE(X) lower_case(X)   #else   #define FIX_CASE(X) (X)
pike.git/lib/master.pike.in:1452:    }    resolv_debug ("dirnode(%O)->ind(%O) => not found in module\n",    dirname, index);    }    else    resolv_debug ("dirnode(%O)->ind(%O) => no module\n", dirname, index);       return low_ind(index);    }    -  mixed selfindex(string index) { -  return ::`[](index); -  } -  +     mixed `[](string index)    {    mixed ret;   #ifdef MODULE_TRACE    werror("%*nDirnode(%O) cache[%O] ?????\n",    sizeof(backtrace()),dirname,index);   #endif    if(!zero_type(ret=cache[index]))    {   #ifdef MODULE_TRACE
pike.git/lib/master.pike.in:1477:    sizeof(backtrace()),dirname,index, ret,    (ret != ZERO_TYPE)?"":" (zero_type)");   #endif    if (ret != ZERO_TYPE) return ret;   #ifdef MODULE_TRACE    werror("%*nDirnode(%O) ZERO_TYPE!\n",    sizeof(backtrace()),dirname);   #endif    return UNDEFINED;    } +  ret=ind(index);    -  switch(index) { -  case "": -  ret = selfindex; -  break; -  case "is_resolv_dirnode": -  ret = 1; -  break; -  default: -  ret = ind(index); -  break; -  } -  +     // We might have gotten placeholder objects in the first pass    // which must not be cached to the second.    if(ret == predef::__placeholder_object) {   #ifdef MODULE_TRACE    werror("%*nDirnode(%O) PLACE_HOLDER.\n",    sizeof(backtrace()),dirname);   #endif    return ret;    }       cache[index] = zero_type(ret) ? ZERO_TYPE : ret;    return ret;    }    -  mixed `->(string index) { -  return `[](index); -  } -  +     mixed safe_index(string index)    {    mixed err;    if (err = catch { return `[](index); }) {    call_compile_warning (compilation_handler,    dirname+"."+fname,    "Compilation failed: " + describe_error(err));    }    return UNDEFINED;    }
pike.git/lib/master.pike.in:1584:    }   }      //! Module node holding possibly multiple directories,   //! and optionally falling back to another level.   //!   //! @seealso   //! @[dirnode]   class joinnode   { +  constant is_resolv_joinnode = 1;    array(object|mapping) joined_modules;    mapping(string:mixed) cache=([]);       object compilation_handler;       // NOTE: Uses the empty mapping as the default fallback    // for simplified code.    joinnode|mapping(mixed:int(0..0)) fallback_module = ([]);    -  void set_fallback_module(joinnode n) { -  fallback_module = n; -  } -  +     string _sprintf(int as)    {    return as=='O' && sprintf("master()->joinnode(%O)",joined_modules);    }       static void create(array(object|mapping) _joined_modules,    object|void _compilation_handler,    joinnode|void _fallback_module)    {    joined_modules = _joined_modules;
pike.git/lib/master.pike.in:1674:    joined_modules, index, fallback_module[index]);    return joinnode(res, compilation_handler, fallback_module[index]);    }       DEC_RESOLV_MSG_DEPTH();    resolv_debug ("joinnode(%O)->ind(%O) => not found. Trying fallback %O\n",    joined_modules, index, fallback_module);    return fallback_module[index];    }    -  mixed selfindex(string index) { -  return ::`[](index); -  } -  +     mixed `[](string index)    {    mixed ret;    if (!zero_type(ret = cache[index])) {    if (ret != ZERO_TYPE) {    return ret;    }    return UNDEFINED;    } -  -  switch(index) { -  case "": -  ret = selfindex; -  break; -  case "is_resolv_joinnode": -  ret = 1; -  break; -  default: +     ret = ind(index); -  break; -  } +        // We might have gotten placeholder objects in the first pass    // which must not be cached to the second.    if(ret == predef::__placeholder_object) return ret;       if (zero_type(ret)) {    cache[index] = ZERO_TYPE;    } else {    cache[index] = ret;    }    return ret;    }    -  mixed `->(string index) { -  return `[](index); -  } -  +     static int _cache_full;       void fill_cache()    {   #if 0    werror(describe_backtrace(({ "Filling cache in joinnode\n",    backtrace() })));   #endif    if (_cache_full) {    return;
pike.git/lib/master.pike.in:1767:    {    if (string name = search (cache, val))    m_delete (cache, name);    for (int i = 0; i < sizeof (joined_modules); i++) {    object|mapping|program o = joined_modules[i];    if (o == val) {    joined_modules = joined_modules[..i - 1] + joined_modules[i + 1..];    i--;    }    else if (objectp (o) && (o->is_resolv_dirnode || o->is_resolv_joinnode)) -  o[""]("delete_value")(val); +  o->delete_value (val);    else if (string name = mappingp (o) && search (o, val))    m_delete (o, name);    }    }       int `== (mixed other)    {    return objectp (other) && other->is_resolv_joinnode && -  equal (mkmultiset (joined_modules), -  mkmultiset (other[""]("joined_modules"))); +  equal (mkmultiset (joined_modules), mkmultiset (other->joined_modules));    }       array(object) _encode()    {    return joined_modules;    }       void _decode (array(object) joined_modules)    {    this_program::joined_modules = joined_modules;
pike.git/lib/master.pike.in:1822:    if (module_node_cache[current_handler][path]) {    return module_node_cache[current_handler][path];    }    } else {    module_node_cache[current_handler] = ([]);    }    module_node node = module_node_cache[current_handler][path] =    module_node("import::"+path, 0, current_handler);   #endif /* 0 */    joinnode node = joinnode(({}), current_handler); -  function add_path = node[""]("add_path"); +    #ifdef PIKE_MODULE_RELOC    // If we have PIKE_MODULE_RELOC enabled,    // we might need to map to multiple directories.    if(path == "/${PIKE_MODULE_PATH}" ||    has_prefix(path, "/${PIKE_MODULE_PATH}/")) {    string tmp = path[21..];    foreach(pike_module_path, string prefix) { -  add_path(sizeof(tmp)? combine_path(prefix, tmp) : prefix); +  node->add_path(sizeof(tmp)? combine_path(prefix, tmp) : prefix);    }    } else   #endif /* PIKE_MODULE_RELOC */ -  add_path(path); +  node->add_path(path);    return node;   }      // Probably not used anymore.   program|object findmodule(string fullname, object|void handler)   {    program|object o;       resolv_debug ("findmodule(%O)\n", fullname);    if(!zero_type(o=fc[fullname]) && o != no_value)
pike.git/lib/master.pike.in:1986:    //! The CompatResolver is initialized with a value that can be    //! casted into a "%d.%d" string, e.g. a version object.    //!    //! It can also optionally be initialized with a fallback resolver.    static void create(mixed version, CompatResolver|void fallback_resolver)    {    resolv_debug("CompatResolver(%O, %O)\n", version, fallback_resolver);    ver=(string)version;   #if 0    if (version) { -  root_module[""]("symbol") = ver + "::"; +  root_module->symbol = ver + "::";    }   #endif    if (CompatResolver::fallback_resolver = fallback_resolver) { -  root_module[""]("set_fallback_module")(fallback_resolver->root_module); +  root_module->fallback_module = fallback_resolver->root_module;    }    predefines = initial_predefines;    }       //! Add a directory to search for include files.    //!    //! This is the same as the command line option @tt{-I@}.    //!    //! @note    //! Note that the added directory will only be searched when using
pike.git/lib/master.pike.in:2036:    //! Add a directory to search for modules.    //!    //! This is the same as the command line option @tt{-M@}.    //!    //! @seealso    //! @[remove_module_path()]    //!    void add_module_path(string tmp)    {    tmp=normalize_path(combine_path_with_cwd(tmp)); -  root_module[""]("add_path")(tmp); +  root_module->add_path(tmp);    pike_module_path = ({ tmp }) + (pike_module_path - ({ tmp }));    }       //! Remove a directory to search for modules.    //!    //! This function performs the reverse operation of @[add_module_path()].    //!    //! @seealso    //! @[add_module_path()]    //!    void remove_module_path(string tmp)    {    tmp=normalize_path(combine_path_with_cwd(tmp)); -  root_module[""]("rem_path")(tmp); +  root_module->rem_path(tmp);    pike_module_path -= ({ tmp });    }       //! Add a directory to search for programs.    //!    //! This is the same as the command line option @tt{-P@}.    //!    //! @seealso    //! @[remove_program_path()]    //!
pike.git/lib/master.pike.in:2192:    if (current_handler->get_default_module) {    mapping(string:mixed) default_module =    current_handler->get_default_module();    if (default_module) {    static_modules = default_module["_static_modules"] || ([]);    }    }       node = joinnode(({ instantiate_static_modules(static_modules),    // Copy relevant stuff from the root module. -  @filter(root_module[""]("joined_modules"), +  @filter(root_module->joined_modules,    lambda(mixed x) {    return objectp(x) && x->is_resolv_dirnode;    }) }),    current_handler, -  root_module[""]("fallback_module")); +  root_module->fallback_module);       // FIXME: Is this needed?    // Kluge to get _static_modules to work at top level. -  node[""]("cache")->_static_modules = static_modules; +  node->cache->_static_modules = static_modules;       return node;    }       //!    mixed resolv_base(string identifier, string|void current_file,    object|void current_handler)    {    // werror("Resolv_base(%O)\n",identifier);    return get_root_module(current_handler)[identifier];
pike.git/lib/master.pike.in:3892:    break compare;    }       if (objectp (resolved)) {    if (object_program (resolved) == what) {    ENC_MSG (" compare_resolved: %O is program of %O\n", what, resolved);    append = ({'p'});    break compare;    }    -  if (resolved->is_resolv_dirnode) { -  mixed module = resolved[""]("module"); -  if (module == what) { +  if (resolved->is_resolv_dirnode) +  if (resolved->module == what) {    ENC_MSG (" compare_resolved: %O is dirnode module of %O\n", what, resolved);    append = ({'m'}); -  resolved = module; +  resolved = resolved->module;    break compare;    } -  else if (object_program (module) == what) { +  else if (object_program (resolved->module) == what) {    ENC_MSG (" compare_resolved: %O is program of dirnode module of %O\n",    what, resolved);    append = ({'m', 'p'});    break compare;    }    else    ENC_MSG (" compare_resolved: %O is different from dirnode module %O\n", -  what, module); -  } +  what, resolved->module);      #if 0    // This is only safe if the joinnode modules don't conflict,    // and we don't know that.    if (resolved->is_resolv_joinnode) {    ENC_MSG (" compare_resolved: searching for %O in joinnode %O\n",    what, resolved); -  foreach (resolved[""]("joined_modules"), mixed part) +  foreach (resolved->joined_modules, mixed part)    if (string|array name = compare_resolved (name, what, part,    module_object)) {    if (module_object) module_object[0] = resolved;    return name;    }    }   #endif    }       ENC_MSG (" compare_resolved: %O is different from %O\n", what, resolved);
pike.git/lib/master.pike.in:3968:    return UNDEFINED;    }       if (string id = rev_constants[what]) ENC_RETURN (id);    if (string id = rev_static_modules[what]) ENC_RETURN (id);       if (objectp (what)) {       if (what->is_resolv_dirnode) {    ENC_MSG (" is a dirnode\n"); -  string name = program_path_to_name (what[""]("dirname")); +  string name = program_path_to_name (what->dirname);    if (string|array ref = compare_resolved (name, what, resolv (name),    module_object))    ENC_RETURN (ref);    }       else if (what->is_resolv_joinnode) {    ENC_MSG (" is a joinnode\n"); -  object modules = Builtin.array_iterator (what[""]("joined_modules")); +  object modules = Builtin.array_iterator (what->joined_modules);    object|mapping value;    check_dirnode:    if (modules && objectp (value = modules->value()) &&    value->is_resolv_dirnode) {    string name = program_path_to_name (value->dirname);    modules += 1;    foreach (modules;; value)    if (!objectp (value) || !value->is_resolv_dirnode ||    program_path_to_name (value->dirname) != name)    break check_dirnode;
pike.git/lib/master.pike.in:4251:    res, sublist[1..i-1], subres);    if (zero_type (subres = ([mapping]subres)[op]))    error ("Cannot find %O in %O%{[%O]%}.\n",    op, res, sublist[1..i-1]);    DEC_MSG (" indexed with %O: %O\n", op, subres);    }    else switch (op) {    case 'm':    if (objectp (subres) && ([object]subres)->is_resolv_joinnode) {    dirnode found; -  foreach (subres[""]("joined_modules"), object|mapping part) +  foreach (([object(joinnode)]subres)->joined_modules, +  object|mapping part)    if (objectp (part) && part->is_resolv_dirnode && part->module) {    if (found)    error ("There are ambiguous module objects in %O.\n",    subres);    else    found = [object(dirnode)]part;    }    if (found) subres = found;    }       if (objectp (subres) && ([object]subres)->is_resolv_dirnode) { -  if (subres[""]("module")) { -  subres = subres[""]("module"); +  if (([object]subres)->module) { +  subres = ([object]subres)->module;    DEC_MSG (" got dirnode module %O\n", subres);    }    else    error ("Cannot find module object in dirnode %O.\n", subres);    }    else    error ("Cannot get module object in thing that isn't "    "a dirnode or unambiguous joinnode: %O\n", subres);    break;