pike.git / lib / master.pike.in

version» Context lines:

pike.git/lib/master.pike.in:1:   /* -*- Pike -*-    * -  * $Id: master.pike.in,v 1.153 2001/04/17 08:41:58 mirar Exp $ +  * $Id: master.pike.in,v 1.154 2001/05/24 18:14:28 grubba 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:436:    compile_warning(oname, 0, "Compiled file is out of date\n");    }    }    }    }      // werror("2.5: %O\n",fname);    programs[fname]=ret=__empty_program();    if ( mixed e=catch {    ret=compile_file(fname, -  0, +  handler,    ret,    mkobj? (objects[ret]=__null_program()) : 0);    } )    {   // werror("-3: %O\n",fname);    ret=programs[fname]=0;    if(arrayp(e) && sizeof(e) && e[0] == "Compilation failed.\n")    e[1]=({});    throw(e);    }
pike.git/lib/master.pike.in:496:      program low_cast_to_program(string pname,    string current_file,    object|void handler,    void|int mkobj)   {    string ext;    string nname;    array(string) tmp=EXPLODE_PATH(pname);    +  // werror("low_cast_to_program(%O, %O, %O, %O)\n", +  // pname, current_file, handler, mkobj); +     if(sscanf(reverse(tmp[-1]),"%s.%s",ext, nname))    {    ext="."+reverse(ext);    tmp[-1]=reverse(nname);    pname=tmp*"/";    }else{    ext="";    }    if(IS_ABSOLUTE_PATH(pname))    {
pike.git/lib/master.pike.in:687:    * previous_object(), can be virtually anything in this function, as it    * is called from the compiler.    */   program handle_inherit(string pname, string current_file, object|void handler)   {    return cast_to_program(pname, current_file, handler);   }      mapping (program:object) objects=([object_program(this_object()):this_object()]);    - object low_cast_to_object(string oname, string current_file) + object low_cast_to_object(string oname, string current_file, +  object|void current_handler)   {    program p;    object o;    -  p=low_cast_to_program(oname, current_file, 0, 1); +  p = low_cast_to_program(oname, current_file, current_handler, 1);    if(!p) return 0;    if(!(o=objects[p])) o=objects[p]=p();    return o;   }      /* This function is called when the drivers wants to cast a string    * to an object because of an implict or explicit cast. This function    * 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 + class dirnode(string dirname, object|void handler)   {    constant is_resolv_dirnode = 1; -  string dirname; +     mixed module=module_checker();    mapping(string:mixed) cache=([]);    array(string) files;    -  void create(string name) -  { -  dirname=name; -  } -  +     class module_checker    {    int `!()    {    module=0; -  if(module=findmodule(dirname+"/module")) +  if(module=findmodule(dirname+"/module", handler))    if(mixed tmp=module->_module_value)    module=tmp;    return !module;    }       mixed `[](string index) { if(module) return module[index]; }    array(string) _indices() { if(module) return indices(module); }    array _values() { if(module) return values(module); }    }   
pike.git/lib/master.pike.in:767:    {    if( search(s, index)!=-1 || search(index,s)!=-1 )    {    ret=1;    break;    }    }    if(!ret)    return UNDEFINED;    index = dirname+"/"+index; -  if(object o=findmodule(index)) +  if(object o=findmodule(index, handler))    {    if(mixed tmp=o->_module_value) o=tmp;    return o;    } -  if (program p=cast_to_program( index, 0 )) +  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)    {
pike.git/lib/master.pike.in:953:    {    fill_cache();    return values(cache);    }   };      // Variables mustn't be static to allow for replace_master().   // /grubba 1998-04-10   mapping(string:mixed) fc=([]);    - object findmodule(string fullname) + object findmodule(string fullname, object|void handler)   {    object o;    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"); +  return fc[fullname]=dirnode(fullname+".pmod", handler);    }    -  if(o=low_cast_to_object(fullname+".pmod","/.")) +  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,"/."); +  return fc[fullname] = low_cast_to_object(fullname, "/.", handler);   #endif       return fc[fullname]=UNDEFINED;   }      mixed handle_import(string what, string|void current_file, object|void handler)   {    array(string) tmp;    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);   }            multiset no_resolv = (<>);   class CompatResolver   {    array(string) pike_include_path=({});    array(string) pike_module_path=({});
pike.git/lib/master.pike.in:1126:    mixed err =catch {    if(x=resolv("__default.all_constants")) x=x();    };       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) +  mixed resolv_base(string identifier, string|void current_file, +  object|void current_handler)    {    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)) { +  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) {    ret = new_ret;    }    tmp += ({ ret });    } else {    if (mixed new_ret = ret->_module_value) {    ret = new_ret;    }
pike.git/lib/master.pike.in:1165:    if (sizeof(tmp)) {    if (sizeof(tmp) == 1) {    return(tmp[0]);    }    return joinnode(tmp);    }    return UNDEFINED;    }       mapping resolv_cache = set_weak_flag( ([]), 1 ); -  mixed resolv(string identifier, string|void current_file) +  mixed resolv(string identifier, string|void current_file, +  object|void current_handler)    { -  +  // FIXME: Support having the cache in the handler?    if( no_resolv[ identifier ] )    return UNDEFINED;       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];    array(string) tmp=identifier/"."; -  ret=resolv_base(tmp[0],current_file); +  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    */    string handle_include(string f,