Skip to content

Commit b3f4b97

Browse files
committed
Feature(runtime): Prototype jsvalue
1 parent 59dd641 commit b3f4b97

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

packages/runtime/jsvalue.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// Created by Dmitry Patsura on 2018-11-08.
3+
//
4+
5+
#ifndef HLVM_RUNTIME_JSVALUE_H
6+
#define HLVM_RUNTIME_JSVALUE_H
7+
8+
class JSObject {
9+
};
10+
11+
union JSValueHolder {
12+
double *number;
13+
bool *boolean;
14+
char *string;
15+
JSObject *object;
16+
};
17+
18+
enum JSValueType {
19+
NUMBER = 0,
20+
NULL = 2,
21+
UNDEFINED = 3,
22+
OBJECT = 4,
23+
BOOLEAN = 5,
24+
SYMBOL = 6,
25+
};
26+
27+
class JSValue {
28+
protected:
29+
JSValueHolder *value;
30+
JSValueType *type;
31+
public:
32+
bool isUndefined() const {
33+
return *this->type == UNDEFINED;
34+
}
35+
};
36+
37+
#endif //HLVM_RUNTIME_JSVALUE_H

0 commit comments

Comments
 (0)