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.233 2002/11/29 11:09:39 grubba Exp $ + // $Id: master.pike.in,v 1.234 2002/12/01 23:47:00 mast 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:37:   #undef BT_MAX_STRING_LEN   #define BT_MAX_STRING_LEN 200   #endif /* !defined(BT_MAX_STRING_LEN) || (BT_MAX_STRING_LEN <= 0) */   constant bt_max_string_len = BT_MAX_STRING_LEN;      //! @decl constant bt_max_string_len = 200   //! This constant contains the maximum length of a function entry in a   //! backtrace. Defaults to 200 if no BT_MAX_STRING_LEN define has been   //! given.    - // Enables the out of date warning in low_find_prog(). + // Enables the out of date warning in low_findprog().   #ifndef OUT_OF_DATE_WARNING   #define OUT_OF_DATE_WARNING 1   #endif /* OUT_OF_DATE_WARNING */   constant out_of_date_warning = OUT_OF_DATE_WARNING;      //! @decl constant out_of_date_warning = 1   //! Should Pike complain about out of date compiled files.   //! 1 means yes and 0 means no. Controlled by the OUT_OF_DATE_WARNING   //! define.   
pike.git/lib/master.pike.in:488:   #endif      #ifdef PIKE_MODULE_RELOC    fname = unrelocate_module(fname);   #endif      #ifdef PIKE_AUTORELOAD    if(!autoreload_on || load_time[fname]>=time())   #endif    { -  if(!zero_type (ret=programs[fname])) return ret; +  if(!zero_type (ret=programs[fname])) { + #ifdef RESOLV_DEBUG +  werror ("low_findprog: %s returning cached (no autoreload)\n", fname); + #endif +  return ret;    } -  +  }      #ifdef __NT__    // Ugly kluge to work better with cygwin32    if(getenv("OSTYPE")=="cygwin32")    {    string tmp=fname[..1];    if((tmp=="//" || tmp=="\\\\") && (fname[3]=='/' || fname[3]=='\\'))    {    if(!master_file_stat(fname))    {
pike.git/lib/master.pike.in:512:    }    }   #endif       if( (s=master_file_stat(fakeroot(fname))) && s[1]>=0 )    {    AUTORELOAD_BEGIN();      #ifdef PIKE_AUTORELOAD    if (load_time[fname] > s[3]) -  if (!zero_type (ret=programs[fname])) return ret; +  if (!zero_type (ret=programs[fname])) { + #ifdef RESOLV_DEBUG +  werror ("low_findprog: %s returning cached (autoreload)\n", fname);   #endif -  +  return ret; +  } + #endif       switch(ext)    {    case "":    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), +  ret = decode_value(master_read_file(oname),    Codec(fname, mkobj)); -  + #ifdef RESOLV_DEBUG +  werror ("low_findprog: %s returning decoded dump\n", fname); + #endif +  return programs[fname] = ret; +     };    m_delete(programs, fname);    if (handler && handler->compile_warning) {    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:551:    if (handler && handler->compile_warning) {    handler->compile_warning(oname, 0,    "Compiled file is out of date\n");    } else {    compile_warning(oname, 0, "Compiled file is out of date\n");    }    }    }    }    -  programs[fname]=ret=__empty_program(); + #ifdef RESOLV_DEBUG +  werror ("low_findprog: %s compiling\n", fname); + #endif +  programs[fname]=ret=__empty_program(0, fname);    if ( mixed e=catch {    ret=compile_file(fname,    handler,    ret,    mkobj? (objects[ret]=__null_program()) : 0);    } )    {    ret=programs[fname]=0;    throw(e);    }    break;   #if constant(load_module)    case ".so":    if (fname == "") {    werror( "low_findprog(\"%s\", \"%s\") => load_module(\"\")\n"    "%s\n", pname, ext, describe_backtrace(backtrace()) );    }       ret=load_module(fakeroot(fname)); -  + #ifdef RESOLV_DEBUG +  werror ("low_findprog: %s loaded binary\n", fname); + #endif   #endif /* load_module */    }       AUTORELOAD_FINISH(ret,programs,fname);       return programs[fname]=ret;    } -  + #ifdef RESOLV_DEBUG +  werror ("low_findprog: %s file not found\n", fname); + #endif    return 0;   }      //   // This function is called by the compiler when a delayed compilation   // error occurs in the given program. It should remove all references   // to the program so that it can be freed.   //   void unregister(program p)   {
pike.git/lib/master.pike.in:599:    m_delete(programs, fname);    // FIXME: The following assumes that programs are always stored    // with '/' as path separators, even on NT. Haven't checked if    // that always is the case.    fname = dirname (fname);    object n;    if ( fname!="" && (n = fc[fname]) )    if (n->is_resolv_dirnode || n->is_resolv_joinnode)    n->delete_value (p);    } -  if (zero_type(objects[p]) != 1) +  if (objectp (objects[p]))    m_delete(objects, p);    foreach (fc; string name; mixed mod)    if (objectp(mod) && object_program(mod) == p)    m_delete(fc, name);   }      static program findprog(string pname,    string ext,    object|void handler,    void|int mkobj)
pike.git/lib/master.pike.in:813:   mapping (program:object) objects=([object_program(this_object()):this_object()]);      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, current_handler, 1);    if(!p) return 0; -  if(zero_type (o=objects[p])) o=objects[p]=p(); +  if(!objectp (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; +  object o = low_cast_to_object(oname, current_file); +  if (objectp (o)) 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;    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=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
pike.git/lib/master.pike.in:958:   #endif    if(!zero_type(ret=cache[index]))    {   #ifdef MODULE_TRACE    werror("%*nDirnode(%O) cache[%O] -> %O\n",sizeof(backtrace()),dirname,index, ret);   #endif    if (ret != ZERO_TYPE) return ret;    return UNDEFINED;    }    ret=ind(index); -  -  // Kluge! -  if(ret == __placeholder_object) return ret; -  +     cache[index] = zero_type(ret) ? ZERO_TYPE : ret;    return ret;    }       static int _cache_full;    void fill_cache()    {   #ifdef RESOLV_DEBUG    werror(describe_backtrace(({ sprintf("Filling cache in dirnode %O\n",    dirname),
pike.git/lib/master.pike.in:1170:    if (o == 0) return UNDEFINED;    return o;    }       if(Stat stat=master_file_stat(fakeroot(fullname+".pmod")))    {    if(stat[1]==-2)    return dirnode(fullname+".pmod", handler);    }    -  if(o = low_cast_to_object(fullname+".pmod", "/.", handler)) +  if(objectp (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    -  return fc[fullname]=UNDEFINED; +  return fc[fullname] = 0;   }      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;
pike.git/lib/master.pike.in:1366:    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); -  mixed ret; -  if(!zero_type(ret=findmodule(file, current_handler))) { -  if ((objectp(ret)) && -  (ret->is_resolv_dirnode || ret->is_resolv_joinnode)) { +  mixed ret = findmodule(file, current_handler); +  if(objectp (ret)) { // ret is either zero or an object here. +  if (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;    }    if (!sizeof(tmp)) {    return ret;
pike.git/lib/master.pike.in:2359:   //! currently either @tt{"."@} or @tt{"->"@}.   string describe_module(object|program mod, array(object)|void ret_obj)   {    if (!mod) return "";    program parent_fun;    if (objectp(mod)) {    parent_fun = object_program(mod);    if (ret_obj) ret_obj[0] = mod;    } else {    parent_fun = mod; -  if (!zero_type (mod = objects[parent_fun]) && ret_obj) ret_obj[0] = mod; +  if (objectp (mod = objects[parent_fun]) && ret_obj) ret_obj[0] = mod;    }    if (mod) {    catch {    string res = sprintf("%O", mod);    if (res != "object" && res != "") -  return (!zero_type (objects[parent_fun]) && programs["/master"] != parent_fun? +  return (objectp (objects[parent_fun]) && programs["/master"] != parent_fun?    res+".":res+"->");    };    }    if (!object_program(parent_fun)) {    // We might be a top-level entity.    string path = get_clean_program_path(parent_fun, "", ".", "()->");    if(path) return path;    }    // Begin by describing our parent.    array(object) parent_obj = ({ 0 });    string res = describe_module(function_object(parent_fun)||    object_program(parent_fun),    parent_obj);    // werror("So far: %O parent_obj:%O\n", res, parent_obj); -  object|program parent = parent_obj[0] || object_program(parent_fun); -  if (mod && parent) { +  object|program parent = +  objectp (parent_obj[0]) ? parent_obj[0] : object_program(parent_fun); +  if (mod && (objectp (parent) || parent)) {    // Object identified.    catch {    // Check if we're an object in parent.    int i = search(values(parent), mod);    if (i >= 0) {    return res + indices(parent)[i] + ".";    }    };    }       // We're cloned from something in parent.    if (string fun_name = function_name(parent_fun)) {    return res + fun_name + "()->";    }       // No such luck.    // Try identifying a clone of ourselves. -  if (!mod && parent) { +  if (!mod && (objectp (parent) || parent)) {    catch {    // Check if there's a clone of parent_fun in parent_obj.    int i;    array(mixed) val = values(parent);    array(string) ind = indices(parent);    for (i=0; i < sizeof(val); i++) {    if (objectp(val[i]) && object_program(val[i]) == parent_fun) {    return res + ind[i] + ".";    }    }
pike.git/lib/master.pike.in:2429:   {    string s;    if(!o) return 0;       function parent_fun = object_program(o);       /* Constant object? */    catch {    object|program parent_obj = function_object(parent_fun);    -  if (parent_obj) { +  if (objectp (parent_obj)) {    /* Check if we have a constant object. */    object tmp = objects[parent_obj]; -  if (!zero_type (tmp)) parent_obj = tmp; +  if (objectp (tmp)) parent_obj = tmp;       /* Try finding ourselves in parent_obj. */    int i;    if (objectp(o)) {    i = search(values(parent_obj), o);    } else {    i = search(map(values(parent_obj),    lambda(mixed x) {    if (objectp(x)) return object_program(x);    return 0;    }), o);    }    if (i >= 0) {    s = indices(parent_obj)[i];    return describe_module(parent_obj) + s;    }    }    }; -  if(!zero_type (objects[parent_fun])) +  if(objectp (objects[parent_fun]))    if(s=get_clean_program_path(parent_fun, "", "", "()"))    return s;    /* Try identifying the program. */    if(( s=describe_program(parent_fun) ))    return s+"()";       return 0;   }      //!
pike.git/lib/master.pike.in:2732:   {    program prog_to_mkobj;       object __register_new_program(program p)    {    if(fname)    {    programs[fname]=prog_to_mkobj=p;    fname=0;    if (mkobj) -  return zero_type (objects[p]) ? (objects[p]=__null_program()) : objects[p]; +  return objectp (objects[p]) ? objects[p] : (objects[p]=__null_program());    }    return 0;    }       mapping f=all_constants();       string nameof(mixed x)    {    if(mixed tmp=search(f,x))    return "efun:"+tmp;
pike.git/lib/master.pike.in:2770:    if(sscanf(x,"efun:%s",x)) return f[x];    if(sscanf(x,"resolv:%s",x)) return resolv(x);    return 0;    }       object objectof(string x)    {    if(sscanf(x,"efun:%s",x)) return f[x];    if(sscanf(x,"resolv:%s",x)) return resolv(x);    if(sscanf(x,"mpath:%s",x)) -  foreach(pike_module_path, string path) -  if(object ret=low_cast_to_object(combine_path(path,x),0)) -  return ret; +  foreach(pike_module_path, string path) { +  object ret = low_cast_to_object(combine_path(path,x),0); +  if (objectp (ret)) return ret; +  }    return cast_to_object(x,0);    }       program programof(string x)    {    if(sscanf(x,"efun:%s",x)) return f[x];    if(sscanf(x,"resolv:%s",x)) return resolv(x);    if(sscanf(x,"mpath:%s",x))    foreach(pike_module_path, string path)    if(program ret=cast_to_program(combine_path(path,x),0))