pike.git / lib / master.pike.in

version» Context lines:

pike.git/lib/master.pike.in:1:   /* -*- Pike -*-    * -  * $Id: master.pike.in,v 1.169 2001/09/02 01:36:13 marcus Exp $ +  * $Id: master.pike.in,v 1.170 2001/10/05 01:30:11 hubbe Exp $    *    * Master-file for Pike.    *    * Based on master.pike 1.67.    */      // Some configurable parameters useful for debugging      #pike __REAL_VERSION__   #define PIKE_AUTORELOAD
pike.git/lib/master.pike.in:470:    case ".pike":    foreach(query_precompiled_names(fname), string oname) {    if(Stat s2=master_file_stat(fakeroot(oname)))    {    if(s2[1]>=0 && s2[3]>=s[3])    {    mixed err=catch {    AUTORELOAD_CHECK_FILE(oname);    return programs[fname] =    decode_value(master_read_file(oname), -  Codec()); +  Codec(fname,mkobj));    };    if (handler) {    handler->compile_warning(oname, 0,    sprintf("Decode failed:\n"    "\t%s", describe_error(err)));    } else {    compile_warning(oname, 0,    sprintf("Decode failed:\n"    "\t%s", describe_error(err)));    }
pike.git/lib/master.pike.in:525:    }       AUTORELOAD_FINISH(ret,programs,fname);      // werror("3: %O (%O)\n",fname, ret);    return programs[fname]=ret;    }    return 0;   }    + // + // This function is called by the compiler + // when a delayed compilation error occurs + // + void unregister(program p) + { +  if(string fname=search(programs,p)) +  m_delete(programs, fname); + } +    static program findprog(string pname,    string ext,    object|void handler,    void|int mkobj)   {    switch(ext)    {    case ".pike":    case ".so":    return low_findprog(pname,ext,handler, mkobj);
pike.git/lib/master.pike.in:780:   //! may also receive more arguments in the future.   object cast_to_object(string oname, string current_file)   {    if(object o=low_cast_to_object(oname, current_file))    return o;    error("Cast '"+oname+"' to object failed"+    ((current_file && current_file!="-")?sprintf(" for '%s'",current_file):"")+".\n");    return 0;   }    - class dirnode(string dirname, object|void handler) + class dirnode   { -  +  string dirname; +  object|void handler;    constant is_resolv_dirnode = 1;    mixed module=module_checker();    mapping(string:mixed) cache=([]);    array(string) files;    -  +  void create(string d, object|void h) +  { +  dirname=d; +  handler=h; +  fc[dirname]=this_object(); +  if(dirname[sizeof(dirname)-5..]==".pmod") +  fc[dirname[..sizeof(dirname)-6]]=this_object(); + #ifdef MODULE_TRACE +  werror("%*ndirnode(%O,%O);\n",sizeof(backtrace())-1,dirname,h); + // werror(describe_backtrace( ({"HERE\n",backtrace()}))); + #endif +  } +     class module_checker    {    int `!()    { -  module=0; + #ifdef MODULE_TRACE +  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) { if(module) return module[index]; } +  mixed `[](string index) +  { + #ifdef MODULE_TRACE +  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); + #endif    if(module)    { -  + #ifdef MODULE_TRACE +  werror("%*nDirnode(%O) module[%O] -> ???\n",sizeof(backtrace()),dirname,index); + #endif    object o; -  + // _describe(module);    if(!zero_type(o=module[index]))    { - // werror("Dirnode(%O) module[%O] -> %O\n",dirname,index, o); + #ifdef MODULE_TRACE +  werror("%*nDirnode(%O) module[%O] -> %O\n",sizeof(backtrace()),dirname,index, o); + #endif    return o;    }    }       if( !files )    files = get_dir(fakeroot(dirname));       int ret;    foreach( files, string s )    {
pike.git/lib/master.pike.in:847:   // 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; - // werror("Dirnode(%O) cache[%O] ?????\n",dirname,index); + #ifdef MODULE_TRACE +  werror("%*nDirnode(%O) cache[%O] ?????\n",sizeof(backtrace()),dirname,index); + #endif    if(!zero_type(ret=cache[index]))    { - // werror("Dirnode(%O) cache[%O] -> %O\n",dirname,index, ret); + #ifdef MODULE_TRACE +  werror("%*nDirnode(%O) cache[%O] -> %O\n",sizeof(backtrace()),dirname,index, ret); + #endif    // The check below is to (hopefully) avoid calling any function    // in ret (like `! or `==) in case it's an object.    if(!intp (ret) || ret) return ret;    return UNDEFINED;    } -  return cache[index]=ind(index); +  ret=ind(index); +  +  // Kluge! +  if(ret == __placeholder_object) return ret; +  +  return cache[index]=ret;    }       static int _cache_full;    void fill_cache()    {   #ifdef RESOLV_DEBUG    werror(describe_backtrace(({ sprintf("Filling cache in dirnode %O\n",    dirname),    backtrace() })));   #endif /* RESOLV_DEBUG */
pike.git/lib/master.pike.in:1019:    }   };      // Variables mustn't be static to allow for replace_master().   // /grubba 1998-04-10   mapping(string:mixed) fc=([]);      object findmodule(string fullname, object|void handler)   {    object o; + #ifdef MODULE_TRACE +  werror("%*nfindmodule(%O)\n",sizeof(backtrace()),fullname); + #endif    if(!zero_type(o=fc[fullname]))    {   // werror("fc[%O] -> %O\n",fullname, o);    return o;    }       if(Stat stat=master_file_stat(fakeroot(fullname+".pmod")))    {    if(stat[1]==-2) -  return fc[fullname]=dirnode(fullname+".pmod", handler); +  return dirnode(fullname+".pmod", handler);    }       if(o = low_cast_to_object(fullname+".pmod", "/.", handler))    return fc[fullname]=o;      #if constant(load_module)    if(master_file_stat(fakeroot(fullname+".so")))    return fc[fullname] = low_cast_to_object(fullname, "/.", handler);   #endif   
pike.git/lib/master.pike.in:1055:    string path;    if(current_file)    {    tmp=EXPLODE_PATH(current_file);    tmp[-1]=what;    path=combine_path_with_cwd( tmp*"/");    }    if (handler) {    return dirnode(path, handler);    } -  return fc[path]=dirnode(path); +  if(fc[path]) return fc[path]; +  return dirnode(path);   }            multiset no_resolv = (<>);      //!   class CompatResolver   {    array(string) pike_include_path=({});
pike.git/lib/master.pike.in:1197:       compat_major=saved_compat_major;    compat_minor=saved_compat_minor;    if(err) throw(err);    return x;    }       mixed resolv_base(string identifier, string|void current_file,    object|void current_handler)    { + // werror("Resolv_base(%O)\n",identifier);    array(mixed) tmp = ({});    string dir=current_file ? dirname(current_file) : "/";       foreach(pike_module_path, string path)    {    string file=combine_path(dir, path, identifier);    if(mixed ret=findmodule(file, current_handler)) {    if ((objectp(ret)) &&    (ret->is_resolv_dirnode || ret->is_resolv_joinnode)) {    if (mixed new_ret = ret->_module_value) {
pike.git/lib/master.pike.in:1238:    }    return joinnode(tmp);    }    return UNDEFINED;    }       mapping resolv_cache = set_weak_flag( ([]), 1 );    mixed resolv(string identifier, string|void current_file,    object|void current_handler)    { + // werror("Resolv(%O)\n",identifier); +     // FIXME: Support having the cache in the handler?    if( no_resolv[ identifier ] )    return UNDEFINED;       if (current_file && !stringp(current_file)) {    throw(({sprintf("resolv(%O, %O, %O): current_file is not a string!\n",    identifier, current_file, current_handler),    backtrace()}));    }       mixed ret;    string id=identifier+":"+(current_file ? dirname(current_file) : "-"); -  if( !zero_type (ret = resolv_cache[id]) ) -  return ret == ZERO_TYPE ? UNDEFINED : resolv_cache[id]; +  if( zero_type (ret = resolv_cache[id]) != 1 ) +  { + // werror("Resolv cached(%O) => %O (%d)\n",id,resolv_cache[id],zero_type(resolv_cache[id])); +  return ret == ZERO_TYPE ? UNDEFINED : ret; +  } +     array(string) tmp=identifier/".";    ret=resolv_base(tmp[0], current_file, current_handler);    foreach(tmp[1..],string index) ret=ret[index];    resolv_cache[id] = zero_type (ret) ? ZERO_TYPE : ret;    return ret;    }       //! This function is called whenever an #include directive is encountered    //! it receives the argument for #include and should return the file name    //! of the file to include
pike.git/lib/master.pike.in:2379:    }) {    return "Error indexing backtrace!\n";    }    }    return sprintf ("Backtrace is of unknown type %t!\n", trace);   }         class Codec   { +  string fname; +  int mkobj; +  program prog_to_mkobj; +  void create(void|string f,void|int m) +  { +  fname=f; +  mkobj=m; +  } +  +  void __register_new_program(program p) +  { +  if(fname) +  { +  programs[fname]=prog_to_mkobj=p; +  fname=0; +  } +  } +  +  +  void __register_new_object(program p) +  { +  if(prog_to_mkobj == p) +  { +  objects[p]=p(); +  prog_to_mkobj=0; +  } +  } +     mapping f=all_constants();       string nameof(mixed x)    {    if(mixed tmp=search(f,x))    return "efun:"+tmp;       if (programp(x)) {    if(mixed tmp=search(programs,x))    return tmp;