Skip to content

Commit

Permalink
Define standardFunctions map in evaluation header
Browse files Browse the repository at this point in the history
  • Loading branch information
asynchroza committed Nov 20, 2023
1 parent 87c82fc commit 4786f18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 7 additions & 6 deletions nulascript/eval/eval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,14 @@ Storage* runForLoop(ForLoop* fl, Environment* env) {
return emptyStorage;
}

Storage* getLoggingFunction() {
return new StandardFunction([&](std::vector<Storage*> args) -> Storage* {
return printStorage(args);
});
}

std::unordered_map<std::string, Storage*> standardFunctions = {
{"log", new StandardFunction([](std::vector<Storage*> args) -> Storage* {
return printStorage(args);
})},
{"loop", new StandardFunction([](std::vector<Storage*> args) -> Storage* {
return runLoop(args);
})}};
{"log", getLoggingFunction()}};

Storage* evaluate(Node* node, Environment* env) {
if (checkBase(node, typeid(Program))) {
Expand Down
2 changes: 2 additions & 0 deletions nulascript/eval/eval.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@

Storage* evaluate(Node* node, Environment* env);

extern std::unordered_map<std::string, Storage*> standardFunctions;

#endif // EVALUATOR_H

0 comments on commit 4786f18

Please sign in to comment.