Skip to content

Commit b0af11c

Browse files
authored
update libetl
update libetl
1 parent f8e3587 commit b0af11c

File tree

3 files changed

+8
-41
lines changed

3 files changed

+8
-41
lines changed

compiler/ETL/libetl/shared/etl.hpp

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,9 @@
66
#include<iostream>
77
#include<sstream>
88

9-
namespace ast {
10-
enum class VarType { NUMBER, STRING, POINTER, TYPE_NULL };
11-
}
129
namespace interp {
13-
struct Var {
14-
Var() = default;
15-
Var(const std::string &n, ast::VarType v) : name{n}, numeric_value{0}, ptr_value{nullptr}, type{v} {}
16-
Var(const std::string &n, const std::string &value) : name{n}, string_value{value}, type{ast::VarType::STRING} {}
17-
Var(const std::string &n, long value) : name{n}, numeric_value{value}, type{ast::VarType::NUMBER} {}
18-
Var(const std::string &n, void *ptr) : name{n}, ptr_value{ptr}, type {ast::VarType::POINTER} {}
19-
Var(const Var &v) : name{v.name}, numeric_value{v.numeric_value}, string_value{v.string_value}, ptr_value{v.ptr_value}, type{v.type} {}
20-
Var(Var &&v) : name{std::move(v.name)}, numeric_value{v.numeric_value}, string_value{std::move(v.string_value)}, ptr_value{v.ptr_value}, type{v.type} {}
21-
22-
Var &operator=(const Var &v) {
23-
name = v.name;
24-
numeric_value = v.numeric_value;
25-
string_value = v.string_value;
26-
ptr_value = v.ptr_value;
27-
type = v.type;
28-
return *this;
29-
}
30-
31-
Var &operator=(Var &&v) {
32-
name = std::move(v.name);
33-
numeric_value = v.numeric_value;
34-
string_value = std::move(v.string_value);
35-
ptr_value = v.ptr_value;
36-
type = v.type;
37-
return *this;
38-
}
39-
40-
std::string name;
41-
long numeric_value = 0;
42-
std::string string_value;
43-
void *ptr_value = nullptr;
44-
ast::VarType type;
45-
};
4610

47-
void check_args(const std::string &n, const std::vector<interp::Var> &v, std::initializer_list<ast::VarType> args) {
11+
inline void check_args(const std::string &n, const std::vector<interp::Var> &v, std::initializer_list<ast::VarType> args) {
4812
if(v.size() != args.size()) {
4913
std::ostringstream stream;
5014
stream << "In function: " << n << " argument count mismatch.\n";

compiler/ETL/libetl/shared/io/io.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include "../../../interp.hpp"
2+
#include "../../../ast.hpp"
13
#include "../etl.hpp"
24
#include<cstdio>
35

@@ -46,7 +48,7 @@ interp::Var func_file_size(const std::vector<interp::Var> &v) {
4648
return interp::Var("return", (long)file_size(v.at(0).ptr_value));
4749
}
4850

49-
extern "C" void initTable(addFunction func) {
51+
extern "C" void libio_rt_initTable(addFunction func) {
5052
func("file_open", (void*)func_file_open);
5153
func("file_print", (void*)func_file_print);
5254
func("file_write", (void*)func_file_write);

compiler/ETL/libetl/shared/sdl/sdl.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* ETL: SDL2 Module */
22
#include"SDL.h"
3+
#include "../../../interp.hpp"
4+
#include "../../../ast.hpp"
35
#include "../etl.hpp"
46

57
extern "C" void sdl_init();
@@ -200,8 +202,7 @@ interp::Var func_sdl_draw_gradient(const std::vector<interp::Var> &v) {
200202
return interp::Var("return", (long)0);
201203
}
202204

203-
204-
extern "C" void initTable(addFunction func) {
205+
extern "C" void libsdl_rt_initTable(addFunction func) {
205206
func("sdl_init", (void*)func_sdl_init);
206207
func("sdl_init_size", (void*)func_sdl_init_size);
207208
func("sdl_quit", (void*)func_sdl_quit);
@@ -231,4 +232,4 @@ extern "C" void initTable(addFunction func) {
231232
func("sdl_setstartcolor", (void*)func_sdl_setstartcolor);
232233
func("sdl_setendcolor", (void*)func_sdl_setendcolor);
233234
func("sdl_draw_gradient", (void*)func_sdl_draw_gradient);
234-
}
235+
}

0 commit comments

Comments
 (0)