General cleanup
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-07-04 18:24:49 +02:00
parent 0446c1098b
commit bb0a6aba19
20 changed files with 90 additions and 92 deletions

View File

@@ -69,7 +69,7 @@ namespace Porygon::Evaluation {
const bool NumericEvalValue::operator==(EvalValue *b) const {
if (b->GetTypeClass() != TypeClass::Number)
return false;
auto numVal = (NumericEvalValue *) b;
auto numVal = dynamic_cast<NumericEvalValue*>(b);
if (this->IsFloat() != numVal->IsFloat())
return false;

View File

@@ -13,8 +13,7 @@ namespace Porygon::Evaluation {
u16string _value;
size_t _hash;
public:
explicit StringEvalValue(u16string s) {
_value = move(s);
explicit StringEvalValue(u16string s) : _value(move(s)){
_hash = Utilities::HashedString::ConstHash(_value.c_str());
}

View File

@@ -5,9 +5,8 @@
namespace Porygon::Evaluation {
EvaluationScope::EvaluationScope(map<Utilities::HashedString, shared_ptr<EvalValue>> *scriptVariables,
int localVariableCount) {
_scriptScope = scriptVariables;
_localScope = map<uint64_t, shared_ptr<EvalValue>>();
int localVariableCount) : _scriptScope(scriptVariables),
_localScope(map<uint64_t, shared_ptr<EvalValue>>()) {
}
void EvaluationScope::CreateVariable(const BoundVariableKey *key, const shared_ptr<EvalValue> &value) {

View File

@@ -33,7 +33,7 @@ namespace Porygon::Evaluation {
case BoundStatementKind::Script:
throw; // Should never happen
case BoundStatementKind::Block:
return this->EvaluateBlockStatement((BoundBlockStatement *) statement);
return this->EvaluateBlockStatement((BoundBlockStatement*)statement);
case BoundStatementKind::Expression:
return this->EvaluateExpressionStatement((BoundExpressionStatement *) statement);
case BoundStatementKind::Assignment:
@@ -382,7 +382,7 @@ namespace Porygon::Evaluation {
auto opt = func->GetOption(option->GetOptionId());
if (option -> IsScriptFunction()){
auto parameterTypes = option->GetParameterTypes();
auto scriptFunctionType = (ScriptFunctionOption*)option;
auto scriptFunctionType = dynamic_cast<const ScriptFunctionOption*>(option);
auto parameterKeys = scriptFunctionType->GetParameterKeys();
auto originalScope = this->_evaluationScope;
auto scriptOption = dynamic_pointer_cast<EvaluationScriptFunctionOption>(opt);
@@ -413,7 +413,7 @@ namespace Porygon::Evaluation {
const shared_ptr<EvalValue> Evaluator::EvaluateFunction(const GenericFunctionEvalValue *function,
const vector<EvalValue *> &parameters) {
auto type = std::dynamic_pointer_cast<GenericFunctionScriptType>(function->GetType());
auto option = (ScriptFunctionOption*)type-> GetFirstOption();
auto option = dynamic_cast<const ScriptFunctionOption*>(type->GetFirstOption());
auto parameterTypes = option->GetParameterTypes();
auto parameterKeys = option->GetParameterKeys();

View File

@@ -59,12 +59,9 @@ namespace Porygon::Evaluation{
const shared_ptr<EvalValue> GetVariable(const BoundVariableExpression *expression);
public:
explicit Evaluator(map<Utilities::HashedString, shared_ptr<EvalValue>>* scriptVariables){
_scriptVariables = scriptVariables;
_hasReturned = false;
_hasBroken = false;
_returnValue = nullptr;
_evaluationScope = nullptr;
explicit Evaluator(map<Utilities::HashedString, shared_ptr<EvalValue>>* scriptVariables)
: _scriptVariables(scriptVariables), _hasReturned(false), _hasBroken(false), _returnValue(nullptr),
_evaluationScope(nullptr){
}
EvalValue* Evaluate(const BoundScriptStatement* statement);