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.224 2002/11/23 13:22:38 grubba Exp $ + // $Id: master.pike.in,v 1.225 2002/11/23 17:07:51 marcus 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:2059:    if (want_warnings)    switch (where + "." + what) {    case "gc.bad_cycle":    // args[0] is an array containing the objects in the cycle    // which aren't destructed and have destroy() functions.   #if 0    // Ignore this warning for now since we do not yet have a weak    // modifier, so it can't be avoided in a reasonable way.    werror ("GC warning: Garbing cycle where destroy() will be called "    "in arbitrary order:\n%{ %s\n%}", -  map (args[0], describe_object)); +  sprintf("%O", args[0][*]));   #endif    break;       default:    werror ("%s warning: %s %O\n", capitalize (where), what, args);    }   }         static mixed _charset_mod;
pike.git/lib/master.pike.in:2220:    case "function":    if (string tmp=describe_function(m)) res = tmp;    else res = typ;    break;    case "program":    if(string tmp=describe_program(m)) res = tmp;    else res = typ;    break;    default:    if (objectp(m)) -  if(string tmp=describe_object(m)) { +  if(string tmp=sprintf("%O", m)) {    res = tmp;    break;    }    res = typ;    }    };    if (!res) {    // Extra paranoia case.    res = sprintf("Instance of %O", _typeof(m));    }
pike.git/lib/master.pike.in:2334:    break;    }    }    }       return ret;    }   }       + static string get_clean_program_path ( program p, string suff1, string suff2 ) + { +  array(string) sort_paths_by_length(array(string) paths) +  { +  sort(map(paths, sizeof), paths); +  return reverse(paths); +  }; +  string path = search(programs, p); +  if (path) { +  if (path == "/master") return "master()"+suff2; +  foreach(sort_paths_by_length(map(pike_module_path - ({""}), +  lambda(string s) { +  if (s[-1] == '/') return s; +  return s+"/"; +  })), +  string prefix) { +  if (has_prefix(path, prefix)) { +  path = path[sizeof(prefix)..]; +  break; +  } +  } +  path = trim_file_name(path); +  string modname = replace(path, ".pmod/", "."); +  if(search(modname, "/")<0) path=modname; +  if (has_suffix(path, ".pmod/module.pmod")) { +  return path[..sizeof(path)-18]+suff1; +  } +  if (has_suffix(path, ".pmod")) { +  return path[..sizeof(path)-6]+suff1; +  } +  if (has_suffix(path, ".so")) { +  return path[..sizeof(path)-4]+suff1; +  } +  if (has_suffix(path, ".pike")) { +  return path[..sizeof(path)-6]+suff2; +  } +  return path + suff2; +  } +  return 0; + } +  +    //! Describe the path to the module @[mod].   //!   //! @param mod   //! If @[mod] is a program, attempt to describe the path   //! to a clone of @[mod].   //!   //! @param ret_obj   //! If an instance of @[mod] is found, it will be returned   //! by changing element @tt{0@} of @[ret_obj].   //!
pike.git/lib/master.pike.in:2364:    if (objectp(mod)) {    parent_fun = object_program(mod);    if (ret_obj) ret_obj[0] = mod;    } else {    parent_fun = mod;    if ((mod = objects[parent_fun]) && ret_obj) ret_obj[0] = mod;    }    if (mod) {    catch {    string res = sprintf("%O", mod); -  if (res != "object" && res != "") return res+"->"; +  if (res != "object" && res != "") +  return (objects[parent_fun]? res+".":res+"->");    };    }    if (!object_program(parent_fun)) {    // We might be a top-level entity. -  string path = search(programs, parent_fun); -  if (path) { -  if (path == "/master") return "master()->"; -  foreach(map(pike_module_path - ({""}), -  lambda(string s) { -  if (s[-1] == '/') return s; -  return s+"/"; -  }), -  string prefix) { -  if (has_prefix(path, prefix)) { -  path = path[sizeof(prefix)..]; -  break; +  string path = get_clean_program_path(parent_fun, ".", "()->"); +  if(path) return path;    } -  } -  if (has_suffix(path, ".pmod/module.pmod")) { -  return path[..sizeof(path)-18]+"."; -  } -  if (has_suffix(path, ".pmod")) { -  return path[..sizeof(path)-6]+"."; -  } -  if (has_suffix(path, ".so")) { -  return path[..sizeof(path)-4]+"."; -  } -  if (has_suffix(path, ".pike")) { -  return path[..sizeof(path)-6]+"()->"; -  } -  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 identified.    catch {
pike.git/lib/master.pike.in:2438:    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] + ".";    }    }    };    }       // We're really out of luck here... -  return res + "unknown_program()->"; +  return res + (describe_program(parent_fun)||"unknown_program") + "()->";   }      //!   string describe_object(object|program o)   {    string s;    if(!o) return 0;    -  if (!catch (s = sprintf("%O",o)) && s != "object") return s; -  +     function parent_fun = object_program(o);       /* Constant object? */    catch {    object|program parent_obj = function_object(parent_fun);       if (parent_obj) {    /* Check if we have a constant object. */    object tmp = objects[parent_obj];    if (tmp) parent_obj = tmp;
pike.git/lib/master.pike.in:2473:    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; +  return describe_module(parent_obj) + s;    }    }    };    /* Try identifying the program. */    if(( s=describe_program(parent_fun) )) -  return s+"()"; +  return (objects[parent_fun]? s : s+"()");       return 0;   }      //!   string describe_program(program p)   {    string s;    if(!p) return 0; -  if(s=search(programs,p)) -  { -  if(has_suffix(s, ".pmod")) -  return EXPLODE_PATH(s[..sizeof(s)-6])[-1]; -  return trim_file_name(s); -  } +     -  +  if(s=get_clean_program_path(p, "", "")) +  return s; +     if(mixed tmp=function_object(p))    {    return describe_module(tmp) + function_name(p);    }       if(s=_static_modules.Builtin()->program_defined(p))    return EXPLODE_PATH(s)[-1];       return 0;   }