jplus-0.4.7
jplus Class Reference

A J+ script. More...

#include <src/jplus.h>

Inheritance diagram for jplus:
Collaboration diagram for jplus:

Public Member Functions

 jplus ()
 initialize J+ engine with no script
 
bool init (std::istream &script)
 Load and pre-parse J+ script.
 
 ~jplus ()
 Free allocated memory.
 
bool set (std::string name, jarray data)
 Set value of the specified variable inside J+ environment, mark all dependent variables "dirty".
 
jarray get (std::string name)
 Perform all the necessary calculations to computate the specified variable, return its value in an array.
 
std::vector< std::string > getProgram (std::set< std::string > vars)
 Pull minimal set of J sentences for computing a given set of variables, assuming everything is "dirty".
 
std::vector< std::string > getProgram ()
 Pull all the sentences in J+ script.
 
- Public Member Functions inherited from jengine
 jengine ()
 Initializes J engine.
 
 ~jengine ()
 Frees J engine memory.
 
bool doJ (const std::string s)
 Executes J sentence.
 
const jarray get (const std::string name)
 Retrieves a named array from J.
 
bool set (const std::string name, jarray &value)
 Assigns J name to the specified array.
 
int getError ()
 J error code for the last unsuccessful operation.
 
bool ok ()
 Conveniently check that there was no error.
 
bool defVerb (std::string name, monad mf, dyad df, int mr=RMAX, int lr=RMAX, int rr=RMAX)
 Defines J verb, calling one (or both) of specified C++ functions.
 
bool defAdverb (std::string name, amonad mf, adyad df)
 defines J adverb, calling one (or both) of specified C++ functions.
 
bool defScript (std::string name, int type, std::string code, int mr=jengine::RMAX, int lr=jengine::RMAX, int rr=jengine::RMAX)
 Defines a J script, given by a (possibly multi-line) string.
 
bool isBuiltin (std::string name) const
 Checks if given name was defined via defScript.
 
std::set< std::string > getBuiltins () const
 Returns set of all names defined via defScript.
 
jarray::I PROLOG ()
 Returns the top of J garbage collection stack.
 
jarray::I EPILOG (jarray::I oldtop)
 Frees all memory, allocated since ttop was recorded.
 
voidEPILOG (jarray::I oldtop, void *hdr)
 Frees all memory, allocated since ttop was recorded.
 

Protected Member Functions

virtual void libInit ()
 Called by the constructor before parsing the J+ script.
 
- Protected Member Functions inherited from jengine
voidGA (const jarray::I t, const jarray::I n, const jarray::I r, const jarray::I *s)
 Allocates J array.
 
void FR (void *hdr)
 Frees J array memory.
 

Additional Inherited Members

- Public Types inherited from jengine
typedef jarray(* monad) (jarray y)
 Pointer to function, implementing monadic variant of a verb.
 
typedef jarray(* dyad) (jarray x, jarray y)
 Pointer to function, implementing dyadic variant of a verb.
 
typedef jarray(* amonad) (monad um, dyad ud, jarray y)
 Pointer to function, implementing monadic variant of an adverb.
 
typedef jarray(* adyad) (monad um, dyad ud, jarray x, jarray y)
 Pointer to function, implementing dyadic variant of an adverb.
 
- Static Public Member Functions inherited from jengine
static void initJlibrary (std::ostream &)
 Loads and links J dynamic library, must be called once before this class is instantiated.
 
- Static Public Attributes inherited from jengine
static const int RMAX =10000
 Constant to denote the infinite rank.
 

Detailed Description

A J+ script.

Constructor & Destructor Documentation

◆ jplus()

jplus::jplus ( )

initialize J+ engine with no script

◆ ~jplus()

jplus::~jplus ( )

Free allocated memory.

Member Function Documentation

◆ get()

jarray jplus::get ( std::string  name)

Perform all the necessary calculations to computate the specified variable, return its value in an array.

Parameters
namename of variable to compute.
Returns
the computed variable value.

◆ getProgram() [1/2]

std::vector< std::string > jplus::getProgram ( )

Pull all the sentences in J+ script.

This pulls all the sentences, assigning value of some variable.

Returns
vector of J sentences in J script.

◆ getProgram() [2/2]

std::vector< std::string > jplus::getProgram ( std::set< std::string >  vars)

Pull minimal set of J sentences for computing a given set of variables, assuming everything is "dirty".

Parameters
varsset of variable names to pull.
Returns
vector of J sentences for computing said variables.

◆ init()

bool jplus::init ( std::istream &  script)

Load and pre-parse J+ script.

Parameters
scriptstream, containing the script to load.
Returns
"true" upon success.

◆ libInit()

virtual void jplus::libInit ( )
protectedvirtual

Called by the constructor before parsing the J+ script.

Does nothing by default, but can be overridden to prepend an additional J+ stream with some definitions and/or define a few verbs and adverbs to be used in J+ program.

Reimplemented in yacts.

◆ set()

bool jplus::set ( std::string  name,
jarray  data 
)

Set value of the specified variable inside J+ environment, mark all dependent variables "dirty".

Parameters
namename of the variable.
dataarray for the variable to refer to.
Returns
"true" upon success.

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