Branch: Tag:

2003-09-09

2003-09-09 16:57:34 by Martin Stjernholm <mast@lysator.liu.se>

Backported fixes for handling bignum objects in the describe functions.

Rev: lib/master.pike.in:1.297

6:   // Pike is distributed under GPL, LGPL and MPL. See the file COPYING   // for more information.   // - // $Id: master.pike.in,v 1.296 2003/09/08 12:57:33 grubba Exp $ + // $Id: master.pike.in,v 1.297 2003/09/09 16:57:34 mast Exp $      #pike __REAL_VERSION__   
2800:   //! currently either @expr{"."@} or @expr{"->"@}.   string describe_module(object|program mod, array(object)|void ret_obj)   { -  if (!mod) return ""; // efun or function in gmp(0). -  program parent_fun; -  if (objectp(mod)) { -  parent_fun = object_program(mod); -  if (ret_obj) ret_obj[0] = [object]mod; -  } else if (intp(mod)) { -  // Function in gmp -  if (ret_obj) ret_obj[0] = [object]mod; -  return sprintf("%O->", mod); -  }else { -  parent_fun = [program]mod; -  if (objectp (mod = objects[parent_fun]) && ret_obj) -  ret_obj[0] = [object]mod; +  // Note: mod might be a bignum object; objectp won't work right for +  // our purposes. object_program returns zero for non-objects, so we +  // use it instead. +  program parent_fun = object_program(mod); +  if (parent_fun) { +  if (ret_obj) ret_obj[0] = mod; +  } else if (programp (mod)) { +  parent_fun = mod; +  if (objectp (mod = objects[parent_fun]) && ret_obj) ret_obj[0] = mod;    } -  +  else +  return ""; // efun +     if (mod) {    catch {    string res = sprintf("%O", mod);
2835:    parent_obj);    // werror("So far: %O parent_obj:%O\n", res, parent_obj);    object|program parent = -  objectp (parent_obj[0]) ? parent_obj[0] : object_program(parent_fun); -  if (mod && (objectp (parent) || parent)) { +  object_program (parent_obj[0]) ? parent_obj[0] : object_program(parent_fun); +  if (mod && (object_program (parent) || parent)) {    // Object identified.    catch {    // Check if we're an object in parent.
2854:       // No such luck.    // Try identifying a clone of ourselves. -  if (!mod && (objectp (parent) || parent)) { +  if (!mod && (object_program (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 = [array(string)]indices(parent);    for (i=0; i < sizeof(val); i++) { -  if (objectp(val[i]) && object_program(val[i]) == parent_fun) { +  if (object_program(val[i]) && object_program(val[i]) == parent_fun) {    return res + ind[i] + ".";    }    }
2894:       /* Try finding ourselves in parent_obj. */    int i; -  if (objectp(o)) { +  if (object_program(o)) {    i = search(values(parent_obj), o);    } else {    i = search(map(values(parent_obj),    lambda(mixed x) { -  if (objectp(x)) return object_program(x); +  if (program p = object_program(x)) return p;    return 0; -  }), o); +  }), (mixed) o);    }    if (i >= 0) {    s = [string]indices(parent_obj)[i];
2965:    if (catch (name = function_name (f))) name = "function";       object o = function_object([function(mixed...:void|mixed)]f); -  if(objectp (o)) { // Check if it's an object in a way that (hopefully) doesn't -  // call any functions in it (neither `== nor `!). +  if(object_program (o)) { // Check if it's an object in a way that +  // (hopefully) doesn't call any functions +  // in it (neither `== nor `!).    string s;    if (!catch (s = sprintf("%O",o)) && s != "object")    return s+"->"+name;