amath  1.8.5
Simple command line calculator
NumericValueNode Class Reference

Use of a numeric value in a syntax tree. More...

#include <values.h>

Inheritance diagram for NumericValueNode:
Collaboration diagram for NumericValueNode:

Public Member Functions

 NumericValueNode ()
 
 NumericValueNode (Number *value)
 
virtual ReductionType GetReductionType ()
 
int GetPrecedence ()
 
char * GetText ()
 
SyntaxNodeGetNext ()
 
NumberEvaluate ()
 
void Attach (SyntaxNode *node)
 
void Detach (SyntaxNode *node)
 
void Replace (SyntaxNode *n, SyntaxNode *x)
 
void ReplaceWith (Number *value)
 
- 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 void ResetIterator ()
 

Protected Member Functions

char * GetNodeText ()
 

Additional Inherited Members

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

Detailed Description

Use of a numeric value in a syntax tree.

Definition at line 150 of file values.h.

Constructor & Destructor Documentation

◆ NumericValueNode() [1/2]

NumericValueNode::NumericValueNode ( )

Definition at line 371 of file values.cpp.

References ExpressionNode::ExpressionNode(), and RealNumber::RealNumber().

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

371  :
373 {
374 }
ExpressionNode()
Definition: nodes.cpp:89
Represent a real number with 15 significant digits.
Definition: real.h:45
Here is the call graph for this function:
Here is the caller graph for this function:

◆ NumericValueNode() [2/2]

NumericValueNode::NumericValueNode ( Number value)
explicit

Definition at line 376 of file values.cpp.

References ExpressionNode::ExpressionNode().

Referenced by ComplexiNode::ComplexiNode(), EulersNumberNode::EulersNumberNode(), Parser::ParseNumber(), PiNode::PiNode(), and Optimizer::ReduceValueNodes().

376  :
377  ExpressionNode(value)
378 {
379 }
ExpressionNode()
Definition: nodes.cpp:89
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ Attach()

void NumericValueNode::Attach ( SyntaxNode node)
virtual

Implements SyntaxNode.

Definition at line 415 of file values.cpp.

416 {
417 }

◆ Detach()

void NumericValueNode::Detach ( SyntaxNode node)
virtual

Implements SyntaxNode.

Definition at line 419 of file values.cpp.

420 {
421 }

◆ Evaluate()

Number * NumericValueNode::Evaluate ( )
virtual

Implements ExpressionNode.

Definition at line 393 of file values.cpp.

References ExpressionNode::result.

Referenced by Optimizer::ReduceUnaryNodes(), and Optimizer::ReduceValueNodes().

394 {
395  return result;
396 }
Number * result
Definition: nodes.h:116
Here is the caller graph for this function:

◆ GetNext()

SyntaxNode * NumericValueNode::GetNext ( )
virtual

Implements SyntaxNode.

Definition at line 410 of file values.cpp.

411 {
412  return nullptr;
413 }

◆ GetNodeText()

char * NumericValueNode::GetNodeText ( )
protectedvirtual

Implements ExpressionNode.

Reimplemented in ComplexiNode, PiNode, and EulersNumberNode.

Definition at line 403 of file values.cpp.

References CharBuffer::ClearAndCopy(), CharBuffer::GetString(), NumeralSystem::GetText(), Program::Input, SyntaxNode::output, and ExpressionNode::result.

Referenced by GetText().

404 {
405  const char* val = Program->Input->GetText(result);
406  output->ClearAndCopy(val);
407  return output->GetString();
408 }
Master control class.
Definition: program.h:55
char * GetString() const
Definition: charbuf.cpp:306
virtual const char * GetText(Number *number)=0
Number * result
Definition: nodes.h:116
CharBuffer * output
Definition: nodes.h:85
void ClearAndCopy(const char *source)
Release memory, allocate and copy source.
Definition: charbuf.cpp:81
class NumeralSystem * Input
Definition: program.h:75
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPrecedence()

int NumericValueNode::GetPrecedence ( )
virtual

Implements ExpressionNode.

Definition at line 386 of file values.cpp.

References Number::GetDefaultPrecedence(), Number::GetPrecedence(), SyntaxNode::leftBottom, and ExpressionNode::result.

387 {
388  return !leftBottom ?
389  result->GetPrecedence() :
391 }
virtual int GetPrecedence()=0
bool leftBottom
Definition: nodes.h:88
Number * result
Definition: nodes.h:116
virtual int GetDefaultPrecedence()=0
Here is the call graph for this function:

◆ GetReductionType()

ReductionType NumericValueNode::GetReductionType ( )
virtual

Reimplemented from SyntaxNode.

Reimplemented in ComplexiNode, PiNode, and EulersNumberNode.

Definition at line 381 of file values.cpp.

References valuereduc.

Referenced by Optimizer::ReduceValueNodes().

382 {
383  return valuereduc;
384 }
Here is the caller graph for this function:

◆ GetText()

char * NumericValueNode::GetText ( )
virtual

Implements ExpressionNode.

Definition at line 398 of file values.cpp.

References GetNodeText().

399 {
400  return GetNodeText();
401 }
char * GetNodeText()
Definition: values.cpp:403
Here is the call graph for this function:

◆ Replace()

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

Implements SyntaxNode.

Definition at line 423 of file values.cpp.

424 {
425 }

◆ ReplaceWith()

void NumericValueNode::ReplaceWith ( Number value)

Definition at line 427 of file values.cpp.

References ExpressionNode::result.

Referenced by Optimizer::ReduceUnaryNodes().

428 {
429  delete result;
430  result = value;
431 }
Number * result
Definition: nodes.h:116
Here is the caller graph for this function:

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