Skip to content

Commit

Permalink
feat: builtins using builtin_object for run_file (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
hrzlgnm authored Dec 15, 2024
1 parent d73a9f9 commit c0b900c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions examples/fibonacci-recursive.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
let fibonacci = fn(x) {
if (x == 0) {
0
} else {
if (x == 1) {
return 1;
} else {
fibonacci(x - 1) + fibonacci(x - 2);
}
}
};

puts(fibonacci(30));
2 changes: 1 addition & 1 deletion source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ auto run_file(const command_line_args& opts) -> int
} else {
auto* global_env = make<environment>();
for (const auto& builtin : builtin_function_expression::builtins) {
global_env->set(builtin->name, make<function_object>(builtin, nullptr));
global_env->set(builtin->name, make<builtin_object>(builtin));
}
const auto* result = prgrm->eval(global_env);
if (!result->is(object::object_type::null)) {
Expand Down

0 comments on commit c0b900c

Please sign in to comment.