Skip to content

Commit 37be049

Browse files
committed
Feature(runtime): Dynamic - support int64/undefined
1 parent 41f638e commit 37be049

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

packages/runtime/dynamic.h

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,39 @@
88
#include <cstdint>
99

1010
enum DynamicType: int8_t {
11-
BOOLEAN_TYPE = 1,
12-
DOUBLE_TYPE = 2,
11+
BOOLEAN = 1,
12+
NUMBER = 2,
13+
INT64 = 3,
14+
UNDEFINED = 3,
1315
};
1416

1517
class Dynamic {
1618
public:
1719
Dynamic(double value) {
18-
this->d = value;
19-
this->type = DynamicType::DOUBLE_TYPE;
20+
this->number = value;
21+
this->type = DynamicType::NUMBER;
2022
}
2123

2224
Dynamic(bool value) {
23-
this->b = value;
24-
this->type = DynamicType::BOOLEAN_TYPE;
25+
this->boolean = value;
26+
this->type = DynamicType::BOOLEAN;
2527
}
2628

27-
void setValue(double value) {
28-
this->d = value;
29-
this->type = DynamicType::DOUBLE_TYPE;
30-
};
29+
Dynamic(int64_t value) {
30+
this->int64 = value;
31+
this->type = DynamicType::INT64;
32+
}
3133

32-
void setValue(bool value) {
33-
this->b = value;
34-
this->type = DynamicType::BOOLEAN_TYPE;
35-
};
34+
Dynamic() {
35+
this->type = DynamicType::UNDEFINED;
36+
}
3637
private:
3738
DynamicType type;
3839

3940
union {
40-
double d;
41-
bool b;
41+
double number;
42+
bool boolean;
43+
int64_t int64;
4244
};
4345
};
4446

0 commit comments

Comments
 (0)