Add location member to UDQDefine
This commit is contained in:
parent
5c1604c5f2
commit
5e6c6be3b8
@ -33,6 +33,7 @@
|
|||||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Util/OrderedMap.hpp>
|
#include <opm/parser/eclipse/EclipseState/Util/OrderedMap.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Util/IOrderSet.hpp>
|
#include <opm/parser/eclipse/EclipseState/Util/IOrderSet.hpp>
|
||||||
|
#include <opm/common/OpmLog/KeywordLocation.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
|
@ -30,13 +30,13 @@
|
|||||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQSet.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQSet.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQContext.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQContext.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.hpp>
|
||||||
|
#include <opm/common/OpmLog/KeywordLocation.hpp>
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
|
|
||||||
class UDQASTNode;
|
class UDQASTNode;
|
||||||
class ParseContext;
|
class ParseContext;
|
||||||
class ErrorGuard;
|
class ErrorGuard;
|
||||||
class KeywordLocation;
|
|
||||||
|
|
||||||
class UDQDefine{
|
class UDQDefine{
|
||||||
public:
|
public:
|
||||||
@ -63,6 +63,7 @@ public:
|
|||||||
T&& errors);
|
T&& errors);
|
||||||
|
|
||||||
UDQDefine(const std::string& keyword,
|
UDQDefine(const std::string& keyword,
|
||||||
|
const KeywordLocation& location,
|
||||||
std::shared_ptr<UDQASTNode> astPtr,
|
std::shared_ptr<UDQASTNode> astPtr,
|
||||||
UDQVarType type,
|
UDQVarType type,
|
||||||
const std::string& string_data);
|
const std::string& string_data);
|
||||||
@ -72,6 +73,7 @@ public:
|
|||||||
UDQSet eval(const UDQContext& context) const;
|
UDQSet eval(const UDQContext& context) const;
|
||||||
const std::string& keyword() const;
|
const std::string& keyword() const;
|
||||||
const std::string& input_string() const;
|
const std::string& input_string() const;
|
||||||
|
const KeywordLocation& location() const;
|
||||||
UDQVarType var_type() const;
|
UDQVarType var_type() const;
|
||||||
std::set<UDQTokenType> func_tokens() const;
|
std::set<UDQTokenType> func_tokens() const;
|
||||||
void required_summary(std::unordered_set<std::string>& summary_keys) const;
|
void required_summary(std::unordered_set<std::string>& summary_keys) const;
|
||||||
@ -84,6 +86,7 @@ public:
|
|||||||
serializer(m_keyword);
|
serializer(m_keyword);
|
||||||
serializer(ast);
|
serializer(ast);
|
||||||
serializer(m_var_type);
|
serializer(m_var_type);
|
||||||
|
m_location.serializeOp(serializer);
|
||||||
serializer(string_data);
|
serializer(string_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +94,7 @@ private:
|
|||||||
std::string m_keyword;
|
std::string m_keyword;
|
||||||
std::shared_ptr<UDQASTNode> ast;
|
std::shared_ptr<UDQASTNode> ast;
|
||||||
UDQVarType m_var_type;
|
UDQVarType m_var_type;
|
||||||
|
KeywordLocation m_location;
|
||||||
std::string string_data;
|
std::string string_data;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,8 @@ UDQDefine::UDQDefine(const UDQParams& udq_params,
|
|||||||
const ParseContext& parseContext,
|
const ParseContext& parseContext,
|
||||||
ErrorGuard& errors) :
|
ErrorGuard& errors) :
|
||||||
m_keyword(keyword),
|
m_keyword(keyword),
|
||||||
m_var_type(UDQ::varType(keyword))
|
m_var_type(UDQ::varType(keyword)),
|
||||||
|
m_location(location)
|
||||||
{
|
{
|
||||||
std::vector<std::string> string_tokens;
|
std::vector<std::string> string_tokens;
|
||||||
for (const std::string& deck_item : deck_data) {
|
for (const std::string& deck_item : deck_data) {
|
||||||
@ -198,7 +199,7 @@ UDQDefine::UDQDefine(const UDQParams& udq_params,
|
|||||||
std::vector<UDQToken> tokens = make_tokens(string_tokens);
|
std::vector<UDQToken> tokens = make_tokens(string_tokens);
|
||||||
|
|
||||||
|
|
||||||
this->ast = std::make_shared<UDQASTNode>( UDQParser::parse(udq_params, this->m_var_type, this->m_keyword, location, tokens, parseContext, errors) );
|
this->ast = std::make_shared<UDQASTNode>( UDQParser::parse(udq_params, this->m_var_type, this->m_keyword, this->m_location, tokens, parseContext, errors) );
|
||||||
this->string_data = "";
|
this->string_data = "";
|
||||||
for (std::size_t index = 0; index < deck_data.size(); index++) {
|
for (std::size_t index = 0; index < deck_data.size(); index++) {
|
||||||
this->string_data += deck_data[index];
|
this->string_data += deck_data[index];
|
||||||
@ -209,16 +210,19 @@ UDQDefine::UDQDefine(const UDQParams& udq_params,
|
|||||||
|
|
||||||
|
|
||||||
UDQDefine::UDQDefine(const std::string& keyword,
|
UDQDefine::UDQDefine(const std::string& keyword,
|
||||||
|
const KeywordLocation& location,
|
||||||
std::shared_ptr<UDQASTNode> astPtr,
|
std::shared_ptr<UDQASTNode> astPtr,
|
||||||
UDQVarType type,
|
UDQVarType type,
|
||||||
const std::string& stringData)
|
const std::string& stringData)
|
||||||
: m_keyword(keyword)
|
: m_keyword(keyword)
|
||||||
, ast(astPtr)
|
, ast(astPtr)
|
||||||
, m_var_type(type)
|
, m_var_type(type)
|
||||||
|
, m_location(location)
|
||||||
, string_data(stringData)
|
, string_data(stringData)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
UDQDefine UDQDefine::serializeObject()
|
UDQDefine UDQDefine::serializeObject()
|
||||||
{
|
{
|
||||||
UDQDefine result;
|
UDQDefine result;
|
||||||
@ -226,6 +230,7 @@ UDQDefine UDQDefine::serializeObject()
|
|||||||
result.ast = std::make_shared<UDQASTNode>(UDQASTNode::serializeObject());
|
result.ast = std::make_shared<UDQASTNode>(UDQASTNode::serializeObject());
|
||||||
result.m_var_type = UDQVarType::SEGMENT_VAR;
|
result.m_var_type = UDQVarType::SEGMENT_VAR;
|
||||||
result.string_data = "test2";
|
result.string_data = "test2";
|
||||||
|
result.m_location = KeywordLocation{"KEYWOR", "file", 100};
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -307,6 +312,9 @@ UDQSet UDQDefine::eval(const UDQContext& context) const {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const KeywordLocation& UDQDefine::location() const {
|
||||||
|
return this->m_location;
|
||||||
|
}
|
||||||
|
|
||||||
UDQVarType UDQDefine::var_type() const {
|
UDQVarType UDQDefine::var_type() const {
|
||||||
return this->m_var_type;
|
return this->m_var_type;
|
||||||
@ -332,6 +340,7 @@ bool UDQDefine::operator==(const UDQDefine& data) const {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
return this->keyword() == data.keyword() &&
|
return this->keyword() == data.keyword() &&
|
||||||
|
this->m_location == data.location() &&
|
||||||
this->var_type() == data.var_type() &&
|
this->var_type() == data.var_type() &&
|
||||||
this->input_string() == data.input_string();
|
this->input_string() == data.input_string();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user