libvata2  [unstable] git snapshot
Classes | Typedefs | Functions
Vata2::VM Namespace Reference

Classes

class  VMValue
 Data type representing a value, which is composed of a type and a pointer to a general memory. More...
 
class  VirtualMachine
 The virtual machine executing VATA code. More...
 
class  VMException
 The exception for virtual machine errors. More...
 

Typedefs

using VMFuncName = std::string
 Data type for function names. More...
 
using VMFuncArgs = std::vector< VMValue >
 Data type for function arguments. More...
 
using VMDispatcherFunc = std::function< VMValue(const VMFuncName &, const VMFuncArgs &)>
 Data type for dispatcher function pointer. More...
 
using VMPointer = const void *
 Data type representing a pointer to a memory holding a value. More...
 
using VMStorage = std::unordered_map< std::string, VMValue >
 A dictionary mapping names to values. More...
 

Functions

void reg_dispatcher (const std::string &type_name, const VMDispatcherFunc &func)
 registers a dispatcher function for a VATA data type More...
 
const VMDispatcherFuncfind_dispatcher (const std::string &type_name)
 finds the dispatcher function for a given type More...
 
VMValue call_dispatch_with_self (const VMValue &val, const VMFuncName &func_name)
 calls a dispatcher function for the given value with it as the only argument More...
 
VMValue default_dispatch (const VMFuncName &func_name, const VMFuncArgs &func_args)
 Default dispatcher function. More...
 

Typedef Documentation

using VMDispatcherFunc = std::function<VMValue(const VMFuncName&, const VMFuncArgs&)>

Data type for dispatcher function pointer.

Definition at line 40 of file vm-dispatch.hh.

using VMFuncArgs = std::vector<VMValue>

Data type for function arguments.

Definition at line 38 of file vm-dispatch.hh.

using VMFuncName = std::string

Data type for function names.

Definition at line 36 of file vm-dispatch.hh.

using VMPointer = const void*

Data type representing a pointer to a memory holding a value.

Definition at line 32 of file vm.hh.

using VMStorage = std::unordered_map<std::string, VMValue>

A dictionary mapping names to values.

Definition at line 88 of file vm.hh.

Function Documentation

VMValue Vata2::VM::call_dispatch_with_self ( const VMValue &  val,
const VMFuncName &  func_name 
)
inline

calls a dispatcher function for the given value with it as the only argument

Definition at line 54 of file vm-dispatch.hh.

References find_dispatcher(), and VMValue::type.

VMValue Vata2::VM::default_dispatch ( const VMFuncName &  func_name,
const VMFuncArgs &  func_args 
)

Default dispatcher function.

const VMDispatcherFunc& Vata2::VM::find_dispatcher ( const std::string &  type_name)

finds the dispatcher function for a given type

Referenced by call_dispatch_with_self().

void Vata2::VM::reg_dispatcher ( const std::string &  type_name,
const VMDispatcherFunc &  func 
)

registers a dispatcher function for a VATA data type