Branch: Tag:

2005-07-13

2005-07-13 09:25:26 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Reverted previous checkin, since it breaks resolver error handling, and kills type checking in the resolver code.

Rev: lib/master.pike.in:1.376

6:   // 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
919:    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];
1225:   {    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;
1459:    return low_ind(index);    }    -  mixed selfindex(string index) { -  return ::`[](index); -  } -  +     mixed `[](string index)    {    mixed ret;
1484:   #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) {
1511:    return ret;    }    -  mixed `->(string index) { -  return `[](index); -  } -  +     mixed safe_index(string index)    {    mixed err;
1591:   //! @[dirnode]   class joinnode   { +  constant is_resolv_joinnode = 1;    array(object|mapping) joined_modules;    mapping(string:mixed) cache=([]);   
1600:    // 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);
1681:    return fallback_module[index];    }    -  mixed selfindex(string index) { -  return ::`[](index); -  } -  +     mixed `[](string index)    {    mixed ret;
1694:    }    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.
1719:    return ret;    }    -  mixed `->(string index) { -  return `[](index); -  } -  +     static int _cache_full;       void fill_cache()
1774:    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);    }
1783:    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()
1829:    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.
1837:    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;   }   
1993:    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;    }
2043:    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 }));    }   
2057:    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 });    }   
2199:       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;    }
3899:    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'});
3915:    }    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,
3924:    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;
3975:       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);
3983:       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()) &&
4258:    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",
4270:    }       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