Reduct  v4.0.5-1-g4851deb
A functional and immutable language.
Loading...
Searching...
No Matches
Evaluation

Detailed Description

Data Structures

struct  reduct_eval_frame_t
 Evaluation frame structure. More...
 
struct  reduct_eval_local_t
 Per-thread eval-related state structure. More...
 

Macros

#define REDUCT_EVAL_REGS_INITIAL   64
 The initial amount of registers.
 
#define REDUCT_EVAL_REGS_GROWTH_FACTOR   2
 The growth factor of the registers array.
 
#define REDUCT_EVAL_FRAMES_INITIAL   32
 The initial size of the frames array.
 
#define REDUCT_EVAL_FRAMES_GROWTH_FACTOR   2
 The growth factor of the frames array.
 

Functions

REDUCT_API void reduct_eval_local_init (reduct_eval_local_t *local)
 Initialize a local eval state.
 
REDUCT_API void reduct_eval_local_deinit (reduct_eval_local_t *local)
 Deinitialize a local eval state.
 
REDUCT_API reduct_handle_t reduct_eval (struct reduct *reduct, reduct_handle_t handle)
 Evaluates a handle.
 
REDUCT_API reduct_handle_t reduct_eval_file (struct reduct *reduct, const char *path, reduct_optimize_flags_t optimize)
 Parses, builds, optimizes, emits and evaluates a file.
 
REDUCT_API reduct_handle_t reduct_eval_string (struct reduct *reduct, const char *str, size_t len, reduct_optimize_flags_t optimize)
 Parses, builds, optimizes, emits and evaluates a string.
 
REDUCT_API reduct_handle_t reduct_eval_call (struct reduct *reduct, reduct_handle_t callable, size_t argc, reduct_handle_t *argv)
 Calls a Reduct callable (closure or native) with arguments.
 
REDUCT_API reduct_handle_t reduct_eval_call_v (struct reduct *reduct, reduct_handle_t callable, size_t argc,...)
 Calls a Reduct callable (closure or native) with variadic arguments.
 

Macro Definition Documentation

◆ REDUCT_EVAL_REGS_INITIAL

#define REDUCT_EVAL_REGS_INITIAL   64

The initial amount of registers.

Definition at line 18 of file eval.h.

◆ REDUCT_EVAL_REGS_GROWTH_FACTOR

#define REDUCT_EVAL_REGS_GROWTH_FACTOR   2

The growth factor of the registers array.

Definition at line 19 of file eval.h.

◆ REDUCT_EVAL_FRAMES_INITIAL

#define REDUCT_EVAL_FRAMES_INITIAL   32

The initial size of the frames array.

Definition at line 21 of file eval.h.

◆ REDUCT_EVAL_FRAMES_GROWTH_FACTOR

#define REDUCT_EVAL_FRAMES_GROWTH_FACTOR   2

The growth factor of the frames array.

Definition at line 22 of file eval.h.

Function Documentation

◆ reduct_eval_local_init()

REDUCT_API void reduct_eval_local_init ( reduct_eval_local_t local)

Initialize a local eval state.

Parameters
localPointer to the local eval state to initialize.

◆ reduct_eval_local_deinit()

REDUCT_API void reduct_eval_local_deinit ( reduct_eval_local_t local)

Deinitialize a local eval state.

Parameters
localPointer to the local eval state to deinitialize.

◆ reduct_eval()

REDUCT_API reduct_handle_t reduct_eval ( struct reduct *  reduct,
reduct_handle_t  handle 
)

Evaluates a handle.

If the handle is a compiled function then it will be interpreted, otherwise, it will first be compiled into a function.

Parameters
reductThe Reduct instance.
handleThe handle to evaluate.
Returns
The result of the evaluation as a Reduct handle.

◆ reduct_eval_file()

REDUCT_API reduct_handle_t reduct_eval_file ( struct reduct *  reduct,
const char *  path,
reduct_optimize_flags_t  optimize 
)

Parses, builds, optimizes, emits and evaluates a file.

Parameters
reductThe Reduct instance.
pathThe path to the file.
flagsOptimization flags to control which optimizations are applied.
Returns
The result of the evaluation.

◆ reduct_eval_string()

REDUCT_API reduct_handle_t reduct_eval_string ( struct reduct *  reduct,
const char *  str,
size_t  len,
reduct_optimize_flags_t  optimize 
)

Parses, builds, optimizes, emits and evaluates a string.

Parameters
reductThe Reduct instance.
strThe string to evaluate.
lenThe length of the string.
flagsOptimization flags to control which optimizations are applied.
Returns
The result of the evaluation.

◆ reduct_eval_call()

REDUCT_API reduct_handle_t reduct_eval_call ( struct reduct *  reduct,
reduct_handle_t  callable,
size_t  argc,
reduct_handle_t argv 
)

Calls a Reduct callable (closure or native) with arguments.

Parameters
reductThe Reduct instance.
callableThe callable item handle.
argcThe number of arguments.
argvPointer to the arguments array.
Returns
The result of the call.

◆ reduct_eval_call_v()

REDUCT_API reduct_handle_t reduct_eval_call_v ( struct reduct *  reduct,
reduct_handle_t  callable,
size_t  argc,
  ... 
)

Calls a Reduct callable (closure or native) with variadic arguments.

Parameters
reductThe Reduct instance.
callableThe callable item handle.
argcThe number of arguments.
...The arguments (as reduct_handle_t).
Returns
The result of the call.