#include "closure.h"
#include "defs.h"
#include "eval.h"
#include "item.h"
#include "standard.h"
#include "parse.h"
#include "compile.h"
Go to the source code of this file.
|
| #define | DISPATCH() |
| |
| #define | OP_COMPARE(_label, _op) |
| |
| #define | OP_ARITH(_label, _op) |
| |
| #define | DECODE_A() reduct_uint32_t a = REDUCT_INST_GET_A(inst) |
| |
| #define | DECODE_B() reduct_uint32_t b = REDUCT_INST_GET_B(inst) |
| |
| #define | DECODE_C_REG() |
| |
| #define | DECODE_C_CONST() |
| |
| #define | DECODE_SBX() reduct_int32_t sbx = REDUCT_INST_GET_SBX(inst) |
| |
| #define | ERROR_CHECK(_expr, ...) |
| |
| #define | OP_ENTRY(_op, _label) [_op] = &&_label, [_op | REDUCT_MODE_CONST] = &&_label |
| |
| #define | OP_ENTRY_C(_op, _label) [_op] = &&_label, [_op | REDUCT_MODE_CONST] = &&_label##_k |
| |
| #define | OP_BITWISE(_label, _op) |
| |
| #define | OP_EQUALITY(_label, _func, _truth) |
| |
| #define | LABEL_C_OP(_label, ...) |
| |
|
| static void | reduct_eval_state_init (reduct_t *reduct, reduct_eval_state_t *state) |
| |
| REDUCT_API void | reduct_eval_state_deinit (reduct_eval_state_t *state) |
| | Deinitialize an evaluation state structure.
|
| |
| static REDUCT_ALWAYS_INLINE void | reduct_eval_ensure_regs (reduct_t *reduct, reduct_eval_state_t *state, reduct_uint32_t neededRegs) |
| |
| static REDUCT_ALWAYS_INLINE void | reduct_eval_push_frame (reduct_t *reduct, reduct_eval_state_t *state, reduct_closure_t *closure, reduct_uint32_t target) |
| |
| static REDUCT_ALWAYS_INLINE void | reduct_eval_pop_frame (reduct_eval_state_t *state) |
| |
| static REDUCT_ALWAYS_INLINE void | reduct_eval_tail_frame (reduct_t *reduct, reduct_eval_state_t *state, reduct_closure_t *closure) |
| |
| static reduct_handle_t | reduct_eval_run (reduct_t *reduct, reduct_eval_state_t *state, reduct_uint32_t initialFrameCount) |
| |
| REDUCT_API reduct_handle_t | reduct_eval (struct reduct *reduct, reduct_function_t *function) |
| |
| REDUCT_API reduct_handle_t | reduct_eval_file (reduct_t *reduct, const char *path) |
| | Parses, compiles and evaluates a file.
|
| |
| REDUCT_API reduct_handle_t | reduct_eval_string (reduct_t *reduct, const char *str, reduct_size_t len) |
| | Parses, compiles and evaluates a string.
|
| |
| REDUCT_API reduct_handle_t | reduct_eval_call (reduct_t *reduct, reduct_handle_t callable, reduct_size_t argc, reduct_handle_t *argv) |
| | Calls a Reduct callable (closure or native) with arguments.
|
| |
◆ DISPATCH
Value: do \
{ \
inst = *ip++; \
goto* dispatchTable[op]; \
} while (0)
#define REDUCT_INST_GET_OP(_inst)
Get the opcode from an instruction.
◆ OP_COMPARE
| #define OP_COMPARE |
( |
|
_label, |
|
|
|
_op |
|
) |
| |
Value:
DECODE_A(); \
DECODE_B(); \
DISPATCH(); \
})
#define LABEL_C_OP(_label,...)
#define REDUCT_HANDLE_FALSE()
Constant false handle.
#define REDUCT_HANDLE_COMPARE_FAST(_reduct, _a, _b, _op)
Compare two handles using a given operator with a fast path for integers and floats.
#define REDUCT_HANDLE_TRUE()
Constant true handle.
◆ OP_ARITH
| #define OP_ARITH |
( |
|
_label, |
|
|
|
_op |
|
) |
| |
Value:
DECODE_A(); \
DECODE_B(); \
REDUCT_HANDLE_ARITHMETIC_FAST(reduct, &base[a], &base[b], &valC, _op); \
DISPATCH(); \
})
◆ DECODE_A
◆ DECODE_B
◆ DECODE_C_REG
Value:
reduct_uint64_t reduct_handle_t
Handle type.
#define REDUCT_INST_GET_C(_inst)
Get the C operand from an instruction.
◆ DECODE_C_CONST
| #define DECODE_C_CONST |
( |
| ) |
|
◆ DECODE_SBX
◆ ERROR_CHECK
| #define ERROR_CHECK |
( |
|
_expr, |
|
|
|
... |
|
) |
| |
Value: do \
{ \
{ \
frame->ip = ip; \
REDUCT_ERROR_RUNTIME(__VA_ARGS__); \
} \
} while (0)
#define REDUCT_UNLIKELY(_x)
◆ OP_ENTRY
| #define OP_ENTRY |
( |
|
_op, |
|
|
|
_label |
|
) |
| [_op] = &&_label, [_op | REDUCT_MODE_CONST] = &&_label |
◆ OP_ENTRY_C
| #define OP_ENTRY_C |
( |
|
_op, |
|
|
|
_label |
|
) |
| [_op] = &&_label, [_op | REDUCT_MODE_CONST] = &&_label##_k |
◆ OP_BITWISE
| #define OP_BITWISE |
( |
|
_label, |
|
|
|
_op |
|
) |
| |
Value:
DECODE_A(); \
DECODE_B(); \
DISPATCH(); \
})
#define REDUCT_HANDLE_FROM_INT(_val)
Create a handle from an integer.
REDUCT_API reduct_handle_t reduct_get_int(struct reduct *reduct, reduct_handle_t *handle)
◆ OP_EQUALITY
| #define OP_EQUALITY |
( |
|
_label, |
|
|
|
_func, |
|
|
|
_truth |
|
) |
| |
Value:
DECODE_A(); \
DECODE_B(); \
DISPATCH(); \
})
◆ LABEL_C_OP
| #define LABEL_C_OP |
( |
|
_label, |
|
|
|
... |
|
) |
| |
Value:_label: \
{ \
DECODE_C_REG(); \
__VA_ARGS__ \
} \
_label##_k: \
{ \
DECODE_C_CONST(); \
__VA_ARGS__ \
}
◆ reduct_eval_state_init()
◆ reduct_eval_ensure_regs()
◆ reduct_eval_push_frame()
◆ reduct_eval_pop_frame()
◆ reduct_eval_tail_frame()
◆ reduct_eval_run()
- Todo:
- Write some macro magic to turn this into a switch case if not using GCC or Clang
Definition at line 138 of file eval_impl.h.
◆ reduct_eval()