23. Introspection
23.1. Value inspection
- Methodarrayp
int
arrayp(mixed
arg
)- Description
Returns
1
ifarg
is an array,0
(zero) otherwise.- See also
intp()
,programp()
,mappingp()
,stringp()
,objectp()
,multisetp()
,floatp()
,functionp()
- Methodcallablep
int
callablep(mixed
arg
)- Description
Returns
1
ifarg
is a callable,0
(zero) otherwise.- See also
mappingp()
,programp()
,arrayp()
,stringp()
,objectp()
,multisetp()
,floatp()
,intp()
- Methoddestructedp
int
destructedp(mixed
arg
)- Description
Returns
1
ifarg
is a destructed object,0
(zero) otherwise.- See also
zero_type
,undefinedp
,intp
- Methodfloatp
int
floatp(mixed
arg
)- Description
Returns
1
ifarg
is a float,0
(zero) otherwise.- See also
intp()
,programp()
,arrayp()
,multisetp()
,objectp()
,mappingp()
,stringp()
,functionp()
- Methodfunctionp
int
functionp(mixed
arg
)- Description
Returns
1
ifarg
is a function,0
(zero) otherwise.- See also
mappingp()
,programp()
,arrayp()
,stringp()
,objectp()
,multisetp()
,floatp()
,intp()
- Methodintp
int
intp(mixed
arg
)- Description
Returns
1
ifarg
is an int,0
(zero) otherwise.- See also
mappingp()
,programp()
,arrayp()
,stringp()
,objectp()
,multisetp()
,floatp()
,functionp()
- Methodmappingp
int
mappingp(mixed
arg
)- Description
Returns
1
ifarg
is a mapping,0
(zero) otherwise.- See also
intp()
,programp()
,arrayp()
,stringp()
,objectp()
,multisetp()
,floatp()
,functionp()
- Methodmultisetp
int
multisetp(mixed
arg
)- Description
Returns
1
ifarg
is a multiset,0
(zero) otherwise.- See also
intp()
,programp()
,arrayp()
,stringp()
,objectp()
,mappingp()
,floatp()
,functionp()
- Methodprogramp
int
programp(mixed
arg
)- Description
Returns
1
ifarg
is a program,0
(zero) otherwise.- See also
mappingp()
,intp()
,arrayp()
,stringp()
,objectp()
,multisetp()
,floatp()
,functionp()
- Methodundefinedp
int
undefinedp(mixed
arg
)- Description
Returns
1
ifarg
is undefined,0
(zero) otherwise.- See also
zero_type
,destructedp
,intp
23.2. Content inspection
- Methodindices
array
indices(string
|array
|mapping
|multiset
|object
x
)- Description
Return an array of all valid indices for the value
x
.- Parameter
x
string
For strings and arrays this is simply an array of ascending numbers.
mapping
For mappings and multisets, the array might contain any value.
object
For objects which define
lfun::_indices()
that return value is used.For other objects an array with the names of all non-protected symbols is returned.
- See also
values()
,types()
,lfun::_indices()
- Methodvalues
array
values(string
|array
|mapping
|multiset
|object
x
)- Description
Return an array of all possible values from indexing the value
x
.- Parameter
x
string
For strings an array of int with the ISO10646 codes of the characters in the string is returned.
multiset
For a multiset an array filled with ones (
1
) is returned.array
For arrays a single-level copy of
x
is returned.mapping
For mappings the array may contain any value.
object
For objects which define
lfun::_values()
that return value is used.For other objects an array with the values of all non-protected symbols is returned.
- See also
indices()
,types()
,lfun::_values()
- Methodtypes
array
(type
) types(string
|array
|mapping
|multiset
|object
|program
x
)- Description
Return an array with the types of all valid indices for the value
x
.- Parameter
x
string
For strings this is simply an array with int
array
For arrays, mappings and multisets this is simply an array with mixed.
object
For objects which define
lfun::_types()
that return value is used.For other objects an array with type types for all non-protected symbols is returned.
- Note
This function was added in Pike 7.9.
- See also
indices()
,values()
,lfun::_types()
- Methodannotations
array
(multiset
(Pike.Annotation
)) annotations(object
|program
|function
(:void
)x
,bool
|void
recurse
)- Description
Return an array with the annotations for all symbols in
x
.- Parameter
x
object
For objects which define
lfun::_annotations()
that return value is used.For other objects an array with annotations for all non-protected symbols is returned.
program
Returns an array with annotations for all non-protected constant symbols.
- Parameter
recurse
Include annotations recursively added via inherits.
- Returns
The order of the resulting array is the same as that of
indices()
for the samex
.- Note
This function was added in Pike 8.1.
- See also
indices()
,values()
,types()
,lfun::_annotations()
,::_annotations()
,Program.annotations
- Methodget_weak_flag
int
get_weak_flag(array
|mapping
|multiset
m
)- Description
Returns the weak flag settings for
m
. It's a combination ofPike.WEAK_INDICES
andPike.WEAK_VALUES
.
23.3. Integer inspection
- Methodzero_type
int
zero_type(mixed
a
)- Description
Return the type of zero.
There are many types of zeros out there, or at least there are two. One is returned by normal functions, and one returned by mapping lookups and
find_call_out()
when what you looked for wasn't there. The only way to separate these two kinds of zeros iszero_type()
.- Returns
When doing a
find_call_out()
or mapping lookup,zero_type()
on this value will return1
if there was no such thing present in the mapping, or if no such call_out could be found.If the argument to
zero_type()
is a destructed object or a function in a destructed object,2
will be returned.In all other cases
zero_type()
will return0
(zero).- See also
find_call_out()
23.4. Function inspection
- Methodfunction_name
string
function_name(function
(:void
)|program
f
)- Description
Return the name of the function or program
f
.If
f
is a global function defined in the runtime0
(zero) will be returned.- See also
function_object()
- Methodfunction_object
object
function_object(function
(:void
)f
)- Description
Return the object the function
f
is in.If
f
is a global function defined in the runtime0
(zero) will be returned.Zero will also be returned if
f
is a constant in the parent class. In that casefunction_program()
can be used to get the parent program.- See also
function_name()
,function_program()
- Methodfunction_program
program
function_program(function
(:void
)|program
f
)- Description
Return the program the function
f
is in.If
f
is a global function defined in the runtime0
(zero) will be returned.- See also
function_name()
,function_object()
23.5. Object inspection
- Methodobject_program
program
|function
(:void
) object_program(mixed
o
)- Description
Return the program from which
o
was instantiated. If the object was instantiated from a class using parent references the generating function will be returned.If
o
is not an object or has been destructed0
(zero) will be returned.
23.6. Program inspection
- Methodget_profiling_info
array
(int
|mapping
(string
:array
(int
))) get_profiling_info(program
prog
)- Description
Get profiling information.
- Returns
Returns an array with two elements.
Array int
num_clones
The first element is the number of times the program
prog
has been instantiated.mapping
(string
:array
(int
))fun_prof_info
The second element is mapping from function name to an array with three elements.
Array int
num_calls
The first element is the number of times the function has been called.
int
total_time
The second element is the total time (in milliseconds) spent executing this function, and any functions called from it.
int
self_time
The third element is the time (in milliseconds) actually spent in this function so far.
- Note
This function is only available if the runtime was compiled with the option --with-profiling.
- Methodtypeof_identifier
type
|zero
typeof_identifier(program
p
,string
identifier
)- Description
Allows access to the static type of an identifier ("member") in a program.
- Returns
The static type of
p->identifier
, orUNDEFINED
if it can not be determined, be it becauseidentifier
does not exist inp
or for other reasons.