Jump to specific function scope when calling function
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-06-08 16:44:47 +02:00
parent d385a9e3ee
commit 4d452b33e0
5 changed files with 28 additions and 6 deletions

View File

@@ -188,6 +188,10 @@ shared_ptr<EvalValue> Evaluator::EvaluateFunctionCallExpression(BoundExpression*
auto type = std::dynamic_pointer_cast<FunctionScriptType>(function->GetType());
auto parameterTypes = type->GetParameterTypes();
auto parameterKeys = type->GetParameterKeys();
auto scope = type -> GetScopeIndex();
auto originalScope = this->_evaluationScope->GetCurrentScope();
this->_evaluationScope->JumpToScope(scope);
for (int i = 0; i < parameterTypes.size() && i < parameterKeys.size() && i < parameters.size(); i++){
auto parameter = parameters[i];
auto requiredType = parameterTypes.at(i);
@@ -198,6 +202,7 @@ shared_ptr<EvalValue> Evaluator::EvaluateFunctionCallExpression(BoundExpression*
this->_evaluationScope->CreateVariable(key->GetScopeId(), key->GetIdentifier(), parameter->Clone());
}
this->EvaluateBlockStatement(function->GetInnerBlock().get());
this->_evaluationScope->JumpToScope(originalScope);
this->_hasReturned = false;
auto r = this -> _returnValue;
this -> _returnValue = nullptr;