AndroMeta  2.0.0
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes
Meta::MNode Class Reference

Used by the framework for symbolic manipulation, e.g: in parsing, interpretation, etc. More...

#include <MNode.h>

List of all members.

Public Types

typedef uint16_t Type

Public Member Functions

 MNode ()
 MNode (const MNode &n)
 MNode (const MVar &v)
 MNode (MObjectBase *obj, Type t=ObjectPointer)
 MNode (const MObjectBase &obj)
 MNode (Type type, const mstr &value)
 MNode (const MVar *v)
 MNode (MVar *v)
 MNode (MStr *s)
 MNode (const MStr &s)
 MNode (const char *s)
 MNode (bool x)
 MNode (uint8_t x)
 MNode (int8_t x)
 MNode (uint16_t x)
 MNode (int16_t x)
 MNode (uint32_t x)
 MNode (int32_t x)
 MNode (uint64_t x)
 MNode (int64_t x)
 MNode (double x)
 MNode (float x)
 MNode (const MVector< MVar > &v)
 MNode (const MList< MVar > &l)
 MNode (const MNum &x)
 MNode (const MReal &x)
MVarattrs ()
const MVarattrs () const
bool hasAttrs () const
void clearAttrs (bool recursive=false)
bool operator== (const MNode &n) const
bool operator!= (const MNode &n) const
bool isSame (const MNode &n) const
MNodeoperator= (const MNode &n)
MNodeoperator[] (size_t i) const
MNodeoperator[] (int i) const
MNodeoperator[] (const MVar &v) const
MNode copy () const
mstr toStr (bool concise=true, bool quote=true) const
MNodeoperator+ (const MNode &n)
MVarvar ()
const MVarvar () const
MVarval ()
const MVarval () const
 operator bool () const
 operator double () const
 operator float () const
 operator uint8_t () const
 operator int8_t () const
 operator uint16_t () const
 operator int16_t () const
 operator uint32_t () const
 operator int32_t () const
 operator uint64_t () const
 operator int64_t () const
 operator const MNum & () const
 operator const char * () const
 operator mstr & ()
 operator const mstr & () const
 operator MVar & ()
 operator const MVar & () const
 operator const MVector< MVar > & () const
 operator MVector< MVar > & ()
 operator const MList< MVar > & () const
 operator MList< MVar > & ()
void add (MNode node)
void addFront (MNode node)
void insert (size_t pos, MNode node)
void remove (size_t pos)
void append (MNode node)
size_t size () const
bool empty () const
void pushBack (MNode node)
void pushFront (MNode node)
void push (MNode node)
MNode popBack ()
MNode popFront ()
MNode pop ()
bool isFunction () const
bool isFunction (const mstr &f) const
bool isFunction (const mstr &f, size_t args) const
bool isFunction (const mstr &f, size_t argsMin, size_t argsMax) const
bool isNumeric () const
int isRational () const
bool isReal () const
bool isObject () const
bool isSymbol () const
bool isSymbol (const mstr &name) const
bool isString () const
bool isConstant () const
bool isCodeData () const
bool isSymbolic () const
bool isTrue () const
bool isFalse () const
bool isPtr () const
void set (MNode n)
void clear ()
Type type () const
void setLineNumber (size_t lineNumber)
size_t lineNumber () const
void setFileName (const mstr &fileName)
const mstrfileName () const
void setStartLine (size_t lineNumber)
size_t startLine () const
void setTokenId (int tokenId)
int tokenId () const
void clearInputs ()
void copyParseInfo (MNode node, bool recursive=true)
MVar toVar () const
MObjectBaseobj ()
const mstrstr () const
mstrstr ()
const char * cstr () const
void findReplace (MNode f, MNode r)
void replace (const MVector< MVar > &ns, MNode r)
void replace (size_t i, MNode ri)
void replace (MNode r)

Static Public Member Functions

static MNode convertVar (const MVar &v, bool convertCodeData=false)

Static Public Attributes

static const Type NumericMask = 0x0010
static const Type DefinedNumericMask = 0x0020
static const Type Undefined = 0x0010
static const Type Constant = 0x0031
static const Type Integer = 0x0032
static const Type Rational = 0x0033
static const Type Float = 0x0034
static const Type Real = 0x0036
static const Type StringMask = 0x0040
static const Type String = 0x0040
static const Type Symbol = 0x0041
static const Type Function = 0x0042
static const Type ObjectMask = 0x0080
static const Type ObjectPointer = 0x0081
static const Type LocalObject = 0x0082
static const Type SharedObject = 0x0083
static const Type RawPointer = 0x0100
static const Type CodeDataMask = 0x0200

Detailed Description

Used by the framework for symbolic manipulation, e.g: in parsing, interpretation, etc.

MNode is the central data type used throughout the framework for symbolic manipulation, e.g: parsing, interpretation, etc. It subsumes mvar, adding symbols, and functions which make use of the MNode recursively.


Constructor & Destructor Documentation

Null node constructor.

Meta::MNode::MNode ( const MNode n)

Copy constructor.


Member Function Documentation

void Meta::MNode::add ( MNode  node)

When this node is a function, add node as an argument.

void Meta::MNode::addFront ( MNode  node)

When this node is a function, add node the the front of the args list.

void Meta::MNode::append ( MNode  node)

When this node is a function, append the arguments of node to this node's arguments.

Clear this nodes arguments and all data contained within.

Clear function arguments.

Copy this node.

void Meta::MNode::copyParseInfo ( MNode  node,
bool  recursive = true 
)

Set line number and filename from node.

const char* Meta::MNode::cstr ( ) const [inline]

Get the c-string this node holds.

bool Meta::MNode::empty ( ) const
Returns:
true is the function has no arguments.
const mstr& Meta::MNode::fileName ( ) const

Get the filename associated with this node.

void Meta::MNode::findReplace ( MNode  f,
MNode  r 
)

f contains a sequence of nodes to search for within this node. When a match is found in f, it replaces that node with the corresponding node in r. f and r must be of equal size.

void Meta::MNode::insert ( size_t  pos,
MNode  node 
)

When this node is a function, insert node at argument position pos.

bool Meta::MNode::isCodeData ( ) const
Returns:
true is this is code data.
bool Meta::MNode::isConstant ( ) const
Returns:
true if this is a constant value, i.e, non-symbolic.
bool Meta::MNode::isFalse ( ) const
Returns:
true if this is false proper (not numeric false), as defined by MNum.
bool Meta::MNode::isFunction ( ) const
Returns:
true if this is a function.
bool Meta::MNode::isFunction ( const mstr f) const
Returns:
true if this is a function named f.
bool Meta::MNode::isFunction ( const mstr f,
size_t  args 
) const
Returns:
true if this is a function named f of arity args.
bool Meta::MNode::isFunction ( const mstr f,
size_t  argsMin,
size_t  argsMax 
) const
Returns:
true if this is a function named f of arity between argsMin and argsMax.
bool Meta::MNode::isNumeric ( ) const
Returns:
true if this is a numeric.
bool Meta::MNode::isObject ( ) const
Returns:
true if this is an object.
bool Meta::MNode::isPtr ( ) const
Returns:
true if this node holds a pointer to an mvar or string.
int Meta::MNode::isRational ( ) const
Returns:
0 if not rational, 1 if integer else 2.
bool Meta::MNode::isReal ( ) const

true if this holds a real.

bool Meta::MNode::isString ( ) const
Returns:
true if this is a string literal.
bool Meta::MNode::isSymbol ( ) const
Returns:
true if this is a symbol.
bool Meta::MNode::isSymbol ( const mstr name) const
Returns:
true if this is a symbol named name.
bool Meta::MNode::isSymbolic ( ) const
Returns:
true if this is symbolic, i.e: a function or symbol.
bool Meta::MNode::isTrue ( ) const
Returns:
true if this is true proper (not numeric true), as defined by MNum.
size_t Meta::MNode::lineNumber ( ) const

Get the line number associated with this node.

Get the object this node holds.

MNode& Meta::MNode::operator+ ( const MNode n)

Equivalent to add().

Equivalent to popBack().

Remove and return the last function argument.

Remove and return the first function argument.

void Meta::MNode::push ( MNode  node)

Equivalent to add().

void Meta::MNode::pushBack ( MNode  node)

Equivalent to add().

void Meta::MNode::pushFront ( MNode  node)

Equivalent to addFront().

void Meta::MNode::remove ( size_t  pos)

When this node is a function, remove the argument at position pos.

void Meta::MNode::replace ( const MVector< MVar > &  ns,
MNode  r 
)

ns is a vector of integers e.g: [1,2,3] which calls findReplace() with f = Tuple(Gen(1),Gen(2),Gen(3)).

void Meta::MNode::replace ( size_t  i,
MNode  ri 
)

Shorthand for the above with f = Tuple(Gen(i))

Shorthand for replace([1,2,...,r.size()], r).

void Meta::MNode::set ( MNode  n)

Set this node's value to n as opposed to node assignment.

void Meta::MNode::setFileName ( const mstr fileName)

Set the filename associated with this node.

void Meta::MNode::setLineNumber ( size_t  lineNumber)

Set the line number associated with this node.

void Meta::MNode::setStartLine ( size_t  lineNumber)

Set the start line number.

void Meta::MNode::setTokenId ( int  tokenId)

Set the token id associated with this node.

size_t Meta::MNode::size ( ) const
Returns:
The number of function arguments.
size_t Meta::MNode::startLine ( ) const

Get the start line number.

const mstr& Meta::MNode::str ( ) const

Get the string this node holds.

Get the string this node holds.

int Meta::MNode::tokenId ( ) const

Get the token id associated with this node. Returns -1 if no token id is associated with this node.

mstr Meta::MNode::toStr ( bool  concise = true,
bool  quote = true 
) const

Get a string representation of the node.

Parameters:
concisetrue to use concise numerics.
quotetrue to quote strings.

Convert an mnode to mvar.

Type Meta::MNode::type ( ) const
Returns:
the type of this node.

val() is a performance-centric equivalent to var(), it returns the same, but does not check that the node is non-null and non-symbolic.


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