-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from mjp41/16-build-out-buildin-funcs
Implement buildin functions and refactor mermaid generation
- Loading branch information
Showing
11 changed files
with
407 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include "../core.h" | ||
#include "../rt.h" | ||
|
||
namespace rt::core | ||
{ | ||
void mermaid_builtins(ui::UI* ui) | ||
{ | ||
if (!ui->is_mermaid()) | ||
{ | ||
return; | ||
} | ||
auto mermaid = reinterpret_cast<ui::MermaidUI*>(ui); | ||
|
||
add_builtin("mermaid_hide", [mermaid](auto frame, auto stack, auto args) { | ||
assert(args >= 1); | ||
|
||
for (int i = 0; i < args; i++) | ||
{ | ||
auto value = stack->back(); | ||
mermaid->add_always_hide(value); | ||
remove_reference(frame, value); | ||
stack->pop_back(); | ||
} | ||
|
||
return std::nullopt; | ||
}); | ||
|
||
add_builtin("mermaid_show", [mermaid](auto frame, auto stack, auto args) { | ||
assert(args >= 1); | ||
|
||
for (int i = 0; i < args; i++) | ||
{ | ||
auto value = stack->back(); | ||
mermaid->remove_unreachable_hide(value); | ||
mermaid->remove_always_hide(value); | ||
remove_reference(frame, value); | ||
stack->pop_back(); | ||
} | ||
|
||
return std::nullopt; | ||
}); | ||
|
||
add_builtin("mermaid_show_all", [mermaid](auto, auto, auto args) { | ||
assert(args == 0); | ||
|
||
mermaid->unreachable_hide.clear(); | ||
mermaid->always_hide.clear(); | ||
|
||
return std::nullopt; | ||
}); | ||
} | ||
|
||
void init_builtins(ui::UI* ui) | ||
{ | ||
mermaid_builtins(ui); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.