Make a lot of one-liner functions inline
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
bb0a6aba19
commit
32836c6c58
|
@ -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<ScriptType>(
|
||||
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<const BoundExpression *> *GetExpressions() const {
|
||||
inline const vector<const BoundExpression *> *GetExpressions() const {
|
||||
return &_expressions;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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<BoundExpression *> *GetParameters() const {
|
||||
inline const vector<BoundExpression *> *GetParameters() const {
|
||||
return &_parameters;
|
||||
}
|
||||
|
||||
const Porygon::GenericFunctionOption *GetFunctionOption() const {
|
||||
inline const Porygon::GenericFunctionOption *GetFunctionOption() const {
|
||||
return _option;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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<BoundBlockStatement> GetBlock() const {
|
||||
inline const std::shared_ptr<BoundBlockStatement> GetBlock() const {
|
||||
return _block;
|
||||
}
|
||||
|
||||
const std::shared_ptr<GenericFunctionScriptType> GetType() const {
|
||||
inline const std::shared_ptr<GenericFunctionScriptType> GetType() const {
|
||||
return _type;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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<BoundStatement *> *GetStatements() const {
|
||||
inline const vector<BoundStatement *> *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;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -36,11 +36,11 @@ namespace Porygon::Binder {
|
|||
|
||||
VariableAssignment AssignVariable(const Utilities::HashedString& identifier, const std::shared_ptr<ScriptType> &type);
|
||||
|
||||
size_t GetLocalVariableCount() {
|
||||
inline size_t GetLocalVariableCount() {
|
||||
return _localScope.size();
|
||||
}
|
||||
|
||||
int GetCurrentScope() {
|
||||
inline int GetCurrentScope() {
|
||||
return _currentScope;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -13,10 +13,10 @@ namespace Porygon::Binder {
|
|||
class BoundVariable {
|
||||
std::shared_ptr<ScriptType> _type;
|
||||
public:
|
||||
explicit BoundVariable(std::shared_ptr<ScriptType> type) : _type(std::move(type)) {
|
||||
inline explicit BoundVariable(std::shared_ptr<ScriptType> type) : _type(std::move(type)) {
|
||||
}
|
||||
|
||||
std::shared_ptr<ScriptType> GetType() {
|
||||
inline std::shared_ptr<ScriptType> GetType() {
|
||||
return _type;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -20,11 +20,11 @@ namespace Porygon::Binder {
|
|||
_key = key;
|
||||
}
|
||||
|
||||
VariableAssignmentResult GetResult() {
|
||||
inline VariableAssignmentResult GetResult() {
|
||||
return _result;
|
||||
}
|
||||
|
||||
BoundVariableKey *GetKey() {
|
||||
inline BoundVariableKey *GetKey() {
|
||||
return _key;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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<std::string> GetArguments(){
|
||||
inline std::vector<std::string> 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;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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<string> arguments) {
|
||||
inline void DiagnosticsHolder::LogError(DiagnosticCode code, unsigned int start, unsigned int length, std::vector<string> arguments) {
|
||||
Log(DiagnosticSeverity::Error, code, start, length, std::move(arguments));
|
||||
}
|
||||
|
||||
void DiagnosticsHolder::LogWarning(DiagnosticCode code, unsigned int start, unsigned int length, std::vector<string> arguments) {
|
||||
inline void DiagnosticsHolder::LogWarning(DiagnosticCode code, unsigned int start, unsigned int length, std::vector<string> arguments) {
|
||||
Log(DiagnosticSeverity::Warning, code, start, length, std::move(arguments));
|
||||
}
|
||||
|
||||
void DiagnosticsHolder::LogInfo(DiagnosticCode code, unsigned int start, unsigned int length, std::vector<string> arguments) {
|
||||
inline void DiagnosticsHolder::LogInfo(DiagnosticCode code, unsigned int start, unsigned int length, std::vector<string> 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];
|
||||
}
|
||||
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
|
@ -73,15 +73,15 @@ namespace Porygon::Evaluation {
|
|||
: _value(val) {
|
||||
}
|
||||
|
||||
const shared_ptr<EvalValue> Clone() const final {
|
||||
inline const shared_ptr<EvalValue> Clone() const final {
|
||||
return make_shared<BooleanEvalValue>(_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;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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<EvalValue> Clone() const final{
|
||||
inline const shared_ptr<EvalValue> Clone() const final{
|
||||
return make_shared<NilEvalValue>();
|
||||
}
|
||||
|
||||
const std::size_t GetHashCode() const final{
|
||||
inline const std::size_t GetHashCode() const final{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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<EvalValue> Clone() const final {
|
||||
inline const shared_ptr<EvalValue> Clone() const final {
|
||||
return make_shared<IntegerEvalValue>(_value);
|
||||
}
|
||||
|
||||
const std::size_t GetHashCode() const final {
|
||||
inline const std::size_t GetHashCode() const final {
|
||||
return std::hash<long>{}(_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<EvalValue> Clone() const final {
|
||||
inline const shared_ptr<EvalValue> Clone() const final {
|
||||
return make_shared<FloatEvalValue>(_value);
|
||||
}
|
||||
|
||||
const std::size_t GetHashCode() const final {
|
||||
inline const std::size_t GetHashCode() const final {
|
||||
return std::hash<double>{}(_value);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<EvalValue> Clone() const final {
|
||||
inline const shared_ptr<EvalValue> Clone() const final {
|
||||
return shared_ptr<EvalValue>(new NumericalTableEvalValue(_table, _hash));
|
||||
}
|
||||
|
||||
const shared_ptr<EvalValue> IndexValue(EvalValue *val) const final {
|
||||
inline const shared_ptr<EvalValue> IndexValue(EvalValue *val) const final {
|
||||
const auto index = val->EvaluateInteger() - 1;
|
||||
return this->_table->at(index);
|
||||
}
|
||||
|
||||
const shared_ptr<EvalValue> IndexValue(uint32_t hash) const final {
|
||||
inline const shared_ptr<EvalValue> IndexValue(uint32_t hash) const final {
|
||||
return this->_table->at(hash - 1);
|
||||
}
|
||||
|
||||
void SetIndexValue(EvalValue *key, const shared_ptr<EvalValue> &value) const final {
|
||||
inline void SetIndexValue(EvalValue *key, const shared_ptr<EvalValue> &value) const final {
|
||||
auto index = key->EvaluateInteger();
|
||||
this->_table->at(index - 1) = value;
|
||||
}
|
||||
|
||||
Iterator * GetKeyIterator() const final;
|
||||
|
||||
const shared_ptr<vector<shared_ptr<EvalValue>>> GetTable() const{
|
||||
inline const shared_ptr<vector<shared_ptr<EvalValue>>> GetTable() const{
|
||||
return _table;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -29,11 +29,11 @@ namespace Porygon::Evaluation {
|
|||
}
|
||||
~EvaluationScriptFunctionOption() final = default;
|
||||
|
||||
const std::shared_ptr<BoundBlockStatement> &GetInnerBlock() const {
|
||||
inline const std::shared_ptr<BoundBlockStatement> &GetInnerBlock() const {
|
||||
return _innerBlock;
|
||||
}
|
||||
|
||||
const std::shared_ptr<EvaluationScope> &GetScope() const {
|
||||
inline const std::shared_ptr<EvaluationScope> &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<GenericFunctionOption>(option));
|
||||
}
|
||||
|
||||
const std::shared_ptr<ScriptType> GetType() const {
|
||||
inline const std::shared_ptr<ScriptType> 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<GenericFunctionOption> GetOption(const size_t id) const{
|
||||
inline const shared_ptr<GenericFunctionOption> GetOption(const size_t id) const{
|
||||
return this->_options.at(id);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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<EvalValue> Clone() const final {
|
||||
inline const shared_ptr<EvalValue> Clone() const final {
|
||||
return make_shared<StringEvalValue>(_value);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ namespace Porygon::Evaluation {
|
|||
return make_shared<StringEvalValue>(u16string(1, _value[l]));
|
||||
}
|
||||
|
||||
const std::size_t GetHashCode() const final {
|
||||
inline const std::size_t GetHashCode() const final {
|
||||
return _hash;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<EvalValue> Clone() const final {
|
||||
inline const shared_ptr<EvalValue> Clone() const final {
|
||||
return shared_ptr<EvalValue>(new TableEvalValue(_table, _hash));
|
||||
}
|
||||
|
||||
const shared_ptr<EvalValue> IndexValue(EvalValue *val) const final {
|
||||
inline const shared_ptr<EvalValue> IndexValue(EvalValue *val) const final {
|
||||
const auto stringKey = val->EvaluateString();
|
||||
return this->_table->at(Utilities::HashedString::CreateLookup(stringKey));
|
||||
}
|
||||
|
||||
const shared_ptr<EvalValue> IndexValue(uint32_t hash) const final {
|
||||
inline const shared_ptr<EvalValue> IndexValue(uint32_t hash) const final {
|
||||
return this->_table->at(Utilities::HashedString::CreateLookup(hash));
|
||||
}
|
||||
|
||||
const shared_ptr<EvalValue> IndexValue(const char *val) const {
|
||||
inline const shared_ptr<EvalValue> 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<EvalValue> &value) const final {
|
||||
inline void SetIndexValue(EvalValue *key, const shared_ptr<EvalValue> &value) const final {
|
||||
auto hash = key->GetHashCode();
|
||||
this->_table->at(Utilities::HashedString::CreateLookup(hash)) = value;
|
||||
}
|
||||
|
||||
Iterator * GetKeyIterator() const final;
|
||||
|
||||
const _Rb_tree_const_iterator<pair<const Utilities::HashedString, shared_ptr<EvalValue>>> GetTableIterator() const{
|
||||
inline const _Rb_tree_const_iterator<pair<const Utilities::HashedString, shared_ptr<EvalValue>>> GetTableIterator() const{
|
||||
return _table->cbegin();
|
||||
};
|
||||
const _Rb_tree_const_iterator<pair<const Utilities::HashedString, shared_ptr<EvalValue>>> GetTableIteratorEnd() const{
|
||||
inline const _Rb_tree_const_iterator<pair<const Utilities::HashedString, shared_ptr<EvalValue>>> GetTableIteratorEnd() const{
|
||||
return _table->cend();
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -16,16 +16,16 @@ namespace Porygon::Evaluation{
|
|||
explicit NumericalKeyIterator(const NumericalTableEvalValue* table)
|
||||
: _vec(table->GetTable()), _size(_vec->size() + 1){}
|
||||
|
||||
shared_ptr<EvalValue> GetCurrent() final{
|
||||
inline shared_ptr<EvalValue> GetCurrent() final{
|
||||
return make_shared<IntegerEvalValue>(_position);
|
||||
}
|
||||
|
||||
bool MoveNext() final{
|
||||
inline bool MoveNext() final{
|
||||
_position++;
|
||||
return _position != _size;
|
||||
}
|
||||
|
||||
void Reset() final{
|
||||
inline void Reset() final{
|
||||
_position = 0;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Porygon::Evaluation{
|
|||
explicit TableKeyIterator(const TableEvalValue* table)
|
||||
: _iterator(table->GetTableIterator()), _end(table->GetTableIteratorEnd()){}
|
||||
|
||||
shared_ptr<EvalValue> GetCurrent() final{
|
||||
inline shared_ptr<EvalValue> GetCurrent() final{
|
||||
return make_shared<StringEvalValue>(*_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");
|
||||
}
|
||||
};
|
||||
|
|
|
@ -17,19 +17,19 @@ namespace Porygon {
|
|||
|
||||
virtual ~GenericFunctionOption() = default;
|
||||
|
||||
const shared_ptr<ScriptType> GetReturnType() const {
|
||||
inline const shared_ptr<ScriptType> GetReturnType() const {
|
||||
return _returnType;
|
||||
}
|
||||
|
||||
void SetOption(size_t v){
|
||||
inline void SetOption(size_t v){
|
||||
_option = v;
|
||||
}
|
||||
|
||||
void SetReturnType(shared_ptr<ScriptType> t) {
|
||||
inline void SetReturnType(shared_ptr<ScriptType> t) {
|
||||
_returnType = move(t);
|
||||
}
|
||||
|
||||
const vector<shared_ptr<ScriptType>> GetParameterTypes() const {
|
||||
inline const vector<shared_ptr<ScriptType>> 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<shared_ptr<Porygon::Binder::BoundVariableKey>> GetParameterKeys() const {
|
||||
inline const vector<shared_ptr<Porygon::Binder::BoundVariableKey>> GetParameterKeys() const {
|
||||
return _parameterKeys;
|
||||
}
|
||||
|
||||
const bool IsScriptFunction() const final {
|
||||
inline const bool IsScriptFunction() const final {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,10 +14,10 @@ namespace Porygon::Parser {
|
|||
}
|
||||
|
||||
|
||||
vector<const IToken *> Lexer::Lex() {
|
||||
vector<const IToken *> tokens;
|
||||
vector<const Token *> Lexer::Lex() {
|
||||
vector<const Token *> 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;
|
||||
|
|
|
@ -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<const IToken*> Lex();
|
||||
vector<const Token*> Lex();
|
||||
explicit Lexer(const u16string& scriptString, Porygon::Script* script);
|
||||
|
||||
};
|
||||
|
|
|
@ -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<const ParsedExpression *> *GetParameters() const {
|
||||
inline const vector<const ParsedExpression *> *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<const ParsedExpression *> *GetExpressions() const {
|
||||
inline const vector<const ParsedExpression *> *GetExpressions() const {
|
||||
return &_expressions;
|
||||
}
|
||||
|
||||
const ParsedExpressionKind GetKind() const final {
|
||||
inline const ParsedExpressionKind GetKind() const final {
|
||||
return ParsedExpressionKind::NumericalTable;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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<const ParsedStatement *> *GetStatements() const {
|
||||
inline const std::vector<const ParsedStatement *> *GetStatements() const {
|
||||
return &_statements;
|
||||
}
|
||||
};
|
||||
|
@ -103,7 +103,7 @@ namespace Porygon::Parser {
|
|||
explicit ParsedScriptStatement(vector<const ParsedStatement *> 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<TypedVariableIdentifier *> *GetParameters() const {
|
||||
inline const vector<TypedVariableIdentifier *> *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;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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<TypedVariableIdentifier *> 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<const IdentifierToken*>(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<const IdentifierToken*>(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<const IntegerToken*>(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();
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#include <utility>
|
||||
|
||||
|
||||
#ifndef PORYGONLANG_PARSER_HPP
|
||||
#define PORYGONLANG_PARSER_HPP
|
||||
|
@ -19,45 +21,45 @@ namespace Porygon::Parser {
|
|||
};
|
||||
|
||||
class Parser {
|
||||
vector<const IToken *> _tokens;
|
||||
vector<const Token *> _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<TokenKind> &endTokens, const vector<const ParsedStatement *> &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<const IToken *> &tokens, Porygon::Script *scriptData) : _tokens(tokens), _position(0),
|
||||
explicit Parser(vector<const Token *> tokens, Porygon::Script *scriptData) : _tokens(std::move(tokens)), _position(0),
|
||||
ScriptData(scriptData){
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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<std::codecvt_utf8_utf16<char16_t>, 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<EvalValue> Porygon::Script::CallFunction(const u16string &key, const vector<EvalValue *>& variables) {
|
||||
inline shared_ptr<EvalValue> Porygon::Script::CallFunction(const u16string &key, const vector<EvalValue *>& variables) {
|
||||
auto var = (GenericFunctionEvalValue*)GetVariable(key);
|
||||
return this->_evaluator->EvaluateFunction(var, variables);
|
||||
}
|
||||
|
|
|
@ -33,11 +33,11 @@ namespace Porygon{
|
|||
|
||||
~Script();
|
||||
|
||||
shared_ptr<ScriptType> GetReturnType(){
|
||||
inline shared_ptr<ScriptType> GetReturnType(){
|
||||
return _returnType;
|
||||
}
|
||||
|
||||
void SetReturnType(shared_ptr<ScriptType> t){
|
||||
inline void SetReturnType(shared_ptr<ScriptType> t){
|
||||
_returnType = std::move(t);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<ScriptType> GetIndexedType(ScriptType* indexer) const final{
|
||||
inline const shared_ptr<ScriptType> GetIndexedType(ScriptType* indexer) const final{
|
||||
return make_shared<StringScriptType>(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<ScriptType> GetIndexedType(ScriptType* indexer) const final{
|
||||
inline const shared_ptr<ScriptType> GetIndexedType(ScriptType* indexer) const final{
|
||||
return _valueType;
|
||||
}
|
||||
|
||||
const bool CanBeIterated() const final{
|
||||
inline const bool CanBeIterated() const final{
|
||||
return true;
|
||||
}
|
||||
shared_ptr<ScriptType> GetIteratorKeyType() const final{
|
||||
inline shared_ptr<ScriptType> GetIteratorKeyType() const final{
|
||||
return make_shared<NumericScriptType>(true, false);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace Porygon::StandardLibraries{
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
static shared_ptr<Evaluation::EvalValue> GetVariable(const Utilities::HashedString &identifier){
|
||||
inline static shared_ptr<Evaluation::EvalValue> GetVariable(const Utilities::HashedString &identifier){
|
||||
return _internal._variables[identifier];
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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<ScriptType> GetIndexedType(uint32_t hash) const final{
|
||||
inline const shared_ptr<ScriptType> GetIndexedType(uint32_t hash) const final{
|
||||
return _values-> at(Utilities::HashedString::CreateLookup(hash))->GetType();
|
||||
}
|
||||
|
||||
const map<Utilities::HashedString, BoundVariable*>* GetValues() const{
|
||||
inline const map<Utilities::HashedString, BoundVariable*>* GetValues() const{
|
||||
return _values;
|
||||
}
|
||||
|
||||
const int GetLocalVariableCount() const{
|
||||
inline const int GetLocalVariableCount() const{
|
||||
return _localVariableCount;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,23 +16,23 @@ namespace Porygon::UserData{
|
|||
: _type(shared_ptr<ScriptType>(type)), _get(getter), _set(setter){
|
||||
}
|
||||
|
||||
shared_ptr<ScriptType> GetType(){
|
||||
inline shared_ptr<ScriptType> 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);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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<ScriptType>(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;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -23,11 +23,11 @@ namespace Porygon::UserData {
|
|||
return _func(_parent, b);
|
||||
}
|
||||
|
||||
const shared_ptr<ScriptType> GetSecondParameterType() const{
|
||||
inline const shared_ptr<ScriptType> GetSecondParameterType() const{
|
||||
return _secondParameter;
|
||||
}
|
||||
|
||||
const shared_ptr<ScriptType> GetReturnType() const{
|
||||
inline const shared_ptr<ScriptType> GetReturnType() const{
|
||||
return _returnType;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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<ScriptType> GetIndexedType(uint32_t hash) const final {
|
||||
inline const shared_ptr<ScriptType> GetIndexedType(uint32_t hash) const final {
|
||||
return _userData->GetField(hash)->GetType();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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<EvalValue> Clone() const final {
|
||||
inline const shared_ptr<EvalValue> Clone() const final {
|
||||
return make_shared<UserDataValue>(_userData, _obj);
|
||||
}
|
||||
|
||||
const std::size_t GetHashCode() const final {
|
||||
inline const std::size_t GetHashCode() const final {
|
||||
return reinterpret_cast<intptr_t>(_obj);
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ namespace Porygon::UserData {
|
|||
return shared_ptr<EvalValue>(field->Get(_obj));
|
||||
}
|
||||
|
||||
const shared_ptr<EvalValue> IndexValue(uint32_t hash) const final {
|
||||
inline const shared_ptr<EvalValue> IndexValue(uint32_t hash) const final {
|
||||
auto field = _userData->GetField(hash);
|
||||
return shared_ptr<EvalValue>(field->Get(_obj));
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ namespace Porygon::UserData {
|
|||
field->Set(_obj, value.get());
|
||||
}
|
||||
|
||||
void* GetObjectPointer(){
|
||||
inline void* GetObjectPointer(){
|
||||
return _obj;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -22,45 +22,45 @@ namespace Porygon::Utilities{
|
|||
_string(std::shared_ptr<const std::u16string>(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<uint32_t>(*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<uint32_t>(*input) + 33 * ConstHash(input + 1) :
|
||||
5381;
|
||||
}
|
||||
|
||||
const uint32_t GetHash() const{
|
||||
inline const uint32_t GetHash() const{
|
||||
return _hash;
|
||||
}
|
||||
|
||||
const std::shared_ptr<const std::u16string> GetString() const{
|
||||
inline const std::shared_ptr<const std::u16string> 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,17 +13,17 @@ namespace Porygon::Utilities{
|
|||
private:
|
||||
static std::wstring_convert<std::codecvt_utf8_utf16<char16_t, 0x10ffff, std::little_endian>, 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;
|
||||
}
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
using namespace Porygon::Parser;
|
||||
|
||||
TEST_CASE( "Parse single true keyword", "[parser]" ) {
|
||||
vector<const IToken*> v {new SimpleToken(TokenKind::TrueKeyword,0,0), new SimpleToken(TokenKind::EndOfFile,0,0)};
|
||||
vector<const Token*> 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<const IToken*> v {new SimpleToken(TokenKind::FalseKeyword,0,0), new SimpleToken(TokenKind::EndOfFile,0,0)};
|
||||
vector<const Token*> 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<const IToken*> v {
|
||||
vector<const Token*> 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<const IToken*> v {
|
||||
vector<const Token*> 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<const IToken*> v {
|
||||
vector<const Token*> 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<const IToken*> v {
|
||||
vector<const Token*> 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<const IToken*> v {
|
||||
vector<const Token*> 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<const IToken*> v {new StringToken(u"foo bar", 0,0), new SimpleToken(TokenKind::EndOfFile,0,0)};
|
||||
vector<const Token*> 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<const IToken*> v {
|
||||
vector<const Token*> 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<const IToken*> v {
|
||||
vector<const Token*> 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<const IToken*> v {
|
||||
vector<const Token*> v {
|
||||
new SimpleToken(TokenKind::FunctionKeyword,0,0),
|
||||
new IdentifierToken(HashedString(new u16string(u"foo")),0,0),
|
||||
new SimpleToken(TokenKind::OpenParenthesis,0,0),
|
||||
|
|
Loading…
Reference in New Issue