amath  1.8.5
Simple command line calculator
SilentStatement Class Reference

Mutes the output of another statement. More...

#include <silent.h>

Inheritance diagram for SilentStatement:
Collaboration diagram for SilentStatement:

Public Member Functions

 SilentStatement (StatementNode *statement)
 
 ~SilentStatement ()
 
char * Execute ()
 
SyntaxNodeGetNext ()
 
void Attach (SyntaxNode *node)
 
void Detach (SyntaxNode *node)
 
void Replace (SyntaxNode *n, SyntaxNode *x)
 
- Public Member Functions inherited from StatementNode
 StatementNode ()
 
 StatementNode (const char *text)
 
virtual ~StatementNode ()
 
NodeType GetNodeType ()
 
virtual char * GetTextCode ()
 
- 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 ()
 

Private Attributes

StatementNodestatement
 

Additional Inherited Members

- Protected Attributes inherited from StatementNode
char * statementText
 
- Protected Attributes inherited from SyntaxNode
CharBufferoutput
 
SyntaxNodeparent
 
SyntaxNodeiterator
 
bool leftBottom
 

Detailed Description

Mutes the output of another statement.

Statement node which encapsulate another statement and mutes the output when executing the inner statement.

Definition at line 42 of file silent.h.

Constructor & Destructor Documentation

◆ SilentStatement()

SilentStatement::SilentStatement ( StatementNode statement)
explicit

Definition at line 33 of file silent.cpp.

References statement, and StatementNode::StatementNode().

Referenced by Parser::ParseEvaluation().

33  :
34  StatementNode(), statement(statement)
35 {
36 }
StatementNode * statement
Definition: silent.h:55
StatementNode()
Definition: node.cpp:34
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~SilentStatement()

SilentStatement::~SilentStatement ( )

Definition at line 38 of file silent.cpp.

References statement.

39 {
40  if (statement != nullptr)
41  {
42  delete statement;
43  }
44 }
StatementNode * statement
Definition: silent.h:55

Member Function Documentation

◆ Attach()

void SilentStatement::Attach ( SyntaxNode node)
virtual

Reimplemented from StatementNode.

Definition at line 63 of file silent.cpp.

References SyntaxNode::SetParent(), and statement.

64 {
65  if (statement == nullptr)
66  {
67  statement = static_cast<StatementNode*>(node);
68  node->SetParent(this);
69  }
70 }
Base class for all statements in a syntax tree.
Definition: node.h:40
StatementNode * statement
Definition: silent.h:55
void SetParent(SyntaxNode *node)
Definition: nodes.cpp:75
Here is the call graph for this function:

◆ Detach()

void SilentStatement::Detach ( SyntaxNode node)
virtual

Reimplemented from StatementNode.

Definition at line 72 of file silent.cpp.

References statement.

73 {
74  if (statement == node)
75  {
76  statement = nullptr;
77  }
78 }
StatementNode * statement
Definition: silent.h:55

◆ Execute()

char * SilentStatement::Execute ( )
virtual

Implements StatementNode.

Definition at line 46 of file silent.cpp.

References StatementNode::Execute(), statement, and StatementNode::statementText.

47 {
48  statement->Execute();
49  return statementText;
50 }
char * statementText
Definition: node.h:55
StatementNode * statement
Definition: silent.h:55
virtual char * Execute()=0
Here is the call graph for this function:

◆ GetNext()

SyntaxNode * SilentStatement::GetNext ( )
virtual

Reimplemented from StatementNode.

Definition at line 52 of file silent.cpp.

References SyntaxNode::iterator, and statement.

53 {
54  if (iterator == nullptr)
55  {
57  return iterator;
58  }
59 
60  return nullptr;
61 }
StatementNode * statement
Definition: silent.h:55
SyntaxNode * iterator
Definition: nodes.h:87

◆ Replace()

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

Reimplemented from StatementNode.

Definition at line 80 of file silent.cpp.

References statement.

81 {
82  if (statement == n)
83  {
84  delete statement;
85  statement = static_cast<StatementNode*>(x);
86  }
87 }
Base class for all statements in a syntax tree.
Definition: node.h:40
StatementNode * statement
Definition: silent.h:55

Member Data Documentation

◆ statement

StatementNode* SilentStatement::statement
private

Definition at line 55 of file silent.h.

Referenced by Attach(), Detach(), Execute(), GetNext(), Replace(), SilentStatement(), and ~SilentStatement().


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