amath  1.8.5
Simple command line calculator
VariableNode Class Reference

Use of a variable in a syntax tree. More...

#include <values.h>

Inheritance diagram for VariableNode:
Collaboration diagram for VariableNode:

Public Member Functions

 VariableNode (Variable *variable)
 
char * GetText ()
 
NumberEvaluate ()
 
void AssignValue (Number *value) const
 
int GetPrecedence ()
 
SyntaxNodeGetNext ()
 
void Attach (SyntaxNode *node)
 
void Detach (SyntaxNode *node)
 
void Replace (SyntaxNode *n, SyntaxNode *x)
 
- 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

Variablevariable
 

Additional Inherited Members

- Protected Attributes inherited from ExpressionNode
Numberresult
 
- Protected Attributes inherited from SyntaxNode
CharBufferoutput
 
SyntaxNodeparent
 
SyntaxNodeiterator
 
bool leftBottom
 

Detailed Description

Use of a variable in a syntax tree.

Definition at line 110 of file values.h.

Constructor & Destructor Documentation

◆ VariableNode()

VariableNode::VariableNode ( Variable variable)
explicit

Definition at line 293 of file values.cpp.

References ExpressionNode::ExpressionNode(), and variable.

Referenced by InsVariableNode::InsVariableNode(), and Parser::ParseIdent().

293  :
294  ExpressionNode(), variable(variable)
295 {
296 }
Variable * variable
Definition: values.h:127
ExpressionNode()
Definition: nodes.cpp:89
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ AssignValue()

void VariableNode::AssignValue ( Number value) const

Definition at line 309 of file values.cpp.

References Variable::AssignValue(), and variable.

Referenced by AssignmentNode::Evaluate().

310 {
311  variable->AssignValue(value);
312 }
Variable * variable
Definition: values.h:127
void AssignValue(Number *value)
Definition: values.cpp:79
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Attach()

void VariableNode::Attach ( SyntaxNode node)
virtual

Implements SyntaxNode.

Definition at line 329 of file values.cpp.

330 {
331 }

◆ Detach()

void VariableNode::Detach ( SyntaxNode node)
virtual

Implements SyntaxNode.

Definition at line 333 of file values.cpp.

334 {
335 }

◆ Evaluate()

Number * VariableNode::Evaluate ( )
virtual

Implements ExpressionNode.

Reimplemented in InsVariableNode.

Definition at line 303 of file values.cpp.

References Variable::GetValue(), ExpressionNode::result, and variable.

Referenced by AssignmentNode::Evaluate().

304 {
305  result = variable->GetValue();
306  return result;
307 }
Number * GetValue() const
Definition: values.cpp:74
Variable * variable
Definition: values.h:127
Number * result
Definition: nodes.h:116
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNext()

SyntaxNode * VariableNode::GetNext ( )
virtual

Implements SyntaxNode.

Definition at line 324 of file values.cpp.

325 {
326  return nullptr;
327 }

◆ GetNodeText()

char * VariableNode::GetNodeText ( )
protectedvirtual

Implements ExpressionNode.

Reimplemented in InsVariableNode.

Definition at line 319 of file values.cpp.

References Variable::GetName(), and variable.

320 {
321  return variable->GetName();
322 }
Variable * variable
Definition: values.h:127
char * GetName() const
Definition: values.cpp:69
Here is the call graph for this function:

◆ GetPrecedence()

int VariableNode::GetPrecedence ( )
virtual

Implements ExpressionNode.

Definition at line 298 of file values.cpp.

299 {
300  return 0;
301 }

◆ GetText()

char * VariableNode::GetText ( )
virtual

Implements ExpressionNode.

Reimplemented in InsVariableNode.

Definition at line 314 of file values.cpp.

References Variable::GetName(), and variable.

315 {
316  return variable->GetName();
317 }
Variable * variable
Definition: values.h:127
char * GetName() const
Definition: values.cpp:69
Here is the call graph for this function:

◆ Replace()

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

Implements SyntaxNode.

Definition at line 337 of file values.cpp.

338 {
339 }

Member Data Documentation

◆ variable

Variable* VariableNode::variable
private

Definition at line 127 of file values.h.

Referenced by AssignValue(), Evaluate(), GetNodeText(), GetText(), and VariableNode().


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