amath  1.8.5
Simple command line calculator
AssignmentNode Class Reference

#include <operators.h>

Inheritance diagram for AssignmentNode:
Collaboration diagram for AssignmentNode:

Public Member Functions

 AssignmentNode (VariableNode *variable, ExpressionNode *expression)
 
int GetPrecedence ()
 
bool IsSilent ()
 
NumberEvaluate ()
 
- Public Member Functions inherited from NumericOperator
 NumericOperator (ExpressionNode *left, ExpressionNode *right)
 
 ~NumericOperator ()
 
SyntaxNodeGetNext ()
 
char * GetText ()
 
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 ()
 
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

VariableNodevariable
 
ExpressionNodeexpression
 

Additional Inherited Members

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

Detailed Description

Definition at line 180 of file operators.h.

Constructor & Destructor Documentation

◆ AssignmentNode()

AssignmentNode::AssignmentNode ( VariableNode variable,
ExpressionNode expression 
)

Definition at line 572 of file operators.cpp.

References expression, NumericOperator::NumericOperator(), and variable.

Referenced by Parser::ParseIdent().

572  :
573  NumericOperator(variable, expression),
574  variable(variable), expression(expression)
575 {
576 }
NumericOperator(ExpressionNode *left, ExpressionNode *right)
Definition: operators.cpp:308
ExpressionNode * expression
Definition: operators.h:193
VariableNode * variable
Definition: operators.h:192
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ Evaluate()

Number * AssignmentNode::Evaluate ( )
virtual

Implements ExpressionNode.

Definition at line 583 of file operators.cpp.

References VariableNode::AssignValue(), ExpressionNode::Evaluate(), VariableNode::Evaluate(), expression, and variable.

584 {
585  // NOTICE: Assignment does not generate a value itself.
587  return variable->Evaluate();
588 }
void AssignValue(Number *value) const
Definition: values.cpp:309
virtual Number * Evaluate()=0
ExpressionNode * expression
Definition: operators.h:193
VariableNode * variable
Definition: operators.h:192
Number * Evaluate()
Definition: values.cpp:303
Here is the call graph for this function:

◆ GetNodeText()

char * AssignmentNode::GetNodeText ( )
protectedvirtual

Implements ExpressionNode.

Definition at line 595 of file operators.cpp.

596 {
597  static char* ret = (char*)"=";
598  return ret;
599 }

◆ GetPrecedence()

int AssignmentNode::GetPrecedence ( )
virtual

Implements ExpressionNode.

Definition at line 578 of file operators.cpp.

579 {
580  return 6;
581 }

◆ IsSilent()

bool AssignmentNode::IsSilent ( )
virtual

Reimplemented from ExpressionNode.

Definition at line 590 of file operators.cpp.

591 {
592  return true;
593 }

Member Data Documentation

◆ expression

ExpressionNode* AssignmentNode::expression
private

Definition at line 193 of file operators.h.

Referenced by AssignmentNode(), and Evaluate().

◆ variable

VariableNode* AssignmentNode::variable
private

Definition at line 192 of file operators.h.

Referenced by AssignmentNode(), and Evaluate().


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