pike.git / lib / master.pike.in

version» Context lines:

pike.git/lib/master.pike.in:2537:    oname,    (current_file && current_file!="-") ? sprintf(" in %O",current_file) : "");   }      // Marker used for negative caching in module caches.   // FIXME: Won't this cause problems when inheriting "/master"?   protected class ZERO_TYPE {};      protected object Unicode;    + void try_issue_deprecation_warning(object compilation_handler) + { +  if (object active_compiler = get_active_compiler()) { +  if (!active_compiler->suppress_deprecation_warnings()) { +  call_compile_warning_lineno(compilation_handler, +  active_compiler->current_file, +  active_compiler->current_line, +  "Using a deprecated value."); +  } +  } + } +    //! Module node representing a single directory.   //!   //! @seealso   //! @[joinnode]   class dirnode (string dirname, object|void compilation_handler,    string|void name)   {    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:int(0..1)) deprecated_cache=([]);       // Maps a base name like "Bar" to an ordered array of file paths,    // e.g. ({ "/lib/Foo.pmod/Bar.pmod", "/lib/Foo.pmod/Bar.so" }).    protected mapping(string:array(string)) file_paths = ([]);      #ifdef __NT__   #define FIX_CASE(X) lower_case(X)   #else   #define FIX_CASE(X) (X)   #endif /* __NT__ */
pike.git/lib/master.pike.in:2654:    resolv_debug ("dirnode(%O)->module_checker()->`!()\n",dirname);       if (mixed err = catch {    // Look up module.    if (module = cache["module"] || low_ind("module", 1)) {    /* This allows for `[] to have side effects first time    * it is called. (Specifically, the Calendar module uses    * this).    */    cache=([]); +  deprecated_cache=([]);    _cache_full=0;    }    resolv_debug("dirnode(%O)->module_checker()->`!() => %s\n",    dirname, !module ? "doesn't exist" : "exists");    return !module;    }) {    //werror ("findmodule error: " + call_describe_backtrace (err));       // findmodule() failed. This can occur due to circularities    // between encode_value()'ed programs.
pike.git/lib/master.pike.in:2797:    resolv_debug("dirnode(%O)->ind(%O) => cache_full %O\n",    dirname, index, cache[index]);    return cache[index];    }       if(module)    {    mixed o;    if(!undefinedp(o=module[index]))    { +  mixed t; +     DEC_RESOLV_MSG_DEPTH();    resolv_debug ("dirnode(%O)->ind(%O) => found %O\n",    dirname, index, o); -  +  +  // TODO:: The exception seems to be Tools.Standalone.module, which +  // neither fulfills functionp(), objectp(), nor programp(), though +  // typeof_identifier() works on it directly. +  // We should thus find a way for detecting things to directly use +  // typeof_identifier on without calling it inside of catch. +  if (objectp(module)) +  t = typeof_identifier(object_program(module), index); +  +  if (t && deprecated_typep(t)) +  { +  deprecated_cache[index] = 1; +  try_issue_deprecation_warning(compilation_handler); +  }    return o;    }    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);       DEC_RESOLV_MSG_DEPTH();    return low_ind(index);
pike.git/lib/master.pike.in:2827:    }       protected mixed `->=(string index, mixed value)    {    return `[]=(index, value);    }       protected mixed `[](string index)    {    mixed ret; +    #ifdef MODULE_TRACE    werror("%*nDirnode(%O) cache[%O] ?????\n",    sizeof(backtrace()),dirname,index);   #endif    if(!undefinedp(ret=cache[index]))    {   #ifdef MODULE_TRACE    werror("%*nDirnode(%O) cache[%O] => %O%s\n",    sizeof(backtrace()),dirname,index, ret,    (ret != ZERO_TYPE)?"":" (zero_type)");   #endif -  if (ret != ZERO_TYPE) return ret; +  if (ret != ZERO_TYPE) +  { +  if (deprecated_cache[index]) +  try_issue_deprecation_warning(compilation_handler); +  return ret; +  }   #ifdef MODULE_TRACE    werror("%*nDirnode(%O) ZERO_TYPE!\n",    sizeof(backtrace()),dirname);   #endif    return UNDEFINED;    }    ret=ind(index);       // We might have gotten placeholder objects in the first pass    // which must not be cached to the second.
pike.git/lib/master.pike.in:2864:    return ret;    }       cache[index] = undefinedp(ret) ? ZERO_TYPE : ret;    return ret;    }       protected mixed `->(string index)    {    if( (< "dirname", "name", "is_resolv_dirnode", -  "module", "delete_value" >)[index] ) +  "module", "delete_value", "identifier_deprecatedp" >)[index] )    return ::`->(index);    return `[](index);    }       protected mixed safe_index(string index)    {    mixed err;    resolv_debug ("dirnode(%O): %O...\n", dirname, index);    if (err = catch { return `[](index); }) {    call_compile_warning (compilation_handler,    dirname+"."+fname,    "Compilation failed: " +    call_describe_error(err));    }    return UNDEFINED;    }    -  +  int(0..1) identifier_deprecatedp(string index) +  { +  if (has_index(cache, index) || deprecated_cache[index]) +  return deprecated_cache[index]; +  safe_index(index); +  return deprecated_cache[index]; +  } +     protected int(0..1) _cache_full;    protected void fill_cache()    {    if (_cache_full) {    return;    }       resolv_debug ("dirnode(%O) => Filling cache...\n", dirname);       // NOTE: We rely on side effects in `[]() and safe_index()
pike.git/lib/master.pike.in:2927:    protected array(mixed) _values()    {    fill_cache();    return values(cache) - ({ZERO_TYPE});    }       void delete_value (mixed val)    {    if (string name = search (cache, val)) {    m_delete (cache, name); +  m_delete (deprecated_cache, name);    _cache_full = 0;    }    }       protected int(0..) _sizeof() {    return sizeof(_values());    }       protected string _sprintf(int as)    {
pike.git/lib/master.pike.in:2955:   //! @seealso   //! @[dirnode]   class joinnode (array(object|mapping) joined_modules,    object|void compilation_handler,    joinnode|mapping(mixed:int(0..0))|void fallback_module,    string|void name)   {    constant is_resolv_joinnode = 1;       mapping(string:mixed) cache=([]); +  mapping(string:int(0..1)) deprecated_cache=([]);       protected string _sprintf(int as)    {    if (as != 'O') return 0;    if (name) {    if (has_value (name, '|'))    return "joinnode(" + name + ")";    else    return name; // Let's be brief.    }
pike.git/lib/master.pike.in:3006:    void add_path(string path)    {    path = combine_path(getcwd(), path);    dirnode node = fc[path] ||    (fc[path] = dirnode(path, compilation_handler,    name && !has_value (name, '|') && name));    if (sizeof(joined_modules) &&    joined_modules[0] == node) return;    joined_modules = ({ node }) + (joined_modules - ({ node }));    cache = ([]); +  deprecated_cache = ([]);    }       void rem_path(string path)    {    path = combine_path(getcwd(), path);    joined_modules = filter(joined_modules,    lambda(dirnode node) {    return !is_dirnode(node) ||    (node->dirname != path);    });    cache = ([]); -  +  deprecated_cache = ([]);    }       protected mixed ind(string index)    {    resolv_debug ("joinnode(%O)->ind(%O)\n", joined_modules, index);    INC_RESOLV_MSG_DEPTH();    -  +  int(0..1) do_depwarn = 0;    array(mixed) res = ({});    foreach(joined_modules, object|mapping o)    {    mixed ret;    if (!undefinedp(ret = o[index]))    {    if (is_dirnode(ret) || is_joinnode(ret))    {    // Only join directorynodes (or joinnodes).    res += ({ ret }); -  +  if (o->identifier_deprecatedp(index)) +  do_depwarn = 1;    } else {    DEC_RESOLV_MSG_DEPTH();    resolv_debug ("joinnode(%O)->ind(%O) => found %O\n",    joined_modules, index, ret); -  +  +  if (objectp(o) && o->identifier_deprecatedp(index)) +  { +  deprecated_cache[index] = 1; +  try_issue_deprecation_warning(compilation_handler); +  }    return (ret);    } -  +  +  if (do_depwarn) +  { +  deprecated_cache[index] = 1; +  try_issue_deprecation_warning(compilation_handler);    }    } -  +  }       if (sizeof(res)) {    DEC_RESOLV_MSG_DEPTH();    resolv_debug("joinnode(%O)->ind(%O) => new joinnode, fallback: %O\n",    joined_modules, index, fallback_module[index]);    return joinnode(res, compilation_handler, fallback_module[index],    name && !has_value (name, '|') &&    (name == "predef::" ? index : name + "." + index));    }   
pike.git/lib/master.pike.in:3076:    protected mixed `->=(string index, mixed value)    {    if( index=="fallback_module" )    return fallback_module=value;    return `[]=(index, value);    }       protected mixed `[](string index)    {    mixed ret; +     if (!undefinedp(ret = cache[index])) {    if (ret != ZERO_TYPE) { -  +  if (deprecated_cache[index]) +  try_issue_deprecation_warning(compilation_handler);    return ret;    }    return UNDEFINED;    }    ret = ind(index);       // 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;   
pike.git/lib/master.pike.in:3100:    } else {    cache[index] = ret;    }    return ret;    }       protected mixed `->(string index)    {    if( (< "joined_modules", "fallback_module", "name", "is_resolv_joinnode",    "add_path", "rem_path", "delete_value", "_encode", -  "_decode" >)[index] ) +  "_decode", "identifier_deprecatedp" >)[index] )    return ::`->(index);    return `[](index);    }    -  +  int(0..1) identifier_deprecatedp(string index) +  { +  if (has_index(cache, index) || deprecated_cache[index]) +  return deprecated_cache[index]; +  `[](index); +  return deprecated_cache[index]; +  } +     protected int _cache_full;       protected void fill_cache()    {    if (_cache_full) {    return;    }    foreach(joined_modules, object|mapping|program o) {    foreach(indices(o), string index) {    if (!has_index(cache, index)) {
pike.git/lib/master.pike.in:3149:    }       protected int(0..) _sizeof()    {    return sizeof(_values());    }       void delete_value (mixed val)    {    if (string name = search (cache, val)) +  {    m_delete (cache, name); -  +  m_delete (deprecated_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 (is_dirnode(o) || is_joinnode(o))    o->delete_value (val);    else if (string name = mappingp (o) && search (o, val))    m_delete (o, name);