amath  1.8.5
Simple command line calculator
UserFunctionNode Class Reference

An expression node able to compute a function value. More...

#include <user.h>

Inheritance diagram for UserFunctionNode:
Collaboration diagram for UserFunctionNode:

Public Member Functions

 UserFunctionNode (UserFunction *function, ExpressionNode *parameter)
 
NumberEvaluate ()
 
SyntaxNodeGetNext ()
 
void Attach (SyntaxNode *node)
 
void Detach (SyntaxNode *node)
 
void Replace (SyntaxNode *n, SyntaxNode *x)
 
- Public Member Functions inherited from FunctionNode
 FunctionNode (ExpressionNode *expression, char *text, char *sys)
 
 ~FunctionNode ()
 
int GetPrecedence ()
 
char * GetText ()
 
- Public Member Functions inherited from ExpressionNode
 ExpressionNode ()
 
 ExpressionNode (Number *value)
 
virtual ~ExpressionNode ()
 
NodeType GetNodeType ()
 
virtual bool IsSilent ()
 
char * GetTextCode ()
 
char * Execute ()
 
- Public Member Functions inherited from SyntaxNode
 SyntaxNode ()
 
virtual ~SyntaxNode ()
 
void SetFirstNode ()
 
bool GetFirstNode () const
 
SyntaxNodeGetParent () const
 
void SetParent (SyntaxNode *node)
 
virtual ReductionType GetReductionType ()
 
virtual void ResetIterator ()
 

Protected Member Functions

char * GetNodeText ()
 

Private Attributes

UserFunctionfunction
 

Additional Inherited Members

- Protected Attributes inherited from FunctionNode
ExpressionNodeexpression
 
char * name
 
char * sysname
 
- Protected Attributes inherited from ExpressionNode
Numberresult
 
- Protected Attributes inherited from SyntaxNode
CharBufferoutput
 
SyntaxNodeparent
 
SyntaxNodeiterator
 
bool leftBottom
 

Detailed Description

An expression node able to compute a function value.

Definition at line 40 of file user.h.

Constructor & Destructor Documentation

◆ UserFunctionNode()

UserFunctionNode::UserFunctionNode ( UserFunction function,
ExpressionNode parameter 
)

Definition at line 33 of file user.cpp.

References function, and FunctionNode::FunctionNode().

Referenced by FunctionList::GetFunctionCall().

33  :
34  FunctionNode(parameter, nullptr, nullptr), function(function)
35 {
36 }
FunctionNode(ExpressionNode *expression, char *text, char *sys)
Definition: node.cpp:34
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ Attach()

void UserFunctionNode::Attach ( SyntaxNode node)
virtual

Reimplemented from FunctionNode.

Definition at line 61 of file user.cpp.

62 {
63  // TODO: Implement Attach in UserFunctionNode
64 }

◆ Detach()

void UserFunctionNode::Detach ( SyntaxNode node)
virtual

Reimplemented from FunctionNode.

Definition at line 66 of file user.cpp.

67 {
68  // TODO: Implement Detach in UserFunctionNode
69 }

◆ Evaluate()

Number * UserFunctionNode::Evaluate ( )
virtual

Implements ExpressionNode.

Definition at line 43 of file user.cpp.

References Variable::AssignValue(), ExpressionNode::Evaluate(), FunctionNode::expression, function, UserFunction::GetExpression(), and UserFunction::GetVariable().

44 {
45  // Set value of function parameter and then evaluate function.
46  function->GetVariable()->AssignValue(expression->Evaluate());
47  return function->GetExpression()->Evaluate();
48 }
virtual Number * Evaluate()=0
ExpressionNode * expression
Definition: node.h:66
Here is the call graph for this function:

◆ GetNext()

SyntaxNode * UserFunctionNode::GetNext ( )
virtual

Reimplemented from FunctionNode.

Definition at line 50 of file user.cpp.

References function, UserFunction::GetExpression(), and SyntaxNode::iterator.

51 {
52  if (iterator == nullptr)
53  {
54  iterator = function->GetExpression();
55  return iterator;
56  }
57 
58  return nullptr;
59 }
SyntaxNode * iterator
Definition: nodes.h:87
Here is the call graph for this function:

◆ GetNodeText()

char * UserFunctionNode::GetNodeText ( )
protectedvirtual

Reimplemented from FunctionNode.

Definition at line 38 of file user.cpp.

References function, and UserFunction::GetName().

39 {
40  return function->GetName();
41 }
Here is the call graph for this function:

◆ Replace()

void UserFunctionNode::Replace ( SyntaxNode n,
SyntaxNode x 
)
virtual

Reimplemented from FunctionNode.

Definition at line 71 of file user.cpp.

72 {
73  // TODO: Implement Replace in UserFunctionNode
74 }

Member Data Documentation

◆ function

UserFunction* UserFunctionNode::function
private

Definition at line 54 of file user.h.

Referenced by Evaluate(), GetNext(), GetNodeText(), and UserFunctionNode().


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