mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
Data Structures | Namespaces | Macros
StackMachine.hpp File Reference
#include <cstdint>
#include <mutable/catalog/Schema.hpp>
#include <mutable/IR/Tuple.hpp>
#include "tables/Opcodes.tbl"
Include dependency graph for StackMachine.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  m::StackMachine
 A stack machine that evaluates an expression. More...
 

Namespaces

namespace  m
 

‍mutable namespace


 
namespace  m::ast
 
namespace  m::cnf
 

Macros

#define M_OPCODE(CODE, ...)   CODE,
 
#define M_OPCODE(CODE, ...)   #CODE,
 
#define SELECT(XXX, _1, _2, _3, FN, ...)   FN(__VA_ARGS__)
 
#define ARGS_0(XXX, ...)
 
#define ARGS_1(I, XXX, ARG0, ...)   uint8_t ARG0
 
#define ARGS_2(I, II, XXX, ARG0, ARG1, ...)   uint8_t ARG0, uint8_t ARG1
 
#define ARGS_3(I, II, III, XXX, ARG0, ARG1, ARG2, ...)   uint8_t ARG0, uint8_t ARG1, uint8_t ARG2
 
#define ARGS(...)   SELECT(__VA_ARGS__, ARGS_3, ARGS_2, ARGS_1, ARGS_0, __VA_ARGS__)
 
#define PUSH_0(XXX, ...)
 
#define PUSH_1(I, XXX, ARG0, ...)    ops.push_back(static_cast<Opcode>((ARG0)));
 
#define PUSH_2(I, II, XXX, ARG0, ARG1, ...)
 
#define PUSH_3(I, II, III, XXX, ARG0, ARG1, ARG2, ...)
 
#define PUSH(...)   SELECT(__VA_ARGS__, PUSH_3, PUSH_2, PUSH_1, PUSH_0, __VA_ARGS__)
 
#define M_OPCODE(CODE, DELTA, ...)
 

Macro Definition Documentation

◆ ARGS

#define ARGS (   ...)    SELECT(__VA_ARGS__, ARGS_3, ARGS_2, ARGS_1, ARGS_0, __VA_ARGS__)

Definition at line 140 of file StackMachine.hpp.

◆ ARGS_0

#define ARGS_0 (   XXX,
  ... 
)

Definition at line 136 of file StackMachine.hpp.

◆ ARGS_1

#define ARGS_1 (   I,
  XXX,
  ARG0,
  ... 
)    uint8_t ARG0

Definition at line 137 of file StackMachine.hpp.

◆ ARGS_2

#define ARGS_2 (   I,
  II,
  XXX,
  ARG0,
  ARG1,
  ... 
)    uint8_t ARG0, uint8_t ARG1

Definition at line 138 of file StackMachine.hpp.

◆ ARGS_3

#define ARGS_3 (   I,
  II,
  III,
  XXX,
  ARG0,
  ARG1,
  ARG2,
  ... 
)    uint8_t ARG0, uint8_t ARG1, uint8_t ARG2

Definition at line 139 of file StackMachine.hpp.

◆ M_OPCODE [1/3]

#define M_OPCODE (   CODE,
  DELTA,
  ... 
)
Value:
void emit_ ## CODE ( ARGS(XXX, ##__VA_ARGS__) ) { \
ops.push_back(StackMachine::Opcode:: CODE ); \
current_stack_size_ += DELTA; \
M_insist(current_stack_size_ >= 0); \
required_stack_size_ = std::max(required_stack_size_, current_stack_size_); \
PUSH(XXX, ##__VA_ARGS__) \
}
#define ARGS(...)

Definition at line 153 of file StackMachine.hpp.

◆ M_OPCODE [2/3]

#define M_OPCODE (   CODE,
  ... 
)    CODE,

Definition at line 153 of file StackMachine.hpp.

◆ M_OPCODE [3/3]

#define M_OPCODE (   CODE,
  ... 
)    #CODE,

Definition at line 153 of file StackMachine.hpp.

◆ PUSH

#define PUSH (   ...)    SELECT(__VA_ARGS__, PUSH_3, PUSH_2, PUSH_1, PUSH_0, __VA_ARGS__)

Definition at line 151 of file StackMachine.hpp.

◆ PUSH_0

#define PUSH_0 (   XXX,
  ... 
)

Definition at line 141 of file StackMachine.hpp.

◆ PUSH_1

#define PUSH_1 (   I,
  XXX,
  ARG0,
  ... 
)     ops.push_back(static_cast<Opcode>((ARG0)));

Definition at line 142 of file StackMachine.hpp.

◆ PUSH_2

#define PUSH_2 (   I,
  II,
  XXX,
  ARG0,
  ARG1,
  ... 
)
Value:
ops.push_back(static_cast<Opcode>((ARG0))); \
ops.push_back(static_cast<Opcode>((ARG1)));

Definition at line 144 of file StackMachine.hpp.

◆ PUSH_3

#define PUSH_3 (   I,
  II,
  III,
  XXX,
  ARG0,
  ARG1,
  ARG2,
  ... 
)
Value:
ops.push_back(static_cast<Opcode>((ARG0))); \
ops.push_back(static_cast<Opcode>((ARG1))); \
ops.push_back(static_cast<Opcode>((ARG2)));

Definition at line 147 of file StackMachine.hpp.

◆ SELECT

#define SELECT (   XXX,
  _1,
  _2,
  _3,
  FN,
  ... 
)    FN(__VA_ARGS__)

Definition at line 135 of file StackMachine.hpp.