ValueType type_of (Value* self) { if (IS_NIL(self)) { return VALUE_TYPE_NIL; } else if (IS_BOOLEAN(self)) { return VALUE_TYPE_BOOLEAN; } else { return self->type; } }
bool JstrChecker::IS_SCALAR(const wstring &str, ScalarCat &cat, wstring &vstr, Number &vnmbr, bool &vbln) { if (IS_STRING(str, vstr)) { cat = ScalarCat::SC_STRING; return true; } if (IS_NUMBER(str, vnmbr)) { cat = ScalarCat::SC_NUMBER; return true; } if (IS_BOOLEAN(str, vbln)) { cat = ScalarCat::SC_BOOLEAN; return true; } if (IS_NULL(str)) { cat = ScalarCat::SC_NULL; return true; } return false; }
uint64_t hash_for (Value* value) { if (IS_NIL(value) || IS_BOOLEAN(value)) { return (uint64_t) value; } else { switch (value->type) { case VALUE_TYPE_INTEGER: return Integer_hash((Integer*) value); case VALUE_TYPE_FLOATING: return Floating_hash((Floating*) value); case VALUE_TYPE_RATIONAL: return Rational_hash((Rational*) value); case VALUE_TYPE_STRING: return String_hash((String*) value); case VALUE_TYPE_BITMAP: return Bitmap_hash((Bitmap*) value); case VALUE_TYPE_TUPLE: return Tuple_hash((Tuple*) value); case VALUE_TYPE_VECTOR: return Vector_hash((Vector*) value); case VALUE_TYPE_MAP: return Map_hash((Map*) value); default: assert(false); } } }
bool is_boolean (Value* self) { return IS_BOOLEAN(self); }