Vita
Classes | Public Member Functions | List of all members
vita::interpreter< i_mep > Class Reference

A specialization of the core_interpreter class. More...

#include <interpreter.h>

Inherits vita::core_interpreter.

Public Member Functions

value_t fetch_arg (unsigned) final
 Fetches the value of the i-th argument of the current gene. More...
 
index_t fetch_index (unsigned) const
 
value_t fetch_opaque_arg (unsigned) final
 Fetches a specific input parameter without assuming referential transparency. More...
 
terminal_param_t fetch_param () const final
 
 interpreter (const i_mep *)
 
const i_mepprogram () const
 
- Public Member Functions inherited from vita::core_interpreter
bool is_valid () const
 
double penalty ()
 
value_t run ()
 
- Public Member Functions inherited from vita::symbol_params
virtual value_t fetch_arg (unsigned)=0
 Fetches a specific input parameter assuming referential transparency. More...
 
virtual value_t fetch_opaque_arg (unsigned)=0
 Fetches a specific input parameter without assuming referential transparency. More...
 
virtual terminal_param_t fetch_param () const =0
 
virtual value_t fetch_var (unsigned)
 
value_t operator[] (unsigned i)
 Equivalent to fetch_arg(). More...
 

Detailed Description

A specialization of the core_interpreter class.

Note
This is an example of dependency injection via constructor injection: the class gets the dependencies as an argument to its constructor. It saves the reference to dependent classes as private variables. All the dependencies are truly visible with constructor signature and cyclic dependencies don't happen because of the well-defined order of instantiation.
See also

Definition at line 42 of file mep/interpreter.h.

Constructor & Destructor Documentation

◆ interpreter()

vita::interpreter< i_mep >::interpreter ( const i_mep ind)
explicit
Parameters
[in]indindividual whose value we are interested in
Warning
The lifetime of ind must extend beyond that of the interpreter.

Definition at line 25 of file interpreter.cc.

Member Function Documentation

◆ fetch_arg()

value_t vita::interpreter< i_mep >::fetch_arg ( unsigned  i)
finalvirtual

Fetches the value of the i-th argument of the current gene.

Parameters
[in]ii-th argument of the current gene
Returns
the required value

We use a cache to avoid recalculating the same value during the same interpreter execution. This means that side effects are not evaluated to date: WE ASSUME REFERENTIAL TRANSPARENCY for all the expressions.

See also

Implements vita::symbol_params.

Definition at line 81 of file interpreter.cc.

◆ fetch_index()

index_t vita::interpreter< i_mep >::fetch_index ( unsigned  i) const
Parameters
[in]ii-th argument of the current function
Returns
the index referenced by the i-th argument of the current function

Definition at line 128 of file interpreter.cc.

◆ fetch_opaque_arg()

value_t vita::interpreter< i_mep >::fetch_opaque_arg ( unsigned  )
finalvirtual

Fetches a specific input parameter without assuming referential transparency.

Remarks
Sometimes return value is ignored: typically for agent simulation (the caller is only interested in the side effects of the call).

Implements vita::symbol_params.

Definition at line 106 of file interpreter.cc.

◆ fetch_param()

terminal_param_t vita::interpreter< i_mep >::fetch_param ( ) const
finalvirtual
Returns
the output value of the current terminal symbol

Implements vita::symbol_params.

Definition at line 58 of file interpreter.cc.

◆ program()

const i_mep & vita::interpreter< i_mep >::program ( ) const
inline

Definition at line 49 of file mep/interpreter.h.


The documentation for this class was generated from the following files: