Skip to content
Snippets Groups Projects
Commit 953e1548 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Rename declarations in view of variable grammar declaration changes

`let_declaration` -> `fct_declaration`
`declaration`     -> `var_declaration`
parent 5e8aea13
Branches
Tags
1 merge request!37Feature/language
Showing
with 86 additions and 56 deletions
...@@ -31,7 +31,8 @@ class CRSMatrix ...@@ -31,7 +31,8 @@ class CRSMatrix
} }
template <typename DataType2> template <typename DataType2>
Vector<MutableDataType> operator*(const Vector<DataType2>& x) const Vector<MutableDataType>
operator*(const Vector<DataType2>& x) const
{ {
static_assert(std::is_same<std::remove_const_t<DataType>, std::remove_const_t<DataType2>>(), static_assert(std::is_same<std::remove_const_t<DataType>, std::remove_const_t<DataType2>>(),
"Cannot multiply matrix and vector of different type"); "Cannot multiply matrix and vector of different type");
......
...@@ -28,14 +28,16 @@ class SparseMatrixDescriptor ...@@ -28,14 +28,16 @@ class SparseMatrixDescriptor
return m_id_value_map.size(); return m_id_value_map.size();
} }
const DataType& operator[](const IndexType& j) const const DataType&
operator[](const IndexType& j) const
{ {
auto i_value = m_id_value_map.find(j); auto i_value = m_id_value_map.find(j);
Assert(i_value != m_id_value_map.end()); Assert(i_value != m_id_value_map.end());
return i_value->second; return i_value->second;
} }
DataType& operator[](const IndexType& j) DataType&
operator[](const IndexType& j)
{ {
auto i_value = m_id_value_map.find(j); auto i_value = m_id_value_map.find(j);
if (i_value != m_id_value_map.end()) { if (i_value != m_id_value_map.end()) {
......
...@@ -20,7 +20,8 @@ class TinyMatrix ...@@ -20,7 +20,8 @@ class TinyMatrix
static_assert((N > 0), "TinyMatrix size must be strictly positive"); static_assert((N > 0), "TinyMatrix size must be strictly positive");
PUGS_FORCEINLINE PUGS_FORCEINLINE
constexpr size_t _index(const size_t& i, const size_t& j) const noexcept // LCOV_EXCL_LINE (due to forced inline) constexpr size_t
_index(const size_t& i, const size_t& j) const noexcept // LCOV_EXCL_LINE (due to forced inline)
{ {
return i * N + j; return i * N + j;
} }
...@@ -48,14 +49,16 @@ class TinyMatrix ...@@ -48,14 +49,16 @@ class TinyMatrix
} }
PUGS_INLINE PUGS_INLINE
constexpr friend TinyMatrix operator*(const T& t, const TinyMatrix& A) constexpr friend TinyMatrix
operator*(const T& t, const TinyMatrix& A)
{ {
TinyMatrix B = A; TinyMatrix B = A;
return B *= t; return B *= t;
} }
PUGS_INLINE PUGS_INLINE
constexpr friend TinyMatrix operator*(const T& t, TinyMatrix&& A) constexpr friend TinyMatrix
operator*(const T& t, TinyMatrix&& A)
{ {
return std::move(A *= t); return std::move(A *= t);
} }
...@@ -71,7 +74,8 @@ class TinyMatrix ...@@ -71,7 +74,8 @@ class TinyMatrix
} }
PUGS_INLINE PUGS_INLINE
constexpr TinyMatrix operator*(const TinyMatrix& B) const constexpr TinyMatrix
operator*(const TinyMatrix& B) const
{ {
const TinyMatrix& A = *this; const TinyMatrix& A = *this;
TinyMatrix AB; TinyMatrix AB;
...@@ -88,7 +92,8 @@ class TinyMatrix ...@@ -88,7 +92,8 @@ class TinyMatrix
} }
PUGS_INLINE PUGS_INLINE
constexpr TinyVector<N, T> operator*(const TinyVector<N, T>& x) const constexpr TinyVector<N, T>
operator*(const TinyVector<N, T>& x) const
{ {
const TinyMatrix& A = *this; const TinyMatrix& A = *this;
TinyVector<N, T> Ax; TinyVector<N, T> Ax;
......
...@@ -88,14 +88,16 @@ class TinyVector ...@@ -88,14 +88,16 @@ class TinyVector
} }
PUGS_INLINE PUGS_INLINE
constexpr friend TinyVector operator*(const T& t, const TinyVector& v) constexpr friend TinyVector
operator*(const T& t, const TinyVector& v)
{ {
TinyVector w = v; TinyVector w = v;
return w *= t; return w *= t;
} }
PUGS_INLINE PUGS_INLINE
constexpr friend TinyVector operator*(const T& t, TinyVector&& v) constexpr friend TinyVector
operator*(const T& t, TinyVector&& v)
{ {
v *= t; v *= t;
return std::move(v); return std::move(v);
...@@ -185,14 +187,16 @@ class TinyVector ...@@ -185,14 +187,16 @@ class TinyVector
} }
PUGS_INLINE PUGS_INLINE
constexpr T& operator[](const size_t& i) noexcept(NO_ASSERT) constexpr T&
operator[](const size_t& i) noexcept(NO_ASSERT)
{ {
Assert(i < N); Assert(i < N);
return m_values[i]; return m_values[i];
} }
PUGS_INLINE PUGS_INLINE
constexpr const T& operator[](const size_t& i) const noexcept(NO_ASSERT) constexpr const T&
operator[](const size_t& i) const noexcept(NO_ASSERT)
{ {
Assert(i < N); Assert(i < N);
return m_values[i]; return m_values[i];
......
...@@ -33,7 +33,8 @@ class Vector // LCOV_EXCL_LINE ...@@ -33,7 +33,8 @@ class Vector // LCOV_EXCL_LINE
return x_copy; return x_copy;
} }
friend Vector operator*(const DataType& a, const Vector& x) friend Vector
operator*(const DataType& a, const Vector& x)
{ {
Vector<std::remove_const_t<DataType>> y = copy(x); Vector<std::remove_const_t<DataType>> y = copy(x);
return y *= a; return y *= a;
...@@ -130,7 +131,8 @@ class Vector // LCOV_EXCL_LINE ...@@ -130,7 +131,8 @@ class Vector // LCOV_EXCL_LINE
} }
PUGS_INLINE PUGS_INLINE
DataType& operator[](const index_type& i) const noexcept(NO_ASSERT) DataType&
operator[](const index_type& i) const noexcept(NO_ASSERT)
{ {
return m_values[i]; return m_values[i];
} }
......
...@@ -154,7 +154,7 @@ struct ASTBuilder::simplify_statement_block : parse_tree::apply<ASTBuilder::simp ...@@ -154,7 +154,7 @@ struct ASTBuilder::simplify_statement_block : parse_tree::apply<ASTBuilder::simp
transform(std::unique_ptr<ASTNode>& n, States&&... st) transform(std::unique_ptr<ASTNode>& n, States&&... st)
{ {
if ((n->is_type<language::statement_block>() or n->is_type<language::block>()) and (n->children.size() == 1)) { if ((n->is_type<language::statement_block>() or n->is_type<language::block>()) and (n->children.size() == 1)) {
if (not n->children[0]->is_type<language::declaration>()) { if (not n->children[0]->is_type<language::var_declaration>()) {
n = std::move(n->children.back()); n = std::move(n->children.back());
transform(n, st...); transform(n, st...);
} else { } else {
...@@ -250,8 +250,8 @@ using selector = parse_tree::selector< ...@@ -250,8 +250,8 @@ using selector = parse_tree::selector<
language::cout_kw, language::cout_kw,
language::cerr_kw, language::cerr_kw,
language::clog_kw, language::clog_kw,
language::declaration, language::var_declaration,
language::let_declaration, language::fct_declaration,
language::type_mapping, language::type_mapping,
language::function_definition, language::function_definition,
language::if_statement, language::if_statement,
......
...@@ -109,13 +109,13 @@ ASTNodeDataTypeBuilder::_buildNodeDataTypes(ASTNode& n) const ...@@ -109,13 +109,13 @@ ASTNodeDataTypeBuilder::_buildNodeDataTypes(ASTNode& n) const
n.m_data_type = ASTNodeDataType::string_t; n.m_data_type = ASTNodeDataType::string_t;
} else if (n.is_type<language::cout_kw>() or n.is_type<language::cerr_kw>() or n.is_type<language::clog_kw>()) { } else if (n.is_type<language::cout_kw>() or n.is_type<language::cerr_kw>() or n.is_type<language::clog_kw>()) {
n.m_data_type = ASTNodeDataType::void_t; n.m_data_type = ASTNodeDataType::void_t;
} else if (n.is_type<language::declaration>()) { } else if (n.is_type<language::var_declaration>()) {
auto& type_node = *(n.children[0]); auto& type_node = *(n.children[0]);
auto& name_node = *(n.children[1]); auto& name_node = *(n.children[1]);
type_node.m_data_type = _buildDeclarationNodeDataTypes(type_node, name_node); type_node.m_data_type = _buildDeclarationNodeDataTypes(type_node, name_node);
n.m_data_type = type_node.m_data_type; n.m_data_type = type_node.m_data_type;
} else if (n.is_type<language::let_declaration>()) { } else if (n.is_type<language::fct_declaration>()) {
n.children[0]->m_data_type = ASTNodeDataType::function_t; n.children[0]->m_data_type = ASTNodeDataType::function_t;
const std::string& symbol = n.children[0]->string(); const std::string& symbol = n.children[0]->string();
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
void void
ASTNodeDeclarationToAffectationConverter::_convertNodeDeclaration(ASTNode& n) ASTNodeDeclarationToAffectationConverter::_convertNodeDeclaration(ASTNode& n)
{ {
if (n.is_type<language::declaration>()) { if (n.is_type<language::var_declaration>()) {
if (n.children.size() == 3) { if (n.children.size() == 3) {
n.children[0] = std::move(n.children[1]); n.children[0] = std::move(n.children[1]);
n.children[1] = std::move(n.children[2]); n.children[1] = std::move(n.children[2]);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
void void
ASTSymbolInitializationChecker::_checkSymbolInitialization(ASTNode& node) ASTSymbolInitializationChecker::_checkSymbolInitialization(ASTNode& node)
{ {
if (node.is_type<language::declaration>()) { if (node.is_type<language::var_declaration>()) {
auto check_if_initialized = [&](ASTNode& name_node) { auto check_if_initialized = [&](ASTNode& name_node) {
const std::string& symbol = name_node.string(); const std::string& symbol = name_node.string();
auto [i_symbol, found] = node.m_symbol_table->find(symbol, name_node.begin()); auto [i_symbol, found] = node.m_symbol_table->find(symbol, name_node.begin());
...@@ -26,7 +26,7 @@ ASTSymbolInitializationChecker::_checkSymbolInitialization(ASTNode& node) ...@@ -26,7 +26,7 @@ ASTSymbolInitializationChecker::_checkSymbolInitialization(ASTNode& node)
check_if_initialized(*child_node); check_if_initialized(*child_node);
} }
} }
} else if (node.is_type<language::let_declaration>()) { } else if (node.is_type<language::fct_declaration>()) {
const std::string& symbol = node.children[0]->string(); const std::string& symbol = node.children[0]->string();
auto [i_symbol, found] = node.m_symbol_table->find(symbol, node.children[0]->begin()); auto [i_symbol, found] = node.m_symbol_table->find(symbol, node.children[0]->begin());
Assert(found, "unexpected error, should have been detected through declaration checking"); Assert(found, "unexpected error, should have been detected through declaration checking");
...@@ -83,7 +83,7 @@ ASTSymbolInitializationChecker::_checkSymbolInitialization(ASTNode& node) ...@@ -83,7 +83,7 @@ ASTSymbolInitializationChecker::_checkSymbolInitialization(ASTNode& node)
} }
} }
if (not(node.is_type<language::declaration>() or node.is_type<language::let_declaration>() or if (not(node.is_type<language::var_declaration>() or node.is_type<language::fct_declaration>() or
node.is_type<language::eq_op>())) { node.is_type<language::eq_op>())) {
for (auto& child : node.children) { for (auto& child : node.children) {
this->_checkSymbolInitialization(*child); this->_checkSymbolInitialization(*child);
......
...@@ -15,7 +15,7 @@ ASTSymbolTableBuilder::buildSymbolTable(ASTNode& n, std::shared_ptr<SymbolTable> ...@@ -15,7 +15,7 @@ ASTSymbolTableBuilder::buildSymbolTable(ASTNode& n, std::shared_ptr<SymbolTable>
this->buildSymbolTable(*child, block_symbol_table); this->buildSymbolTable(*child, block_symbol_table);
} }
} }
} else if (n.is_type<language::let_declaration>()) { } else if (n.is_type<language::fct_declaration>()) {
std::shared_ptr local_symbol_table = std::shared_ptr local_symbol_table =
std::make_shared<SymbolTable>(symbol_table, std::make_shared<SymbolTable::Context>()); std::make_shared<SymbolTable>(symbol_table, std::make_shared<SymbolTable::Context>());
...@@ -39,7 +39,7 @@ ASTSymbolTableBuilder::buildSymbolTable(ASTNode& n, std::shared_ptr<SymbolTable> ...@@ -39,7 +39,7 @@ ASTSymbolTableBuilder::buildSymbolTable(ASTNode& n, std::shared_ptr<SymbolTable>
} else { } else {
n.m_symbol_table = symbol_table; n.m_symbol_table = symbol_table;
if (n.has_content()) { if (n.has_content()) {
if (n.is_type<language::declaration>()) { if (n.is_type<language::var_declaration>()) {
auto register_symbol = [&](const ASTNode& argument_node) { auto register_symbol = [&](const ASTNode& argument_node) {
auto [i_symbol, success] = symbol_table->add(argument_node.string(), argument_node.begin()); auto [i_symbol, success] = symbol_table->add(argument_node.string(), argument_node.begin());
if (not success) { if (not success) {
......
...@@ -21,7 +21,8 @@ class CFunctionEmbedderTable ...@@ -21,7 +21,8 @@ class CFunctionEmbedderTable
} }
PUGS_INLINE PUGS_INLINE
const std::shared_ptr<ICFunctionEmbedder>& operator[](size_t function_id) const const std::shared_ptr<ICFunctionEmbedder>&
operator[](size_t function_id) const
{ {
Assert(function_id < m_c_function_embedder_list.size()); Assert(function_id < m_c_function_embedder_list.size());
return m_c_function_embedder_list[function_id]; return m_c_function_embedder_list[function_id];
......
...@@ -57,14 +57,16 @@ class FunctionTable ...@@ -57,14 +57,16 @@ class FunctionTable
} }
PUGS_INLINE PUGS_INLINE
FunctionDescriptor& operator[](size_t function_id) FunctionDescriptor&
operator[](size_t function_id)
{ {
Assert(function_id < m_function_descriptor_list.size()); Assert(function_id < m_function_descriptor_list.size());
return m_function_descriptor_list[function_id]; return m_function_descriptor_list[function_id];
} }
PUGS_INLINE PUGS_INLINE
const FunctionDescriptor& operator[](size_t function_id) const const FunctionDescriptor&
operator[](size_t function_id) const
{ {
Assert(function_id < m_function_descriptor_list.size()); Assert(function_id < m_function_descriptor_list.size());
return m_function_descriptor_list[function_id]; return m_function_descriptor_list[function_id];
......
...@@ -71,13 +71,12 @@ struct vector_type : seq< R_set, ignored, one< '^' >, ignored, integer >{}; ...@@ -71,13 +71,12 @@ struct vector_type : seq< R_set, ignored, one< '^' >, ignored, integer >{};
struct basic_type : sor< scalar_type, string_type >{}; struct basic_type : sor< scalar_type, string_type >{};
struct type_name;
struct type_specifier : sor< vector_type, basic_type >{}; struct type_specifier : sor< vector_type, basic_type >{};
struct TYPE_SPECIFIER : seq< type_specifier, ignored >{}; struct TYPE_SPECIFIER : seq< type_specifier, ignored >{};
struct type_expression : list_must< TYPE_SPECIFIER, seq< one< '*' >, ignored > >{}; struct type_expression : list< TYPE_SPECIFIER, seq< one< '*' >, ignored > >{};
struct TYPE_EXPRESSION : seq< type_expression, ignored >{};
struct and_kw : TAO_PEGTL_KEYWORD("and") {}; struct and_kw : TAO_PEGTL_KEYWORD("and") {};
struct or_kw : TAO_PEGTL_KEYWORD("or") {}; struct or_kw : TAO_PEGTL_KEYWORD("or") {};
...@@ -118,13 +117,15 @@ struct cout_kw : TAO_PEGTL_KEYWORD("cout") {}; ...@@ -118,13 +117,15 @@ struct cout_kw : TAO_PEGTL_KEYWORD("cout") {};
struct cerr_kw : TAO_PEGTL_KEYWORD("cerr") {}; struct cerr_kw : TAO_PEGTL_KEYWORD("cerr") {};
struct clog_kw : TAO_PEGTL_KEYWORD("clog") {}; struct clog_kw : TAO_PEGTL_KEYWORD("clog") {};
struct keywork : sor < basic_type, import_kw, true_kw, false_kw, let_kw, do_kw, while_kw, for_kw, if_kw, else_kw, and_kw, or_kw, xor_kw, break_kw, continue_kw, cout_kw, cerr_kw, clog_kw > {}; struct keywork : sor < basic_type, import_kw, true_kw, false_kw, let_kw, do_kw, while_kw, for_kw, if_kw, else_kw, and_kw, or_kw, xor_kw, not_kw, break_kw, continue_kw, cout_kw, cerr_kw, clog_kw > {};
struct identifier_minus_keyword : minus< identifier, keywork > {}; struct identifier_minus_keyword : minus< identifier, keywork > {};
struct module_name : identifier_minus_keyword {}; struct module_name : identifier_minus_keyword {};
struct MODULE_NAME : seq< module_name, ignored > {}; struct MODULE_NAME : seq< module_name, ignored > {};
struct type_name : identifier_minus_keyword {};
struct name : identifier_minus_keyword {}; struct name : identifier_minus_keyword {};
struct NAME : seq< name, ignored > {}; struct NAME : seq< name, ignored > {};
...@@ -235,15 +236,15 @@ struct affectation : seq< sor< lvalue_expression, lvalue_list >, if_must< affect ...@@ -235,15 +236,15 @@ struct affectation : seq< sor< lvalue_expression, lvalue_list >, if_must< affect
struct name_list; struct name_list;
struct declaration : if_must< TYPE_EXPRESSION, sor< NAME, name_list>, opt< if_must< seq< one< '=' >, ignored >, sor< expression_list, expression > > > >{}; struct var_declaration : seq< type_expression, sor< NAME, name_list>, opt< if_must< seq< one< '=' >, ignored >, sor< expression_list, expression > > > >{};
struct type_mapping : seq< TYPE_EXPRESSION, RIGHT_ARROW, TYPE_EXPRESSION >{}; struct type_mapping : seq< type_expression, RIGHT_ARROW, type_expression >{};
struct name_list : seq< open_parent, list_must< NAME, COMMA >, close_parent >{}; struct name_list : seq< open_parent, list_must< NAME, COMMA >, close_parent >{};
struct function_definition : seq< sor< name_list, NAME >, RIGHT_ARROW, sor< expression_list, expression > >{}; struct function_definition : seq< sor< name_list, NAME >, RIGHT_ARROW, sor< expression_list, expression > >{};
struct let_declaration : if_must< LET, NAME, COLUMN, type_mapping, COMMA, function_definition >{}; struct fct_declaration : if_must< LET, NAME, COLUMN, type_mapping, COMMA, function_definition >{};
struct open_brace : seq< one< '{' >, ignored >{}; struct open_brace : seq< one< '{' >, ignored >{};
struct close_brace : seq< one< '}' >, ignored >{}; struct close_brace : seq< one< '}' >, ignored >{};
...@@ -265,7 +266,7 @@ struct do_while_statement : if_must< DO, statement_block, WHILE, parented_expres ...@@ -265,7 +266,7 @@ struct do_while_statement : if_must< DO, statement_block, WHILE, parented_expres
struct while_statement : if_must< WHILE, parented_expression, statement_block >{}; struct while_statement : if_must< WHILE, parented_expression, statement_block >{};
struct for_init : opt< sor< declaration, affectation, expression > >{}; struct for_init : opt< sor< var_declaration, affectation, expression > >{};
struct for_test : opt< sor< affectation, expression > >{}; struct for_test : opt< sor< affectation, expression > >{};
struct for_post : opt< sor< affectation, expression > >{}; struct for_post : opt< sor< affectation, expression > >{};
...@@ -277,18 +278,18 @@ struct ostream_object : seq< sor< cout_kw, cerr_kw, clog_kw >, ignored >{}; ...@@ -277,18 +278,18 @@ struct ostream_object : seq< sor< cout_kw, cerr_kw, clog_kw >, ignored >{};
struct ostream_statement : seq< ostream_object, star< if_must< shift_left_op, expression, ignored > > >{}; struct ostream_statement : seq< ostream_object, star< if_must< shift_left_op, expression, ignored > > >{};
struct instruction struct instruction
: sor<if_must< let_declaration, semicol >, : sor<if_statement,
if_must< declaration, semicol >,
if_must< affectation, semicol >,
if_statement,
if_must<do_while_statement, semicol>, if_must<do_while_statement, semicol>,
while_statement, while_statement,
for_statement, for_statement,
if_must< ostream_statement, semicol >, if_must< ostream_statement, semicol >,
if_must< BREAK, semicol >, if_must< BREAK, semicol >,
if_must< CONTINUE, semicol >, if_must< CONTINUE, semicol >,
if_must< expression, semicol >,
block, block,
if_must< var_declaration, semicol >,
if_must< fct_declaration, semicol >,
if_must< affectation, semicol >,
if_must< expression, semicol >,
semicol> semicol>
{}; {};
......
...@@ -78,8 +78,8 @@ parser(const std::string& filename) ...@@ -78,8 +78,8 @@ parser(const std::string& filename)
// optimizations // optimizations
ASTNodeDeclarationToAffectationConverter{*root_node}; ASTNodeDeclarationToAffectationConverter{*root_node};
ASTNodeTypeCleaner<language::declaration>{*root_node}; ASTNodeTypeCleaner<language::var_declaration>{*root_node};
ASTNodeTypeCleaner<language::let_declaration>{*root_node}; ASTNodeTypeCleaner<language::fct_declaration>{*root_node};
ASTNodeEmptyBlockCleaner{*root_node}; ASTNodeEmptyBlockCleaner{*root_node};
......
...@@ -35,12 +35,14 @@ class ExecutionPolicy ...@@ -35,12 +35,14 @@ class ExecutionPolicy
return m_shared_values->size(); return m_shared_values->size();
} }
DataVariant& operator[](size_t i) DataVariant&
operator[](size_t i)
{ {
return (*m_shared_values)[i]; return (*m_shared_values)[i];
} }
const DataVariant& operator[](size_t i) const const DataVariant&
operator[](size_t i) const
{ {
return (*m_shared_values)[i]; return (*m_shared_values)[i];
} }
......
...@@ -29,7 +29,8 @@ class ItemToItemMatrix ...@@ -29,7 +29,8 @@ class ItemToItemMatrix
} }
PUGS_INLINE PUGS_INLINE
TargetItemId operator[](const size_t& j) const TargetItemId
operator[](const size_t& j) const
{ {
return m_row(j); return m_row(j);
} }
...@@ -73,14 +74,16 @@ class ItemToItemMatrix ...@@ -73,14 +74,16 @@ class ItemToItemMatrix
} }
PUGS_INLINE PUGS_INLINE
auto operator[](const SourceItemId& source_id) const auto
operator[](const SourceItemId& source_id) const
{ {
using RowType = decltype(m_connectivity_matrix.rowConst(source_id)); using RowType = decltype(m_connectivity_matrix.rowConst(source_id));
return SubItemList<RowType>(m_connectivity_matrix.rowConst(source_id)); return SubItemList<RowType>(m_connectivity_matrix.rowConst(source_id));
} }
template <typename IndexType> template <typename IndexType>
PUGS_INLINE const auto& operator[](const IndexType& source_id) const PUGS_INLINE const auto&
operator[](const IndexType& source_id) const
{ {
static_assert(std::is_same_v<IndexType, SourceItemId>, "ItemToItemMatrix must be indexed using correct ItemId"); static_assert(std::is_same_v<IndexType, SourceItemId>, "ItemToItemMatrix must be indexed using correct ItemId");
using RowType = decltype(m_connectivity_matrix.rowConst(source_id)); using RowType = decltype(m_connectivity_matrix.rowConst(source_id));
......
...@@ -85,14 +85,16 @@ class ItemValue ...@@ -85,14 +85,16 @@ class ItemValue
// Following Kokkos logic, these classes are view and const view does allow // Following Kokkos logic, these classes are view and const view does allow
// changes in data // changes in data
PUGS_FORCEINLINE PUGS_FORCEINLINE
DataType& operator[](const ItemId& i) const noexcept(NO_ASSERT) DataType&
operator[](const ItemId& i) const noexcept(NO_ASSERT)
{ {
Assert(this->isBuilt()); Assert(this->isBuilt());
return m_values[i]; return m_values[i];
} }
template <typename IndexType> template <typename IndexType>
DataType& operator[](const IndexType&) const noexcept(NO_ASSERT) DataType&
operator[](const IndexType&) const noexcept(NO_ASSERT)
{ {
static_assert(std::is_same_v<IndexType, ItemId>, "ItemValue must be indexed by ItemId"); static_assert(std::is_same_v<IndexType, ItemId>, "ItemValue must be indexed by ItemId");
} }
......
...@@ -59,14 +59,16 @@ class SubItemValuePerItem ...@@ -59,14 +59,16 @@ class SubItemValuePerItem
public: public:
PUGS_INLINE PUGS_INLINE
const DataType& operator[](const size_t& i) const noexcept(NO_ASSERT) const DataType&
operator[](const size_t& i) const noexcept(NO_ASSERT)
{ {
Assert(i < m_size); Assert(i < m_size);
return m_sub_values[i]; return m_sub_values[i];
} }
PUGS_FORCEINLINE PUGS_FORCEINLINE
DataType& operator[](const size_t& i) noexcept(NO_ASSERT) DataType&
operator[](const size_t& i) noexcept(NO_ASSERT)
{ {
Assert(i < m_size); Assert(i < m_size);
return m_sub_values[i]; return m_sub_values[i];
...@@ -130,14 +132,16 @@ class SubItemValuePerItem ...@@ -130,14 +132,16 @@ class SubItemValuePerItem
// Following Kokkos logic, these classes are view and const view does allow // Following Kokkos logic, these classes are view and const view does allow
// changes in data // changes in data
PUGS_FORCEINLINE PUGS_FORCEINLINE
DataType& operator[](const size_t& i) const noexcept(NO_ASSERT) DataType&
operator[](const size_t& i) const noexcept(NO_ASSERT)
{ {
Assert(this->isBuilt()); Assert(this->isBuilt());
return m_values[i]; return m_values[i];
} }
template <typename IndexType> template <typename IndexType>
DataType& operator[](const IndexType& i) const noexcept(NO_ASSERT) DataType&
operator[](const IndexType& i) const noexcept(NO_ASSERT)
{ {
static_assert(std::is_same_v<IndexType, size_t>, "Access to SubItemValuePerItem's array must be indexed by " static_assert(std::is_same_v<IndexType, size_t>, "Access to SubItemValuePerItem's array must be indexed by "
"size_t"); "size_t");
......
...@@ -43,7 +43,8 @@ class Array ...@@ -43,7 +43,8 @@ class Array
friend PUGS_INLINE Array<DataType2> encapsulate(const Kokkos::View<DataType2*, RT...>& values); friend PUGS_INLINE Array<DataType2> encapsulate(const Kokkos::View<DataType2*, RT...>& values);
PUGS_INLINE PUGS_INLINE
DataType& operator[](const index_type& i) const noexcept(NO_ASSERT) DataType&
operator[](const index_type& i) const noexcept(NO_ASSERT)
{ {
Assert(i < m_values.extent(0)); Assert(i < m_values.extent(0));
return m_values[i]; return m_values[i];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment