OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
Bool.cpp
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2// $RCSfile: Bool.cpp,v $
3// ------------------------------------------------------------------------
4// $Revision: 1.1.1.1 $
5// ------------------------------------------------------------------------
6// Copyright: see Copyright.readme
7// ------------------------------------------------------------------------
8//
9// Class Attributes::Bool
10// A class used to parse boolean attributes.
11//
12// ------------------------------------------------------------------------
13//
14// $Date: 2000/03/27 09:33:36 $
15// $Author: Andreas Adelmann $
16//
17// ------------------------------------------------------------------------
18
19#include "Attributes/Bool.h"
23#include "Expressions/SValue.h"
26#include "OpalParser/Token.h"
28
29using namespace Expressions;
30using std::cerr;
31using std::endl;
32
33// Class Attributes::Bool
34// ------------------------------------------------------------------------
35
36namespace Attributes {
37
38 Bool::Bool(const std::string& name, const std::string& help)
39 : AttributeHandler(name, help, new SValue<bool>(true)) {}
40
42
43 const std::string& Bool::getType() const {
44 static const std::string type("logical");
45 return type;
46 }
47
48 void Bool::parse(Attribute& attr, Statement& stat, bool eval) const {
49 PtrToScalar<bool> expr = parseBool(stat);
50
51 if (eval || expr->isConstant()) {
52 attr.set(new SValue<bool>(expr->evaluate()));
53 } else if (is_deferred) {
54 attr.set(new SDeferred<bool>(expr));
55 } else {
56 attr.set(new SAutomatic<bool>(expr));
57 }
58 }
59
60}; // namespace Attributes
Abstract base class for attribute parsers.
bool is_deferred
Defer flag.
A representation of an Object attribute.
Definition Attribute.h:52
void set(AttributeBase *newBase)
Define new value.
Definition Attribute.cpp:86
virtual const std::string & getType() const
Return attribute type string `‘logical’'.
Definition Bool.cpp:43
virtual ~Bool()
Definition Bool.cpp:41
virtual void parse(Attribute &, Statement &, bool) const
Parse the attribute.
Definition Bool.cpp:48
A pointer to a scalar expression.
Object attribute with an `‘automatic’' scalar value.
Definition SAutomatic.h:38
Object attribute with a `‘deferred’' scalar value.
Definition SDeferred.h:39
Object attribute with a constant scalar value.
Definition SValue.h:34
Interface for statements.
Definition Statement.h:37
A collection of routines to construct object Attributes and retrieve.
Representation objects and parsers for attribute expressions.
PtrToScalar< bool > parseBool(Statement &)
Parse boolean expression.