mirror of
https://gitlab.com/rnger/amath
synced 2025-10-06 02:49:59 +00:00
194 lines
4.3 KiB
Groff
194 lines
4.3 KiB
Groff
.TH "EvalStatement" 3 "Tue Jan 24 2017" "Version 1.6.2" "amath" \" -*- nroff -*-
|
|
.ad l
|
|
.nh
|
|
.SH NAME
|
|
EvalStatement \- Evaluate arithmetic expression\&.
|
|
|
|
.SH SYNOPSIS
|
|
.br
|
|
.PP
|
|
.PP
|
|
\fC#include <statements\&.h>\fP
|
|
.PP
|
|
Inherits \fBStatementNode\fP\&.
|
|
.SS "Public Member Functions"
|
|
|
|
.in +1c
|
|
.ti -1c
|
|
.RI "\fBEvalStatement\fP (\fBExpressionNode\fP *\fBexpression\fP)"
|
|
.br
|
|
.ti -1c
|
|
.RI "\fB~EvalStatement\fP ()"
|
|
.br
|
|
.ti -1c
|
|
.RI "char * \fBExecute\fP ()"
|
|
.br
|
|
.ti -1c
|
|
.RI "\fBSyntaxNode\fP * \fBGetNext\fP ()"
|
|
.br
|
|
.ti -1c
|
|
.RI "void \fBAttach\fP (\fBSyntaxNode\fP *node)"
|
|
.br
|
|
.ti -1c
|
|
.RI "void \fBDetach\fP (\fBSyntaxNode\fP *node)"
|
|
.br
|
|
.ti -1c
|
|
.RI "void \fBReplace\fP (\fBSyntaxNode\fP *n, \fBSyntaxNode\fP *x)"
|
|
.br
|
|
.in -1c
|
|
.SS "Private Attributes"
|
|
|
|
.in +1c
|
|
.ti -1c
|
|
.RI "\fBExpressionNode\fP * \fBexpression\fP"
|
|
.br
|
|
.in -1c
|
|
.SS "Additional Inherited Members"
|
|
.SH "Detailed Description"
|
|
.PP
|
|
Evaluate arithmetic expression\&.
|
|
.PP
|
|
Definition at line 155 of file statements\&.h\&.
|
|
.SH "Constructor & Destructor Documentation"
|
|
.PP
|
|
.SS "EvalStatement::EvalStatement (\fBExpressionNode\fP * expression)"
|
|
|
|
.PP
|
|
Definition at line 251 of file statements\&.cpp\&.
|
|
.PP
|
|
References expression, and StatementNode::StatementNode()\&.
|
|
.PP
|
|
Referenced by Parser::ParseEvaluation(), and Parser::ParseStatement()\&.
|
|
.PP
|
|
.nf
|
|
251 :
|
|
252 StatementNode(), expression(expression) { }
|
|
.fi
|
|
.SS "EvalStatement::~EvalStatement ()"
|
|
|
|
.PP
|
|
Definition at line 254 of file statements\&.cpp\&.
|
|
.PP
|
|
References expression\&.
|
|
.PP
|
|
.nf
|
|
255 {
|
|
256 if (expression != NOMEM) {
|
|
257 delete expression;
|
|
258 }
|
|
259 }
|
|
.fi
|
|
.SH "Member Function Documentation"
|
|
.PP
|
|
.SS "void EvalStatement::Attach (\fBSyntaxNode\fP * node)\fC [virtual]\fP"
|
|
|
|
.PP
|
|
Reimplemented from \fBStatementNode\fP\&.
|
|
.PP
|
|
Definition at line 292 of file statements\&.cpp\&.
|
|
.PP
|
|
References expression, and SyntaxNode::SetParent()\&.
|
|
.PP
|
|
.nf
|
|
293 {
|
|
294 if (expression == NOMEM) {
|
|
295 expression = (ExpressionNode*)node;
|
|
296 node->SetParent(this);
|
|
297 }
|
|
298 }
|
|
.fi
|
|
.SS "void EvalStatement::Detach (\fBSyntaxNode\fP * node)\fC [virtual]\fP"
|
|
|
|
.PP
|
|
Reimplemented from \fBStatementNode\fP\&.
|
|
.PP
|
|
Definition at line 300 of file statements\&.cpp\&.
|
|
.PP
|
|
References expression\&.
|
|
.PP
|
|
.nf
|
|
301 {
|
|
302 if (expression == node) {
|
|
303 expression = NOMEM;
|
|
304 }
|
|
305 }
|
|
.fi
|
|
.SS "char * EvalStatement::Execute ()\fC [virtual]\fP"
|
|
|
|
.PP
|
|
Implements \fBStatementNode\fP\&.
|
|
.PP
|
|
Definition at line 261 of file statements\&.cpp\&.
|
|
.PP
|
|
References CharBuffer::Append(), CharBuffer::Empty(), CharBuffer::EnsureSize(), ExpressionNode::Evaluate(), expression, CharBuffer::GetString(), NumeralSystem::GetText(), ExpressionNode::GetText(), Program::Output, SyntaxNode::output, Program::SetLastResult(), and StrLen()\&.
|
|
.PP
|
|
.nf
|
|
262 {
|
|
263 Number* result = expression->Evaluate();
|
|
264 Program->SetLastResult(result);
|
|
265 const char *text = expression->GetText();
|
|
266 const char *val = Program->Output->GetText(result);
|
|
267
|
|
268 output->Empty();
|
|
269 output->EnsureSize(
|
|
270 StrLen(text) + 3 +
|
|
271 StrLen(val) +
|
|
272 StrLen(NEWLINE) + 1);
|
|
273
|
|
274 output->Append(text);
|
|
275 output->Append(" = ");
|
|
276 output->Append(val);
|
|
277 output->Append(NEWLINE);
|
|
278
|
|
279 return output->GetString();
|
|
280 }
|
|
.fi
|
|
.SS "\fBSyntaxNode\fP * EvalStatement::GetNext ()\fC [virtual]\fP"
|
|
|
|
.PP
|
|
Reimplemented from \fBStatementNode\fP\&.
|
|
.PP
|
|
Definition at line 282 of file statements\&.cpp\&.
|
|
.PP
|
|
References expression, and SyntaxNode::iterator\&.
|
|
.PP
|
|
.nf
|
|
283 {
|
|
284 if (iterator == NOMEM) {
|
|
285 iterator = expression;
|
|
286 return iterator;
|
|
287 }
|
|
288
|
|
289 return NOMEM;
|
|
290 }
|
|
.fi
|
|
.SS "void EvalStatement::Replace (\fBSyntaxNode\fP * n, \fBSyntaxNode\fP * x)\fC [virtual]\fP"
|
|
|
|
.PP
|
|
Reimplemented from \fBStatementNode\fP\&.
|
|
.PP
|
|
Definition at line 307 of file statements\&.cpp\&.
|
|
.PP
|
|
References expression\&.
|
|
.PP
|
|
.nf
|
|
308 {
|
|
309 if (expression == n) {
|
|
310 delete expression;
|
|
311 expression = (ExpressionNode*)x;
|
|
312 }
|
|
313 }
|
|
.fi
|
|
.SH "Member Data Documentation"
|
|
.PP
|
|
.SS "\fBExpressionNode\fP* EvalStatement::expression\fC [private]\fP"
|
|
|
|
.PP
|
|
Definition at line 167 of file statements\&.h\&.
|
|
.PP
|
|
Referenced by Attach(), Detach(), EvalStatement(), Execute(), GetNext(), Replace(), and ~EvalStatement()\&.
|
|
|
|
.SH "Author"
|
|
.PP
|
|
Generated automatically by Doxygen for amath from the source code\&.
|