Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
srcs
sbnana
sbnanalysis
ana
SBNOscReco
uScript
value.h
Go to the documentation of this file.
1
#ifndef uscript_value_h
2
#define uscript_value_h
3
#include <string>
4
5
#include "
tclass.h
"
6
7
namespace
uscript {
8
9
enum
ValueType
{
10
VAL_BOOL
,
11
VAL_NIL
,
12
VAL_NUMBER
,
13
VAL_INTEGER
,
14
VAL_OBJ_STRING
,
15
VAL_OBJ_TINSTANCE
,
16
};
17
18
struct
ObjString
{
19
const
char
*
string
;
20
};
21
22
struct
TClassInfo
;
23
24
struct
ObjTInstance
{
25
uint8_t *
loc
;
26
TData
data
;
27
};
28
29
struct
Value
{
30
ValueType
val
;
31
union
{
32
bool
boolean
;
33
double
number
;
34
int
integer
;
35
ObjString
string
;
36
ObjTInstance
tinst
;
37
}
as
;
38
void
Print
()
const
;
39
void
PrintObj
()
const
;
40
41
bool
operator!
()
const
;
42
};
43
}
// end namespace
44
45
#define BOOL_VAL(value) ((uscript::Value){ uscript::VAL_BOOL, { .boolean = value }})
46
#define NIL_VAL ((uscript::Value){ uscript::VAL_NIL, { .integer = 0 }})
47
#define NUMBER_VAL(value) ((uscript::Value){ uscript::VAL_NUMBER, { .number = value }})
48
#define INTEGER_VAL(value) ((uscript::Value){ uscript::VAL_INTEGER, { .integer = value }})
49
#define STRING_VAL(value) ((uscript::Value){ uscript::VAL_OBJ_STRING, { .string = (uscript::ObjString){ value } }})
50
#define TINSTANCE_VAL(value) ((uscript::Value){ uscript::VAL_OBJ_TINSTANCE, { .tinst = value }})
51
52
#define AS_BOOL(value) ((value).as.boolean)
53
#define AS_NUMBER(value) ((value).as.number)
54
#define AS_INTEGER(value) ((value).as.integer)
55
#define AS_STRING(value) ((value).as.string)
56
#define AS_CSTRING(value) ((value).as.string.string)
57
#define AS_TINSTANCE(value) ((value).as.tinst)
58
59
#define IS_NIL(value) ((value).val == uscript::VAL_NIL)
60
#define IS_BOOL(value) ((value).val == uscript::VAL_BOOL)
61
#define IS_NUMBER(value) ((value).val == uscript::VAL_NUMBER)
62
#define IS_INTEGER(value) ((value).val == uscript::VAL_INTEGER)
63
#define IS_STRING(value) ((value).val == uscript::VAL_OBJ_STRING)
64
#define IS_TINSTANCE(value) ((value).val == uscript::VAL_OBJ_TINSTANCE)
65
66
#endif
uscript::VAL_NUMBER
Definition:
value.h:12
uscript::VAL_NIL
Definition:
value.h:11
uscript::VAL_BOOL
Definition:
value.h:10
uscript::Value::string
ObjString string
Definition:
value.h:35
uscript::ObjTInstance::loc
uint8_t * loc
Definition:
value.h:25
uscript::VAL_OBJ_TINSTANCE
Definition:
value.h:15
uscript::Value::PrintObj
void PrintObj() const
uscript::Value::operator!
bool operator!() const
Definition:
value.cc:16
uscript::ObjTInstance::data
TData data
Definition:
value.h:26
uscript::ObjTInstance
Definition:
value.h:24
uscript::ObjString::string
const char * string
Definition:
value.h:19
uscript::Value::number
double number
Definition:
value.h:33
uscript::Value::tinst
ObjTInstance tinst
Definition:
value.h:36
uscript::Value
Definition:
value.h:29
uscript::Value::val
ValueType val
Definition:
value.h:30
uscript::TClassInfo
Definition:
tclass.h:36
uscript::Value::Print
void Print() const
Definition:
value.cc:5
uscript::VAL_OBJ_STRING
Definition:
value.h:14
uscript::Value::as
union uscript::Value::@3 as
tclass.h
uscript::Value::integer
int integer
Definition:
value.h:34
uscript::TData
Definition:
tclass.h:23
uscript::Value::boolean
bool boolean
Definition:
value.h:32
uscript::ValueType
ValueType
Definition:
value.h:9
uscript::ObjString
Definition:
value.h:18
uscript::VAL_INTEGER
Definition:
value.h:13
Generated by
1.8.5