Skip to content

Commit

Permalink
Fix some includes for the C++ frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
perost committed Jun 14, 2024
1 parent 0051418 commit d428cc4
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 29 deletions.
3 changes: 3 additions & 0 deletions OMCompiler/Compiler/FrontEndCpp/Inst.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include <string>
#include <vector>
#include <iostream>
#include <chrono>
#include <utility>

#include "MetaModelica.h"
#include "Absyn/Element.h"
Expand Down
28 changes: 14 additions & 14 deletions OMCompiler/Compiler/FrontEndCpp/MetaModelica.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ mmc_uint_t get_header(void *data)
return MMC_HDR_UNMARK(MMC_GETHDR(data));
}

void* get_index(void *data, size_t index)
void* get_index(void *data, std::size_t index)
{
return MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(data), index + 1));
}

size_t get_slots(void *data)
std::size_t get_slots(void *data)
{
auto hdr = MMC_HDR_UNMARK(MMC_GETHDR(data));
return MMC_HDRSLOTS(hdr);
Expand Down Expand Up @@ -461,7 +461,7 @@ bool List::empty() const noexcept
return MMC_NILTEST(_value);
}

size_t List::size() const noexcept
std::size_t List::size() const noexcept
{
return listLength(_value);
}
Expand All @@ -484,7 +484,7 @@ std::ostream& OpenModelica::MetaModelica::operator<< (std::ostream &os, List lis
return os;
}

IndexedConstIterator::IndexedConstIterator(void *value, size_t index) noexcept
IndexedConstIterator::IndexedConstIterator(void *value, std::size_t index) noexcept
: _value{value}, _index{index}
{

Expand Down Expand Up @@ -563,17 +563,17 @@ bool Array::empty() const noexcept
return size() == 0;
}

size_t Array::size() const noexcept
std::size_t Array::size() const noexcept
{
return get_slots(_value);
}

Value Array::operator[](size_t index) const noexcept
Value Array::operator[](std::size_t index) const noexcept
{
return Value{get_index(_value, index)};
}

Value Array::at(size_t index) const
Value Array::at(std::size_t index) const
{
if (index >= size()) {
throw std::out_of_range("Array::at: " + std::to_string(index) + " >= " + std::to_string(size()));
Expand Down Expand Up @@ -633,17 +633,17 @@ IndexedConstIterator Tuple::cend() const noexcept
return end();
}

size_t Tuple::size() const noexcept
std::size_t Tuple::size() const noexcept
{
return get_slots(_value);
}

Value Tuple::operator[](size_t index) const noexcept
Value Tuple::operator[](std::size_t index) const noexcept
{
return Value{get_index(_value, index)};
}

Value Tuple::at(size_t index) const
Value Tuple::at(std::size_t index) const
{
if (index >= size()) {
throw std::out_of_range("Tuple::at: " + std::to_string(index) + " >= " + std::to_string(size()));
Expand Down Expand Up @@ -736,7 +736,7 @@ IndexedConstIterator Record::cend() const noexcept
return end();
}

size_t Record::size() const noexcept
std::size_t Record::size() const noexcept
{
return get_slots(_value) - 1;
}
Expand All @@ -746,12 +746,12 @@ Value Record::operator[](std::string_view name) const noexcept
return *find(name);
}

Value Record::operator[](size_t index) const noexcept
Value Record::operator[](std::size_t index) const noexcept
{
return Value{get_index(_value, index + 1)};
}

Value Record::at(size_t index) const
Value Record::at(std::size_t index) const
{
if (index >= size()) {
throw std::out_of_range("Record::at: " + std::to_string(index) + " >= " + std::to_string(size()));
Expand All @@ -764,7 +764,7 @@ IndexedConstIterator Record::find(std::string_view name) const noexcept
{
auto desc = static_cast<record_description*>(get_index(_value, 0));

for (size_t i = 0u; i < size(); ++i) {
for (std::size_t i = 0u; i < size(); ++i) {
if (desc->fieldNames[i] == name) {
return {_value, i + 1};
}
Expand Down
27 changes: 14 additions & 13 deletions OMCompiler/Compiler/FrontEndCpp/MetaModelica.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
#define METAMODELICA_H

#include <cstdint>
#include <cstddef>
#include <string>
#include <string_view>
#include <iosfwd>
#include <optional>
#include <functional>
#include <memory>
#include <initializer_list>
#include <iterator>
#include <vector>

struct record_description;

Expand Down Expand Up @@ -252,7 +253,7 @@ namespace OpenModelica
ConstIterator end() const noexcept;
ConstIterator cend() const noexcept;
bool empty() const noexcept;
size_t size() const noexcept;
std::size_t size() const noexcept;

void cons(Value v) noexcept;
void* data() const noexcept;
Expand Down Expand Up @@ -300,7 +301,7 @@ namespace OpenModelica
using pointer = value_type*;
using reference = value_type&;

IndexedConstIterator(void *value, size_t index) noexcept;
IndexedConstIterator(void *value, std::size_t index) noexcept;

value_type operator*() const noexcept;
Value::ArrowProxy operator->() const noexcept;
Expand All @@ -312,7 +313,7 @@ namespace OpenModelica

private:
void *_value;
size_t _index = 0;
std::size_t _index = 0;
};

bool operator== (const IndexedConstIterator &i1, const IndexedConstIterator &i2) noexcept;
Expand All @@ -330,10 +331,10 @@ namespace OpenModelica
IndexedConstIterator end() const noexcept;
IndexedConstIterator cend() const noexcept;
bool empty() const noexcept;
size_t size() const noexcept;
std::size_t size() const noexcept;

Value operator[](size_t index) const noexcept;
Value at(size_t index) const;
Value operator[](std::size_t index) const noexcept;
Value at(std::size_t index) const;
void* data() const noexcept;

template<typename T>
Expand Down Expand Up @@ -380,10 +381,10 @@ namespace OpenModelica
IndexedConstIterator cbegin() const noexcept;
IndexedConstIterator end() const noexcept;
IndexedConstIterator cend() const noexcept;
size_t size() const noexcept;
std::size_t size() const noexcept;

Value operator[](size_t index) const noexcept;
Value at(size_t index) const;
Value operator[](std::size_t index) const noexcept;
Value at(std::size_t index) const;
void* data() const noexcept;

private:
Expand Down Expand Up @@ -414,11 +415,11 @@ namespace OpenModelica
IndexedConstIterator cbegin() const noexcept;
IndexedConstIterator end() const noexcept;
IndexedConstIterator cend() const noexcept;
size_t size() const noexcept;
std::size_t size() const noexcept;

Value operator[](std::string_view name) const noexcept;
Value operator[](size_t index) const noexcept;
Value at(size_t index) const;
Value operator[](std::size_t index) const noexcept;
Value at(std::size_t index) const;
IndexedConstIterator find(std::string_view name) const noexcept;
bool contains(std::string_view name) const noexcept;
void* data() const noexcept;
Expand Down
2 changes: 1 addition & 1 deletion OMCompiler/Compiler/FrontEndCpp/Path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void Path::pop_back() noexcept
_names.pop_back();
}

size_t Path::size() const noexcept
std::size_t Path::size() const noexcept
{
return _names.size();
}
Expand Down
4 changes: 3 additions & 1 deletion OMCompiler/Compiler/FrontEndCpp/Path.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#ifndef PATH_H
#define PATH_H

#include <cstddef>
#include <string>
#include <vector>
#include <utility>
#include <string_view>
#include <iosfwd>

Expand All @@ -22,7 +24,7 @@ namespace OpenModelica
void push_back(std::string name) noexcept;
void pop_back() noexcept;

size_t size() const noexcept;
std::size_t size() const noexcept;
bool isIdent() const noexcept;
bool isQualified() const noexcept;
bool isFullyQualified() const noexcept;
Expand Down
1 change: 1 addition & 0 deletions OMCompiler/Compiler/FrontEndCpp/Prefixes.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <array>
#include <ostream>

#include "Prefixes.h"
Expand Down

0 comments on commit d428cc4

Please sign in to comment.