Large cleanup
Some checks reported errors
continuous-integration/drone/push Build was killed

This commit is contained in:
2019-07-25 17:23:54 +02:00
parent e639a2c170
commit e2a0c35992
58 changed files with 700 additions and 539 deletions

View File

@@ -12,7 +12,7 @@
using namespace std;
namespace Porygon::Binder {
enum class BoundExpressionKind {
enum class BoundExpressionKind : u_int8_t {
Bad,
LiteralInteger,
@@ -33,9 +33,9 @@ namespace Porygon::Binder {
class BoundExpression {
const unsigned int _start;
const unsigned int _length;
const shared_ptr<ScriptType> _type;
const shared_ptr<const ScriptType> _type;
public:
BoundExpression(unsigned int start, unsigned int length, shared_ptr<ScriptType> type)
BoundExpression(unsigned int start, unsigned int length, shared_ptr<const ScriptType> type)
: _start(start),
_length(length),
_type(std::move(type)) {
@@ -43,23 +43,23 @@ namespace Porygon::Binder {
virtual ~BoundExpression() = default;
virtual const BoundExpressionKind GetKind() const = 0;
[[nodiscard]]
virtual BoundExpressionKind GetKind() const = 0;
virtual const std::shared_ptr<ScriptType> &GetType() const {
[[nodiscard]]
virtual const std::shared_ptr<const ScriptType> &GetType() const {
return _type;
};
inline const unsigned int GetStartPosition() const {
[[nodiscard]]
inline unsigned int GetStartPosition() const {
return _start;
}
inline const unsigned int GetLength() const {
[[nodiscard]]
inline unsigned int GetLength() const {
return _length;
}
inline const unsigned int GetEndPosition() const {
return _start + _length - 1;
}
};
class BoundBadExpression : public BoundExpression {
@@ -68,7 +68,8 @@ namespace Porygon::Binder {
make_shared<ScriptType>(
TypeClass::Error)) {}
inline const BoundExpressionKind GetKind() const final {
[[nodiscard]]
inline BoundExpressionKind GetKind() const final {
return BoundExpressionKind::Bad;
}
};
@@ -81,11 +82,13 @@ namespace Porygon::Binder {
_value(value) {
}
inline const BoundExpressionKind GetKind() const final {
[[nodiscard]]
inline BoundExpressionKind GetKind() const final {
return BoundExpressionKind::LiteralInteger;
}
inline const long GetValue() const {
[[nodiscard]]
inline long GetValue() const {
return _value;
}
};
@@ -98,11 +101,13 @@ namespace Porygon::Binder {
_value(value) {
}
inline const BoundExpressionKind GetKind() const final {
[[nodiscard]]
inline BoundExpressionKind GetKind() const final {
return BoundExpressionKind::LiteralFloat;
}
inline const double GetValue() const {
[[nodiscard]]
inline double GetValue() const {
return _value;
}
};
@@ -116,12 +121,14 @@ namespace Porygon::Binder {
_value(value) {
}
inline const BoundExpressionKind GetKind() const final {
[[nodiscard]]
inline BoundExpressionKind GetKind() const final {
return BoundExpressionKind::LiteralString;
}
inline const u16string GetValue() const {
return _value;
[[nodiscard]]
inline const u16string* GetValue() const {
return &_value;
}
};
@@ -133,11 +140,13 @@ namespace Porygon::Binder {
_value(value) {
}
inline const BoundExpressionKind GetKind() const final {
[[nodiscard]]
inline BoundExpressionKind GetKind() const final {
return BoundExpressionKind::LiteralBool;
}
inline const bool GetValue() const {
[[nodiscard]]
inline bool GetValue() const {
return _value;
}
};
@@ -145,9 +154,9 @@ namespace Porygon::Binder {
class BoundVariableExpression : public BoundExpression {
const BoundVariableKey *_key;
public:
BoundVariableExpression(BoundVariableKey *key, shared_ptr<ScriptType> type, unsigned int start,
BoundVariableExpression(BoundVariableKey *key, const shared_ptr<const ScriptType>& type, unsigned int start,
unsigned int length)
: BoundExpression(start, length, std::move(type)),
: BoundExpression(start, length, type),
_key(key) {
}
@@ -155,10 +164,12 @@ namespace Porygon::Binder {
delete _key;
}
inline const BoundExpressionKind GetKind() const final {
[[nodiscard]]
inline BoundExpressionKind GetKind() const final {
return BoundExpressionKind::Variable;
}
[[nodiscard]]
inline const BoundVariableKey *GetKey() const {
return _key;
}
@@ -183,19 +194,23 @@ namespace Porygon::Binder {
delete _right;
}
inline const BoundExpressionKind GetKind() const final {
[[nodiscard]]
inline BoundExpressionKind GetKind() const final {
return BoundExpressionKind::Binary;
}
[[nodiscard]]
inline const BoundExpression *GetLeft() const {
return _left;
}
[[nodiscard]]
inline const BoundExpression *GetRight() const {
return _right;
}
inline const BoundBinaryOperation GetOperation() const {
[[nodiscard]]
inline BoundBinaryOperation GetOperation() const {
return _operation;
}
};
@@ -215,15 +230,18 @@ namespace Porygon::Binder {
delete _operand;
}
inline const BoundExpressionKind GetKind() const final {
[[nodiscard]]
inline BoundExpressionKind GetKind() const final {
return BoundExpressionKind::Unary;
}
[[nodiscard]]
inline const BoundExpression *GetOperand() const {
return _operand;
}
inline const BoundUnaryOperation GetOperation() const {
[[nodiscard]]
inline BoundUnaryOperation GetOperation() const {
return _operation;
}
};
@@ -233,7 +251,7 @@ namespace Porygon::Binder {
const BoundExpression *_indexExpression;
public:
BoundIndexExpression(BoundExpression *indexableExpression, BoundExpression *indexExpression,
shared_ptr<ScriptType> result,
shared_ptr<const ScriptType> result,
unsigned int start, unsigned int length)
: BoundExpression(start, length, std::move(result)), _indexableExpression(indexableExpression),
_indexExpression(indexExpression) {}
@@ -243,14 +261,17 @@ namespace Porygon::Binder {
delete _indexExpression;
}
inline const BoundExpressionKind GetKind() const final {
[[nodiscard]]
inline BoundExpressionKind GetKind() const final {
return BoundExpressionKind::Index;
}
[[nodiscard]]
inline const BoundExpression *GetIndexableExpression() const {
return _indexableExpression;
}
[[nodiscard]]
inline const BoundExpression *GetIndexExpression() const {
return _indexExpression;
}
@@ -260,8 +281,8 @@ namespace Porygon::Binder {
const BoundExpression *_indexableExpression;
const Utilities::HashedString _index;
public:
BoundPeriodIndexExpression(BoundExpression *indexableExpression, Utilities::HashedString index,
shared_ptr<ScriptType> result,
BoundPeriodIndexExpression(BoundExpression *indexableExpression, const Utilities::HashedString& index,
shared_ptr<const ScriptType> result,
unsigned int start, unsigned int length)
: BoundExpression(start, length, std::move(result)), _indexableExpression(indexableExpression),
_index(index) {}
@@ -270,23 +291,26 @@ namespace Porygon::Binder {
delete _indexableExpression;
}
inline const BoundExpressionKind GetKind() const final {
[[nodiscard]]
inline BoundExpressionKind GetKind() const final {
return BoundExpressionKind::PeriodIndex;
}
[[nodiscard]]
inline const BoundExpression *GetIndexableExpression() const {
return _indexableExpression;
}
inline const Utilities::HashedString GetIndex() const {
return _index;
[[nodiscard]]
inline const Utilities::HashedString* GetIndex() const {
return &_index;
}
};
class BoundNumericalTableExpression : public BoundExpression {
const vector<const BoundExpression *> _expressions;
public:
BoundNumericalTableExpression(vector<const BoundExpression *> expressions, shared_ptr<ScriptType> type,
BoundNumericalTableExpression(vector<const BoundExpression *> expressions, shared_ptr<const ScriptType> type,
unsigned int start, unsigned int length)
: BoundExpression(start, length, std::move(type)),
_expressions(std::move(expressions)) {}
@@ -297,10 +321,12 @@ namespace Porygon::Binder {
}
}
inline const BoundExpressionKind GetKind() const final {
[[nodiscard]]
inline BoundExpressionKind GetKind() const final {
return BoundExpressionKind::NumericalTable;
}
[[nodiscard]]
inline const vector<const BoundExpression *> *GetExpressions() const {
return &_expressions;
}