mu
t
able
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
src
backend
WasmMacro.hpp
Go to the documentation of this file.
1
#pragma once
2
3
4
/*======================================================================================================================
5
* Convenience macros
6
*====================================================================================================================*/
7
8
#define BLOCK_OPEN(BLK) if (m::wasm::BlockUser ThisBlockUser((BLK)); (void)(ThisBlockUser), false) { } else
9
10
#define M_WASM_BLOCK_NAMED_(NAME) \
11
if (m::wasm::Block NAME(#NAME, true); (void)(NAME), false) { } else BLOCK_OPEN(NAME)
12
#define M_WASM_BLOCK_ANON_() \
13
if (m::wasm::Block ThisBlock(true); (void)(ThisBlock), false) { } else BLOCK_OPEN(ThisBlock)
14
#define M_GET_WASM_BLOCK_(XXX, _1, NAME, ...) NAME
15
#define BLOCK(...) M_GET_WASM_BLOCK_(XXX, ##__VA_ARGS__, M_WASM_BLOCK_NAMED_, M_WASM_BLOCK_ANON_)(__VA_ARGS__)
16
17
#define FUNCTION(NAME, TYPE) \
18
m::wasm::FunctionProxy<TYPE> NAME(#NAME); \
19
if (auto ThisFunction = NAME.make_function(); (void)(ThisFunction), false) { } else BLOCK_OPEN(ThisFunction.body())
20
#define PARAMETER(IDX) ThisFunction.template parameter<IDX>()
21
#define RETURN(RES) ThisFunction.emit_return(RES)
22
23
#define IF(COND) if (m::wasm::If ThisIf((COND)); false) { } else ThisIf.Then = [&]
24
#define ELSE , ThisIf.Else = [&]
25
26
#define M_WASM_LOOP_NAMED_(NAME) \
27
if (m::wasm::Loop ThisLoop((NAME)); (void)(ThisLoop), false) { } else BLOCK_OPEN(ThisLoop.body())
28
#define M_WASM_LOOP_ANON_() M_WASM_LOOP_NAMED_("loop"
)
29
#define M_GET_WASM_LOOP_(XXX, _1, NAME, ...) NAME
30
#define LOOP(...) M_GET_WASM_LOOP_(XXX, ##__VA_ARGS__, M_WASM_LOOP_NAMED_, M_WASM_LOOP_ANON_)(__VA_ARGS__)
31
32
#define M_WASM_DO_WHILE_NAMED_(NAME, COND) \
33
if (m::wasm::DoWhile ThisDoWhile((NAME), (COND)); (void)(ThisDoWhile), false) { } else \
34
BLOCK_OPEN(ThisDoWhile.body())
35
#define M_WASM_DO_WHILE_ANON_(COND) M_WASM_DO_WHILE_NAMED_("do-while"
, COND)
36
#define M_GET_WASM_DO_WHILE_(XXX, _1, _2, NAME, ...) NAME
37
#define DO_WHILE(...) M_GET_WASM_DO_WHILE_(XXX, ##__VA_ARGS__, M_WASM_DO_WHILE_NAMED_, M_WASM_DO_WHILE_ANON_)(__VA_ARGS__)
38
39
#define M_WASM_WHILE_NAMED_(NAME, COND) \
40
if (m::wasm::While ThisWhile((NAME), (COND)); (void)(ThisWhile), false) { } else BLOCK_OPEN(ThisWhile.body())
41
#define M_WASM_WHILE_ANON_(COND) M_WASM_WHILE_NAMED_("while"
, COND)
42
#define M_GET_WASM_WHILE_(XXX, _1, _2, NAME, ...) NAME
43
#define WHILE(...) M_GET_WASM_WHILE_(XXX, ##__VA_ARGS__, M_WASM_WHILE_NAMED_, M_WASM_WHILE_ANON_)(__VA_ARGS__)
44
45
#define M_WASM_THROW2_(TYPE, MSG) m::wasm::Module::Get().emit_throw(TYPE, __FILE__, __LINE__, MSG)
46
#define M_WASM_THROW1_(TYPE) M_WASM_THROW2_(TYPE, nullptr)
47
#define M_GET_WASM_THROW_(XXX, _1, _2, NAME, ...) NAME
48
#define Throw(...) M_GET_WASM_THROW_(XXX, ##__VA_ARGS__, M_WASM_THROW2_, M_WASM_THROW1_)(__VA_ARGS__)
mu
t
able website
GitHub
Generated by
1.9.6