|
AndroMeta
2.0.0
|
Provides the M interpreter, storing/restoring objects, distributed objects, and more. More...
#include <MObject.h>
Provides the M interpreter, storing/restoring objects, distributed objects, and more.
MObject implements the M interpreter and the essential functions associated with it. M is a language based on functional programming principles which is both that which is processed by the M interpreter directly and at the same time, the basis of the AST (abstract syntax tree) used by the parsers and generators. All M functions begin in upper-case e.g: Add(), Def() -- some M functions evaluate their arguments while others are lazy or may perform partial evaluation, e.g: symbol lookup. Each MObject is effectively an interpreter with state allowing M methods/functions and attributes to be defined within. MObject also provides an interface that supports storing/restoring objects, and distributed functionality. Throughout the documentation, we refer to the client-side of a distributed object as a "remote object." And the server-side as the "distributed object." MObject is fully storeable/restoreable.
The attribute modes used for manipulating attributes.
Raw - set/retrieve directly by value.
Exists - same as Raw but throw an MError when attribute does not exist.
TryProtected - Try to manipulate the value through an accessor or mutator e.g: getX(), setX(value), falling back to raw mode if such a method does not exist.
TryProtectedExists - same as TryProtected but throws an MError when attribute does not exist.
Protected - manipulation must go through an accessor or mutator. If such a method does not exist, an MError is thrown.
Constructor.
| Meta::MObject::MObject | ( | MBrokerBase * | broker | ) |
Constructor that subclasses call to create a remote object.
| Meta::MObject::MObject | ( | const MObject & | object | ) |
Copy constructor.
| Meta::MObject::MObject | ( | const mvar & | v, |
| RestoreOpt | opt | ||
| ) |
Restore constructor.
| virtual Meta::MObject::~MObject | ( | ) | [virtual] |
Destructor.
Absolute value.
Arcosine.
Arc hyperbolic cosine.
Arc Cotangent.
Arc hyperbolic cotangent.
Arc cosecant.
Arc hyperbolic cosecant.
| mnode Meta::MObject::Add_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Addition.
| mnode Meta::MObject::AddA_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Add to, i.e: +=
| mnode Meta::MObject::And_ | ( | mnode | n1, |
| mnode | n2 | ||
| ) |
Logical AND with short-circuiting.
Evaluate the arguments of function f.
Arc secant.
Arc hyberbolic secant.
Arcsine.
Arc hyperbolic sine.
| mnode Meta::MObject::ATan2_ | ( | mnode | y, |
| mnode | x | ||
| ) |
Arctangent 2.
Arctangent.
Arc hyperbolic tangent.
Get an attribute. Error if s does not exist.
| mnode Meta::MObject::Attr_ | ( | mnode | s, |
| mnode | v | ||
| ) |
Declare or the set the value of an existing attribute.
| mnode Meta::MObject::attribute | ( | const mstr & | name, |
| AttributeMode | mode = Raw |
||
| ) |
Get the named attribute.
| mnode Meta::MObject::attribute | ( | size_t | i | ) |
Get the i-th attribute.
| size_t Meta::MObject::attributeCount | ( | ) | const |
| mstr Meta::MObject::attributeName | ( | size_t | i | ) | const |
Get the name of the i-th attribute.
| virtual mnode Meta::MObject::autoprocess | ( | mnode | n, |
| uint32_t | flags = 0 |
||
| ) | [virtual] |
Auto-generated process method. Do not implement.
| virtual void Meta::MObject::autostore | ( | mvar & | v | ) | const [virtual] |
Auto-generated store method. Do not implement.
Return the last item in n's sequence or function arguments.
Break.
Perform a call, evaluating function f's arguments first.
High precision Catalan constant.
Ceiling function.
Used for evaluation at the compilation/parsing stage.
| mnode Meta::MObject::CEval_ | ( | mnode | n1, |
| mnode | n2 | ||
| ) |
Used for evaluation at the compilation/parsing stage.
| mnode Meta::MObject::Class_ | ( | mnode | n1, |
| mnode | n2 | ||
| ) |
Declare a class.
Functional version of MVar::clear().
| void Meta::MObject::clearAttribute | ( | const mstr & | name | ) |
Clear the named attribute.
Functional version of MVar::clearMap().
Functional version of MVar::clearSeq().
| virtual MObjectBase* Meta::MObject::clone | ( | ) | const [virtual] |
Reimplemented from Meta::MObjectBase.
Reimplemented in Meta::MMLEntity, and Meta::MRandom.
Copy an object.
A closure, when evaluated n is returned.
Used to specifiy code which is to be treated as data and not executed.
| mnode Meta::MObject::Complement_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Return the result of applying ComplementA to v1 and v2.
| mnode Meta::MObject::ComplementA_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Functional version of MVar::complement().
Continue.
Cosine.
Hyperboic cosine.
Cotangent.
Hyperbolic cotangent.
Create a new object with managed memory deallocation.
Cosecant.
Hyperbolic cosecant.
Pre-decrement.
Post-decrement.
| mnode Meta::MObject::Def_ | ( | mnode | s, |
| mnode | v | ||
| ) |
Lazy definition (v is not evaluated), used for defining a function or aliasing a symbol to a function.
e.g: Def(diff(a,b),Sub(a,b))
| mnode Meta::MObject::Def_ | ( | mnode | scope, |
| mnode | s, | ||
| mnode | v | ||
| ) |
Identical to Def(2), but define within specified scope.
e.g: Def(Global,x,10)
Delete an object.
| mnode Meta::MObject::Div_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Division.
| mnode Meta::MObject::DivA_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Divide by, i.e: /=
| mnode Meta::MObject::Elem_ | ( | mnode | n, |
| mnode | ni | ||
| ) |
Extract an element from a node, e.g: Elem(Add(1,2),0) => 1
| void Meta::MObject::enableInterrupts | ( | bool | flag | ) |
Set whether this object periodically checks interrupts. See MInterrupt. For performance reasons, the default is not to check for interrupts.
| mnode Meta::MObject::Eq_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Equal to.
| mnode Meta::MObject::Erase_ | ( | mnode | v, |
| mnode | k | ||
| ) |
Functional version of MVar::erase().
High precision Euler constant.
| mvar Meta::MObject::eval | ( | const mvar & | code | ) |
Process code data at the head of an mvar. If the result contains symbolic data, it is converted to code data and returned.
Evaluate n.
| mnode Meta::MObject::Ex_ | ( | mnode | n | ) |
Execute n.
Exponential function.
Expand a function containing Range() functions.
Finish used to stop execution in various contexts.
| mnode Meta::MObject::Finish_ | ( | mnode | value | ) |
Finish used to stop execution in various contexts.
Perform the inverse of LRec() and RRec().
Floor function.
| mnode Meta::MObject::ForEach_ | ( | mnode | item, |
| mnode | sequence, | ||
| mnode | block | ||
| ) |
Foreach loop.
| mnode Meta::MObject::ForList_ | ( | mnode | n1, |
| mnode | n2, | ||
| mnode | n3 | ||
| ) |
For list.
| mnode Meta::MObject::ForVec_ | ( | mnode | n1, |
| mnode | n2, | ||
| mnode | n3 | ||
| ) |
For vector.
| mnode Meta::MObject::GE_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Greater than or equal to.
Get a symbol value or function defintion from scope.
| mnode Meta::MObject::Get_ | ( | mnode | n, |
| mnode | nk | ||
| ) |
Index n with nk, creating the entry at nk if it doesn't exist.
| mnode Meta::MObject::GetF_ | ( | mnode | f, |
| mnode | s, | ||
| mnode | p | ||
| ) |
Get a function definition.
Get a symbol from the immediate scope.
| mnode Meta::MObject::GT_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Greater than.
| mnode Meta::MObject::HasKey_ | ( | mnode | v, |
| mnode | k | ||
| ) |
Functional version of MVar::hasKey().
Head, e.g: Head(Neg(1)) => "Neg" or the head of an mvar.
| mnode Meta::MObject::Idx_ | ( | mnode | n, |
| mnode | nk | ||
| ) |
Index n at nk, nk must be a valid key or an MError is thrown.
| mnode Meta::MObject::IdxR_ | ( | mnode | n, |
| mnode | nk | ||
| ) |
Index n at nk, returning a reference to the element, nk must be a valid key or an MError is thrown.
| mnode Meta::MObject::If_ | ( | mnode | n1, |
| mnode | n2 | ||
| ) |
Conditional, if-then.
| mnode Meta::MObject::If_ | ( | mnode | n1, |
| mnode | n2, | ||
| mnode | n3 | ||
| ) |
Conditional, if-then-else.
Import library functions.
Pre-increment.
Post-increment.
| mnode Meta::MObject::Index_ | ( | mnode | v, |
| mnode | x | ||
| ) |
Functional version of MVar::index().
| mnode Meta::MObject::Index_ | ( | mnode | v, |
| mnode | x, | ||
| mnode | start | ||
| ) |
Functional version of MVar::index().
Functional version of MVar::index().
| mnode Meta::MObject::IndexMap_ | ( | mnode | v, |
| mnode | flag | ||
| ) |
Functional version of MVar::indexMap().
Info embeds information in M code which is ignored by the interpreter.
| virtual bool Meta::MObject::instanceOf | ( | ClassIdType | classId | ) | const [virtual] |
Reimplemented from Meta::MObjectBase.
Reimplemented in Meta::MMLEntity.
| mnode Meta::MObject::Intersect_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Functional version of MVar::intersect().
| mnode Meta::MObject::Intersect_ | ( | mnode | v1, |
| mnode | v2, | ||
| mnode | outer | ||
| ) |
Functional version of MVar::intersect().
| mnode Meta::MObject::Intersection_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Inverse.
| bool Meta::MObject::inVirtual | ( | ) |
| bool Meta::MObject::isConnected | ( | ) | const |
Called on the client-side of a distributed object.
Functional version of MVar::isDefined().
| bool Meta::MObject::isDistributed | ( | ) | const |
Functional version of MVar::isEmpty().
| bool Meta::MObject::isExact | ( | ) | const |
| bool Meta::MObject::isLocal | ( | ) | const |
| bool Meta::MObject::isRemote | ( | ) | const |
| static bool Meta::MObject::isStandardType | ( | const mstr & | type | ) | [static] |
| bool Meta::MObject::isStrict | ( | ) | const |
| mnode Meta::MObject::Itp_ | ( | mnode | s, |
| mnode | si | ||
| ) |
Interpolate values in si into string s.
| mnode Meta::MObject::Join_ | ( | mnode | v, |
| mnode | delimiter | ||
| ) |
Functional version of MVar::join().
Functional version of MVar::keys().
| mnode Meta::MObject::Lambda_ | ( | mnode | n1, |
| mnode | n2, | ||
| mnode | n3 | ||
| ) |
Define a lambda function.
| mnode Meta::MObject::LE_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Less than or equal to.
Return the length/size of n.
| mnode Meta::MObject::ListRange_ | ( | mnode | end | ) |
Functional version of MMath::listRange().
| mnode Meta::MObject::ListRange_ | ( | mnode | start, |
| mnode | end | ||
| ) |
Functional version of MMath::listRange().
| mnode Meta::MObject::ListRange_ | ( | mnode | start, |
| mnode | end, | ||
| mnode | increment | ||
| ) |
Functional version of MMath::listRange().
| mnode Meta::MObject::Ln_ | ( | mnode | v | ) |
Logarithm base e.
Logarithm base 10.
Log, same as Print() but with a newline appended.
Use left-recursion to convert n to nested binary functions, e.g: Add(1,2,3) => Add(Add(1,2),3)
| mnode Meta::MObject::LRec_ | ( | mnode | n, |
| mnode | k, | ||
| mnode | all | ||
| ) |
Use left-recursion to convert n to k-arity nested functions.
| mnode Meta::MObject::LT_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Less than.
| mnode Meta::MObject::Max_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Max value.
Used to specifiy embedded raw M code.
| mnode Meta::MObject::Merge_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Functional version of MVar::merge().
| mnode Meta::MObject::MergeScope_ | ( | mnode | s1, |
| mnode | s2 | ||
| ) |
Merge scopes.
| mnode Meta::MObject::method | ( | const mstr & | name, |
| size_t | inputs | ||
| ) |
| mnode Meta::MObject::method | ( | size_t | i | ) |
| mnode Meta::MObject::Method_ | ( | mnode | n1, |
| mnode | n2, | ||
| mnode | n3 | ||
| ) |
Declare a method.
| size_t Meta::MObject::methodCount | ( | ) | const |
Resolve a symbol which may be recursively defined.
| mnode Meta::MObject::Min_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Min value.
| mnode Meta::MObject::Mod_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Modulus.
| mnode Meta::MObject::ModA_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Modulus by, i.e: %=
| mnode Meta::MObject::Mul_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Multiplication.
| mnode Meta::MObject::MulA_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Multiply by, i.e: *=
| mnode Meta::MObject::NamedArg_ | ( | mnode | s, |
| mnode | v | ||
| ) |
Named argument.
| mnode Meta::MObject::NE_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Not equal to.
Negation.
Construct a new object.
A no-op, which may be erased from the M code.
Logical negation.
Used to execute a function f once, leaving behind the value as evaluated.
| virtual void Meta::MObject::onClientClosed | ( | const mvar & | session | ) | [virtual] |
Called on the server-side of a distributed object when a connection to client is closed.
| session | The session data associated with the client. |
| virtual void Meta::MObject::onServerClosed | ( | ) | [virtual] |
Called on the client-side of a distributed object when the connection to server is closed.
| mnode Meta::MObject::Or_ | ( | mnode | n1, |
| mnode | n2 | ||
| ) |
Logical OR with short-circuiting.
| mnode Meta::MObject::OuterMergeScope_ | ( | mnode | s1, |
| mnode | s2 | ||
| ) |
Outer merge scope (s2's symbols/functions take precedence).
| std::ostream& Meta::MObject::outputStream | ( | ) | const |
Get the output stream.
Typically called when n is a parameter passed to a function to be partially evaluated, e.g: for symbol lookup.
Partial evalation of parameters in f.
A no-op placeholder.
High precision constant pi.
Functional version of MVar::pop().
Functional version of MVar::popBack().
Functional version of MVar::popFront().
Pop a scope from the current call stack.
| mnode Meta::MObject::Pow_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Exponentiation.
| mnode Meta::MObject::PreEval_ | ( | mnode | n1, |
| mnode | n2 | ||
| ) |
Pre-evaluate functions selectively.
Print.
| virtual mnode Meta::MObject::process | ( | mnode | n, |
| uint32_t | flags = 0 |
||
| ) | [virtual] |
Process method for processing a node through the M interpreter.
Implements Meta::MProcessor.
Reimplemented in Meta::MLib, Meta::MRandom, Meta::MMLEntity, Meta::MMLGrid, Meta::MMLRoot, Meta::MVideoEncoder, Meta::MMage, Meta::MMLSharedVar, and Meta::MDLDomain.
| mnode Meta::MObject::Push_ | ( | mnode | v, |
| mnode | x | ||
| ) |
Functional version of MVar::push().
| mnode Meta::MObject::PushBack_ | ( | mnode | v, |
| mnode | x | ||
| ) |
Functional version of MVar::pushBack().
| mnode Meta::MObject::PushFront_ | ( | mnode | v, |
| mnode | x | ||
| ) |
Functional version of MVar::pushFront().
Push scope s onto the current scope stack.
| mnode Meta::MObject::PushScope_ | ( | mnode | o, |
| mnode | s | ||
| ) |
Push scope s onto o's scope stack.
| mnode Meta::MObject::Range_ | ( | mnode | end | ) |
Functional version of MMath::vectorRange().
| mnode Meta::MObject::Range_ | ( | mnode | start, |
| mnode | end | ||
| ) |
Functional version of MMath::vectorRange().
| mnode Meta::MObject::Range_ | ( | mnode | start, |
| mnode | end, | ||
| mnode | increment | ||
| ) |
Functional version of MMath::vectorRange().
Construct a real number.
| mnode Meta::MObject::ReDef_ | ( | mnode | s, |
| mnode | v | ||
| ) |
Redefine a symbol or function. Redefines the first matching symbol or function on the stack.
| bool Meta::MObject::release | ( | ) |
From the client-side, release a remote object.
| mnode Meta::MObject::remoteProcess | ( | mnode | f, |
| bool | block = true, |
||
| mnode | fail = 0 |
||
| ) |
If this is a remote object (checked through isRemote()) then dispatch a request through a broker to process a method on the server-side of the object.
| block | false in order to not wait for the response. |
| fail | The node to return upon failure, e.g: if a disconnect occurs during processing. |
| mnode Meta::MObject::ReplaceSymbols_ | ( | mnode | f, |
| mnode | m | ||
| ) |
Replace symbols in f with those mapped in m.
Reset the interpreter, clearing all state.
Reset the global scope and other global state.
Return a value.
Round to nearest integer.
| mnode Meta::MObject::Round_ | ( | mnode | v, |
| mnode | precision | ||
| ) |
Round to specfied precision.
Use right-recursion to convert n to nested binary functions, e.g: Add(1,2,3) => Add(1,Add(2,3))
| mnode Meta::MObject::RRec_ | ( | mnode | n, |
| mnode | k, | ||
| mnode | all | ||
| ) |
Use right-recursion to convert n to k-arity nested functions/
Get or create a named scope.
| mnode Meta::MObject::Scope_ | ( | mnode | s, |
| mnode | f | ||
| ) |
Execute f from within scope s.
Execute f from within a new scope pushed onto the call stack.
Secant.
Hyberbolic secant.
Called on the server-side of a distributed object.
| const mvar& Meta::MObject::session | ( | ) | const |
Called on the server-side of a distributed object.
| mnode Meta::MObject::Set_ | ( | mnode | n, |
| mnode | v | ||
| ) |
Set n's value to value v.
| void Meta::MObject::setAttribute | ( | const mstr & | name, |
| mnode | n, | ||
| AttributeMode | mode = Raw |
||
| ) |
Set the named attribute.
| void Meta::MObject::setExact | ( | bool | flag | ) |
Set whether the interpreter uses exact math rather than returning floating point approximations (in some cases), e.g: an exact interpreter returns Sqrt(2) when Sqrt(2) is requested while non-exact mode would return 1.41421. The initial behavior of the object is to use non-exact math.
| void Meta::MObject::setMethod | ( | mnode | sig, |
| mnode | body | ||
| ) |
| sig | e.g: sum(a,b) |
| body | e.g: Ret(Add(a,b,)) |
| void Meta::MObject::setOutputStream | ( | std::ostream & | ostr | ) |
Set the output stream used in print, logging, etc. Defaults to MProgram's outputStream.
| void Meta::MObject::setSharedScope | ( | MObject * | object | ) |
Set the shared scope object. By default, the shared scope defaults to the global scope.
| void Meta::MObject::setSharedScope | ( | ) |
Set the shared scope to this object.
| mnode Meta::MObject::SetSharedScope_ | ( | mnode | o, |
| mnode | s | ||
| ) |
Set the shared scope of o to s.
| void Meta::MObject::setStrict | ( | bool | flag | ) |
Set whether to enable strict interpretation (default is true). Strict interpreters throw an MProcessError when they attempt to process an undefined symbol or function. Non-strict interpreters leave it untouched, returning the unknown symbol or function.
Show the unevaluated value of a symbol.
Sine.
Hyperboic sine.
Functional version of MVar::size().
| mnode Meta::MObject::Split_ | ( | mnode | v, |
| mnode | delimiter, | ||
| mnode | maxTokens | ||
| ) |
Functional version of MVar::split().
| mnode Meta::MObject::Split_ | ( | mnode | v, |
| mnode | delimiter | ||
| ) |
Functional version of MVar::split().
Square root.
| virtual void Meta::MObject::store | ( | mvar & | v | ) | const [virtual] |
Store this object to v.
Reimplemented from Meta::MObjectBase.
Reimplemented in Meta::MMLEntity, Meta::MMLRoot, Meta::MAuth, Meta::MRandom, Meta::MMage, and Meta::MDLDomain.
| mnode Meta::MObject::StrToSym_ | ( | mnode | str | ) |
| mnode Meta::MObject::Sub_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Subtraction.
| mnode Meta::MObject::SubA_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Subtract from, i.e: -=
| mnode Meta::MObject::SubsumesData_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Return true if v1's data subsumes v2.
| mnode Meta::MObject::Super_ | ( | mnode | n1, |
| mnode | n2 | ||
| ) |
Execute a super-class method.
| mnode Meta::MObject::SymToStr_ | ( | mnode | sym | ) |
Tangent.
Hyperboic tangent.
| mnode Meta::MObject::Throw_ | ( | mnode | n, |
| mnode | msg | ||
| ) |
Throw an MError with specified message. Node n contains the filename/line number.
| mnode Meta::MObject::Throw_ | ( | mnode | n, |
| mnode | msg, | ||
| mnode | type | ||
| ) |
Throw an MError with the specified type and message. Node n contains the filename/line number.
Get the i-th scope from the top.
| mnode Meta::MObject::Type_ | ( | mnode | n1, |
| mnode | n2, | ||
| mnode | n3 | ||
| ) |
Construct a type.
Construct a type with initial value.
Undefine n from scope.
| mnode Meta::MObject::Union_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Functional version of MVar::unite().
| mnode Meta::MObject::Unite_ | ( | mnode | v1, |
| mnode | v2 | ||
| ) |
Functional version of MVar::unite().
| mnode Meta::MObject::Unite_ | ( | mnode | v1, |
| mnode | v2, | ||
| mnode | outer | ||
| ) |
Functional version of MVar::unite().
| mnode Meta::MObject::Value_ | ( | mnode | n1, |
| mnode | n2, | ||
| mnode | n3 | ||
| ) |
Return a typed value.
| mnode Meta::MObject::Var_ | ( | mnode | n1 | ) |
Construct a variable.
| mnode Meta::MObject::Var_ | ( | mnode | n1, |
| mnode | n2 | ||
| ) |
Construct a variable with an initial value.
| mnode Meta::MObject::VSet_ | ( | mnode | n1, |
| mnode | n2 | ||
| ) |
Set the value of an existing variable or declare a new variable if it does not exist in scope.
| mnode Meta::MObject::While_ | ( | mnode | n1, |
| mnode | n2 | ||
| ) |
While loop.
| mnode Meta::MObject::XOr_ | ( | mnode | n1, |
| mnode | n2 | ||
| ) |
Logical exclusive-OR with short-circuiting.
1.7.6.1