pike.git / lib / master.pike.in

version» Context lines:

pike.git/lib/master.pike.in:1:   /* -*- Pike -*-    * -  * $Id: master.pike.in,v 1.127 2000/08/29 14:46:36 mast Exp $ +  * $Id: master.pike.in,v 1.128 2000/08/29 21:54:01 mast Exp $    *    * Master-file for Pike.    *    * Based on master.pike 1.67.    */      // Some configurable parameters useful for debugging      #define PIKE_AUTORELOAD   
pike.git/lib/master.pike.in:1413:    else if (multisetp (stuff)) {    if (!ident[stuff]++)    foreach (indices (stuff), mixed elem)    identify_parts (elem);    }    else if (mappingp (stuff)) {    if (!ident[stuff]++)    foreach (indices (stuff), mixed elem)    identify_parts (elem), identify_parts (stuff[elem]);    } -  else if (objectp (stuff)) +  else if (objectp (stuff) || functionp (stuff) || programp (stuff))    ident[stuff]++;    }    -  string describe (mixed m, int maxlen) +  string describe_string (string m, int maxlen)    { -  if (stringp (ident[m])) return ident[m]; -  else if (intp (ident[m]) && ident[m] > 1) -  ident[m] = "@" + identcount++; -  -  string res, typ; -  if (catch (typ=sprintf("%t",m))) -  typ = "object"; // Object with a broken _sprintf(), probably. -  switch(typ) -  { -  case "int": -  case "float": -  return (string)m; -  -  case "string": +     canclip++;    if(sizeof(m) < maxlen)    {    string t = sprintf("%O", m);    if (sizeof(t) < (maxlen + 2)) {    return t;    }    t = 0;    }    clipped++;    if(maxlen>10)    {    return sprintf("%O+[%d]",m[..maxlen-5],sizeof(m)-(maxlen-5));    }else{    return "string["+sizeof(m)+"]";    } -  +  }    -  case "array": -  if(!sizeof(m)) res = "({})"; +  string describe_array (array m, int maxlen) +  { +  if(!sizeof(m)) return "({})";    else {    if(maxlen<5)    {    clipped++; -  res = "array["+sizeof(m)+"]"; +  return "array["+sizeof(m)+"]";    }    else {    canclip++; -  res = "({" + describe_comma_list(m,maxlen-2) +"})"; +  return "({" + describe_comma_list(m,maxlen-2) +"})";    }    } -  break; +  }    -  +  string describe_mapping (mapping m, int maxlen) +  { +  if(!sizeof(m)) return "([])"; +  else return "mapping["+sizeof(m)+"]"; +  } +  +  string describe_multiset (multiset m, int maxlen) +  { +  if(!sizeof(m)) return "(<>)"; +  else return "multiset["+sizeof(m)+"]"; +  } +  +  string describe (mixed m, int maxlen) +  { +  if (stringp (ident[m])) return ident[m]; +  else if (intp (ident[m]) && ident[m] > 1) +  ident[m] = "@" + identcount++; +  +  string res, typ; +  if (catch (typ=sprintf("%t",m))) +  typ = "object"; // Object with a broken _sprintf(), probably. +  switch(typ) +  { +  case "int": +  case "float": +  return (string)m; +  case "string": +  return describe_string (m, maxlen); +  case "array": +  res = describe_array (m, maxlen); +  break;    case "mapping": -  if(!sizeof(m)) res = "([])"; -  else res = "mapping["+sizeof(m)+"]"; +  res = describe_mapping (m, maxlen);    break; -  +     case "multiset": -  if(!sizeof(m)) res = "(<>)"; -  else res = "multiset["+sizeof(m)+"]"; +  res = describe_multiset (m, maxlen);    break; -  +     case "function": -  if(string tmp=describe_program(m)) return tmp; -  if(object o=function_object(m)) { -  string s = describe_object(o); -  if (s && s != "object") return s+"->"+function_name(m); -  else return function_name(m); -  } -  else { -  string tmp; -  if (catch (tmp = function_name(m))) -  // The function object has probably been destructed. -  return "function"; -  return tmp || "function"; -  } -  +  if (string tmp=describe_function(m)) res = tmp; +  else res = typ; +  break;    case "program": -  if(string tmp=describe_program(m)) return tmp; -  return typ; -  +  if(string tmp=describe_program(m)) res = tmp; +  else res = typ; +  break;    default:    if (objectp(m))    if(string tmp=describe_object(m)) {    res = tmp;    break;    } -  return typ; +  res = typ;    }       if (stringp (ident[m]))    return ident[m] + "=" + res;    return res;    }       string describe_comma_list(array x, int maxlen)    {    string ret="";
pike.git/lib/master.pike.in:1637:    if(mixed tmp=function_object(p))    if(s=describe_program(object_program(tmp)))    return s+"."+function_name(p);       if(s=_static_modules.Builtin()->program_defined(p))    return EXPLODE_PATH(s)[-1];       return 0;   }    + string describe_function (function f) + { +  if (!f) return 0; +  +  string name; +  +  if(string s=search(programs,f)) +  { +  if(sscanf(reverse(s),"%s.%s",string ext,string rest) && ext=="domp") +  name = EXPLODE_PATH(reverse(rest))[-1]; +  else +  name = trim_file_name(s); +  } +  else +  if (catch (name = function_name (f))) name = "function"; +  +  if(object o=function_object(f)) { +  string s; +  if (!catch (s = sprintf("%O",o)) && s != "object") +  return s+"->"+name; +  } +  return name; + } +    /* It is possible that this should be a real efun,    * it is currently used by handle_error to convert a backtrace to a    * readable message.    */   string describe_backtrace(mixed trace, void|int linewidth)   {    int e;    string ret;    int backtrace_len=((int)getenv("PIKE_BACKTRACE_LEN")) || bt_max_string_len;   
pike.git/lib/master.pike.in:1721:    };    }    pos=desc;    }       string data;       if(sizeof(tmp)>=3)    {    if(functionp(tmp[2])) { -  data = ""; -  if (object o = function_object(tmp[2])) { -  string s; -  if (!catch (s = sprintf("%O",o)) && s != "object") -  data = s + "->"; +  data = describe_function (tmp[2]);    } -  data += function_name(tmp[2]); -  } +     else if (stringp(tmp[2])) {    data= tmp[2];    } else    data ="unknown function";       data+="("+    desc->describe_comma_list(tmp[3..], backtrace_len)+    ")";       if(sizeof(pos)+sizeof(data) < linewidth-4)