Skip to content

Commit 55b72f2

Browse files
committed
clang-format
1 parent 1b4252c commit 55b72f2

File tree

4 files changed

+61
-59
lines changed

4 files changed

+61
-59
lines changed

src/Debug/debugger.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,8 @@ void Debugger::inspect(Module *m, const uint16_t sizeStateArray,
921921
this->channel->write("%s", addComma ? "," : "");
922922
this->channel->write("\"io\": [");
923923
bool comma = false;
924-
std::vector<IOStateElement *> external_state = m->warduino->interpreter->get_io_state(m);
924+
std::vector<IOStateElement *> external_state =
925+
m->warduino->interpreter->get_io_state(m);
925926
for (auto state_elem : external_state) {
926927
this->channel->write("%s{", comma ? ", " : "");
927928
this->channel->write(
@@ -1382,7 +1383,8 @@ bool Debugger::saveState(Module *m, uint8_t *interruptData) {
13821383
state_elem.output ? "output" : "input",
13831384
state_elem.value);
13841385
}
1385-
m->warduino->interpreter->restore_external_state(m, external_state);
1386+
m->warduino->interpreter->restore_external_state(
1387+
m, external_state);
13861388
break;
13871389
}
13881390
case overridesState: {

src/Interpreter/interpreter.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <set>
55

66
#include "../WARDuino/internals.h"
7-
//#include "../Utils/macros.h"
7+
// #include "../Utils/macros.h"
88

99
class Interpreter {
1010
public:
@@ -65,26 +65,26 @@ class Interpreter {
6565
//------------------------------------------------------
6666
// ReSharper disable once CppDFAConstantFunctionResult
6767
bool resolve_primitive(const char *symbol, Primitive *val) {
68-
//debug("Resolve primitives (%d) for %s \n", ALL_PRIMITIVES, symbol);
68+
// debug("Resolve primitives (%d) for %s \n", ALL_PRIMITIVES, symbol);
6969

7070
for (auto &primitive : primitives) {
7171
// printf("Checking %s = %s \n", symbol, primitive.name);
7272
if (!strcmp(symbol, primitive.name)) {
73-
//debug("FOUND PRIMITIVE\n");
73+
// debug("FOUND PRIMITIVE\n");
7474
*val = primitive.f;
7575
return true;
7676
}
7777
}
78-
//FATAL("Could not find primitive %s \n", symbol);
78+
// FATAL("Could not find primitive %s \n", symbol);
7979
return false;
8080
// return false; // unreachable
8181
}
8282

8383
//------------------------------------------------------
8484
// Restore external state when restoring a snapshot
8585
//------------------------------------------------------
86-
void restore_external_state(Module *m,
87-
const std::vector<IOStateElement> &external_state) {
86+
void restore_external_state(
87+
Module *m, const std::vector<IOStateElement> &external_state) {
8888
std::set<std::string> prim_names;
8989
for (uint32_t i = 0; i < m->import_count; i++) {
9090
prim_names.emplace(m->functions[i].import_field);

src/Primitives/primitives.h

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ void install_primitives(Interpreter *interpreter);
2020
/*std::vector<IOStateElement *> get_io_state(Module *m);
2121
2222
void restore_external_state(Module *m,
23-
const std::vector<IOStateElement> &external_state);*/
23+
const std::vector<IOStateElement>
24+
&external_state);*/
2425

2526
inline void create_stack(std::vector<StackValue> *) {}
2627

@@ -60,7 +61,8 @@ void create_stack(std::vector<StackValue> *stack, T value, Ts... args) {
6061
template <typename... Ts>
6162
void invoke_primitive(Module *m, const std::string &function_name, Ts... args) {
6263
Primitive primitive;
63-
m->warduino->interpreter->resolve_primitive(function_name.c_str(), &primitive);
64+
m->warduino->interpreter->resolve_primitive(function_name.c_str(),
65+
&primitive);
6466

6567
std::vector<StackValue> argStack;
6668
create_stack(&argStack, args...);
@@ -71,30 +73,27 @@ void invoke_primitive(Module *m, const std::string &function_name, Ts... args) {
7173
primitive(m);
7274
}
7375

74-
#define _install_primitive(prim_name) \
76+
#define _install_primitive(prim_name) \
7577
/*dbg_info("installing primitive number: %d of %d with name: %s\n", \ \
76-
prim_index + 1, ALL_PRIMITIVES, #prim_name); \*/\
77-
PrimitiveEntry p; \
78-
p.name = #prim_name; \
79-
p.t = &(prim_name##_type); \
80-
p.f = &(prim_name); \
81-
p.f_reverse = nullptr; \
82-
p.f_serialize_state = nullptr; \
83-
interpreter->register_primitive(p); \
84-
85-
#define install_primitive(prim_name) \
86-
{ \
87-
/*dbg_info("installing primitive number: %d of %d with name: %s\n", \ \
88-
prim_index + 1, ALL_PRIMITIVES, #prim_name); \*/\
89-
_install_primitive(prim_name) \
90-
}
91-
92-
#define install_reversible_primitive(prim_name) \
93-
{ \
94-
_install_primitive(prim_name) \
95-
p.f_reverse = &(prim_name##_reverse); \
96-
p.f_serialize_state = &(prim_name##_serialize); \
97-
}
78+
prim_index + 1, ALL_PRIMITIVES, #prim_name); \*/ \
79+
PrimitiveEntry p; \
80+
p.name = #prim_name; \
81+
p.t = &(prim_name##_type); \
82+
p.f = &(prim_name); \
83+
p.f_reverse = nullptr; \
84+
p.f_serialize_state = nullptr; \
85+
interpreter->register_primitive(p);
86+
87+
#define install_primitive(prim_name) \
88+
{/*dbg_info("installing primitive number: %d of %d with name: %s\n", \ \
89+
prim_index + 1, ALL_PRIMITIVES, #prim_name); \*/ \
90+
_install_primitive(prim_name)}
91+
92+
#define install_reversible_primitive(prim_name) \
93+
{ \
94+
_install_primitive(prim_name) p.f_reverse = &(prim_name##_reverse); \
95+
p.f_serialize_state = &(prim_name##_serialize); \
96+
}
9897

9998
#define def_prim(function_name, type) \
10099
Type function_name##_type = type; \
@@ -133,7 +132,7 @@ inline uint32_t param_I32_arr_len2[2] = {I32, I32};
133132
inline uint32_t param_I32_arr_len3[3] = {I32, I32, I32};
134133
inline uint32_t param_I32_arr_len4[4] = {I32, I32, I32, I32};
135134
inline uint32_t param_I32_arr_len10[10] = {I32, I32, I32, I32, I32,
136-
I32, I32, I32, I32, I32};
135+
I32, I32, I32, I32, I32};
137136
inline uint32_t param_I64_arr_len1[1] = {I64};
138137

139138
inline Type oneToNoneU32 = {
@@ -228,24 +227,24 @@ inline Type tenToOneU32 = {
228227
};
229228

230229
inline Type NoneToNoneU32 = {.form = FUNC,
231-
.param_count = 0,
232-
.params = nullptr,
233-
.result_count = 0,
234-
.results = nullptr,
235-
.mask = 0x80000};
230+
.param_count = 0,
231+
.params = nullptr,
232+
.result_count = 0,
233+
.results = nullptr,
234+
.mask = 0x80000};
236235

237236
inline Type NoneToOneU32 = {.form = FUNC,
238-
.param_count = 0,
239-
.params = nullptr,
240-
.result_count = 1,
241-
.results = param_I32_arr_len1,
242-
.mask = 0x81000};
237+
.param_count = 0,
238+
.params = nullptr,
239+
.result_count = 1,
240+
.results = param_I32_arr_len1,
241+
.mask = 0x81000};
243242

244243
inline Type NoneToOneU64 = {.form = FUNC,
245-
.param_count = 0,
246-
.params = nullptr,
247-
.result_count = 1,
248-
.results = param_I64_arr_len1,
249-
.mask = 0x82000};
244+
.param_count = 0,
245+
.params = nullptr,
246+
.result_count = 1,
247+
.results = param_I64_arr_len1,
248+
.mask = 0x82000};
250249

251250
#endif

src/WARDuino/WARDuino.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
char exception[512];
1717

1818
// UTIL
19-
bool resolvesym(Interpreter *interpreter, char *filename, char *symbol, uint8_t external_kind, void **val,
20-
char **err) {
19+
bool resolvesym(Interpreter *interpreter, char *filename, char *symbol,
20+
uint8_t external_kind, void **val, char **err) {
2121
if (nullptr != filename && !strcmp(filename, "env")) {
2222
switch (external_kind) {
2323
case 0x00: // Function
@@ -435,8 +435,9 @@ void WARDuino::instantiate_module(Module *m, uint8_t *bytes,
435435
// TODO add special case form primitives with resolvePrim
436436
do {
437437
// Try using module as handle filename
438-
if (resolvesym(m->warduino->interpreter, import_module, import_field,
439-
external_kind, &val, &err)) {
438+
if (resolvesym(m->warduino->interpreter, import_module,
439+
import_field, external_kind, &val,
440+
&err)) {
440441
break;
441442
}
442443

@@ -449,8 +450,8 @@ void WARDuino::instantiate_module(Module *m, uint8_t *bytes,
449450
sym[sidx] = '_';
450451
}
451452
}
452-
if (resolvesym(m->warduino->interpreter, nullptr, sym, external_kind, &val,
453-
&err)) {
453+
if (resolvesym(m->warduino->interpreter, nullptr, sym,
454+
external_kind, &val, &err)) {
454455
break;
455456
}
456457

@@ -460,17 +461,17 @@ void WARDuino::instantiate_module(Module *m, uint8_t *bytes,
460461
(strncmp("env", import_module, 4) == 0) &&
461462
(strncmp("_", import_field, 1) == 0)) {
462463
sprintf(sym, "%s", import_field + 1);
463-
if (resolvesym(m->warduino->interpreter, nullptr, sym, external_kind, &val,
464-
&err)) {
464+
if (resolvesym(m->warduino->interpreter, nullptr,
465+
sym, external_kind, &val, &err)) {
465466
break;
466467
}
467468
}
468469

469470
// Try the plain symbol by itself with module
470471
// name/handle
471472
sprintf(sym, "%s", import_field);
472-
if (resolvesym(m->warduino->interpreter, nullptr, sym, external_kind, &val,
473-
&err)) {
473+
if (resolvesym(m->warduino->interpreter, nullptr, sym,
474+
external_kind, &val, &err)) {
474475
break;
475476
}
476477

0 commit comments

Comments
 (0)