1
0
Fork 0
mirror of https://gitlab.com/niansa/pilang3.git synced 2025-03-06 20:49:20 +01:00

Fixed evaluation dereference being cached in function

This commit is contained in:
niansa 2021-02-14 19:03:14 +01:00
parent 5d835929cb
commit d185ff9b20
2 changed files with 7 additions and 5 deletions

View file

@ -28,9 +28,9 @@ int main() {
std::cout << " ";
} catch (exceptions::exit& e) {
return e.code;
} /*catch (exceptions::langException& e) {
} catch (exceptions::langException& e) {
std::cout << "E: Language exception: " << e.what() << std::endl;
line.clear();
}*/
}
}
}

View file

@ -321,10 +321,12 @@ namespace Pilang3 {
scope[argumentNames[args_idx - 1]] = std::make_shared<Variable>(args[args_idx - 1]);
}
env->variableScope.push(scope); // Start new scope
// Execute all evaluations
// Copy, derefer and execute all evaluations
for (auto& evaluation : evalChain) {
evaluation->derefer(env);
fres = evaluation->execute(env);
auto thiseval = Evaluation(*evaluation);
thiseval.derefer(env);
fres = thiseval.execute(env);
// Return on return
if (fres.type == Variable::id_retval) {
auto fresdata = std::get<SharedVariable>(fres.data);
env->variableScope.pop(); // End scope