Skip to content

Commit

Permalink
Merge pull request #67 from bksaiki/environments
Browse files Browse the repository at this point in the history
Top-level environments
  • Loading branch information
bksaiki authored Apr 19, 2024
2 parents 18aac51 + c891ea3 commit b0ae25a
Show file tree
Hide file tree
Showing 21 changed files with 438 additions and 234 deletions.
1 change: 0 additions & 1 deletion src/boot/c/boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ void minim_boot_init() {
tc_stack_size(tc) = stack_size;
tc_sfp(tc) = tc_stack_base(tc);
tc_esp(tc) = tc_sfp(tc) + tc_stack_size(tc) - stack_slop;
tc_env(tc) = make_env();
current_tc() = tc;
}
2 changes: 1 addition & 1 deletion src/boot/c/minim.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int main(int argc, char **argv) {

// load the prelude
tc = current_tc();
load_prelude(tc_env(tc));
load_prelude(tc);

if (opt_load_library)
load_library();
Expand Down
10 changes: 5 additions & 5 deletions src/boot/s/boot.min

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/boot/test/jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void no_check(const char *input) {
istream = tmpfile();
tc = current_tc();
load(istream, input);
tc_env(tc) = make_env();
tc_env(tc) = make_base_env();
eval_expr(tc, read_object(istream));
}

Expand All @@ -53,7 +53,7 @@ void check_true(const char *input) {
istream = tmpfile();
tc = current_tc();
load(istream, input);
tc_env(tc) = make_env();
tc_env(tc) = make_base_env();
result = eval_expr(tc, read_object(istream));
if (!minim_truep(result)) {
log_failed_case(input, "#t", write(result));
Expand All @@ -70,7 +70,7 @@ void check_false(const char *input) {
istream = tmpfile();
tc = current_tc();
load(istream, input);
tc_env(tc) = make_env();
tc_env(tc) = make_base_env();
result = eval_expr(tc, read_object(istream));
if (!minim_falsep(result)) {
log_failed_case(input, "#f", write(result));
Expand All @@ -88,7 +88,7 @@ void check_equal(const char *input, const char *expect) {
istream = tmpfile();
tc = current_tc();
load(istream, input);
tc_env(tc) = make_env();
tc_env(tc) = make_base_env();
result = eval_expr(tc, read_object(istream));
str = write(result);
if (strcmp(str, expect) != 0) {
Expand Down
17 changes: 6 additions & 11 deletions src/boot/test/prims.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,15 @@ char *write(mobj o) {
printf(" %s => expected: %s, actual: %s\n", s, expect, actual); \
}

void no_check(const char *input) {
FILE *istream;

istream = tmpfile();
load(istream, input);
eval_expr(read_object(istream), make_env());
}

void check_true(const char *input) {
FILE *istream;
mobj tc, result;

istream = tmpfile();
tc = current_tc();
load(istream, input);
tc_env(tc) = make_env();
tc_tenv(tc) = make_base_env();
tc_env(tc) = tc_tenv(tc);
result = eval_expr(tc, read_object(istream));
if (!minim_truep(result)) {
log_failed_case(input, "#t", write(result));
Expand All @@ -72,7 +65,8 @@ void check_false(const char *input) {
istream = tmpfile();
tc = current_tc();
load(istream, input);
tc_env(tc) = make_env();
tc_tenv(tc) = make_base_env();
tc_env(tc) = tc_tenv(tc);
result = eval_expr(tc, read_object(istream));
if (!minim_falsep(result)) {
log_failed_case(input, "#f", write(result));
Expand All @@ -90,7 +84,8 @@ void check_equal(const char *input, const char *expect) {
istream = tmpfile();
tc = current_tc();
load(istream, input);
tc_env(tc) = make_env();
tc_tenv(tc) = make_base_env();
tc_env(tc) = tc_tenv(tc);
result = eval_expr(tc, read_object(istream));
str = write(result);
if (strcmp(str, expect) != 0) {
Expand Down
Loading

0 comments on commit b0ae25a

Please sign in to comment.