The Croc Programming Language
Reflection

Functions

const char * croc_getNameOf (CrocThread *t, word_t obj)
 
const char * croc_getNameOfn (CrocThread *t, word_t obj, uword_t *len)
 
int croc_hasField (CrocThread *t, word_t obj, const char *fieldName)
 
int croc_hasFieldStk (CrocThread *t, word_t obj, word_t name)
 
int croc_hasMethod (CrocThread *t, word_t obj, const char *methodName)
 
int croc_hasMethodStk (CrocThread *t, word_t obj, word_t name)
 
int croc_hasHField (CrocThread *t, word_t obj, const char *fieldName)
 
int croc_hasHFieldStk (CrocThread *t, word_t obj, word_t name)
 
int croc_isInstanceOf (CrocThread *t, word_t obj, word_t base)
 
word_t croc_superOf (CrocThread *t, word_t slot)
 

Detailed Description

Various kinds of introspection.

Function Documentation

const char* croc_getNameOf ( CrocThread t,
word_t  obj 
)
Returns
the name of the value at slot obj. The value must be a function, funcdef, class, or namespace.

The string returned from this points into Croc's memory. Do not modify this string, and do not store the pointer unless you know it won't be collected!

const char* croc_getNameOfn ( CrocThread t,
word_t  obj,
uword_t len 
)

Like croc_getNameOf, but returns the length of the string in bytes through the len parameter.

The string returned from this points into Croc's memory. Do not modify this string, and do not store the pointer unless you know it won't be collected!

int croc_hasField ( CrocThread t,
word_t  obj,
const char *  fieldName 
)
Returns
nonzero if the object in slot obj has a field named fieldName. Does not take opField metamethods into account.
int croc_hasFieldStk ( CrocThread t,
word_t  obj,
word_t  name 
)
Returns
nonzero if the object in slot obj has a field named the string in slot name. Does not take opField metamethods into account.
int croc_hasMethod ( CrocThread t,
word_t  obj,
const char *  methodName 
)
Returns
nonzero if the object in slot obj can have the method named methodName called on it. Does not take opMethod metamethods into account.
int croc_hasMethodStk ( CrocThread t,
word_t  obj,
word_t  name 
)
Returns
nonzero if the object in slot obj can have the method named the string in slot name called on it. Does not take opMethod metamethods into account.
int croc_hasHField ( CrocThread t,
word_t  obj,
const char *  fieldName 
)
Returns
nonzero if the class or instance in slot obj has a hidden field named fieldName.
int croc_hasHFieldStk ( CrocThread t,
word_t  obj,
word_t  name 
)
Returns
nonzero if the class or instance in slot obj has a hidden field named the string in slot name.
int croc_isInstanceOf ( CrocThread t,
word_t  obj,
word_t  base 
)
Returns
nonzero if the value in slot obj is an instance, and the class it was instantiated from is the class in slot base. Note that this returns false if obj is not an instance, instead of throwing an error.
word_t croc_superOf ( CrocThread t,
word_t  slot 
)

Gets the super of the object in slot and pushes it.

For instances, this is the class it was instantiated from; for namespaces, the parent namespace (or null if none).

Returns
the stack index of the pushed value.