From 32836c6c58e482fd6c6fedd05d45976525db2d66 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Thu, 4 Jul 2019 19:08:13 +0200 Subject: [PATCH] Make a lot of one-liner functions inline --- .../BoundExpressions/BoundExpression.hpp | 58 +++++++------- .../BoundFunctionCallExpression.hpp | 8 +- .../BoundExpressions/BoundTableExpression.hpp | 4 +- .../BoundFunctionDeclarationStatement.hpp | 8 +- src/Binder/BoundStatements/BoundStatement.hpp | 68 ++++++++-------- src/Binder/BoundVariables/BoundScope.hpp | 4 +- src/Binder/BoundVariables/BoundVariable.hpp | 4 +- .../BoundVariables/BoundVariableKey.hpp | 8 +- .../VariableAssigmentResult.hpp | 4 +- src/Diagnostics/Diagnostic.hpp | 14 ++-- src/Diagnostics/DiagnosticsHolder.cpp | 12 +-- src/Diagnostics/DiagnosticsHolder.hpp | 2 +- src/Evaluator/EvalValues/EvalValue.hpp | 8 +- src/Evaluator/EvalValues/EvalValueHelper.hpp | 28 +++---- src/Evaluator/EvalValues/NilEvalValue.hpp | 8 +- src/Evaluator/EvalValues/NumericEvalValue.hpp | 26 ++++--- .../EvalValues/NumericalTableEvalValue.cpp | 2 +- .../EvalValues/NumericalTableEvalValue.hpp | 16 ++-- .../EvalValues/ScriptFunctionEvalValue.hpp | 14 ++-- src/Evaluator/EvalValues/StringEvalValue.hpp | 8 +- src/Evaluator/EvalValues/TableEvalValue.cpp | 2 +- src/Evaluator/EvalValues/TableEvalValue.hpp | 20 ++--- src/Evaluator/EvaluationException.hpp | 2 +- .../Iterator/NumericalKeyIterator.hpp | 6 +- src/Evaluator/Iterator/SimpleKeyIterator.hpp | 4 +- src/FunctionScriptType.hpp | 16 ++-- src/GlobalScriptOptions.hpp | 2 +- src/Parser/Lexer.cpp | 14 ++-- src/Parser/Lexer.hpp | 10 +-- .../ParsedExpressions/ParsedExpression.hpp | 72 ++++++++--------- .../ParsedStatements/ParsedStatement.hpp | 78 +++++++++---------- src/Parser/Parser.cpp | 34 ++++---- src/Parser/Parser.hpp | 38 ++++----- src/Parser/Token.hpp | 50 ++++++------ src/Parser/TypedVariableIdentifier.hpp | 6 +- src/Script.cpp | 10 +-- src/Script.hpp | 4 +- src/ScriptType.cpp | 2 +- src/ScriptType.hpp | 16 ++-- src/StandardLibraries/StaticScope.hpp | 2 +- src/TableScriptType.hpp | 8 +- src/UserData/UserData.hpp | 8 +- src/UserData/UserDataField.hpp | 10 +-- src/UserData/UserDataFunction.hpp | 2 +- src/UserData/UserDataFunctionType.hpp | 4 +- src/UserData/UserDataOperation.hpp | 4 +- src/UserData/UserDataScriptType.hpp | 6 +- src/UserData/UserDataStorage.hpp | 4 +- src/UserData/UserDataValue.hpp | 10 +-- src/Utilities/HashedString.hpp | 20 ++--- src/Utilities/StringUtils.hpp | 8 +- tests/parser/LexerTests.cpp | 54 ++++++------- tests/parser/ParserTests.cpp | 22 +++--- 53 files changed, 428 insertions(+), 424 deletions(-) diff --git a/src/Binder/BoundExpressions/BoundExpression.hpp b/src/Binder/BoundExpressions/BoundExpression.hpp index 73842c5..e7b219b 100644 --- a/src/Binder/BoundExpressions/BoundExpression.hpp +++ b/src/Binder/BoundExpressions/BoundExpression.hpp @@ -49,15 +49,15 @@ namespace Porygon::Binder { return _type; }; - const unsigned int GetStartPosition() const { + inline const unsigned int GetStartPosition() const { return _start; } - const unsigned int GetLength() const { + inline const unsigned int GetLength() const { return _length; } - const unsigned int GetEndPosition() const { + inline const unsigned int GetEndPosition() const { return _start + _length - 1; } }; @@ -68,7 +68,7 @@ namespace Porygon::Binder { make_shared( TypeClass::Error)) {} - const BoundExpressionKind GetKind() const final { + inline const BoundExpressionKind GetKind() const final { return BoundExpressionKind::Bad; } }; @@ -81,11 +81,11 @@ namespace Porygon::Binder { _value(value) { } - const BoundExpressionKind GetKind() const final { + inline const BoundExpressionKind GetKind() const final { return BoundExpressionKind::LiteralInteger; } - const long GetValue() const { + inline const long GetValue() const { return _value; } }; @@ -98,11 +98,11 @@ namespace Porygon::Binder { _value(value) { } - const BoundExpressionKind GetKind() const final { + inline const BoundExpressionKind GetKind() const final { return BoundExpressionKind::LiteralFloat; } - const double GetValue() const { + inline const double GetValue() const { return _value; } }; @@ -116,11 +116,11 @@ namespace Porygon::Binder { _value(value) { } - const BoundExpressionKind GetKind() const final { + inline const BoundExpressionKind GetKind() const final { return BoundExpressionKind::LiteralString; } - const u16string GetValue() const { + inline const u16string GetValue() const { return _value; } }; @@ -133,11 +133,11 @@ namespace Porygon::Binder { _value(value) { } - const BoundExpressionKind GetKind() const final { + inline const BoundExpressionKind GetKind() const final { return BoundExpressionKind::LiteralBool; } - const bool GetValue() const { + inline const bool GetValue() const { return _value; } }; @@ -155,11 +155,11 @@ namespace Porygon::Binder { delete _key; } - const BoundExpressionKind GetKind() const final { + inline const BoundExpressionKind GetKind() const final { return BoundExpressionKind::Variable; } - const BoundVariableKey *GetKey() const { + inline const BoundVariableKey *GetKey() const { return _key; } }; @@ -183,19 +183,19 @@ namespace Porygon::Binder { delete _right; } - const BoundExpressionKind GetKind() const final { + inline const BoundExpressionKind GetKind() const final { return BoundExpressionKind::Binary; } - const BoundExpression *GetLeft() const { + inline const BoundExpression *GetLeft() const { return _left; } - const BoundExpression *GetRight() const { + inline const BoundExpression *GetRight() const { return _right; } - const BoundBinaryOperation GetOperation() const { + inline const BoundBinaryOperation GetOperation() const { return _operation; } }; @@ -215,15 +215,15 @@ namespace Porygon::Binder { delete _operand; } - const BoundExpressionKind GetKind() const final { + inline const BoundExpressionKind GetKind() const final { return BoundExpressionKind::Unary; } - const BoundExpression *GetOperand() const { + inline const BoundExpression *GetOperand() const { return _operand; } - const BoundUnaryOperation GetOperation() const { + inline const BoundUnaryOperation GetOperation() const { return _operation; } }; @@ -243,15 +243,15 @@ namespace Porygon::Binder { delete _indexExpression; } - const BoundExpressionKind GetKind() const final { + inline const BoundExpressionKind GetKind() const final { return BoundExpressionKind::Index; } - const BoundExpression *GetIndexableExpression() const { + inline const BoundExpression *GetIndexableExpression() const { return _indexableExpression; } - const BoundExpression *GetIndexExpression() const { + inline const BoundExpression *GetIndexExpression() const { return _indexExpression; } }; @@ -270,15 +270,15 @@ namespace Porygon::Binder { delete _indexableExpression; } - const BoundExpressionKind GetKind() const final { + inline const BoundExpressionKind GetKind() const final { return BoundExpressionKind::PeriodIndex; } - const BoundExpression *GetIndexableExpression() const { + inline const BoundExpression *GetIndexableExpression() const { return _indexableExpression; } - const Utilities::HashedString GetIndex() const { + inline const Utilities::HashedString GetIndex() const { return _index; } }; @@ -297,11 +297,11 @@ namespace Porygon::Binder { } } - const BoundExpressionKind GetKind() const final { + inline const BoundExpressionKind GetKind() const final { return BoundExpressionKind::NumericalTable; } - const vector *GetExpressions() const { + inline const vector *GetExpressions() const { return &_expressions; } }; diff --git a/src/Binder/BoundExpressions/BoundFunctionCallExpression.hpp b/src/Binder/BoundExpressions/BoundFunctionCallExpression.hpp index 184a216..bd49cee 100644 --- a/src/Binder/BoundExpressions/BoundFunctionCallExpression.hpp +++ b/src/Binder/BoundExpressions/BoundFunctionCallExpression.hpp @@ -22,19 +22,19 @@ namespace Porygon::Binder { } } - const Porygon::Binder::BoundExpressionKind GetKind() const final { + inline const Porygon::Binder::BoundExpressionKind GetKind() const final { return Porygon::Binder::BoundExpressionKind::FunctionCall; } - const BoundExpression *GetFunctionExpression() const { + inline const BoundExpression *GetFunctionExpression() const { return _functionExpression; } - const vector *GetParameters() const { + inline const vector *GetParameters() const { return &_parameters; } - const Porygon::GenericFunctionOption *GetFunctionOption() const { + inline const Porygon::GenericFunctionOption *GetFunctionOption() const { return _option; } }; diff --git a/src/Binder/BoundExpressions/BoundTableExpression.hpp b/src/Binder/BoundExpressions/BoundTableExpression.hpp index c2d65ba..403cae3 100644 --- a/src/Binder/BoundExpressions/BoundTableExpression.hpp +++ b/src/Binder/BoundExpressions/BoundTableExpression.hpp @@ -20,11 +20,11 @@ namespace Porygon::Binder { delete _block; } - const BoundExpressionKind GetKind() const final { + inline const BoundExpressionKind GetKind() const final { return BoundExpressionKind::Table; } - const BoundBlockStatement *GetBlock() const { + inline const BoundBlockStatement *GetBlock() const { return _block; } }; diff --git a/src/Binder/BoundStatements/BoundFunctionDeclarationStatement.hpp b/src/Binder/BoundStatements/BoundFunctionDeclarationStatement.hpp index 05936c2..4675fa1 100644 --- a/src/Binder/BoundStatements/BoundFunctionDeclarationStatement.hpp +++ b/src/Binder/BoundStatements/BoundFunctionDeclarationStatement.hpp @@ -21,19 +21,19 @@ namespace Porygon::Binder { delete _key; } - const BoundStatementKind GetKind() const final { + inline const BoundStatementKind GetKind() const final { return BoundStatementKind::FunctionDeclaration; } - const BoundVariableKey *GetKey() const { + inline const BoundVariableKey *GetKey() const { return _key; } - const std::shared_ptr GetBlock() const { + inline const std::shared_ptr GetBlock() const { return _block; } - const std::shared_ptr GetType() const { + inline const std::shared_ptr GetType() const { return _type; } }; diff --git a/src/Binder/BoundStatements/BoundStatement.hpp b/src/Binder/BoundStatements/BoundStatement.hpp index c37c78d..7b95841 100644 --- a/src/Binder/BoundStatements/BoundStatement.hpp +++ b/src/Binder/BoundStatements/BoundStatement.hpp @@ -35,14 +35,14 @@ namespace Porygon::Binder { class BoundBadStatement : public BoundStatement { public: - const BoundStatementKind GetKind() const final { + inline const BoundStatementKind GetKind() const final { return BoundStatementKind::Bad; } }; class BoundBreakStatement : public BoundStatement { public: - const BoundStatementKind GetKind() const final { + inline const BoundStatementKind GetKind() const final { return BoundStatementKind::Break; } }; @@ -60,11 +60,11 @@ namespace Porygon::Binder { } } - const BoundStatementKind GetKind() const override { + inline const BoundStatementKind GetKind() const override { return BoundStatementKind::Block; } - const vector *GetStatements() const { + inline const vector *GetStatements() const { return &_statements; } }; @@ -77,11 +77,11 @@ namespace Porygon::Binder { _localVariableCount(localVariableCount) { } - const BoundStatementKind GetKind() const final { + inline const BoundStatementKind GetKind() const final { return BoundStatementKind::Script; } - const int GetLocalVariableCount() const { + inline const int GetLocalVariableCount() const { return _localVariableCount; } }; @@ -98,11 +98,11 @@ namespace Porygon::Binder { delete _expression; } - const BoundStatementKind GetKind() const final { + inline const BoundStatementKind GetKind() const final { return BoundStatementKind::Expression; } - const BoundExpression *GetExpression() const { + inline const BoundExpression *GetExpression() const { return _expression; } }; @@ -120,15 +120,15 @@ namespace Porygon::Binder { delete _expression; } - const BoundStatementKind GetKind() const final { + inline const BoundStatementKind GetKind() const final { return BoundStatementKind::Assignment; } - const BoundVariableKey *GetKey() const { + inline const BoundVariableKey *GetKey() const { return _key; } - const BoundExpression *GetExpression() const { + inline const BoundExpression *GetExpression() const { return _expression; } }; @@ -146,15 +146,15 @@ namespace Porygon::Binder { delete _valueExpression; } - const BoundStatementKind GetKind() const final { + inline const BoundStatementKind GetKind() const final { return BoundStatementKind::IndexAssignment; } - const BoundExpression *GetIndexExpression() const { + inline const BoundExpression *GetIndexExpression() const { return _indexExpression; } - const BoundExpression *GetValueExpression() const { + inline const BoundExpression *GetValueExpression() const { return _valueExpression; } }; @@ -170,11 +170,11 @@ namespace Porygon::Binder { delete _expression; } - const BoundStatementKind GetKind() const final { + inline const BoundStatementKind GetKind() const final { return BoundStatementKind::Return; } - const BoundExpression *GetExpression() const { + inline const BoundExpression *GetExpression() const { return _expression; } }; @@ -194,19 +194,19 @@ namespace Porygon::Binder { delete _elseStatement; } - const BoundStatementKind GetKind() const final { + inline const BoundStatementKind GetKind() const final { return BoundStatementKind::Conditional; } - const BoundExpression *GetCondition() const { + inline const BoundExpression *GetCondition() const { return _condition; } - const BoundStatement *GetBlock() const { + inline const BoundStatement *GetBlock() const { return _block; } - const BoundStatement *GetElseStatement() const { + inline const BoundStatement *GetElseStatement() const { return _elseStatement; } }; @@ -233,27 +233,27 @@ namespace Porygon::Binder { delete _block; } - const BoundStatementKind GetKind() const final { + inline const BoundStatementKind GetKind() const final { return BoundStatementKind::NumericalFor; } - const BoundVariableKey* GetIdentifier() const{ + inline const BoundVariableKey* GetIdentifier() const{ return _identifier; } - const BoundExpression* GetStart() const{ + inline const BoundExpression* GetStart() const{ return _start; } - const BoundExpression* GetEnd() const{ + inline const BoundExpression* GetEnd() const{ return _end; } - const BoundExpression* GetStep() const{ + inline const BoundExpression* GetStep() const{ return _step; } - const BoundStatement* GetBlock() const{ + inline const BoundStatement* GetBlock() const{ return _block; } }; @@ -278,23 +278,23 @@ namespace Porygon::Binder { delete _block; } - const BoundStatementKind GetKind() const final { + inline const BoundStatementKind GetKind() const final { return BoundStatementKind::GenericFor; } - const BoundVariableKey* GetKeyIdentifier() const{ + inline const BoundVariableKey* GetKeyIdentifier() const{ return _keyIdentifier; } - const BoundVariableKey* GetValueIdentifier() const{ + inline const BoundVariableKey* GetValueIdentifier() const{ return _valueIdentifier; } - const BoundExpression* GetIterator() const{ + inline const BoundExpression* GetIterator() const{ return _iterator; } - const BoundStatement* GetBlock() const{ + inline const BoundStatement* GetBlock() const{ return _block; } }; @@ -312,15 +312,15 @@ namespace Porygon::Binder { delete _block; } - const BoundStatementKind GetKind() const final { + inline const BoundStatementKind GetKind() const final { return BoundStatementKind::While; } - const BoundExpression* GetCondition() const{ + inline const BoundExpression* GetCondition() const{ return _condition; } - const BoundStatement* GetBlock() const{ + inline const BoundStatement* GetBlock() const{ return _block; } }; diff --git a/src/Binder/BoundVariables/BoundScope.hpp b/src/Binder/BoundVariables/BoundScope.hpp index 795f532..1306378 100644 --- a/src/Binder/BoundVariables/BoundScope.hpp +++ b/src/Binder/BoundVariables/BoundScope.hpp @@ -36,11 +36,11 @@ namespace Porygon::Binder { VariableAssignment AssignVariable(const Utilities::HashedString& identifier, const std::shared_ptr &type); - size_t GetLocalVariableCount() { + inline size_t GetLocalVariableCount() { return _localScope.size(); } - int GetCurrentScope() { + inline int GetCurrentScope() { return _currentScope; } }; diff --git a/src/Binder/BoundVariables/BoundVariable.hpp b/src/Binder/BoundVariables/BoundVariable.hpp index d6e8e5e..d2ce0a1 100644 --- a/src/Binder/BoundVariables/BoundVariable.hpp +++ b/src/Binder/BoundVariables/BoundVariable.hpp @@ -13,10 +13,10 @@ namespace Porygon::Binder { class BoundVariable { std::shared_ptr _type; public: - explicit BoundVariable(std::shared_ptr type) : _type(std::move(type)) { + inline explicit BoundVariable(std::shared_ptr type) : _type(std::move(type)) { } - std::shared_ptr GetType() { + inline std::shared_ptr GetType() { return _type; } }; diff --git a/src/Binder/BoundVariables/BoundVariableKey.hpp b/src/Binder/BoundVariables/BoundVariableKey.hpp index b08a8ae..24d9314 100644 --- a/src/Binder/BoundVariables/BoundVariableKey.hpp +++ b/src/Binder/BoundVariables/BoundVariableKey.hpp @@ -26,19 +26,19 @@ namespace Porygon::Binder { _hash(KnuthsHash(id.GetHash(), scope)) {} - const Utilities::HashedString GetIdentifier() const { + inline const Utilities::HashedString GetIdentifier() const { return _identifier; } - const unsigned int GetScopeId() const { + inline const unsigned int GetScopeId() const { return _scopeId; } - const bool IsCreation() const { + inline const bool IsCreation() const { return _isCreation; } - const uint64_t GetHash() const { + inline const uint64_t GetHash() const { return _hash; } }; diff --git a/src/Binder/BoundVariables/VariableAssigmentResult.hpp b/src/Binder/BoundVariables/VariableAssigmentResult.hpp index 2fbcfae..3a6c0ae 100644 --- a/src/Binder/BoundVariables/VariableAssigmentResult.hpp +++ b/src/Binder/BoundVariables/VariableAssigmentResult.hpp @@ -20,11 +20,11 @@ namespace Porygon::Binder { _key = key; } - VariableAssignmentResult GetResult() { + inline VariableAssignmentResult GetResult() { return _result; } - BoundVariableKey *GetKey() { + inline BoundVariableKey *GetKey() { return _key; } }; diff --git a/src/Diagnostics/Diagnostic.hpp b/src/Diagnostics/Diagnostic.hpp index acb4752..146c46b 100644 --- a/src/Diagnostics/Diagnostic.hpp +++ b/src/Diagnostics/Diagnostic.hpp @@ -28,31 +28,31 @@ namespace Porygon::Diagnostics { delete _message; } - DiagnosticSeverity GetSeverity() { + inline DiagnosticSeverity GetSeverity() { return _severity; } - DiagnosticCode GetCode() { + inline DiagnosticCode GetCode() { return _code; } - unsigned int GetStartPosition() { + inline unsigned int GetStartPosition() { return _start; } - unsigned int GetLength() { + inline unsigned int GetLength() { return _length; } - std::vector GetArguments(){ + inline std::vector GetArguments(){ return _arguments; } - void SetMessage(std::string* s){ + inline void SetMessage(std::string* s){ this -> _message = s; } - std::string* GetMessage(){ + inline std::string* GetMessage(){ return _message; } }; diff --git a/src/Diagnostics/DiagnosticsHolder.cpp b/src/Diagnostics/DiagnosticsHolder.cpp index 9fa7e5f..a5cb963 100644 --- a/src/Diagnostics/DiagnosticsHolder.cpp +++ b/src/Diagnostics/DiagnosticsHolder.cpp @@ -17,27 +17,27 @@ void DiagnosticsHolder::Log(DiagnosticSeverity severity, DiagnosticCode code, un } } -void DiagnosticsHolder::LogError(DiagnosticCode code, unsigned int start, unsigned int length, std::vector arguments) { +inline void DiagnosticsHolder::LogError(DiagnosticCode code, unsigned int start, unsigned int length, std::vector arguments) { Log(DiagnosticSeverity::Error, code, start, length, std::move(arguments)); } -void DiagnosticsHolder::LogWarning(DiagnosticCode code, unsigned int start, unsigned int length, std::vector arguments) { +inline void DiagnosticsHolder::LogWarning(DiagnosticCode code, unsigned int start, unsigned int length, std::vector arguments) { Log(DiagnosticSeverity::Warning, code, start, length, std::move(arguments)); } -void DiagnosticsHolder::LogInfo(DiagnosticCode code, unsigned int start, unsigned int length, std::vector arguments) { +inline void DiagnosticsHolder::LogInfo(DiagnosticCode code, unsigned int start, unsigned int length, std::vector arguments) { Log(DiagnosticSeverity::Info, code, start, length, std::move(arguments)); } -bool DiagnosticsHolder::HasErrors() { +inline bool DiagnosticsHolder::HasErrors() { return _hasErrors; } -int DiagnosticsHolder::DiagnosticsCount() { +inline int DiagnosticsHolder::DiagnosticsCount() { return _diagnostics.size(); } -Diagnostic *DiagnosticsHolder::GetDiagnosticAt(int position) { +inline Diagnostic *DiagnosticsHolder::GetDiagnosticAt(int position) { return &_diagnostics[position]; } diff --git a/src/Diagnostics/DiagnosticsHolder.hpp b/src/Diagnostics/DiagnosticsHolder.hpp index 74c7b49..1c44585 100644 --- a/src/Diagnostics/DiagnosticsHolder.hpp +++ b/src/Diagnostics/DiagnosticsHolder.hpp @@ -52,7 +52,7 @@ namespace Porygon::Diagnostics { Diagnostic *GetDiagnosticAt(int position); size_t GetLineFromPosition(size_t i); - size_t GetStartPositionForLine(size_t i){ + inline size_t GetStartPositionForLine(size_t i){ return _lineStarts[i]; } diff --git a/src/Evaluator/EvalValues/EvalValue.hpp b/src/Evaluator/EvalValues/EvalValue.hpp index 3f2d7b6..f05e10b 100644 --- a/src/Evaluator/EvalValues/EvalValue.hpp +++ b/src/Evaluator/EvalValues/EvalValue.hpp @@ -73,15 +73,15 @@ namespace Porygon::Evaluation { : _value(val) { } - const shared_ptr Clone() const final { + inline const shared_ptr Clone() const final { return make_shared(_value); } - const TypeClass GetTypeClass() const final { + inline const TypeClass GetTypeClass() const final { return TypeClass::Bool; } - const bool EvaluateBool() const final { + inline const bool EvaluateBool() const final { return _value; } @@ -91,7 +91,7 @@ namespace Porygon::Evaluation { return this->EvaluateBool() == b->EvaluateBool(); }; - const std::size_t GetHashCode() const final { + inline const std::size_t GetHashCode() const final { return _value; } }; diff --git a/src/Evaluator/EvalValues/EvalValueHelper.hpp b/src/Evaluator/EvalValues/EvalValueHelper.hpp index 770a48b..8b37e82 100644 --- a/src/Evaluator/EvalValues/EvalValueHelper.hpp +++ b/src/Evaluator/EvalValues/EvalValueHelper.hpp @@ -10,48 +10,48 @@ namespace Porygon::Evaluation{ class EvalValueHelper{ public: - static EvalValue* Create(unsigned char i){ + inline static EvalValue* Create(unsigned char i){ return new IntegerEvalValue((long)i); } - static EvalValue* Create(signed char i){ + inline static EvalValue* Create(signed char i){ return new IntegerEvalValue((long)i); } - static EvalValue* Create(short int i){ + inline static EvalValue* Create(short int i){ return new IntegerEvalValue(i); } - static EvalValue* Create(unsigned short int i){ + inline static EvalValue* Create(unsigned short int i){ return new IntegerEvalValue(i); } - static EvalValue* Create(signed int i){ + inline static EvalValue* Create(signed int i){ return new IntegerEvalValue(i); } - static EvalValue* Create(unsigned int i){ + inline static EvalValue* Create(unsigned int i){ return new IntegerEvalValue(i); } - static EvalValue* Create(signed long l){ + inline static EvalValue* Create(signed long l){ return new IntegerEvalValue(l); } - static EvalValue* Create(unsigned long l){ + inline static EvalValue* Create(unsigned long l){ return new IntegerEvalValue(l); } - static EvalValue* Create(float f){ + inline static EvalValue* Create(float f){ return new FloatEvalValue(f); } - static EvalValue* Create(double f){ + inline static EvalValue* Create(double f){ return new FloatEvalValue(f); } - static EvalValue* Create(long double f){ + inline static EvalValue* Create(long double f){ return new FloatEvalValue(f); } - static EvalValue* Create(bool b){ + inline static EvalValue* Create(bool b){ return new BooleanEvalValue(b); } - static EvalValue* Create(const string& s){ + inline static EvalValue* Create(const string& s){ return new StringEvalValue(Utilities::StringUtils::ToUTF8(s)); } - static EvalValue* Create(u16string s){ + inline static EvalValue* Create(u16string s){ return new StringEvalValue(std::move(s)); } }; diff --git a/src/Evaluator/EvalValues/NilEvalValue.hpp b/src/Evaluator/EvalValues/NilEvalValue.hpp index b681d81..900409d 100644 --- a/src/Evaluator/EvalValues/NilEvalValue.hpp +++ b/src/Evaluator/EvalValues/NilEvalValue.hpp @@ -5,18 +5,18 @@ namespace Porygon::Evaluation{ class NilEvalValue : public EvalValue{ - const TypeClass GetTypeClass() const final{ + inline const TypeClass GetTypeClass() const final{ return TypeClass ::Nil; } - const bool operator==(EvalValue *b) const final{ + inline const bool operator==(EvalValue *b) const final{ return b->GetTypeClass() == TypeClass ::Nil; } - const shared_ptr Clone() const final{ + inline const shared_ptr Clone() const final{ return make_shared(); } - const std::size_t GetHashCode() const final{ + inline const std::size_t GetHashCode() const final{ return 0; } }; diff --git a/src/Evaluator/EvalValues/NumericEvalValue.hpp b/src/Evaluator/EvalValues/NumericEvalValue.hpp index ba63e34..5e2889c 100644 --- a/src/Evaluator/EvalValues/NumericEvalValue.hpp +++ b/src/Evaluator/EvalValues/NumericEvalValue.hpp @@ -16,7 +16,7 @@ namespace Porygon::Evaluation { public: virtual const bool IsFloat() const = 0; - const TypeClass GetTypeClass() const final { + inline const TypeClass GetTypeClass() const final { return TypeClass::Number; } @@ -52,23 +52,23 @@ namespace Porygon::Evaluation { explicit IntegerEvalValue(long value) : _value(value) { } - const bool IsFloat() const final { + inline const bool IsFloat() const final { return false; } - const long EvaluateInteger() const final { + inline const long EvaluateInteger() const final { return _value; } - const std::u16string EvaluateString() const final{ + inline const std::u16string EvaluateString() const final{ return Utilities::StringUtils::IntToString(_value); } - const shared_ptr Clone() const final { + inline const shared_ptr Clone() const final { return make_shared(_value); } - const std::size_t GetHashCode() const final { + inline const std::size_t GetHashCode() const final { return std::hash{}(_value); } }; @@ -76,29 +76,31 @@ namespace Porygon::Evaluation { class FloatEvalValue : public NumericEvalValue { const double _value; - const long GetIntegerValue() const final { + inline const long GetIntegerValue() const final { throw EvaluationException("Attempting to retrieve float from int eval value."); } - const double GetFloatValue() const final { return _value; } + inline const double GetFloatValue() const final { + return _value; + } public: explicit FloatEvalValue(double value) : _value(value) { } - const bool IsFloat() const final { + inline const bool IsFloat() const final { return true; } - const double EvaluateFloat() const final { + inline const double EvaluateFloat() const final { return _value; } - const shared_ptr Clone() const final { + inline const shared_ptr Clone() const final { return make_shared(_value); } - const std::size_t GetHashCode() const final { + inline const std::size_t GetHashCode() const final { return std::hash{}(_value); } }; diff --git a/src/Evaluator/EvalValues/NumericalTableEvalValue.cpp b/src/Evaluator/EvalValues/NumericalTableEvalValue.cpp index c7878c4..eb40561 100644 --- a/src/Evaluator/EvalValues/NumericalTableEvalValue.cpp +++ b/src/Evaluator/EvalValues/NumericalTableEvalValue.cpp @@ -1,6 +1,6 @@ #include "NumericalTableEvalValue.hpp" #include "../Iterator/NumericalKeyIterator.hpp" -Porygon::Evaluation::Iterator *Porygon::Evaluation::NumericalTableEvalValue::GetKeyIterator() const { +inline Porygon::Evaluation::Iterator *Porygon::Evaluation::NumericalTableEvalValue::GetKeyIterator() const { return new NumericalKeyIterator(this); } diff --git a/src/Evaluator/EvalValues/NumericalTableEvalValue.hpp b/src/Evaluator/EvalValues/NumericalTableEvalValue.hpp index e351638..fdd30ef 100644 --- a/src/Evaluator/EvalValues/NumericalTableEvalValue.hpp +++ b/src/Evaluator/EvalValues/NumericalTableEvalValue.hpp @@ -26,39 +26,39 @@ namespace Porygon::Evaluation { { } - const TypeClass GetTypeClass() const final { + inline const TypeClass GetTypeClass() const final { return TypeClass::Table; } - const size_t GetHashCode() const final { + inline const size_t GetHashCode() const final { return _hash; } - const bool operator==(EvalValue *b) const final { + inline const bool operator==(EvalValue *b) const final { return this->_hash == b->GetHashCode(); } - const shared_ptr Clone() const final { + inline const shared_ptr Clone() const final { return shared_ptr(new NumericalTableEvalValue(_table, _hash)); } - const shared_ptr IndexValue(EvalValue *val) const final { + inline const shared_ptr IndexValue(EvalValue *val) const final { const auto index = val->EvaluateInteger() - 1; return this->_table->at(index); } - const shared_ptr IndexValue(uint32_t hash) const final { + inline const shared_ptr IndexValue(uint32_t hash) const final { return this->_table->at(hash - 1); } - void SetIndexValue(EvalValue *key, const shared_ptr &value) const final { + inline void SetIndexValue(EvalValue *key, const shared_ptr &value) const final { auto index = key->EvaluateInteger(); this->_table->at(index - 1) = value; } Iterator * GetKeyIterator() const final; - const shared_ptr>> GetTable() const{ + inline const shared_ptr>> GetTable() const{ return _table; }; }; diff --git a/src/Evaluator/EvalValues/ScriptFunctionEvalValue.hpp b/src/Evaluator/EvalValues/ScriptFunctionEvalValue.hpp index cb6ff53..2405e9c 100644 --- a/src/Evaluator/EvalValues/ScriptFunctionEvalValue.hpp +++ b/src/Evaluator/EvalValues/ScriptFunctionEvalValue.hpp @@ -29,11 +29,11 @@ namespace Porygon::Evaluation { } ~EvaluationScriptFunctionOption() final = default; - const std::shared_ptr &GetInnerBlock() const { + inline const std::shared_ptr &GetInnerBlock() const { return _innerBlock; } - const std::shared_ptr &GetScope() const { + inline const std::shared_ptr &GetScope() const { return _scope; } }; @@ -57,15 +57,15 @@ namespace Porygon::Evaluation { return t; } - void RegisterOption(GenericFunctionOption* option){ + inline void RegisterOption(GenericFunctionOption* option){ _options.push_back(shared_ptr(option)); } - const std::shared_ptr GetType() const { + inline const std::shared_ptr GetType() const { return _type; } - const TypeClass GetTypeClass() const final { + inline const TypeClass GetTypeClass() const final { return TypeClass::Function; } @@ -75,11 +75,11 @@ namespace Porygon::Evaluation { return this->_hash == ((GenericFunctionEvalValue *) b)->_hash; }; - const std::size_t GetHashCode() const final { + inline const std::size_t GetHashCode() const final { return _hash; } - const shared_ptr GetOption(const size_t id) const{ + inline const shared_ptr GetOption(const size_t id) const{ return this->_options.at(id); } }; diff --git a/src/Evaluator/EvalValues/StringEvalValue.hpp b/src/Evaluator/EvalValues/StringEvalValue.hpp index 03c7730..23f6e85 100644 --- a/src/Evaluator/EvalValues/StringEvalValue.hpp +++ b/src/Evaluator/EvalValues/StringEvalValue.hpp @@ -17,7 +17,7 @@ namespace Porygon::Evaluation { _hash = Utilities::HashedString::ConstHash(_value.c_str()); } - const TypeClass GetTypeClass() const final { + inline const TypeClass GetTypeClass() const final { return TypeClass::String; } @@ -27,11 +27,11 @@ namespace Porygon::Evaluation { return this->_hash == b->GetHashCode(); }; - const u16string EvaluateString() const final { + inline const u16string EvaluateString() const final { return _value; } - const shared_ptr Clone() const final { + inline const shared_ptr Clone() const final { return make_shared(_value); } @@ -41,7 +41,7 @@ namespace Porygon::Evaluation { return make_shared(u16string(1, _value[l])); } - const std::size_t GetHashCode() const final { + inline const std::size_t GetHashCode() const final { return _hash; } }; diff --git a/src/Evaluator/EvalValues/TableEvalValue.cpp b/src/Evaluator/EvalValues/TableEvalValue.cpp index d40ae2f..26f2495 100644 --- a/src/Evaluator/EvalValues/TableEvalValue.cpp +++ b/src/Evaluator/EvalValues/TableEvalValue.cpp @@ -1,6 +1,6 @@ #include "TableEvalValue.hpp" #include "../Iterator/SimpleKeyIterator.hpp" -Porygon::Evaluation::Iterator * Porygon::Evaluation::TableEvalValue::GetKeyIterator() const { +inline Porygon::Evaluation::Iterator * Porygon::Evaluation::TableEvalValue::GetKeyIterator() const { return new TableKeyIterator(this); } diff --git a/src/Evaluator/EvalValues/TableEvalValue.hpp b/src/Evaluator/EvalValues/TableEvalValue.hpp index 6ae8134..94c5489 100644 --- a/src/Evaluator/EvalValues/TableEvalValue.hpp +++ b/src/Evaluator/EvalValues/TableEvalValue.hpp @@ -25,47 +25,47 @@ namespace Porygon::Evaluation { { } - const TypeClass GetTypeClass() const final { + inline const TypeClass GetTypeClass() const final { return TypeClass::Table; } - const size_t GetHashCode() const final { + inline const size_t GetHashCode() const final { return _hash; } - const bool operator==(EvalValue *b) const final { + inline const bool operator==(EvalValue *b) const final { return this->_hash == b->GetHashCode(); } - const shared_ptr Clone() const final { + inline const shared_ptr Clone() const final { return shared_ptr(new TableEvalValue(_table, _hash)); } - const shared_ptr IndexValue(EvalValue *val) const final { + inline const shared_ptr IndexValue(EvalValue *val) const final { const auto stringKey = val->EvaluateString(); return this->_table->at(Utilities::HashedString::CreateLookup(stringKey)); } - const shared_ptr IndexValue(uint32_t hash) const final { + inline const shared_ptr IndexValue(uint32_t hash) const final { return this->_table->at(Utilities::HashedString::CreateLookup(hash)); } - const shared_ptr IndexValue(const char *val) const { + inline const shared_ptr IndexValue(const char *val) const { auto hash = Utilities::HashedString::ConstHash(val); return this->_table->at(Utilities::HashedString::CreateLookup(hash)); } - void SetIndexValue(EvalValue *key, const shared_ptr &value) const final { + inline void SetIndexValue(EvalValue *key, const shared_ptr &value) const final { auto hash = key->GetHashCode(); this->_table->at(Utilities::HashedString::CreateLookup(hash)) = value; } Iterator * GetKeyIterator() const final; - const _Rb_tree_const_iterator>> GetTableIterator() const{ + inline const _Rb_tree_const_iterator>> GetTableIterator() const{ return _table->cbegin(); }; - const _Rb_tree_const_iterator>> GetTableIteratorEnd() const{ + inline const _Rb_tree_const_iterator>> GetTableIteratorEnd() const{ return _table->cend(); }; }; diff --git a/src/Evaluator/EvaluationException.hpp b/src/Evaluator/EvaluationException.hpp index e2c0a16..32879ce 100644 --- a/src/Evaluator/EvaluationException.hpp +++ b/src/Evaluator/EvaluationException.hpp @@ -17,7 +17,7 @@ namespace Porygon::Evaluation { const string defaultErrorText = "An evaluation exception occurred: "; - const char *what() const noexcept final { + inline const char *what() const noexcept final { return _message.c_str(); } }; diff --git a/src/Evaluator/Iterator/NumericalKeyIterator.hpp b/src/Evaluator/Iterator/NumericalKeyIterator.hpp index 180feb2..c869180 100644 --- a/src/Evaluator/Iterator/NumericalKeyIterator.hpp +++ b/src/Evaluator/Iterator/NumericalKeyIterator.hpp @@ -16,16 +16,16 @@ namespace Porygon::Evaluation{ explicit NumericalKeyIterator(const NumericalTableEvalValue* table) : _vec(table->GetTable()), _size(_vec->size() + 1){} - shared_ptr GetCurrent() final{ + inline shared_ptr GetCurrent() final{ return make_shared(_position); } - bool MoveNext() final{ + inline bool MoveNext() final{ _position++; return _position != _size; } - void Reset() final{ + inline void Reset() final{ _position = 0; } }; diff --git a/src/Evaluator/Iterator/SimpleKeyIterator.hpp b/src/Evaluator/Iterator/SimpleKeyIterator.hpp index 26b8808..9f212f4 100644 --- a/src/Evaluator/Iterator/SimpleKeyIterator.hpp +++ b/src/Evaluator/Iterator/SimpleKeyIterator.hpp @@ -15,7 +15,7 @@ namespace Porygon::Evaluation{ explicit TableKeyIterator(const TableEvalValue* table) : _iterator(table->GetTableIterator()), _end(table->GetTableIteratorEnd()){} - shared_ptr GetCurrent() final{ + inline shared_ptr GetCurrent() final{ return make_shared(*_iterator->first.GetString()); } @@ -28,7 +28,7 @@ namespace Porygon::Evaluation{ return _iterator != _end; } - void Reset() final{ + inline void Reset() final{ throw EvaluationException("Can't reset table key iterator"); } }; diff --git a/src/FunctionScriptType.hpp b/src/FunctionScriptType.hpp index 22eaa7a..772e6f7 100644 --- a/src/FunctionScriptType.hpp +++ b/src/FunctionScriptType.hpp @@ -17,19 +17,19 @@ namespace Porygon { virtual ~GenericFunctionOption() = default; - const shared_ptr GetReturnType() const { + inline const shared_ptr GetReturnType() const { return _returnType; } - void SetOption(size_t v){ + inline void SetOption(size_t v){ _option = v; } - void SetReturnType(shared_ptr t) { + inline void SetReturnType(shared_ptr t) { _returnType = move(t); } - const vector> GetParameterTypes() const { + inline const vector> GetParameterTypes() const { return _parameterTypes; } @@ -45,7 +45,7 @@ namespace Porygon { return true; } - const size_t GetOptionId() const{ + inline const size_t GetOptionId() const{ return _option; } @@ -83,7 +83,7 @@ namespace Porygon { return nullptr; } - GenericFunctionOption* GetFirstOption(){ + inline GenericFunctionOption* GetFirstOption(){ return _options[0]; } }; @@ -96,11 +96,11 @@ namespace Porygon { : GenericFunctionOption(move(returnType), std::move(parameterTypes)), _parameterKeys(move(parameterKeys)) { } - const vector> GetParameterKeys() const { + inline const vector> GetParameterKeys() const { return _parameterKeys; } - const bool IsScriptFunction() const final { + inline const bool IsScriptFunction() const final { return true; } }; diff --git a/src/GlobalScriptOptions.hpp b/src/GlobalScriptOptions.hpp index d886c87..54a0436 100644 --- a/src/GlobalScriptOptions.hpp +++ b/src/GlobalScriptOptions.hpp @@ -9,7 +9,7 @@ namespace Porygon{ static std::streambuf* _printBuffer; static std::ostream* _printStream; public: - static void Print(const std::u16string& s){ + inline static void Print(const std::u16string& s){ GlobalScriptOptions::_print(s); } diff --git a/src/Parser/Lexer.cpp b/src/Parser/Lexer.cpp index 64a5691..18c3078 100644 --- a/src/Parser/Lexer.cpp +++ b/src/Parser/Lexer.cpp @@ -14,10 +14,10 @@ namespace Porygon::Parser { } - vector Lexer::Lex() { - vector tokens; + vector Lexer::Lex() { + vector tokens; while (true) { - IToken *next = this->LexNext(this->Next()); + Token *next = this->LexNext(this->Next()); auto nextKind = next->GetKind(); if (nextKind != TokenKind::WhiteSpace) tokens.push_back(next); @@ -41,7 +41,7 @@ namespace Porygon::Parser { return next; } - IToken *Lexer::LexNext(char16_t c) { + Token *Lexer::LexNext(char16_t c) { switch (c) { case '\0': return new SimpleToken(TokenKind::EndOfFile, this->_position - 1, 1); @@ -154,7 +154,7 @@ namespace Porygon::Parser { } } - IToken *Lexer::LexNumber(char16_t c) { + Token *Lexer::LexNumber(char16_t c) { long int_value = CharToInt(c); double float_value = 0; short decimal_index = 0; @@ -201,7 +201,7 @@ namespace Porygon::Parser { } } - IToken *Lexer::LexIdentifierOrKeyword() { + Token *Lexer::LexIdentifierOrKeyword() { auto start = this->_position - 1; auto end = start; while (true) { @@ -275,7 +275,7 @@ namespace Porygon::Parser { {'\\', '\\'}, }; - IToken *Lexer::LexString(char16_t c) { + Token *Lexer::LexString(char16_t c) { auto start = this->_position - 1; auto end = start; char16_t last = c; diff --git a/src/Parser/Lexer.hpp b/src/Parser/Lexer.hpp index 58d1f81..6224633 100644 --- a/src/Parser/Lexer.hpp +++ b/src/Parser/Lexer.hpp @@ -17,14 +17,14 @@ namespace Porygon::Parser{ unsigned int _scriptSize; char16_t Peek(); char16_t Next(); - IToken* LexNext(char16_t c); - IToken* LexNumber(char16_t c); - IToken* LexIdentifierOrKeyword(); - IToken* LexString(char16_t c); + Token* LexNext(char16_t c); + Token* LexNumber(char16_t c); + Token* LexIdentifierOrKeyword(); + Token* LexString(char16_t c); public: Porygon::Script* ScriptData; - vector Lex(); + vector Lex(); explicit Lexer(const u16string& scriptString, Porygon::Script* script); }; diff --git a/src/Parser/ParsedExpressions/ParsedExpression.hpp b/src/Parser/ParsedExpressions/ParsedExpression.hpp index 5fbb254..a4c1486 100644 --- a/src/Parser/ParsedExpressions/ParsedExpression.hpp +++ b/src/Parser/ParsedExpressions/ParsedExpression.hpp @@ -43,15 +43,15 @@ namespace Porygon::Parser { virtual const ParsedExpressionKind GetKind() const = 0; - const unsigned int GetStartPosition() const { + inline const unsigned int GetStartPosition() const { return _position; } - const unsigned int GetEndPosition() const { + inline const unsigned int GetEndPosition() const { return _position + _length - 1; } - const unsigned int GetLength() const { + inline const unsigned int GetLength() const { return _length; } }; @@ -60,7 +60,7 @@ namespace Porygon::Parser { public: BadExpression(unsigned int position, unsigned int length) : ParsedExpression(position, length) {} - const ParsedExpressionKind GetKind() const final { + inline const ParsedExpressionKind GetKind() const final { return ParsedExpressionKind::Bad; } }; @@ -68,7 +68,7 @@ namespace Porygon::Parser { class LiteralIntegerExpression : public ParsedExpression { const long _value; public: - const ParsedExpressionKind GetKind() const final { + inline const ParsedExpressionKind GetKind() const final { return ParsedExpressionKind::LiteralInteger; } @@ -77,7 +77,7 @@ namespace Porygon::Parser { _value(token->GetValue()) { } - const long GetValue() const { + inline const long GetValue() const { return _value; } }; @@ -85,7 +85,7 @@ namespace Porygon::Parser { class LiteralFloatExpression : public ParsedExpression { const double _value; public: - const ParsedExpressionKind GetKind() const final { + inline const ParsedExpressionKind GetKind() const final { return ParsedExpressionKind::LiteralFloat; } @@ -94,7 +94,7 @@ namespace Porygon::Parser { _value(token->GetValue()) { } - const double GetValue() const { + inline const double GetValue() const { return _value; } }; @@ -102,16 +102,16 @@ namespace Porygon::Parser { class LiteralStringExpression : public ParsedExpression { const u16string _value; public: - const ParsedExpressionKind GetKind() const final { + inline const ParsedExpressionKind GetKind() const final { return ParsedExpressionKind::LiteralString; } explicit LiteralStringExpression(const StringToken *token) : ParsedExpression(token->GetStartPosition(), token->GetLength()), - _value(std::move(token->GetValue())) { + _value(token->GetValue()) { } - const u16string &GetValue() const { + inline const u16string &GetValue() const { return _value; } }; @@ -119,16 +119,16 @@ namespace Porygon::Parser { class LiteralBoolExpression : public ParsedExpression { const bool _value; public: - const ParsedExpressionKind GetKind() const final { + inline const ParsedExpressionKind GetKind() const final { return ParsedExpressionKind::LiteralBool; } - explicit LiteralBoolExpression(const IToken *token) + explicit LiteralBoolExpression(const Token *token) : ParsedExpression(token->GetStartPosition(), token->GetLength()), _value(token->GetKind() == TokenKind::TrueKeyword) { } - const bool GetValue() const { + inline const bool GetValue() const { return _value; } }; @@ -136,7 +136,7 @@ namespace Porygon::Parser { class VariableExpression : public ParsedExpression { const HashedString _value; public: - const ParsedExpressionKind GetKind() const final { + inline const ParsedExpressionKind GetKind() const final { return ParsedExpressionKind::Variable; } @@ -145,7 +145,7 @@ namespace Porygon::Parser { _value(HashedString(token->GetValue())) { } - const HashedString GetValue() const { + inline const HashedString GetValue() const { return _value; } }; @@ -158,7 +158,7 @@ namespace Porygon::Parser { delete _expression; } - const ParsedExpressionKind GetKind() const final { + inline const ParsedExpressionKind GetKind() const final { return ParsedExpressionKind::Parenthesized; } @@ -166,7 +166,7 @@ namespace Porygon::Parser { : ParsedExpression(start, length), _expression(innerExpression) { } - const ParsedExpression *GetInnerExpression() const { + inline const ParsedExpression *GetInnerExpression() const { return _expression; } }; @@ -179,7 +179,7 @@ namespace Porygon::Parser { delete _operand; } - const ParsedExpressionKind GetKind() const final { + inline const ParsedExpressionKind GetKind() const final { return ParsedExpressionKind::Unary; } @@ -188,11 +188,11 @@ namespace Porygon::Parser { _kind(kind), _operand(operand) { } - const UnaryOperatorKind GetOperatorKind() const { + inline const UnaryOperatorKind GetOperatorKind() const { return _kind; } - const ParsedExpression *GetOperand() const { + inline const ParsedExpression *GetOperand() const { return _operand; } }; @@ -207,7 +207,7 @@ namespace Porygon::Parser { delete _right; } - const ParsedExpressionKind GetKind() const final { + inline const ParsedExpressionKind GetKind() const final { return ParsedExpressionKind::Binary; } @@ -217,15 +217,15 @@ namespace Porygon::Parser { _kind(kind), _left(left), _right(right) { } - const BinaryOperatorKind GetOperatorKind() const { + inline const BinaryOperatorKind GetOperatorKind() const { return _kind; } - const ParsedExpression *GetLeft() const { + inline const ParsedExpression *GetLeft() const { return _left; } - const ParsedExpression *GetRight() const { + inline const ParsedExpression *GetRight() const { return _right; } }; @@ -246,15 +246,15 @@ namespace Porygon::Parser { } } - const ParsedExpressionKind GetKind() const final { + inline const ParsedExpressionKind GetKind() const final { return ParsedExpressionKind::FunctionCall; } - const ParsedExpression *GetFunction() const { + inline const ParsedExpression *GetFunction() const { return _function.get(); } - const vector *GetParameters() const { + inline const vector *GetParameters() const { return &_parameters; } }; @@ -273,15 +273,15 @@ namespace Porygon::Parser { delete _indexExpression; } - const ParsedExpressionKind GetKind() const final { + inline const ParsedExpressionKind GetKind() const final { return ParsedExpressionKind::Indexer; } - const ParsedExpression *GetIndexer() const { + inline const ParsedExpression *GetIndexer() const { return _indexerExpression; } - const ParsedExpression *GetIndex() const { + inline const ParsedExpression *GetIndex() const { return _indexExpression; } }; @@ -299,15 +299,15 @@ namespace Porygon::Parser { delete _indexerExpression; } - const ParsedExpressionKind GetKind() const final { + inline const ParsedExpressionKind GetKind() const final { return ParsedExpressionKind::PeriodIndexer; } - const ParsedExpression *GetIndexer() const { + inline const ParsedExpression *GetIndexer() const { return _indexerExpression; } - const HashedString &GetIndex() const { + inline const HashedString &GetIndex() const { return _index; } }; @@ -327,11 +327,11 @@ namespace Porygon::Parser { } } - const vector *GetExpressions() const { + inline const vector *GetExpressions() const { return &_expressions; } - const ParsedExpressionKind GetKind() const final { + inline const ParsedExpressionKind GetKind() const final { return ParsedExpressionKind::NumericalTable; } }; diff --git a/src/Parser/ParsedStatements/ParsedStatement.hpp b/src/Parser/ParsedStatements/ParsedStatement.hpp index e08540f..d9729d5 100644 --- a/src/Parser/ParsedStatements/ParsedStatement.hpp +++ b/src/Parser/ParsedStatements/ParsedStatement.hpp @@ -56,7 +56,7 @@ namespace Porygon::Parser { public: ParsedBadStatement(unsigned int start, unsigned int length) : ParsedStatement(start, length) {}; - const ParsedStatementKind GetKind() const final { + inline const ParsedStatementKind GetKind() const final { return ParsedStatementKind::Bad; } }; @@ -65,7 +65,7 @@ namespace Porygon::Parser { public: ParsedBreakStatement(unsigned int start, unsigned int length) : ParsedStatement(start, length) {}; - const ParsedStatementKind GetKind() const final { + inline const ParsedStatementKind GetKind() const final { return ParsedStatementKind::Break; } }; @@ -89,11 +89,11 @@ namespace Porygon::Parser { } } - const ParsedStatementKind GetKind() const override { + inline const ParsedStatementKind GetKind() const override { return ParsedStatementKind::Block; } - const std::vector *GetStatements() const { + inline const std::vector *GetStatements() const { return &_statements; } }; @@ -103,7 +103,7 @@ namespace Porygon::Parser { explicit ParsedScriptStatement(vector statements) : ParsedBlockStatement( move(statements)) {} - const ParsedStatementKind GetKind() const final { + inline const ParsedStatementKind GetKind() const final { return ParsedStatementKind::Script; } }; @@ -120,15 +120,15 @@ namespace Porygon::Parser { delete _expression; } - void NullifyExpression(){ + inline void NullifyExpression(){ _expression = nullptr; } - const ParsedStatementKind GetKind() const final { + inline const ParsedStatementKind GetKind() const final { return ParsedStatementKind::Expression; } - const ParsedExpression *GetExpression() const { + inline const ParsedExpression *GetExpression() const { return _expression; } }; @@ -151,19 +151,19 @@ namespace Porygon::Parser { delete _block; } - const ParsedStatementKind GetKind() const final { + inline const ParsedStatementKind GetKind() const final { return ParsedStatementKind::FunctionDeclaration; } - const HashedString GetIdentifier() const { + inline const HashedString GetIdentifier() const { return _identifier; } - const vector *GetParameters() const { + inline const vector *GetParameters() const { return &_parameters; } - const ParsedBlockStatement *GetBlock() const { + inline const ParsedBlockStatement *GetBlock() const { return _block; } }; @@ -182,19 +182,19 @@ namespace Porygon::Parser { delete _expression; } - const ParsedStatementKind GetKind() const final { + inline const ParsedStatementKind GetKind() const final { return ParsedStatementKind::Assignment; } - const bool IsLocal() const { + inline const bool IsLocal() const { return _local; } - const HashedString GetIdentifier() const { + inline const HashedString GetIdentifier() const { return _identifier; } - const ParsedExpression *GetExpression() const { + inline const ParsedExpression *GetExpression() const { return _expression; } }; @@ -214,15 +214,15 @@ namespace Porygon::Parser { delete _valueExpression; } - const ParsedStatementKind GetKind() const final { + inline const ParsedStatementKind GetKind() const final { return ParsedStatementKind::IndexAssignment; } - const ParsedExpression *GetIndexExpression() const { + inline const ParsedExpression *GetIndexExpression() const { return _indexExpression; } - const ParsedExpression *GetValueExpression() const { + inline const ParsedExpression *GetValueExpression() const { return _valueExpression; } }; @@ -239,11 +239,11 @@ namespace Porygon::Parser { delete _expression; } - const ParsedStatementKind GetKind() const final { + inline const ParsedStatementKind GetKind() const final { return ParsedStatementKind::Return; } - const ParsedExpression *GetExpression() const { + inline const ParsedExpression *GetExpression() const { return _expression; } }; @@ -273,19 +273,19 @@ namespace Porygon::Parser { delete _elseStatement; } - const ParsedStatementKind GetKind() const final { + inline const ParsedStatementKind GetKind() const final { return ParsedStatementKind::Conditional; } - const ParsedExpression *GetCondition() const { + inline const ParsedExpression *GetCondition() const { return _condition; } - const ParsedStatement *GetBlock() const { + inline const ParsedStatement *GetBlock() const { return _block; } - const ParsedStatement *GetElseStatement() const { + inline const ParsedStatement *GetElseStatement() const { return _elseStatement; } }; @@ -310,27 +310,27 @@ namespace Porygon::Parser { delete _block; } - const ParsedStatementKind GetKind() const final { + inline const ParsedStatementKind GetKind() const final { return ParsedStatementKind::NumericalFor; } - const HashedString GetIdentifier() const{ + inline const HashedString GetIdentifier() const{ return _identifier; } - const ParsedExpression *GetStart() const{ + inline const ParsedExpression *GetStart() const{ return _start; } - const ParsedExpression *GetEnd() const{ + inline const ParsedExpression *GetEnd() const{ return _end; } - const ParsedExpression *GetStep() const{ + inline const ParsedExpression *GetStep() const{ return _step; } - const ParsedStatement *GetBlock() const{ + inline const ParsedStatement *GetBlock() const{ return _block; } }; @@ -352,23 +352,23 @@ namespace Porygon::Parser { delete _block; } - const ParsedStatementKind GetKind() const final { + inline const ParsedStatementKind GetKind() const final { return ParsedStatementKind::GenericFor; } - const HashedString GetKeyIdentifier() const{ + inline const HashedString GetKeyIdentifier() const{ return _keyIdentifier; } - const HashedString GetValueIdentifier() const{ + inline const HashedString GetValueIdentifier() const{ return _valueIdentifier; } - const ParsedExpression* GetIteratorExpression() const{ + inline const ParsedExpression* GetIteratorExpression() const{ return _iteratorExpression; } - const ParsedStatement* GetBlock() const{ + inline const ParsedStatement* GetBlock() const{ return _block; } }; @@ -386,15 +386,15 @@ namespace Porygon::Parser { delete _block; } - const ParsedStatementKind GetKind() const final { + inline const ParsedStatementKind GetKind() const final { return ParsedStatementKind::While; } - const ParsedExpression* GetCondition(){ + inline const ParsedExpression* GetCondition(){ return _condition; } - const ParsedStatement* GetBlock(){ + inline const ParsedStatement* GetBlock(){ return _block; } }; diff --git a/src/Parser/Parser.cpp b/src/Parser/Parser.cpp index 8d20fe1..826dfcf 100644 --- a/src/Parser/Parser.cpp +++ b/src/Parser/Parser.cpp @@ -20,20 +20,20 @@ namespace Porygon::Parser { return new ParsedScriptStatement(statements); } - const IToken *Parser::Peek() { + inline const Token *Parser::Peek() { return this->_tokens[_position]; } - const IToken *Parser::PeekAt(int offset) { + inline const Token *Parser::PeekAt(int offset) { return this->_tokens[_position + offset]; } - const IToken *Parser::Next() { + inline const Token *Parser::Next() { this->_position++; return this->_tokens[_position - 1]; } - ParsedStatement *Parser::ParseStatement(const IToken *current) { + ParsedStatement *Parser::ParseStatement(const Token *current) { auto currentKind = current->GetKind(); switch (currentKind) { case TokenKind::LocalKeyword: @@ -65,9 +65,9 @@ namespace Porygon::Parser { return new ParsedExpressionStatement(expression); } - ParsedStatement *Parser::ParseVariableAssignment(const IToken *current) { + ParsedStatement *Parser::ParseVariableAssignment(const Token *current) { bool isLocal = false; - const IToken *identifier; + const Token *identifier; if (current->GetKind() == TokenKind::LocalKeyword) { isLocal = true; identifier = this->Next(); @@ -125,7 +125,7 @@ namespace Porygon::Parser { return new ParsedBlockStatement(statements); } - ParsedStatement *Parser::ParseFunctionDeclaration(const IToken *current) { + ParsedStatement *Parser::ParseFunctionDeclaration(const Token *current) { auto functionIdentifierToken = this->Next(); auto openParenthesis = this->Next(); vector parameters; @@ -196,7 +196,7 @@ namespace Porygon::Parser { block->GetEndPosition() - start); } - ParsedStatement *Parser::ParseReturnStatement(const IToken *current) { + ParsedStatement *Parser::ParseReturnStatement(const Token *current) { auto start = current->GetStartPosition(); auto startLine = this -> ScriptData -> Diagnostics ->GetLineFromPosition(start); if (startLine != this -> ScriptData -> Diagnostics -> GetLineFromPosition(this -> Peek() -> GetStartPosition())){ @@ -206,7 +206,7 @@ namespace Porygon::Parser { return new ParsedReturnStatement(expression, start, expression->GetEndPosition() - start); } - ParsedStatement *Parser::ParseIfStatement(const IToken *current) { + ParsedStatement *Parser::ParseIfStatement(const Token *current) { auto condition = this->ParseExpression(this->Next()); auto next = this->Next(); if (next->GetKind() != TokenKind::ThenKeyword) { @@ -238,7 +238,7 @@ namespace Porygon::Parser { } } - ParsedStatement *Parser::ParseNumericForStatement(const IToken *current) { + ParsedStatement *Parser::ParseNumericForStatement(const Token *current) { auto identifier = dynamic_cast(current); this->Next(); // consume assignment token bool hasErrors = false; @@ -270,7 +270,7 @@ namespace Porygon::Parser { } - ParsedStatement *Parser::ParseGenericForStatement(const IToken *current) { + ParsedStatement *Parser::ParseGenericForStatement(const Token *current) { auto keyIdentifier = dynamic_cast(current)->GetValue(); const IdentifierToken* valueIdentifierToken = nullptr; bool hasErrors = false; @@ -314,7 +314,7 @@ namespace Porygon::Parser { } } - ParsedStatement *Parser::ParseWhileStatement(const IToken *current) { + ParsedStatement *Parser::ParseWhileStatement(const Token *current) { auto condition = this -> ParseExpression(this -> Next()); auto doKeyword = this -> Next(); if (doKeyword -> GetKind() != TokenKind::DoKeyword){ @@ -331,7 +331,7 @@ namespace Porygon::Parser { // Expressions // ///////////////// - ParsedExpression *Parser::ParseExpression(const IToken *current) { + ParsedExpression *Parser::ParseExpression(const Token *current) { auto expression = this->ParseBinaryExpression(current, OperatorPrecedence::No); auto peekKind = this->Peek()->GetKind(); while (peekKind == TokenKind::OpenParenthesis || @@ -447,7 +447,7 @@ namespace Porygon::Parser { } } - ParsedExpression *Parser::ParseBinaryExpression(const IToken *current, OperatorPrecedence parentPrecedence) { + ParsedExpression *Parser::ParseBinaryExpression(const Token *current, OperatorPrecedence parentPrecedence) { OperatorPrecedence unaryPrecedence = GetUnaryPrecedence(current->GetKind()); ParsedExpression *left; if (unaryPrecedence != OperatorPrecedence::No && unaryPrecedence >= parentPrecedence) { @@ -474,7 +474,7 @@ namespace Porygon::Parser { return left; } - ParsedExpression *Parser::ParsePrimaryExpression(const IToken *current) { + ParsedExpression *Parser::ParsePrimaryExpression(const Token *current) { switch (current->GetKind()) { case TokenKind::Integer: return new LiteralIntegerExpression(dynamic_cast(current)); @@ -502,7 +502,7 @@ namespace Porygon::Parser { } } - ParsedExpression *Parser::ParseParenthesizedExpression(const IToken *current) { + ParsedExpression *Parser::ParseParenthesizedExpression(const Token *current) { auto next = this->Next(); auto expression = this->ParseExpression(next); auto closeToken = this->Next(); @@ -571,7 +571,7 @@ namespace Porygon::Parser { } - ParsedExpression *Parser::ParseTableExpression(const IToken *current) { + ParsedExpression *Parser::ParseTableExpression(const Token *current) { if (this->Peek()->GetKind() == TokenKind::CloseCurlyBracket) { this->Next(); auto start = current->GetStartPosition(); diff --git a/src/Parser/Parser.hpp b/src/Parser/Parser.hpp index cfb96d5..503ca86 100644 --- a/src/Parser/Parser.hpp +++ b/src/Parser/Parser.hpp @@ -1,3 +1,5 @@ +#include + #ifndef PORYGONLANG_PARSER_HPP #define PORYGONLANG_PARSER_HPP @@ -19,45 +21,45 @@ namespace Porygon::Parser { }; class Parser { - vector _tokens; + vector _tokens; unsigned int _position; Porygon::Script *ScriptData; - const IToken *Peek(); + const Token *Peek(); - const IToken *PeekAt(int offset); + const Token *PeekAt(int offset); - const IToken *Next(); + const Token *Next(); // Statements - ParsedStatement *ParseStatement(const IToken *current); - ParsedStatement *ParseVariableAssignment(const IToken *current); + ParsedStatement *ParseStatement(const Token *current); + ParsedStatement *ParseVariableAssignment(const Token *current); ParsedStatement *ParseIndexAssignment(ParsedExpression *indexer); ParsedBlockStatement *ParseBlock(const vector &endTokens, const vector &openStatements = {}); - ParsedStatement *ParseFunctionDeclaration(const IToken *current); - ParsedStatement *ParseReturnStatement(const IToken *current); - ParsedStatement *ParseIfStatement(const IToken *current); + ParsedStatement *ParseFunctionDeclaration(const Token *current); + ParsedStatement *ParseReturnStatement(const Token *current); + ParsedStatement *ParseIfStatement(const Token *current); ParsedStatement *ParseForStatement(); - ParsedStatement *ParseNumericForStatement(const IToken *current); - ParsedStatement *ParseGenericForStatement(const IToken *current); - ParsedStatement *ParseWhileStatement(const IToken *current); + ParsedStatement *ParseNumericForStatement(const Token *current); + ParsedStatement *ParseGenericForStatement(const Token *current); + ParsedStatement *ParseWhileStatement(const Token *current); // Expressions - ParsedExpression *ParseExpression(const IToken *current); - ParsedExpression *ParseBinaryExpression(const IToken *current, OperatorPrecedence parentPrecedence); - ParsedExpression *ParsePrimaryExpression(const IToken *current); - ParsedExpression *ParseParenthesizedExpression(const IToken *current); + ParsedExpression *ParseExpression(const Token *current); + ParsedExpression *ParseBinaryExpression(const Token *current, OperatorPrecedence parentPrecedence); + ParsedExpression *ParsePrimaryExpression(const Token *current); + ParsedExpression *ParseParenthesizedExpression(const Token *current); ParsedExpression *ParseFunctionCallExpression(ParsedExpression *functionExpression); ParsedExpression *ParseIndexExpression(ParsedExpression *indexingExpression); ParsedExpression *ParsePeriodIndexExpression(ParsedExpression *indexingExpression); - ParsedExpression *ParseTableExpression(const IToken *current); + ParsedExpression *ParseTableExpression(const Token *current); public: ParsedScriptStatement *Parse(); - explicit Parser(const vector &tokens, Porygon::Script *scriptData) : _tokens(tokens), _position(0), + explicit Parser(vector tokens, Porygon::Script *scriptData) : _tokens(std::move(tokens)), _position(0), ScriptData(scriptData){ } diff --git a/src/Parser/Token.hpp b/src/Parser/Token.hpp index ec70b1a..4c44da6 100644 --- a/src/Parser/Token.hpp +++ b/src/Parser/Token.hpp @@ -13,113 +13,113 @@ using namespace std; using namespace Porygon::Utilities; namespace Porygon::Parser { - class IToken { + class Token { const unsigned int _position; const unsigned int _length; public: virtual const TokenKind GetKind() const = 0; - IToken(unsigned int position, unsigned int length) + Token(unsigned int position, unsigned int length) : _position(position), _length(length) { } - const unsigned int GetStartPosition() const { + inline const unsigned int GetStartPosition() const { return _position; } - const unsigned int GetEndPosition() const { + inline const unsigned int GetEndPosition() const { return _position + _length - 1; } - const unsigned int GetLength() const { + inline const unsigned int GetLength() const { return _length; } - virtual ~IToken() = default; + virtual ~Token() = default; }; - class SimpleToken : public IToken { + class SimpleToken : public Token { const TokenKind _kind; public: explicit SimpleToken(TokenKind kind, unsigned int position, unsigned int length) - : IToken(position, length), + : Token(position, length), _kind(kind) { } - const TokenKind GetKind() const final { + inline const TokenKind GetKind() const final { return _kind; } }; - class IntegerToken : public IToken { + class IntegerToken : public Token { const long _value; public: explicit IntegerToken(long value, unsigned int position, unsigned int length) - : IToken(position, length), + : Token(position, length), _value(value) { } - const TokenKind GetKind() const final { + inline const TokenKind GetKind() const final { return TokenKind::Integer; } - const long GetValue() const { + inline const long GetValue() const { return _value; } }; - class FloatToken : public IToken { + class FloatToken : public Token { const double _value; public: explicit FloatToken(double value, unsigned int position, unsigned int length) - : IToken(position, length), + : Token(position, length), _value(value) { } - const TokenKind GetKind() const final { + inline const TokenKind GetKind() const final { return TokenKind::Float; } - const double GetValue() const { + inline const double GetValue() const { return _value; } }; - class StringToken : public IToken { + class StringToken : public Token { const u16string _value; public: explicit StringToken(u16string value, unsigned int position, unsigned int length) - : IToken(position, length), + : Token(position, length), _value(std::move(value)) { } - const TokenKind GetKind() const final { + inline const TokenKind GetKind() const final { return TokenKind::String; } - const u16string &GetValue() const { + inline const u16string &GetValue() const { return _value; } }; - class IdentifierToken : public IToken { + class IdentifierToken : public Token { const Utilities::HashedString _value; public: explicit IdentifierToken(const HashedString value, unsigned int position, unsigned int length) - : IToken(position, length), + : Token(position, length), _value(value) { } - const TokenKind GetKind() const final { + inline const TokenKind GetKind() const final { return TokenKind::Identifier; } - const HashedString GetValue() const { + inline const HashedString GetValue() const { return _value; } }; diff --git a/src/Parser/TypedVariableIdentifier.hpp b/src/Parser/TypedVariableIdentifier.hpp index e96ed71..b701e73 100644 --- a/src/Parser/TypedVariableIdentifier.hpp +++ b/src/Parser/TypedVariableIdentifier.hpp @@ -9,15 +9,15 @@ namespace Porygon::Parser { HashedString _type; HashedString _identifier; public: - TypedVariableIdentifier(HashedString type, HashedString identifier) + TypedVariableIdentifier(const HashedString& type, const HashedString& identifier) : _type(type), _identifier(identifier) { } - HashedString GetType() { + inline HashedString GetType() { return _type; } - HashedString GetIdentifier() { + inline HashedString GetIdentifier() { return _identifier; } }; diff --git a/src/Script.cpp b/src/Script.cpp index ecb9f92..f6e71c5 100644 --- a/src/Script.cpp +++ b/src/Script.cpp @@ -11,7 +11,7 @@ #include "Parser/Parser.hpp" #include "Binder/Binder.hpp" -Porygon::Script* Porygon::Script::Create(const u16string& script) { +inline Porygon::Script* Porygon::Script::Create(const u16string& script) { return new Script(script); } @@ -20,7 +20,7 @@ std::u16string To_UTF16(const string &s) std::wstring_convert, char16_t> conv; return conv.from_bytes(s); } -Porygon::Script *Porygon::Script::Create(const string &script) { +inline Porygon::Script *Porygon::Script::Create(const string &script) { return Script::Create(To_UTF16(script)); } @@ -65,7 +65,7 @@ void Porygon::Script::Parse(const u16string& script) { delete parseResult; } -EvalValue *Porygon::Script::GetVariable(const u16string &key) { +inline EvalValue *Porygon::Script::GetVariable(const u16string &key) { return _scriptVariables -> at(HashedString::CreateLookup(key)).get(); } @@ -74,7 +74,7 @@ bool Porygon::Script::HasVariable(const u16string &key) { return f != _scriptVariables->end(); } -EvalValue *Porygon::Script::GetLastValue() { +inline EvalValue *Porygon::Script::GetLastValue() { return _evaluator->GetLastValue(); } @@ -83,7 +83,7 @@ bool Porygon::Script::HasFunction(const u16string &key) { return f != _scriptVariables->end() && f.operator->()->second->GetTypeClass() == TypeClass ::Function; } -shared_ptr Porygon::Script::CallFunction(const u16string &key, const vector& variables) { +inline shared_ptr Porygon::Script::CallFunction(const u16string &key, const vector& variables) { auto var = (GenericFunctionEvalValue*)GetVariable(key); return this->_evaluator->EvaluateFunction(var, variables); } diff --git a/src/Script.hpp b/src/Script.hpp index 23486e7..4ac06a6 100644 --- a/src/Script.hpp +++ b/src/Script.hpp @@ -33,11 +33,11 @@ namespace Porygon{ ~Script(); - shared_ptr GetReturnType(){ + inline shared_ptr GetReturnType(){ return _returnType; } - void SetReturnType(shared_ptr t){ + inline void SetReturnType(shared_ptr t){ _returnType = std::move(t); } diff --git a/src/ScriptType.cpp b/src/ScriptType.cpp index c0e4607..de4e34a 100644 --- a/src/ScriptType.cpp +++ b/src/ScriptType.cpp @@ -2,7 +2,7 @@ #include "UserData/UserDataFunctionType.hpp" namespace Porygon{ - const bool ScriptType::CanBeIndexedWith(ScriptType *indexer) const{ + inline const bool ScriptType::CanBeIndexedWith(ScriptType *indexer) const{ return false; } diff --git a/src/ScriptType.hpp b/src/ScriptType.hpp index db2fb0f..c9a4830 100644 --- a/src/ScriptType.hpp +++ b/src/ScriptType.hpp @@ -81,11 +81,11 @@ namespace Porygon{ _isFloat = isFloat; } - const bool IsAwareOfFloat() const{ + inline const bool IsAwareOfFloat() const{ return _awareOfFloat; } - const bool IsFloat() const{ + inline const bool IsFloat() const{ return _isFloat; } }; @@ -106,15 +106,15 @@ namespace Porygon{ return !(num->IsAwareOfFloat() && num->IsFloat()); } - const shared_ptr GetIndexedType(ScriptType* indexer) const final{ + inline const shared_ptr GetIndexedType(ScriptType* indexer) const final{ return make_shared(false, 0); } - const bool IsKnownAtBind() const{ + inline const bool IsKnownAtBind() const{ return _isKnownAtBind; } - const uint32_t GetHashValue() const{ + inline const uint32_t GetHashValue() const{ return _hashValue; } }; @@ -134,14 +134,14 @@ namespace Porygon{ return !(num->IsAwareOfFloat() && num->IsFloat()); } - const shared_ptr GetIndexedType(ScriptType* indexer) const final{ + inline const shared_ptr GetIndexedType(ScriptType* indexer) const final{ return _valueType; } - const bool CanBeIterated() const final{ + inline const bool CanBeIterated() const final{ return true; } - shared_ptr GetIteratorKeyType() const final{ + inline shared_ptr GetIteratorKeyType() const final{ return make_shared(true, false); } }; diff --git a/src/StandardLibraries/StaticScope.hpp b/src/StandardLibraries/StaticScope.hpp index 7c552f8..64a276a 100644 --- a/src/StandardLibraries/StaticScope.hpp +++ b/src/StandardLibraries/StaticScope.hpp @@ -47,7 +47,7 @@ namespace Porygon::StandardLibraries{ return nullptr; } - static shared_ptr GetVariable(const Utilities::HashedString &identifier){ + inline static shared_ptr GetVariable(const Utilities::HashedString &identifier){ return _internal._variables[identifier]; } }; diff --git a/src/TableScriptType.hpp b/src/TableScriptType.hpp index be09760..b601a16 100644 --- a/src/TableScriptType.hpp +++ b/src/TableScriptType.hpp @@ -22,7 +22,7 @@ namespace Porygon{ delete _values; } - const bool CanBeIndexedWith(ScriptType* indexer) const final{ + inline const bool CanBeIndexedWith(ScriptType* indexer) const final{ return indexer->GetClass() == TypeClass ::String; } @@ -38,15 +38,15 @@ namespace Porygon{ throw "TODO: indexing with dynamic keys"; } - const shared_ptr GetIndexedType(uint32_t hash) const final{ + inline const shared_ptr GetIndexedType(uint32_t hash) const final{ return _values-> at(Utilities::HashedString::CreateLookup(hash))->GetType(); } - const map* GetValues() const{ + inline const map* GetValues() const{ return _values; } - const int GetLocalVariableCount() const{ + inline const int GetLocalVariableCount() const{ return _localVariableCount; } }; diff --git a/src/UserData/UserData.hpp b/src/UserData/UserData.hpp index f3c74fa..b76ff59 100644 --- a/src/UserData/UserData.hpp +++ b/src/UserData/UserData.hpp @@ -52,19 +52,19 @@ namespace Porygon::UserData { delete _concatenation; } - bool ContainsField(uint32_t fieldId) const{ + inline bool ContainsField(uint32_t fieldId) const{ return _fields.find(fieldId) != _fields.end(); } - UserDataField *GetField(uint32_t fieldId) const { + inline UserDataField *GetField(uint32_t fieldId) const { return _fields.at(fieldId); } - void CreateField(uint32_t fieldId, UserDataField *field) { + inline void CreateField(uint32_t fieldId, UserDataField *field) { _fields.insert({fieldId, field}); } - int32_t GetFieldCount() const{ + inline int32_t GetFieldCount() const{ return _fields.size(); } diff --git a/src/UserData/UserDataField.hpp b/src/UserData/UserDataField.hpp index ce320c5..8a92898 100644 --- a/src/UserData/UserDataField.hpp +++ b/src/UserData/UserDataField.hpp @@ -16,23 +16,23 @@ namespace Porygon::UserData{ : _type(shared_ptr(type)), _get(getter), _set(setter){ } - shared_ptr GetType(){ + inline shared_ptr GetType(){ return _type; } - bool HasGetter(){ + inline bool HasGetter(){ return _get != nullptr; } - Evaluation::EvalValue* Get(void* obj){ + inline Evaluation::EvalValue* Get(void* obj){ return this ->_get(obj); } - bool HasSetter(){ + inline bool HasSetter(){ return _set != nullptr; } - void Set(void* obj, Evaluation::EvalValue* val){ + inline void Set(void* obj, Evaluation::EvalValue* val){ this->_set(obj, val); } }; diff --git a/src/UserData/UserDataFunction.hpp b/src/UserData/UserDataFunction.hpp index 0714a41..d743651 100644 --- a/src/UserData/UserDataFunction.hpp +++ b/src/UserData/UserDataFunction.hpp @@ -27,7 +27,7 @@ namespace Porygon::UserData{ } - Evaluation::EvalValue* Call(Evaluation::EvalValue* parameters[], int parameterCount){ + inline Evaluation::EvalValue* Call(Evaluation::EvalValue* parameters[], int parameterCount){ return _call(_obj, parameters, parameterCount); } }; diff --git a/src/UserData/UserDataFunctionType.hpp b/src/UserData/UserDataFunctionType.hpp index 1530f7d..047f0cc 100644 --- a/src/UserData/UserDataFunctionType.hpp +++ b/src/UserData/UserDataFunctionType.hpp @@ -21,7 +21,7 @@ namespace Porygon::UserData{ return new UserDataFunctionOption(rt, p); } - static UserDataFunctionOption* FromRawPointers(ScriptType* returnType){ + inline static UserDataFunctionOption* FromRawPointers(ScriptType* returnType){ auto rt = shared_ptr(returnType); return new UserDataFunctionOption(rt, {}); } @@ -29,7 +29,7 @@ namespace Porygon::UserData{ - const bool IsScriptFunction() const final{ + inline const bool IsScriptFunction() const final{ return false; } }; diff --git a/src/UserData/UserDataOperation.hpp b/src/UserData/UserDataOperation.hpp index 59c4e53..b8515f1 100644 --- a/src/UserData/UserDataOperation.hpp +++ b/src/UserData/UserDataOperation.hpp @@ -23,11 +23,11 @@ namespace Porygon::UserData { return _func(_parent, b); } - const shared_ptr GetSecondParameterType() const{ + inline const shared_ptr GetSecondParameterType() const{ return _secondParameter; } - const shared_ptr GetReturnType() const{ + inline const shared_ptr GetReturnType() const{ return _returnType; } }; diff --git a/src/UserData/UserDataScriptType.hpp b/src/UserData/UserDataScriptType.hpp index eb67cf4..67cc24e 100644 --- a/src/UserData/UserDataScriptType.hpp +++ b/src/UserData/UserDataScriptType.hpp @@ -30,11 +30,11 @@ namespace Porygon::UserData { return _userData->ContainsField(str->GetHashValue()); } - const bool CanBeIndexedWithIdentifier(uint32_t hash) const final { + inline const bool CanBeIndexedWithIdentifier(uint32_t hash) const final { return _userData -> ContainsField(hash); } - UserDataField *GetField(uint32_t id) { + inline UserDataField *GetField(uint32_t id) { return _userData->GetField(id); } @@ -46,7 +46,7 @@ namespace Porygon::UserData { throw "TODO: indexing with dynamic keys"; } - const shared_ptr GetIndexedType(uint32_t hash) const final { + inline const shared_ptr GetIndexedType(uint32_t hash) const final { return _userData->GetField(hash)->GetType(); } }; diff --git a/src/UserData/UserDataStorage.hpp b/src/UserData/UserDataStorage.hpp index c7bd012..e266177 100644 --- a/src/UserData/UserDataStorage.hpp +++ b/src/UserData/UserDataStorage.hpp @@ -43,11 +43,11 @@ namespace Porygon::UserData { _internal._userData.clear(); } - static bool HasUserDataType(uint32_t i) { + inline static bool HasUserDataType(uint32_t i) { return UserDataStorage::_internal._userData.find(i) != UserDataStorage::_internal._userData.end(); } - static UserData* GetUserDataType(uint32_t i) { + inline static UserData* GetUserDataType(uint32_t i) { return UserDataStorage::_internal._userData[i]; } }; diff --git a/src/UserData/UserDataValue.hpp b/src/UserData/UserDataValue.hpp index 2343703..47f56d0 100644 --- a/src/UserData/UserDataValue.hpp +++ b/src/UserData/UserDataValue.hpp @@ -22,7 +22,7 @@ namespace Porygon::UserData { _obj = obj; } - const TypeClass GetTypeClass() const final { + inline const TypeClass GetTypeClass() const final { return TypeClass::UserData; } @@ -32,11 +32,11 @@ namespace Porygon::UserData { return _obj == ((UserDataValue *) b)->_obj; } - const shared_ptr Clone() const final { + inline const shared_ptr Clone() const final { return make_shared(_userData, _obj); } - const std::size_t GetHashCode() const final { + inline const std::size_t GetHashCode() const final { return reinterpret_cast(_obj); } @@ -46,7 +46,7 @@ namespace Porygon::UserData { return shared_ptr(field->Get(_obj)); } - const shared_ptr IndexValue(uint32_t hash) const final { + inline const shared_ptr IndexValue(uint32_t hash) const final { auto field = _userData->GetField(hash); return shared_ptr(field->Get(_obj)); } @@ -57,7 +57,7 @@ namespace Porygon::UserData { field->Set(_obj, value.get()); } - void* GetObjectPointer(){ + inline void* GetObjectPointer(){ return _obj; } }; diff --git a/src/Utilities/HashedString.hpp b/src/Utilities/HashedString.hpp index 520369a..5bb0f4a 100644 --- a/src/Utilities/HashedString.hpp +++ b/src/Utilities/HashedString.hpp @@ -22,45 +22,45 @@ namespace Porygon::Utilities{ _string(std::shared_ptr(s)) { } - static HashedString CreateLookup(const std::u16string& s){ + inline static HashedString CreateLookup(const std::u16string& s){ return HashedString(s); } - static HashedString CreateLookup(uint32_t hash){ + inline static HashedString CreateLookup(uint32_t hash){ return HashedString(hash); } HashedString(const HashedString& b) = default; - static uint32_t constexpr ConstHash(char16_t const *input) { + inline static uint32_t constexpr ConstHash(char16_t const *input) { return *input ? static_cast(*input) + 33 * ConstHash(input + 1) : 5381; } - static uint32_t constexpr ConstHash(char const *input) { + inline static uint32_t constexpr ConstHash(char const *input) { return *input ? static_cast(*input) + 33 * ConstHash(input + 1) : 5381; } - const uint32_t GetHash() const{ + inline const uint32_t GetHash() const{ return _hash; } - const std::shared_ptr GetString() const{ + inline const std::shared_ptr GetString() const{ return _string; } - bool operator==(const HashedString& b) const{ + inline bool operator==(const HashedString& b) const{ return _hash == b._hash; } - bool operator!=(const HashedString& b) const{ + inline bool operator!=(const HashedString& b) const{ return _hash != b._hash; } - bool operator<(const HashedString& b) const{ + inline bool operator<(const HashedString& b) const{ return _hash < b._hash; } - bool operator>(const HashedString& b) const{ + inline bool operator>(const HashedString& b) const{ return _hash > b._hash; } diff --git a/src/Utilities/StringUtils.hpp b/src/Utilities/StringUtils.hpp index b00c06a..70accbd 100644 --- a/src/Utilities/StringUtils.hpp +++ b/src/Utilities/StringUtils.hpp @@ -13,17 +13,17 @@ namespace Porygon::Utilities{ private: static std::wstring_convert, char16_t> to_16; public: - static std::u16string IntToString(long const &i) { + inline static std::u16string IntToString(long const &i) { return to_16.from_bytes(std::to_string(i)); } - static std::u16string ToUTF8(const std::string &s) { + inline static std::u16string ToUTF8(const std::string &s) { return to_16.from_bytes(s); } - static std::string FromUTF8(const std::u16string &s) { + inline static std::string FromUTF8(const std::u16string &s) { return to_16.to_bytes(s); } - static int64_t ParseInteger(const std::u16string &s){ + inline static int64_t ParseInteger(const std::u16string &s){ auto parsed = std::stol(FromUTF8(s)); return parsed; } diff --git a/tests/parser/LexerTests.cpp b/tests/parser/LexerTests.cpp index 4d9a8a6..3f3dfd4 100644 --- a/tests/parser/LexerTests.cpp +++ b/tests/parser/LexerTests.cpp @@ -77,7 +77,7 @@ TEST_CASE( "Lex Equality Token", "[lexer]" ) { Lexer lexer = Lexer(u"==", nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::EqualityToken); for (auto t: tokens){ delete t; @@ -117,7 +117,7 @@ TEST_CASE( "Lex Longer Integers", "[lexer]" ) { Lexer lexer = Lexer(s, nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::Integer); auto* integerToken = (IntegerToken *)firstToken; CHECK(integerToken -> GetValue() == integer); @@ -139,7 +139,7 @@ TEST_CASE( "Lex Floats", "[lexer]" ) { Lexer lexer = Lexer(s, nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::Float); auto* floatToken = (FloatToken *)firstToken; CHECK(floatToken -> GetValue() == Approx(f)); @@ -154,7 +154,7 @@ TEST_CASE( "Lex And Keyword", "[lexer]" ) { Lexer lexer = Lexer(u"and", nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::AndKeyword); for (auto t: tokens){ delete t; @@ -164,7 +164,7 @@ TEST_CASE( "Lex Break Keyword", "[lexer]" ) { Lexer lexer = Lexer(u"break", nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::BreakKeyword); for (auto t: tokens){ delete t; @@ -174,7 +174,7 @@ TEST_CASE( "Lex Do Keyword", "[lexer]" ) { Lexer lexer = Lexer(u"do", nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::DoKeyword); for (auto t: tokens){ delete t; @@ -184,7 +184,7 @@ TEST_CASE( "Lex else Keyword", "[lexer]" ) { Lexer lexer = Lexer(u"else", nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::ElseKeyword); for (auto t: tokens){ delete t; @@ -194,7 +194,7 @@ TEST_CASE( "Lex else if Keyword", "[lexer]" ) { Lexer lexer = Lexer(u"elseif", nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::ElseIfKeyword); for (auto t: tokens){ delete t; @@ -204,7 +204,7 @@ TEST_CASE( "Lex end Keyword", "[lexer]" ) { Lexer lexer = Lexer(u"end", nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::EndKeyword); for (auto t: tokens){ delete t; @@ -214,7 +214,7 @@ TEST_CASE( "Lex false Keyword", "[lexer]" ) { Lexer lexer = Lexer(u"false", nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::FalseKeyword); for (auto t: tokens){ delete t; @@ -224,7 +224,7 @@ TEST_CASE( "Lex for Keyword", "[lexer]" ) { Lexer lexer = Lexer(u"for", nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::ForKeyword); for (auto t: tokens){ delete t; @@ -235,7 +235,7 @@ TEST_CASE( "Lex function Keyword", "[lexer]" ) { Lexer lexer = Lexer(*s, nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::FunctionKeyword); for (auto t: tokens){ delete t; @@ -246,7 +246,7 @@ TEST_CASE( "Lex if Keyword", "[lexer]" ) { Lexer lexer = Lexer(u"if", nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::IfKeyword); for (auto t: tokens){ delete t; @@ -256,7 +256,7 @@ TEST_CASE( "Lex in Keyword", "[lexer]" ) { Lexer lexer = Lexer(u"in", nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::InKeyword); for (auto t: tokens){ delete t; @@ -266,7 +266,7 @@ TEST_CASE( "Lex local Keyword", "[lexer]" ) { Lexer lexer = Lexer(u"local", nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::LocalKeyword); for (auto t: tokens){ delete t; @@ -276,7 +276,7 @@ TEST_CASE( "Lex nil Keyword", "[lexer]" ) { Lexer lexer = Lexer(u"nil", nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::NilKeyword); for (auto t: tokens){ delete t; @@ -286,7 +286,7 @@ TEST_CASE( "Lex not Keyword", "[lexer]" ) { Lexer lexer = Lexer(u"not", nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::NotKeyword); for (auto t: tokens){ delete t; @@ -296,7 +296,7 @@ TEST_CASE( "Lex or Keyword", "[lexer]" ) { Lexer lexer = Lexer(u"or", nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::OrKeyword); for (auto t: tokens){ delete t; @@ -306,7 +306,7 @@ TEST_CASE( "Lex return Keyword", "[lexer]" ) { Lexer lexer = Lexer(u"return", nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::ReturnKeyword); for (auto t: tokens){ delete t; @@ -316,7 +316,7 @@ TEST_CASE( "Lex then Keyword", "[lexer]" ) { Lexer lexer = Lexer(u"then", nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::ThenKeyword); for (auto t: tokens){ delete t; @@ -326,7 +326,7 @@ TEST_CASE( "Lex true Keyword", "[lexer]" ) { Lexer lexer = Lexer(u"true", nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::TrueKeyword); for (auto t: tokens){ delete t; @@ -336,7 +336,7 @@ TEST_CASE( "Lex while Keyword", "[lexer]" ) { Lexer lexer = Lexer(u"while", nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::WhileKeyword); for (auto t: tokens){ delete t; @@ -347,7 +347,7 @@ TEST_CASE( "Lex identifier", "[lexer]" ) { Lexer lexer = Lexer(u"foo", nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::Identifier); REQUIRE(((IdentifierToken*)firstToken) -> GetValue() == HashedString::CreateLookup(u"foo")); for (auto t: tokens){ @@ -392,7 +392,7 @@ TEST_CASE("Lex Double Quote String", "[lexer]") { Lexer lexer = Lexer(*s, nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::String); REQUIRE(((StringToken*)firstToken) -> GetValue() == u"foo bar"); for (auto t: tokens){ @@ -406,7 +406,7 @@ TEST_CASE("Lex Single Quote String", "[lexer]") { Lexer lexer = Lexer(*s, nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::String); REQUIRE(((StringToken*)firstToken) -> GetValue() == u"foo bar"); for (auto t: tokens){ @@ -420,7 +420,7 @@ TEST_CASE("Lex Double Quote String, Escape Quote", "[lexer]") { Lexer lexer = Lexer(*s, nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::String); REQUIRE(((StringToken*)firstToken) -> GetValue() == u"foo\"bar"); for (auto t: tokens){ @@ -434,7 +434,7 @@ TEST_CASE("Lex String with newline", "[lexer]") { Lexer lexer = Lexer(*s, nullptr); auto tokens = lexer.Lex(); REQUIRE(tokens.size() == 2); - const IToken* firstToken = tokens[0]; + const Token* firstToken = tokens[0]; REQUIRE(firstToken -> GetKind() == TokenKind::String); REQUIRE(((StringToken*)firstToken) -> GetValue() == u"foo\nbar"); for (auto t: tokens){ diff --git a/tests/parser/ParserTests.cpp b/tests/parser/ParserTests.cpp index ff644e3..ee4ce3a 100644 --- a/tests/parser/ParserTests.cpp +++ b/tests/parser/ParserTests.cpp @@ -6,7 +6,7 @@ using namespace Porygon::Parser; TEST_CASE( "Parse single true keyword", "[parser]" ) { - vector v {new SimpleToken(TokenKind::TrueKeyword,0,0), new SimpleToken(TokenKind::EndOfFile,0,0)}; + vector v {new SimpleToken(TokenKind::TrueKeyword,0,0), new SimpleToken(TokenKind::EndOfFile,0,0)}; Parser parser = Parser(v, nullptr); auto parsedScript = parser.Parse(); auto parsedStatements = parsedScript -> GetStatements(); @@ -25,7 +25,7 @@ TEST_CASE( "Parse single true keyword", "[parser]" ) { } TEST_CASE( "Parse single false keyword", "[parser]" ) { - vector v {new SimpleToken(TokenKind::FalseKeyword,0,0), new SimpleToken(TokenKind::EndOfFile,0,0)}; + vector v {new SimpleToken(TokenKind::FalseKeyword,0,0), new SimpleToken(TokenKind::EndOfFile,0,0)}; Parser parser = Parser(v, nullptr); auto parsedScript = parser.Parse(); auto parsedStatements = parsedScript -> GetStatements(); @@ -44,7 +44,7 @@ TEST_CASE( "Parse single false keyword", "[parser]" ) { } TEST_CASE( "Parse simple addition", "[parser]" ) { - vector v { + vector v { new IntegerToken(5, 0, 0), new SimpleToken(TokenKind::PlusToken,0,0), new IntegerToken(10, 0, 0), @@ -74,7 +74,7 @@ TEST_CASE( "Parse simple addition", "[parser]" ) { } TEST_CASE( "Parse simple negation", "[parser]" ) { - vector v { + vector v { new SimpleToken(TokenKind::MinusToken,0,0), new IntegerToken(10, 0, 0), new SimpleToken(TokenKind::EndOfFile,0,0) @@ -99,7 +99,7 @@ TEST_CASE( "Parse simple negation", "[parser]" ) { } TEST_CASE( "Parse logical negation", "[parser]" ) { - vector v { + vector v { new SimpleToken(TokenKind::NotKeyword,0,0), new SimpleToken(TokenKind::FalseKeyword,0,0), new SimpleToken(TokenKind::EndOfFile,0,0) @@ -124,7 +124,7 @@ TEST_CASE( "Parse logical negation", "[parser]" ) { } TEST_CASE( "Are parenthesized expressions valid", "[parser]" ) { - vector v { + vector v { new IntegerToken(5, 0, 0), new SimpleToken(TokenKind::PlusToken,0,0), new IntegerToken(10, 0, 0), @@ -159,7 +159,7 @@ TEST_CASE( "Are parenthesized expressions valid", "[parser]" ) { } TEST_CASE( "Assert binary precedence", "[parser]" ) { - vector v { + vector v { new SimpleToken(TokenKind::OpenParenthesis,0,0), new IntegerToken(10, 0, 0), new SimpleToken(TokenKind::CloseParenthesis,0,0), @@ -183,7 +183,7 @@ TEST_CASE( "Assert binary precedence", "[parser]" ) { } TEST_CASE( "Parse String Tokens", "[parser]" ) { - vector v {new StringToken(u"foo bar", 0,0), new SimpleToken(TokenKind::EndOfFile,0,0)}; + vector v {new StringToken(u"foo bar", 0,0), new SimpleToken(TokenKind::EndOfFile,0,0)}; Parser parser = Parser(v, nullptr); auto parsedScript = parser.Parse(); auto parsedStatements = parsedScript -> GetStatements(); @@ -202,7 +202,7 @@ TEST_CASE( "Parse String Tokens", "[parser]" ) { } TEST_CASE( "Parse Global Assignment", "[parser]" ) { - vector v { + vector v { new IdentifierToken(HashedString::CreateLookup(u"foo"),0,0), new SimpleToken(TokenKind::AssignmentToken,0,0), new SimpleToken(TokenKind::TrueKeyword,0,0), @@ -226,7 +226,7 @@ TEST_CASE( "Parse Global Assignment", "[parser]" ) { } TEST_CASE( "Parse local Assignment", "[parser]" ) { - vector v { + vector v { new SimpleToken(TokenKind::LocalKeyword,0,0), new IdentifierToken(HashedString(new u16string(u"foo")),0,0), new SimpleToken(TokenKind::AssignmentToken,0,0), @@ -252,7 +252,7 @@ TEST_CASE( "Parse local Assignment", "[parser]" ) { } TEST_CASE( "Parse function declaration", "[parser]" ){ - vector v { + vector v { new SimpleToken(TokenKind::FunctionKeyword,0,0), new IdentifierToken(HashedString(new u16string(u"foo")),0,0), new SimpleToken(TokenKind::OpenParenthesis,0,0),