OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
RealArray.cpp
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2// $RCSfile: RealArray.cpp,v $
3// ------------------------------------------------------------------------
4// $Revision: 1.1.1.1 $
5// ------------------------------------------------------------------------
6// Copyright: see Copyright.readme
7// ------------------------------------------------------------------------
8//
9// Class RealArray:
10// A class used to parse real array attributes.
11//
12// ------------------------------------------------------------------------
13//
14// $Date: 2000/03/27 09:33:36 $
15// $Author: Andreas Adelmann $
16//
17// ------------------------------------------------------------------------
18
20#include <vector>
25#include "Expressions/AList.h"
28
29using namespace Expressions;
30
31// Class RealArray
32// ------------------------------------------------------------------------
33
34namespace Attributes {
35
36 RealArray::RealArray(const std::string& name, const std::string& help)
37 : AttributeHandler(name, help, 0) {}
38
40
41 const std::string& RealArray::getType() const {
42 static std::string type = "real array";
43 return type;
44 }
45
46 void RealArray::parse(Attribute& attr, Statement& statement, bool eval) const {
47 PtrToArray<double> expr = parseRealArray(statement);
48
49 if (eval) {
50 // Use ADeferred here, since a component may be overridden later
51 // by an expression.
52 attr.set(new ADeferred<double>(expr->evaluate()));
53 } else if (is_deferred) {
54 attr.set(new ADeferred<double>(expr));
55 } else {
56 attr.set(new AAutomatic<double>(expr));
57 }
58 }
59
60 void RealArray::parseComponent(Attribute& attr, Statement& stat, bool eval, int index) const {
61 ADeferred<double>* array = 0;
62
63 if (AttributeBase* base = &(attr.getBase())) {
64 array = dynamic_cast<ADeferred<double>*>(base);
65 } else {
66 attr.set(array = new ADeferred<double>());
67 }
68
69 PtrToScalar<double> expr = parseReal(stat);
70 if (eval) expr = new SConstant<double>(expr->evaluate());
71 array->setComponent(index, expr);
72 }
73
74}; // namespace Attributes
Abstract base class for attribute values of different types.
Abstract base class for attribute parsers.
bool is_deferred
Defer flag.
A representation of an Object attribute.
Definition Attribute.h:52
AttributeBase & getBase() const
Return reference to polymorphic value.
Definition Attribute.cpp:52
void set(AttributeBase *newBase)
Define new value.
Definition Attribute.cpp:86
virtual const std::string & getType() const
Return attribute type string `‘real array’'.
Definition RealArray.cpp:41
virtual void parseComponent(Attribute &, Statement &, bool, int) const
Parse a component of the array.
Definition RealArray.cpp:60
virtual void parse(Attribute &, Statement &, bool) const
Parse the attribute.
Definition RealArray.cpp:46
Object attribute with an `‘automatic’' array value.
Definition AAutomatic.h:38
Object attribute with a `‘deferred’' array value.
Definition ADeferred.h:40
void setComponent(int i, const PtrToScalar< T > expr)
Set a component of the value.
Definition ADeferred.h:203
A pointer to an array expression.
A pointer to a scalar expression.
A scalar constant expression.
Definition SConstant.h:35
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< double > parseReal(Statement &)
Parse real expression.
PtrToArray< double > parseRealArray(Statement &)
Parse real array expression.