diff --git a/src/Binder/BoundExpressions/BoundExpression.hpp b/src/Binder/BoundExpressions/BoundExpression.hpp index e1b75b3..5a16baa 100644 --- a/src/Binder/BoundExpressions/BoundExpression.hpp +++ b/src/Binder/BoundExpressions/BoundExpression.hpp @@ -76,9 +76,9 @@ namespace Porygon::Binder { }; class BoundLiteralIntegerExpression : public BoundExpression { - const long _value; + const int64_t _value; public: - BoundLiteralIntegerExpression(long value, unsigned int start, unsigned int length) + BoundLiteralIntegerExpression(int64_t value, unsigned int start, unsigned int length) : BoundExpression(start, length, make_shared(true, false)), _value(value) { } @@ -89,7 +89,7 @@ namespace Porygon::Binder { } [[nodiscard]] - inline long GetValue() const { + inline int64_t GetValue() const { return _value; } }; diff --git a/src/Evaluator/EvalValues/EvalValue.cpp b/src/Evaluator/EvalValues/EvalValue.cpp index d36c386..a4a1c7e 100644 --- a/src/Evaluator/EvalValues/EvalValue.cpp +++ b/src/Evaluator/EvalValues/EvalValue.cpp @@ -37,7 +37,7 @@ namespace Porygon::Evaluation { } - EvalValue *CreateIntegerEvalValue(long l) { + EvalValue *CreateIntegerEvalValue(int64_t l) { return new IntegerEvalValue(l); } diff --git a/src/Evaluator/EvalValues/EvalValue.hpp b/src/Evaluator/EvalValues/EvalValue.hpp index 68197ff..d0f3488 100644 --- a/src/Evaluator/EvalValues/EvalValue.hpp +++ b/src/Evaluator/EvalValues/EvalValue.hpp @@ -37,7 +37,7 @@ namespace Porygon::Evaluation { virtual EvalValue* Clone() const = 0; [[nodiscard]] - virtual long EvaluateInteger() const { + virtual int64_t EvaluateInteger() const { throw EvaluationException("Can't evaluate this EvalValue as integer."); } diff --git a/src/Evaluator/EvalValues/EvalValueHelper.hpp b/src/Evaluator/EvalValues/EvalValueHelper.hpp index 17764b7..93136bf 100644 --- a/src/Evaluator/EvalValues/EvalValueHelper.hpp +++ b/src/Evaluator/EvalValues/EvalValueHelper.hpp @@ -9,10 +9,10 @@ namespace Porygon::Evaluation{ class EvalValueHelper{ public: inline static EvalValue* Create(unsigned char i){ - return new IntegerEvalValue((long)i); + return new IntegerEvalValue((int64_t )i); } inline static EvalValue* Create(signed char i){ - return new IntegerEvalValue((long)i); + return new IntegerEvalValue((int64_t )i); } inline static EvalValue* Create(short int i){ return new IntegerEvalValue(i); @@ -26,10 +26,10 @@ namespace Porygon::Evaluation{ inline static EvalValue* Create(unsigned int i){ return new IntegerEvalValue(i); } - inline static EvalValue* Create(signed long l){ + inline static EvalValue* Create(int64_t l){ return new IntegerEvalValue(l); } - inline static EvalValue* Create(unsigned long l){ + inline static EvalValue* Create(uint64_t l){ return new IntegerEvalValue(l); } diff --git a/src/Evaluator/EvalValues/NumericEvalValue.hpp b/src/Evaluator/EvalValues/NumericEvalValue.hpp index 593c5d4..da0ed48 100644 --- a/src/Evaluator/EvalValues/NumericEvalValue.hpp +++ b/src/Evaluator/EvalValues/NumericEvalValue.hpp @@ -10,7 +10,7 @@ namespace Porygon::Evaluation { class NumericEvalValue : public EvalValue { [[nodiscard]] - virtual long GetIntegerValue() const = 0; + virtual int64_t GetIntegerValue() const = 0; [[nodiscard]] virtual double GetFloatValue() const = 0; @@ -44,10 +44,10 @@ namespace Porygon::Evaluation { }; class IntegerEvalValue : public NumericEvalValue { - const long _value; + const int64_t _value; [[nodiscard]] - long GetIntegerValue() const final { return _value; } + int64_t GetIntegerValue() const final { return _value; } [[nodiscard]] double GetFloatValue() const final { @@ -55,7 +55,7 @@ namespace Porygon::Evaluation { } public: - explicit IntegerEvalValue(long value) : _value(value) { + explicit IntegerEvalValue(int64_t value) : _value(value) { } [[nodiscard]] @@ -64,7 +64,7 @@ namespace Porygon::Evaluation { } [[nodiscard]] - inline long EvaluateInteger() const final { + inline int64_t EvaluateInteger() const final { return _value; } @@ -85,7 +85,7 @@ namespace Porygon::Evaluation { [[nodiscard]] inline std::size_t GetHashCode() const final { - return std::hash{}(_value); + return std::hash{}(_value); } [[nodiscard]] @@ -104,8 +104,8 @@ namespace Porygon::Evaluation { const double _value; [[nodiscard]] - inline long GetIntegerValue() const final { - throw EvaluationException("Attempting to retrieve float from int eval value."); + inline int64_t GetIntegerValue() const final { + return _value; } [[nodiscard]] @@ -128,8 +128,8 @@ namespace Porygon::Evaluation { } [[nodiscard]] - inline long EvaluateInteger() const final { - return static_cast(_value); + inline int64_t EvaluateInteger() const final { + return static_cast(_value); } [[nodiscard]] @@ -168,13 +168,13 @@ namespace Porygon::Evaluation { auto rightVal = right->EvaluateInteger(); switch (operation) { case Binder::BoundBinaryOperation::Addition: - return new IntegerEvalValue((long) _value + rightVal); + return new IntegerEvalValue((int64_t ) _value + rightVal); case Binder::BoundBinaryOperation::Subtraction: - return new IntegerEvalValue((long) _value - rightVal); + return new IntegerEvalValue((int64_t ) _value - rightVal); case Binder::BoundBinaryOperation::Multiplication: - return new IntegerEvalValue((long) _value * rightVal); + return new IntegerEvalValue((int64_t ) _value * rightVal); case Binder::BoundBinaryOperation::Division: - return new IntegerEvalValue((long) _value / rightVal); + return new IntegerEvalValue((int64_t ) _value / rightVal); case Binder::BoundBinaryOperation::LessThan: return new BooleanEvalValue(_value < rightVal); case Binder::BoundBinaryOperation::LessThanEquals: diff --git a/src/Evaluator/Evaluator.cpp b/src/Evaluator/Evaluator.cpp index a908dc4..cedc7b5 100644 --- a/src/Evaluator/Evaluator.cpp +++ b/src/Evaluator/Evaluator.cpp @@ -140,9 +140,9 @@ namespace Porygon::Evaluation { } void Evaluator::EvaluateNumericalForStatement(const BoundNumericalForStatement *statement) { - long start = this->EvaluateExpression(statement -> GetStart()) -> EvaluateInteger(); - long end = this->EvaluateExpression(statement -> GetEnd()) -> EvaluateInteger(); - long step = 1; + int64_t start = this->EvaluateExpression(statement -> GetStart()) -> EvaluateInteger(); + int64_t end = this->EvaluateExpression(statement -> GetEnd()) -> EvaluateInteger(); + int64_t step = 1; auto stepExp = statement -> GetStep(); if (stepExp != nullptr){ step = this -> EvaluateExpression(stepExp) -> EvaluateInteger(); @@ -152,7 +152,7 @@ namespace Porygon::Evaluation { auto block = (BoundBlockStatement*)statement -> GetBlock(); auto statements = *block -> GetStatements(); if (step >= 0){ - for (long i = start; i <= end; i += step){ + for (int64_t i = start; i <= end; i += step){ this -> _evaluationScope -> SetVariable(identifier, new IntegerEvalValue(i)); for (auto s: statements) { this->EvaluateStatement(s); @@ -163,7 +163,7 @@ namespace Porygon::Evaluation { break; } } else{ - for (long i = start; i >= end; i += step){ + for (int64_t i = start; i >= end; i += step){ this -> _evaluationScope -> SetVariable(identifier, new IntegerEvalValue(i)); for (auto s: statements) { this->EvaluateStatement(s); diff --git a/src/Evaluator/Iterator/NumericalKeyIterator.hpp b/src/Evaluator/Iterator/NumericalKeyIterator.hpp index 9db05d1..b615d94 100644 --- a/src/Evaluator/Iterator/NumericalKeyIterator.hpp +++ b/src/Evaluator/Iterator/NumericalKeyIterator.hpp @@ -11,7 +11,7 @@ namespace Porygon::Evaluation{ class NumericalKeyIterator : public Iterator{ const shared_ptr> _vec; const size_t _size; - long _position = 0; + size_t _position = 0; public: explicit NumericalKeyIterator(const NumericalTableEvalValue* table) : _vec(table->GetTable()), _size(_vec->size() + 1){} diff --git a/src/Parser/Lexer.cpp b/src/Parser/Lexer.cpp index 23b3b2e..f98f45a 100644 --- a/src/Parser/Lexer.cpp +++ b/src/Parser/Lexer.cpp @@ -154,7 +154,7 @@ namespace Porygon::Parser { } Token *Lexer::LexNumber(char16_t c) { - long int_value = CharToInt(c); + int64_t int_value = CharToInt(c); double float_value = 0; short decimal_index = 0; bool has_point = false; diff --git a/src/Parser/ParsedExpressions/ParsedExpression.hpp b/src/Parser/ParsedExpressions/ParsedExpression.hpp index a4c1486..a5801b1 100644 --- a/src/Parser/ParsedExpressions/ParsedExpression.hpp +++ b/src/Parser/ParsedExpressions/ParsedExpression.hpp @@ -66,7 +66,7 @@ namespace Porygon::Parser { }; class LiteralIntegerExpression : public ParsedExpression { - const long _value; + const int64_t _value; public: inline const ParsedExpressionKind GetKind() const final { return ParsedExpressionKind::LiteralInteger; @@ -77,7 +77,7 @@ namespace Porygon::Parser { _value(token->GetValue()) { } - inline const long GetValue() const { + inline const int64_t GetValue() const { return _value; } }; diff --git a/src/Parser/Token.hpp b/src/Parser/Token.hpp index 60b5e01..8441a44 100644 --- a/src/Parser/Token.hpp +++ b/src/Parser/Token.hpp @@ -50,10 +50,10 @@ namespace Porygon::Parser { }; class IntegerToken : public Token { - const long _value; + const int64_t _value; public: - explicit IntegerToken(long value, unsigned int position, unsigned int length) + explicit IntegerToken(int64_t value, unsigned int position, unsigned int length) : Token(position, length), _value(value) { } @@ -62,7 +62,7 @@ namespace Porygon::Parser { return TokenKind::Integer; } - [[nodiscard]] inline long GetValue() const { + [[nodiscard]] inline int64_t GetValue() const { return _value; } }; diff --git a/src/Utilities/Random.hpp b/src/Utilities/Random.hpp index 549b3b8..8734b6e 100644 --- a/src/Utilities/Random.hpp +++ b/src/Utilities/Random.hpp @@ -10,7 +10,7 @@ namespace Porygon::Utilities { _rng.seed(new_seed); } - static inline long Get() { + static inline int64_t Get() { return _rng.operator()(); } }; diff --git a/src/Utilities/StringUtils.hpp b/src/Utilities/StringUtils.hpp index aa58b74..ac13c27 100644 --- a/src/Utilities/StringUtils.hpp +++ b/src/Utilities/StringUtils.hpp @@ -13,7 +13,7 @@ namespace Porygon::Utilities{ private: static std::wstring_convert, char16_t> to_16; public: - inline static std::u16string IntToString(long const &i) { + inline static std::u16string IntToString(int64_t const &i) { return to_16.from_bytes(std::to_string(i)); } inline static std::u16string FloatToString(double const &i) {