a580e12000-09-27Fredrik Hübinette (Hubbe) #pike __REAL_VERSION__
29a20a2003-04-27Martin Nilsson #pragma strict_types
a20af62000-09-26Fredrik Hübinette (Hubbe) 
856ad61999-09-06Fredrik Hübinette (Hubbe) constant inherit_list = __builtin.inherit_list; constant inherits = __builtin.program_inherits; constant implements = __builtin.program_implements;
838e732013-08-20Per Hedbor  // documented in the C-code. string defined(program x,string|void y) { if( !y ) return __builtin.program_defined(x); return __builtin.program_identifier_defined(x,y); }
856ad61999-09-06Fredrik Hübinette (Hubbe) 
9762ce2014-09-28Chris Angelico //! Recursively enumerate all programs this program inherits. //! Similar to inherit_tree() but returns a flat array.
856ad61999-09-06Fredrik Hübinette (Hubbe) array(program) all_inherits(program p) {
9762ce2014-09-28Chris Angelico  return inherit_list(p) + all_inherits(inherit_list(p)[*]) * ({});
856ad61999-09-06Fredrik Hübinette (Hubbe) }
7069d32001-11-07Martin Nilsson //! Recursively builds a inheritance tree by //! fetching programs inheritance lists. //! //! @returns //! Returns an array with programs or arrays //! as elements. //! //! @example //! > class a{} //! > class b{} //! > class c{ inherit a; } //! > class d{ inherit b; inherit c; } //! > Program.inherit_tree(d); //! Result: ({ /* 3 elements */ //! d, //! ({ /* 1 element */ //! program //! }), //! ({ /* 2 elements */ //! c, //! ({ /* 1 element */ //! program //! }) //! }) //! }) array inherit_tree(program p)
856ad61999-09-06Fredrik Hübinette (Hubbe) { return ({ p })+ Array.map(inherit_list(p),inherit_tree); }