The Croc Programming Language
Type queries

Macros

#define croc_isNull(t, slot)   (croc_type((t), (slot)) == CrocType_Null)
 
#define croc_isBool(t, slot)   (croc_type((t), (slot)) == CrocType_Bool)
 
#define croc_isInt(t, slot)   (croc_type((t), (slot)) == CrocType_Int)
 
#define croc_isFloat(t, slot)   (croc_type((t), (slot)) == CrocType_Float)
 
#define croc_isNativeobj(t, slot)   (croc_type((t), (slot)) == CrocType_Nativeobj)
 
#define croc_isString(t, slot)   (croc_type((t), (slot)) == CrocType_String)
 
#define croc_isWeakref(t, slot)   (croc_type((t), (slot)) == CrocType_Weakref)
 
#define croc_isTable(t, slot)   (croc_type((t), (slot)) == CrocType_Table)
 
#define croc_isNamespace(t, slot)   (croc_type((t), (slot)) == CrocType_Namespace)
 
#define croc_isArray(t, slot)   (croc_type((t), (slot)) == CrocType_Array)
 
#define croc_isMemblock(t, slot)   (croc_type((t), (slot)) == CrocType_Memblock)
 
#define croc_isFunction(t, slot)   (croc_type((t), (slot)) == CrocType_Function)
 
#define croc_isFuncdef(t, slot)   (croc_type((t), (slot)) == CrocType_Funcdef)
 
#define croc_isClass(t, slot)   (croc_type((t), (slot)) == CrocType_Class)
 
#define croc_isInstance(t, slot)   (croc_type((t), (slot)) == CrocType_Instance)
 
#define croc_isThread(t, slot)   (croc_type((t), (slot)) == CrocType_Thread)
 

Functions

CrocType croc_type (CrocThread *t, word_t slot)
 
word_t croc_pushTypeString (CrocThread *t, word_t slot)
 
int croc_isNum (CrocThread *t, word_t slot)
 
int croc_isChar (CrocThread *t, word_t slot)
 

Detailed Description

Checking the types of values.

Macro Definition Documentation

#define croc_isNull (   t,
  slot 
)    (croc_type((t), (slot)) == CrocType_Null)

These are all convenience macros which evaluate to nonzero if the given slot is the given type.

#define croc_isBool (   t,
  slot 
)    (croc_type((t), (slot)) == CrocType_Bool)

These are all convenience macros which evaluate to nonzero if the given slot is the given type.

#define croc_isInt (   t,
  slot 
)    (croc_type((t), (slot)) == CrocType_Int)

These are all convenience macros which evaluate to nonzero if the given slot is the given type.

#define croc_isFloat (   t,
  slot 
)    (croc_type((t), (slot)) == CrocType_Float)

These are all convenience macros which evaluate to nonzero if the given slot is the given type.

#define croc_isNativeobj (   t,
  slot 
)    (croc_type((t), (slot)) == CrocType_Nativeobj)

These are all convenience macros which evaluate to nonzero if the given slot is the given type.

#define croc_isString (   t,
  slot 
)    (croc_type((t), (slot)) == CrocType_String)

These are all convenience macros which evaluate to nonzero if the given slot is the given type.

#define croc_isWeakref (   t,
  slot 
)    (croc_type((t), (slot)) == CrocType_Weakref)

These are all convenience macros which evaluate to nonzero if the given slot is the given type.

#define croc_isTable (   t,
  slot 
)    (croc_type((t), (slot)) == CrocType_Table)

These are all convenience macros which evaluate to nonzero if the given slot is the given type.

#define croc_isNamespace (   t,
  slot 
)    (croc_type((t), (slot)) == CrocType_Namespace)

These are all convenience macros which evaluate to nonzero if the given slot is the given type.

#define croc_isArray (   t,
  slot 
)    (croc_type((t), (slot)) == CrocType_Array)

These are all convenience macros which evaluate to nonzero if the given slot is the given type.

#define croc_isMemblock (   t,
  slot 
)    (croc_type((t), (slot)) == CrocType_Memblock)

These are all convenience macros which evaluate to nonzero if the given slot is the given type.

#define croc_isFunction (   t,
  slot 
)    (croc_type((t), (slot)) == CrocType_Function)

These are all convenience macros which evaluate to nonzero if the given slot is the given type.

#define croc_isFuncdef (   t,
  slot 
)    (croc_type((t), (slot)) == CrocType_Funcdef)

These are all convenience macros which evaluate to nonzero if the given slot is the given type.

#define croc_isClass (   t,
  slot 
)    (croc_type((t), (slot)) == CrocType_Class)

These are all convenience macros which evaluate to nonzero if the given slot is the given type.

#define croc_isInstance (   t,
  slot 
)    (croc_type((t), (slot)) == CrocType_Instance)

These are all convenience macros which evaluate to nonzero if the given slot is the given type.

#define croc_isThread (   t,
  slot 
)    (croc_type((t), (slot)) == CrocType_Thread)

These are all convenience macros which evaluate to nonzero if the given slot is the given type.

Function Documentation

CrocType croc_type ( CrocThread t,
word_t  slot 
)
Returns
a member of the CrocType enumeration telling what type of value is in the given stack slot.
word_t croc_pushTypeString ( CrocThread t,
word_t  slot 
)

Pushes a nice string representation of the type of the value in slot, which is useful for error messages.

This is equivalent to Croc's niceTypeof library function.

int croc_isNum ( CrocThread t,
word_t  slot 
)
Returns
nonzero if the given stack slot holds either an int or a float, and 0 otherwise.
int croc_isChar ( CrocThread t,
word_t  slot 
)
Returns
nonzero if the given stack slot holds a string that is exactly one codepoint long, and 0 otherwise.