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.249 2003/01/15 23:55:21 mast Exp $ + // $Id: master.pike.in,v 1.250 2003/01/20 17:38:52 nilsson Exp $      #pike __REAL_VERSION__      // Some programs destroys character pairs beginning with the currency   // symbol when running in chinese locale.   #if "ยค/" != "\244/"   #error "master.pike.in is corrupted."   #endif      // --- Some configurable parameters
pike.git/lib/master.pike.in:806:    "putenv",      #ifdef GETCWD_CACHE    "cd",    "getcwd",   #endif   });      string include_prefix;    + //! @appears strlen + //! Alias for @[sizeof]. + //! @deprecated sizeof +  + //! @appears write + //! Writes a string on stdout. Works just like @[Stdio.File.write] + //! on @[Stdio.stdout]. +    /* Note that create is called before add_precompiled_program    */   void create()   {    object o = this_object();       foreach(master_efuns, string e)    if (o[e])    add_constant(e, o[e]);    else
pike.git/lib/master.pike.in:900:    // objectp() is intentionally not used on the module object, to    // allow a module to deny its own existence with `!.    mixed module=module_checker();    mapping(string:mixed) cache=([]);    array(string) files;       void create(string d, object|void h)    {   #ifdef MODULE_TRACE    werror("%*ndirnode(%O,%O);\n",sizeof(backtrace())-1,d,h); - // werror(describe_backtrace( ({"HERE\n",backtrace()}))); +    #endif    dirname=d;    handler=h;    fc[dirname]=this_object();    if(has_suffix(dirname,".pmod"))    fc[dirname[..sizeof(dirname)-6]]=this_object();    }    -  +  void get_files() { +  if (!(files = get_dir(fakeroot(dirname)))) { +  werror ("Error listing module directory %O: %s\n", +  dirname, strerror (errno())); +  files = ({}); +  } +  } +     class module_checker    {    int `!()    {   #ifdef MODULE_TRACE -  werror("%*ndirnode(%O)->module_checker()->`!()\n",sizeof(backtrace()),dirname); +  werror("%*ndirnode(%O)->module_checker()->`!()\n", +  sizeof(backtrace()),dirname);   #endif    if(module=findmodule(dirname+"/module", handler))    {    if(mixed tmp=module->_module_value)    module=tmp;       /* This allows for `[] to have side effects first time    * it is called. (Specifically, the Calendar module uses    * this    */    cache=([]);    _cache_full=0;    }       return !module;    }       mixed `[](string index)    {   #ifdef MODULE_TRACE -  werror("%*ndirnode(%O)->module_checker()[%O]\n",sizeof(backtrace()),dirname,index); +  werror("%*ndirnode(%O)->module_checker()[%O]\n", +  sizeof(backtrace()),dirname,index);   #endif    if(module) return module[index];    }    array(string) _indices() { if(module) return indices(module); }    array _values() { if(module) return values(module); }    }       static mixed ind(string index)    {   #ifdef MODULE_TRACE -  werror("%*nDirnode(%O) ind[%O] -> ???\n",sizeof(backtrace()),dirname,index); +  werror("%*nDirnode(%O) ind[%O] -> ???\n", +  sizeof(backtrace()),dirname,index);   #endif    if(module)    {   #ifdef MODULE_TRACE -  werror("%*nDirnode(%O) module[%O] -> ???\n",sizeof(backtrace()),dirname,index); +  werror("%*nDirnode(%O) module[%O] -> ???\n", +  sizeof(backtrace()),dirname,index);   #endif    mixed o;   // _describe(module);    if(!zero_type(o=module[index]))    {   #ifdef MODULE_TRACE -  werror("%*nDirnode(%O) module[%O] -> %O\n",sizeof(backtrace()),dirname,index, o); +  werror("%*nDirnode(%O) module[%O] -> %O\n", +  sizeof(backtrace()),dirname,index, o);   #endif    return o;    }    }    -  if( !files ) -  if (!(files = get_dir(fakeroot(dirname)))) { -  werror ("Error listing module directory %O: %s\n", -  dirname, strerror (errno())); -  files = ({}); -  } +  if(!files) get_files();    -  int ret; +  int(0..1) ret;    foreach( files, string s ) -  { +     if( has_value(s, index) || has_value(index,s) )    {    ret=1;    break;    } -  } +     if(!ret)    return UNDEFINED; -  +     index = dirname+"/"+index;   #ifdef MODULE_TRACE    werror("%*nDirnode(%O) findmodule(%O)\n",    sizeof(backtrace()), dirname, dirname+"/"+index);   #endif    if(object o=findmodule(index, handler))    {    if(mixed tmp=o->_module_value) o=tmp;    return o;    }    if (program p=cast_to_program( index, 0, handler ))    { - // werror("dirnode(%O)[%O] -> %O\n",dirname,index,p); +     return p;    } - // werror("Returning UNDEFINED for %s\n",ind); +     return UNDEFINED;    }       mixed `[](string index)    {    mixed ret;   #ifdef MODULE_TRACE -  werror("%*nDirnode(%O) cache[%O] ?????\n",sizeof(backtrace()),dirname,index); +  werror("%*nDirnode(%O) cache[%O] ?????\n", +  sizeof(backtrace()),dirname,index);   #endif    if(!zero_type(ret=cache[index]))    {   #ifdef MODULE_TRACE -  werror("%*nDirnode(%O) cache[%O] -> %O\n",sizeof(backtrace()),dirname,index, ret); +  werror("%*nDirnode(%O) cache[%O] -> %O\n", +  sizeof(backtrace()),dirname,index, ret);   #endif    if (ret != ZERO_TYPE) 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;       cache[index] = zero_type(ret) ? ZERO_TYPE : ret;    return ret;    }    -  static int _cache_full; +  static int(0..1) _cache_full;    void fill_cache()    {   #ifdef RESOLV_DEBUG    werror(describe_backtrace(({ sprintf("Filling cache in dirnode %O\n",    dirname),    backtrace() })));   #endif /* RESOLV_DEBUG */    if (_cache_full) {    return;    }       if (module) {    foreach(indices(module), string index) {    cache[index] = module[index];    }    }    -  if( !files ) -  if (!(files = get_dir(fakeroot(dirname)))) { -  werror ("Error listing module directory %O: %s\n", -  dirname, strerror (errno())); -  files = ({}); -  } +  if(!files) get_files();       foreach(files, string fname) {    mixed err = catch {    if (((< ".pike", ".pmod" >)[fname[sizeof(fname)-5..]]) &&    !zero_type(`[](fname[..sizeof(fname)-6]))) {    continue;    } else if ((fname[sizeof(fname)-3..] == ".so") &&    !zero_type(`[](fname[..sizeof(fname)-4]))) {    continue;    }    };    if (err) {    compile_warning(dirname+"."+fname, 0,    sprintf("Compilation failed:\n"    "%s\n",    describe_backtrace(err)));    }    }    _cache_full = 1;    } -  array(string) _indices() +  +  static array(string) _indices()    { -  // werror("indices(%O) called\n", dirname); +     fill_cache(); -  return indices(filter(cache, lambda(mixed x) {return cache[x] != ZERO_TYPE;})); +  return indices(filter(cache, lambda(mixed x) { +  return cache[x] != ZERO_TYPE; +  } ));    } -  array(mixed) _values() +  +  static array(mixed) _values()    { -  // werror("values(%O) called\n", dirname); +     fill_cache();    return values(cache) - ({ZERO_TYPE});    }       void delete_value (mixed val)    {    if (string name = search (cache, val))    m_delete (cache, name);    }    -  string _sprintf(int as) +  static int(0..) _sizeof() { +  return sizeof(_values()); +  } +  +  static string _sprintf(int as)    {    return as=='O' && sprintf("master()->dirnode(%O)",dirname);    } -  + }    - }; -  +    static class ZERO_TYPE {};      class joinnode   {    constant is_resolv_joinnode = 1;    array(object|mapping) joined_modules;    mapping(string:mixed) cache=([]);       string _sprintf(int as)    {