Work on performance improvements
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2019-06-13 16:26:10 +02:00
parent e93bcab14d
commit 1cb65f17c9
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
19 changed files with 84 additions and 108 deletions

View File

@ -13,7 +13,7 @@ BoundScriptStatement *Binder::Bind(Script* script, ParsedScriptStatement *s, Bou
for (int i = 0; i < statements->size(); i++){ for (int i = 0; i < statements->size(); i++){
boundStatements[i] = binder.BindStatement(statements->at(i)); boundStatements[i] = binder.BindStatement(statements->at(i));
} }
return new BoundScriptStatement(boundStatements, scriptScope->GetDeepestScope()); return new BoundScriptStatement(boundStatements, scriptScope->GetLocalVariableCount());
} }
Binder::~Binder() { Binder::~Binder() {
@ -434,7 +434,7 @@ BoundExpression *Binder::BindTableExpression(ParsedTableExpression *expression)
auto block = this -> BindBlockStatement(expression -> GetBlock()); auto block = this -> BindBlockStatement(expression -> GetBlock());
this -> _scope = currentScope; this -> _scope = currentScope;
auto tableType = shared_ptr<TableScriptType>(new TableScriptType(tableScope, innerScope->GetDeepestScope())); auto tableType = shared_ptr<TableScriptType>(new TableScriptType(tableScope, innerScope->GetLocalVariableCount()));
delete innerScope; delete innerScope;
return new BoundTableExpression((BoundBlockStatement*)block, tableType, expression->GetStartPosition(), expression->GetLength()); return new BoundTableExpression((BoundBlockStatement*)block, tableType, expression->GetStartPosition(), expression->GetLength());

View File

@ -57,18 +57,19 @@ public:
}; };
class BoundScriptStatement : public BoundBlockStatement{ class BoundScriptStatement : public BoundBlockStatement{
int _deepestScope; int _localVariableCount;
public: public:
explicit BoundScriptStatement(vector<BoundStatement*> statements, int deepestScope) : BoundBlockStatement(std::move(statements)){ explicit BoundScriptStatement(vector<BoundStatement*> statements, int localVariableCount)
_deepestScope = deepestScope; : BoundBlockStatement(std::move(statements)){
_localVariableCount = localVariableCount;
} }
BoundStatementKind GetKind() final{ BoundStatementKind GetKind() final{
return BoundStatementKind ::Script; return BoundStatementKind ::Script;
} }
int GetDeepestScope(){ int GetLocalVariableCount(){
return _deepestScope; return _localVariableCount;
} }
}; };

View File

@ -6,7 +6,6 @@
BoundScope::BoundScope(unordered_map<int, BoundVariable *> *tableScope) { BoundScope::BoundScope(unordered_map<int, BoundVariable *> *tableScope) {
_tableScope = tableScope; _tableScope = tableScope;
_currentScope = 1; _currentScope = 1;
_deepestScope = 1;
_lastCreatedScope = 1; _lastCreatedScope = 1;
auto localUpmostScope = new unordered_map<int, BoundVariable*>(); auto localUpmostScope = new unordered_map<int, BoundVariable*>();
_localScope.push_back(localUpmostScope); _localScope.push_back(localUpmostScope);
@ -28,10 +27,6 @@ void BoundScope::GoInnerScope() {
auto innerScope = new unordered_map<int, BoundVariable*>(); auto innerScope = new unordered_map<int, BoundVariable*>();
_localScope.push_back(innerScope); _localScope.push_back(innerScope);
} }
/*
if (_deepestScope < _currentScope){
_deepestScope = _currentScope;
}*/
} }
void BoundScope::GoOuterScope() { void BoundScope::GoOuterScope() {

View File

@ -18,7 +18,6 @@ class BoundScope {
vector<unordered_map<int, BoundVariable*>*> _localScope; vector<unordered_map<int, BoundVariable*>*> _localScope;
int _currentScope; int _currentScope;
int _lastCreatedScope; int _lastCreatedScope;
int _deepestScope;
public: public:
explicit BoundScope(unordered_map<int, BoundVariable*> *tableScope); explicit BoundScope(unordered_map<int, BoundVariable*> *tableScope);
~BoundScope(); ~BoundScope();
@ -31,8 +30,8 @@ public:
VariableAssignment CreateExplicitLocal(int identifier, std::shared_ptr<ScriptType> type); VariableAssignment CreateExplicitLocal(int identifier, std::shared_ptr<ScriptType> type);
VariableAssignment AssignVariable(int identifier, const std::shared_ptr<ScriptType>& type); VariableAssignment AssignVariable(int identifier, const std::shared_ptr<ScriptType>& type);
int GetDeepestScope(){ size_t GetLocalVariableCount(){
return _deepestScope; return _localScope.size();
} }
int GetCurrentScope(){ int GetCurrentScope(){

View File

@ -1,5 +1,3 @@
#include <utility>
#ifndef PORYGONLANG_BOUNDVARIABLEKEY_HPP #ifndef PORYGONLANG_BOUNDVARIABLEKEY_HPP
#define PORYGONLANG_BOUNDVARIABLEKEY_HPP #define PORYGONLANG_BOUNDVARIABLEKEY_HPP
@ -7,39 +5,39 @@
#include <string> #include <string>
class BoundVariableKey{ class BoundVariableKey{
int _identifier; const int _identifier;
unsigned int _scopeId; const unsigned int _scopeId;
bool _isCreation; const bool _isCreation;
uint64_t _hash; const uint64_t _hash;
static uint64_t KnuthsHash(int i1, int i2) static uint64_t KnuthsHash(unsigned int i1, unsigned int i2)
{ {
uint64_t ret = i1; uint64_t ret = i1;
ret *= 2654435761U; ret *= 2654435761U;
return ret ^ i2; return ret ^ i2;
} }
public: public:
BoundVariableKey(int id, unsigned int scope, bool creation){ BoundVariableKey(int id, unsigned int scope, bool creation)
_identifier = id; : _identifier(id),
_scopeId = scope; _scopeId(scope),
_hash = KnuthsHash(scope, id); _isCreation(creation),
_isCreation = creation; _hash(KnuthsHash(id, scope))
} {}
int GetIdentifier(){ const int GetIdentifier(){
return _identifier; return _identifier;
} }
unsigned int GetScopeId(){ const unsigned int GetScopeId(){
return _scopeId; return _scopeId;
} }
bool IsCreation(){ const bool IsCreation(){
return _isCreation; return _isCreation;
} }
uint64_t GetHash(){ const uint64_t GetHash(){
return _hash; return _hash;
} }
}; };

View File

@ -5,11 +5,7 @@
extern "C" { extern "C" {
TypeClass GetEvalValueTypeClass(EvalValue* v){ TypeClass GetEvalValueTypeClass(EvalValue* v){
return v->GetType().get()->GetClass(); return v->GetTypeClass();
}
ScriptType* GetEvalValueType(EvalValue* v){
return v->GetType().get();
} }
int64_t EvaluateEvalValueInteger(EvalValue* v){ int64_t EvaluateEvalValueInteger(EvalValue* v){

View File

@ -12,7 +12,7 @@ class EvalValue{
public: public:
EvalValue() = default; EvalValue() = default;
virtual ~EvalValue() = default; virtual ~EvalValue() = default;
virtual std::shared_ptr<ScriptType> GetType() = 0; virtual const TypeClass GetTypeClass() = 0;
virtual bool operator ==(EvalValue* b) = 0; virtual bool operator ==(EvalValue* b) = 0;
@ -43,28 +43,27 @@ public:
}; };
class BooleanEvalValue : public EvalValue{ class BooleanEvalValue : public EvalValue{
bool _value; const bool _value;
std::shared_ptr<ScriptType> _type;
public: public:
explicit BooleanEvalValue(bool val){ explicit BooleanEvalValue(bool val)
_value = val; : _value(val)
_type = std::make_shared<ScriptType>(TypeClass::Bool); {
} }
shared_ptr<EvalValue> Clone() final{ shared_ptr<EvalValue> Clone() final{
return make_shared<BooleanEvalValue>(_value); return make_shared<BooleanEvalValue>(_value);
} }
std::shared_ptr<ScriptType> GetType() final{ const TypeClass GetTypeClass() final{
return _type; return TypeClass ::Bool;
}; }
bool EvaluateBool() final{ bool EvaluateBool() final{
return _value; return _value;
} }
bool operator ==(EvalValue* b) final{ bool operator ==(EvalValue* b) final{
if (b->GetType()->GetClass() != TypeClass::Bool) if (b->GetTypeClass() != TypeClass::Bool)
return false; return false;
return this->EvaluateBool() == b->EvaluateBool(); return this->EvaluateBool() == b->EvaluateBool();
}; };

View File

@ -66,7 +66,7 @@ NumericEvalValue *NumericEvalValue::operator/(NumericEvalValue *b) {
} }
bool NumericEvalValue::operator==(EvalValue *b) { bool NumericEvalValue::operator==(EvalValue *b) {
if (b->GetType()->GetClass() != TypeClass::Number) if (b->GetTypeClass() != TypeClass::Number)
return false; return false;
auto numVal = (NumericEvalValue*)b; auto numVal = (NumericEvalValue*)b;
if (this->IsFloat() != numVal->IsFloat()) if (this->IsFloat() != numVal->IsFloat())

View File

@ -10,12 +10,11 @@ class NumericEvalValue : public EvalValue{
virtual long GetIntegerValue() = 0; virtual long GetIntegerValue() = 0;
virtual double GetFloatValue() = 0; virtual double GetFloatValue() = 0;
protected:
std::shared_ptr<ScriptType> _type;
public: public:
virtual const bool IsFloat() = 0; virtual const bool IsFloat() = 0;
std::shared_ptr<ScriptType> GetType() override {
return _type; const TypeClass GetTypeClass() final{
return TypeClass ::Number;
} }
NumericEvalValue* operator +(NumericEvalValue* b); NumericEvalValue* operator +(NumericEvalValue* b);
@ -35,7 +34,6 @@ class IntegerEvalValue : public NumericEvalValue{
double GetFloatValue() final{ throw EvaluationException("Attempting to retrieve float from int eval value."); } double GetFloatValue() final{ throw EvaluationException("Attempting to retrieve float from int eval value."); }
public: public:
explicit IntegerEvalValue(long value){ explicit IntegerEvalValue(long value){
_type = std::make_shared<NumericScriptType>(true, false);
_value = value; _value = value;
} }
const bool IsFloat() final{ const bool IsFloat() final{
@ -61,7 +59,6 @@ class FloatEvalValue : public NumericEvalValue{
double GetFloatValue() final{return _value;} double GetFloatValue() final{return _value;}
public: public:
explicit FloatEvalValue(double value){ explicit FloatEvalValue(double value){
_type = std::make_shared<NumericScriptType>(true, true);
_value = value; _value = value;
} }
const bool IsFloat() final{ const bool IsFloat() final{

View File

@ -38,17 +38,21 @@ public:
_hash = rand(); _hash = rand();
} }
std::shared_ptr<ScriptType> GetType() final{ std::shared_ptr<ScriptType> GetType(){
return _type; return _type;
} }
const TypeClass GetTypeClass() final{
return TypeClass ::Function;
}
shared_ptr<EvalValue> Clone() final{ shared_ptr<EvalValue> Clone() final{
return shared_ptr<ScriptFunctionEvalValue>(new ScriptFunctionEvalValue(_innerBlock, _scope, _type, _hash)); return shared_ptr<ScriptFunctionEvalValue>(new ScriptFunctionEvalValue(_innerBlock, _scope, _type, _hash));
} }
bool operator ==(EvalValue* b) final{ bool operator ==(EvalValue* b) final{
if (b->GetType()->GetClass() != TypeClass::Function) if (b->GetTypeClass() != TypeClass::Function)
return false; return false;
return this->_hash == ((ScriptFunctionEvalValue*)b)->_hash; return this->_hash == ((ScriptFunctionEvalValue*)b)->_hash;
}; };

View File

@ -1,2 +0,0 @@
#include "StringEvalValue.hpp"

View File

@ -11,19 +11,18 @@ using namespace std;
class StringEvalValue : public EvalValue{ class StringEvalValue : public EvalValue{
string _value; string _value;
size_t _hash; size_t _hash;
std::shared_ptr<ScriptType> _type;
public: public:
explicit StringEvalValue(string s){ explicit StringEvalValue(string s){
_value = move(s); _value = move(s);
_hash = HashedString::ConstHash (_value.c_str()); _hash = HashedString::ConstHash (_value.c_str());
_type = std::make_shared<StringScriptType>(true, _hash);
} }
std::shared_ptr<ScriptType> GetType() final{ const TypeClass GetTypeClass() final{
return _type; return TypeClass ::String;
}; }
bool operator ==(EvalValue* b) final{ bool operator ==(EvalValue* b) final{
if (b->GetType()->GetClass() != TypeClass::String) if (b->GetTypeClass() != TypeClass::String)
return false; return false;
return this->_hash == b->GetHashCode(); return this->_hash == b->GetHashCode();
}; };

View File

@ -1,2 +0,0 @@
#include "TableEvalValue.hpp"

View File

@ -8,23 +8,20 @@ using namespace std;
class TableEvalValue : public EvalValue { class TableEvalValue : public EvalValue {
shared_ptr<unordered_map<size_t, shared_ptr<EvalValue>>> _table; shared_ptr<unordered_map<size_t, shared_ptr<EvalValue>>> _table;
shared_ptr<ScriptType> _type;
size_t _hash; size_t _hash;
explicit TableEvalValue(shared_ptr<unordered_map<size_t, shared_ptr<EvalValue>>> table, shared_ptr<ScriptType> type, size_t hash){ explicit TableEvalValue(shared_ptr<unordered_map<size_t, shared_ptr<EvalValue>>> table, size_t hash){
_table = std::move(table); _table = std::move(table);
_type = std::move(type);
_hash = hash; _hash = hash;
} }
public: public:
explicit TableEvalValue(shared_ptr<unordered_map<size_t, shared_ptr<EvalValue>>> table, shared_ptr<ScriptType> type){ explicit TableEvalValue(shared_ptr<unordered_map<size_t, shared_ptr<EvalValue>>> table){
_table = std::move(table); _table = std::move(table);
_type = std::move(type);
_hash = rand(); _hash = rand();
} }
std::shared_ptr<ScriptType> GetType() final{ const TypeClass GetTypeClass() final{
return _type; return TypeClass ::Table;
} }
size_t GetHashCode() final{ size_t GetHashCode() final{
@ -36,7 +33,7 @@ public:
} }
shared_ptr<EvalValue> Clone() final{ shared_ptr<EvalValue> Clone() final{
return shared_ptr<EvalValue>(new TableEvalValue(_table, _type, _hash)); return shared_ptr<EvalValue>(new TableEvalValue(_table, _hash));
} }
shared_ptr<EvalValue> IndexValue(EvalValue* val) final{ shared_ptr<EvalValue> IndexValue(EvalValue* val) final{

View File

@ -2,9 +2,9 @@
#include "EvaluationScope.hpp" #include "EvaluationScope.hpp"
#include <memory> #include <memory>
EvaluationScope::EvaluationScope(unordered_map<size_t, shared_ptr<EvalValue>> *scriptVariables, int deepestScope) { EvaluationScope::EvaluationScope(unordered_map<size_t, shared_ptr<EvalValue>> *scriptVariables, int localVariableCount) {
_scriptScope = scriptVariables; _scriptScope = scriptVariables;
_localScope = unordered_map<uint64_t, shared_ptr<EvalValue>>(deepestScope); _localScope = unordered_map<uint64_t, shared_ptr<EvalValue>>(localVariableCount);
} }
void EvaluationScope::CreateVariable(BoundVariableKey* key, const shared_ptr<EvalValue> &value) { void EvaluationScope::CreateVariable(BoundVariableKey* key, const shared_ptr<EvalValue> &value) {

View File

@ -1,3 +1,5 @@
#include <memory>
#include <utility> #include <utility>
#include <memory> #include <memory>
#include "Evaluator.hpp" #include "Evaluator.hpp"
@ -12,7 +14,7 @@
using namespace std; using namespace std;
EvalValue* Evaluator::Evaluate(BoundScriptStatement *statement) { EvalValue* Evaluator::Evaluate(BoundScriptStatement *statement) {
this->_evaluationScope = make_shared<EvaluationScope>(this->_scriptData->_scriptVariables, statement->GetDeepestScope()); this->_evaluationScope = make_shared<EvaluationScope>(this->_scriptData->_scriptVariables, statement->GetLocalVariableCount());
EvaluateBlockStatement(statement, false); EvaluateBlockStatement(statement, false);
return this -> _returnValue.get(); return this -> _returnValue.get();
} }
@ -223,10 +225,6 @@ shared_ptr<EvalValue> Evaluator::EvaluateFunctionCallExpression(BoundExpression*
for (int i = 0; i < parameterTypes.size() && i < parameterKeys.size() && i < parameters.size(); i++){ for (int i = 0; i < parameterTypes.size() && i < parameterKeys.size() && i < parameters.size(); i++){
auto parameter = parameters[i]; auto parameter = parameters[i];
auto requiredType = parameterTypes.at(i);
if (*parameter->GetType() != requiredType.get()){
throw EvaluationException("Passed wrong type to function.");
}
auto key = parameterKeys.at(i); auto key = parameterKeys.at(i);
this->_evaluationScope->CreateVariable(key.get(), parameter->Clone()); this->_evaluationScope->CreateVariable(key.get(), parameter->Clone());
} }
@ -249,10 +247,6 @@ shared_ptr<EvalValue> Evaluator::EvaluateFunction(ScriptFunctionEvalValue *funct
for (int i = 0; i < parameterTypes.size() && i < parameterKeys.size() && i < parameters.size(); i++){ for (int i = 0; i < parameterTypes.size() && i < parameterKeys.size() && i < parameters.size(); i++){
auto parameter = parameters[i]; auto parameter = parameters[i];
auto requiredType = parameterTypes.at(i);
if (*parameter->GetType() != requiredType.get()){
throw EvaluationException("Passed wrong type to function.");
}
auto key = parameterKeys.at(i); auto key = parameterKeys.at(i);
this->_evaluationScope->CreateVariable(key.get(), parameter->Clone()); this->_evaluationScope->CreateVariable(key.get(), parameter->Clone());
} }
@ -280,7 +274,7 @@ shared_ptr<EvalValue> Evaluator::EvaluateNumericTableExpression(BoundExpression
values -> insert({i + 1, val}); values -> insert({i + 1, val});
} }
auto valuesPointer = shared_ptr<unordered_map<size_t, shared_ptr<EvalValue>>>(values); auto valuesPointer = shared_ptr<unordered_map<size_t, shared_ptr<EvalValue>>>(values);
return make_shared<TableEvalValue>(valuesPointer, tableExpression->GetType()); return make_shared<TableEvalValue>(valuesPointer);
} }
shared_ptr<EvalValue> Evaluator::EvaluateComplexTableExpression(BoundExpression *expression) { shared_ptr<EvalValue> Evaluator::EvaluateComplexTableExpression(BoundExpression *expression) {
@ -291,10 +285,10 @@ shared_ptr<EvalValue> Evaluator::EvaluateComplexTableExpression(BoundExpression
for (auto i : *declaredVars){ for (auto i : *declaredVars){
variables->insert({i.first, nullptr}); variables->insert({i.first, nullptr});
} }
auto evaluator = make_shared<EvaluationScope>(variables.get(), type -> GetDeepestScope()); auto evaluator = make_shared<EvaluationScope>(variables.get(), type -> GetLocalVariableCount());
auto currentEvaluator = this -> _evaluationScope; auto currentEvaluator = this -> _evaluationScope;
this -> _evaluationScope = evaluator; this -> _evaluationScope = evaluator;
this -> EvaluateBlockStatement(tableExpression->GetBlock(), false); this -> EvaluateBlockStatement(tableExpression->GetBlock(), false);
this -> _evaluationScope = currentEvaluator; this -> _evaluationScope = currentEvaluator;
return shared_ptr<TableEvalValue>(new TableEvalValue(variables, tableExpression->GetType())); return make_shared<TableEvalValue>(variables);
} }

View File

@ -69,7 +69,7 @@ EvalValue *Script::GetLastValue() {
bool Script::HasFunction(const string &key) { bool Script::HasFunction(const string &key) {
auto f = _scriptVariables->find(HashedString(key).GetHash()); auto f = _scriptVariables->find(HashedString(key).GetHash());
return f != _scriptVariables->end() && f.operator->()->second->GetType()->GetClass() == TypeClass ::Function; return f != _scriptVariables->end() && f.operator->()->second->GetTypeClass() == TypeClass ::Function;
} }
shared_ptr<EvalValue> Script::CallFunction(const string &key, vector<EvalValue *> variables) { shared_ptr<EvalValue> Script::CallFunction(const string &key, vector<EvalValue *> variables) {

View File

@ -5,13 +5,14 @@
#include "Binder/BoundVariables/BoundVariable.hpp" #include "Binder/BoundVariables/BoundVariable.hpp"
class TableScriptType : public ScriptType{ class TableScriptType : public ScriptType{
unordered_map<int, BoundVariable*>* _values; const unordered_map<int, BoundVariable*>* _values;
int _deepestScope; const int _localVariableCount;
public: public:
explicit TableScriptType(unordered_map<int, BoundVariable*>* values, int deepestScope) : ScriptType(TypeClass::Table){ explicit TableScriptType(unordered_map<int, BoundVariable*>* values, int localVariableCount)
_values = values; : ScriptType(TypeClass::Table),
_deepestScope = deepestScope; _values(values),
} _localVariableCount(localVariableCount)
{}
~TableScriptType() final{ ~TableScriptType() final{
for (auto i : *_values){ for (auto i : *_values){
@ -32,12 +33,12 @@ public:
throw "TODO: indexing with dynamic keys"; throw "TODO: indexing with dynamic keys";
} }
unordered_map<int, BoundVariable*>* GetValues(){ const unordered_map<int, BoundVariable*>* GetValues(){
return _values; return _values;
} }
int GetDeepestScope(){ const int GetLocalVariableCount(){
return _deepestScope; return _localVariableCount;
} }
}; };

View File

@ -8,7 +8,7 @@ TEST_CASE( "Define script function", "[integration]" ) {
script->Evaluate(); script->Evaluate();
auto variable = script->GetVariable("add"); auto variable = script->GetVariable("add");
REQUIRE(variable != nullptr); REQUIRE(variable != nullptr);
REQUIRE(variable->GetType()->GetClass() == TypeClass::Function); REQUIRE(variable->GetTypeClass() == TypeClass::Function);
delete script; delete script;
} }
@ -18,9 +18,9 @@ TEST_CASE( "Define script function and call", "[integration]" ) {
script->Evaluate(); script->Evaluate();
auto variable = script->GetVariable("add"); auto variable = script->GetVariable("add");
REQUIRE(variable != nullptr); REQUIRE(variable != nullptr);
REQUIRE(variable->GetType()->GetClass() == TypeClass::Function); REQUIRE(variable->GetTypeClass() == TypeClass::Function);
auto result = script->GetVariable("result"); auto result = script->GetVariable("result");
REQUIRE(result->GetType()->GetClass() == TypeClass::Number); REQUIRE(result->GetTypeClass() == TypeClass::Number);
REQUIRE(result->EvaluateInteger() == 3); REQUIRE(result->EvaluateInteger() == 3);
delete script; delete script;
} }
@ -31,9 +31,9 @@ TEST_CASE( "Define script function and call multiple times", "[integration]" ) {
script->Evaluate(); script->Evaluate();
auto variable = script->GetVariable("add"); auto variable = script->GetVariable("add");
REQUIRE(variable != nullptr); REQUIRE(variable != nullptr);
REQUIRE(variable->GetType()->GetClass() == TypeClass::Function); REQUIRE(variable->GetTypeClass() == TypeClass::Function);
auto result = script->GetVariable("result"); auto result = script->GetVariable("result");
REQUIRE(result->GetType()->GetClass() == TypeClass::Number); REQUIRE(result->GetTypeClass() == TypeClass::Number);
REQUIRE(result->EvaluateInteger() == 5); REQUIRE(result->EvaluateInteger() == 5);
delete script; delete script;
} }
@ -52,7 +52,7 @@ TEST_CASE( "Define script function and call from extern", "[integration]" ) {
delete toAddVal; delete toAddVal;
auto result = script->GetVariable("result"); auto result = script->GetVariable("result");
REQUIRE(result->GetType()->GetClass() == TypeClass::Number); REQUIRE(result->GetTypeClass() == TypeClass::Number);
REQUIRE(result->EvaluateInteger() == 11); REQUIRE(result->EvaluateInteger() == 11);
delete script; delete script;
} }
@ -74,11 +74,11 @@ TEST_CASE( "Define script function and return", "[integration]" ) {
delete toAddVal; delete toAddVal;
delete toAddVal2; delete toAddVal2;
REQUIRE(result->GetType()->GetClass() == TypeClass::Number); REQUIRE(result->GetTypeClass() == TypeClass::Number);
REQUIRE(result->EvaluateInteger() == 11); REQUIRE(result->EvaluateInteger() == 11);
auto variable = script->GetVariable("val"); auto variable = script->GetVariable("val");
REQUIRE(variable->GetType()->GetClass() == TypeClass::Number); REQUIRE(variable->GetTypeClass() == TypeClass::Number);
REQUIRE(variable->EvaluateInteger() == 0); REQUIRE(variable->EvaluateInteger() == 0);
delete script; delete script;
@ -100,7 +100,7 @@ end
script->CallFunction("add", {}); script->CallFunction("add", {});
auto variable = script->GetVariable("val"); auto variable = script->GetVariable("val");
REQUIRE(variable->GetType()->GetClass() == TypeClass::Number); REQUIRE(variable->GetTypeClass() == TypeClass::Number);
REQUIRE(variable->EvaluateInteger() == 5); REQUIRE(variable->EvaluateInteger() == 5);
delete script; delete script;
@ -128,7 +128,7 @@ test()
script->Evaluate(); script->Evaluate();
auto variable = script->GetVariable("result"); auto variable = script->GetVariable("result");
REQUIRE(variable->GetType()->GetClass() == TypeClass::Number); REQUIRE(variable->GetTypeClass() == TypeClass::Number);
REQUIRE(variable->EvaluateInteger() == 50); REQUIRE(variable->EvaluateInteger() == 50);
delete script; delete script;