Skip to content

Commit c168ae6

Browse files
committed
Feature(runtime): Start working on dynamic
1 parent abc86c8 commit c168ae6

3 files changed

Lines changed: 53 additions & 1 deletion

File tree

packages/runtime/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ set(SOURCE_FILES
1818
machine.h
1919
array.cpp
2020
array.h
21+
dynamic.cpp
22+
dynamic.h
2123
v8/src/base/platform/mutex.cc
2224
v8/src/base/platform/time.cc
2325
v8/src/base/platform/semaphore.cc
@@ -55,7 +57,7 @@ if (LINUX)
5557
SOURCE_FILES
5658
${SOURCE_FILES}
5759
v8/src/base/platform/platform-linux.cc
58-
)
60+
dynamic.cpp dynamic.h)
5961
endif()
6062

6163
add_library(hlvm-runtime STATIC ${SOURCE_FILES})

packages/runtime/dynamic.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//
2+
// Created by Dmitry Patsura on 2019-01-03.
3+
//
4+
5+
#include "dynamic.h"

packages/runtime/dynamic.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// Created by Dmitry Patsura on 2019-01-03.
3+
//
4+
5+
#ifndef HLVM_RUNTIME_DYNAMIC_H
6+
#define HLVM_RUNTIME_DYNAMIC_H
7+
8+
#include <cstdint>
9+
10+
enum DynamicType: int8_t {
11+
BOOLEAN_TYPE = 1,
12+
DOUBLE_TYPE = 2,
13+
};
14+
15+
class Dynamic {
16+
public:
17+
Dynamic(double value) {
18+
this->d = value;
19+
this->type = DynamicType::DOUBLE_TYPE;
20+
}
21+
22+
Dynamic(bool value) {
23+
this->b = value;
24+
this->type = DynamicType::BOOLEAN_TYPE;
25+
}
26+
27+
void setValue(double value) {
28+
this->d = value;
29+
this->type = DynamicType::DOUBLE_TYPE;
30+
};
31+
32+
void setValue(bool value) {
33+
this->b = value;
34+
this->type = DynamicType::BOOLEAN_TYPE;
35+
};
36+
private:
37+
DynamicType type;
38+
39+
union {
40+
double d;
41+
bool b;
42+
};
43+
};
44+
45+
#endif //HLVM_RUNTIME_DYNAMIC_H

0 commit comments

Comments
 (0)