Skip to content

Commit

Permalink
I learned much from this. keeping sms_callstack global, though it wil…
Browse files Browse the repository at this point in the history
…l be unusued for now. It's the datastack for bytecode mode.
  • Loading branch information
reginaldford committed Sep 7, 2024
1 parent db2a987 commit c2e4d52
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
3 changes: 3 additions & 0 deletions scripts/clang-format-all.sh
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
cd .. &&
make clean &&
cd scripts &&
clang-format --verbose -i ../src/**/*.c ../src/**/*.h ../src/**/**/*.c ../src/**/**/*.h
1 change: 1 addition & 0 deletions sms_src/examples/benchmark.sms
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/local/bin/sms -qm550
#Use this to benchmark something
{
let _errHandler=(x)=>{putLn(str(x));x;};
let t1 =[];
let t2 =[];
let time_elapsed =0;
Expand Down
2 changes: 1 addition & 1 deletion sms_src/examples/generateBWImg.sms
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/local/bin/sms -qm225
#!/usr/local/bin/sms -qm64
# Demonstrates generating a black and white striped TGA image with 3 shades

{
Expand Down
9 changes: 1 addition & 8 deletions src/main/engine/sm_ast_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,10 @@ static inline sm_object *eager_type_check3(sm_expr *sme, int operand, int param_
#define IS_FALSE(x) ((void *)x == (void *)sms_false)

#define ENGINE_RETURN(x) \
{ \
for (int i = 0; i < 3; i++) \
sm_stack_pop(sms_callstack); \
return x; \
}
{ return x; }

// Recursive engine
inline sm_object *sm_engine_eval(sm_object *input, sm_cx *current_cx, sm_expr *sf) {
sms_callstack = sm_stack_push(sms_callstack, &input);
sms_callstack = sm_stack_push(sms_callstack, &current_cx);
sms_callstack = sm_stack_push(sms_callstack, &sf);
switch (input->my_type) {
case SM_EXPR_TYPE: {
sm_expr *sme = (sm_expr *)input;
Expand Down
9 changes: 5 additions & 4 deletions src/main/memory/sm_gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,13 @@ void sm_garbage_collect() {

// Explicit callstack currently stores ptr triplets
// They point to input, current_cx, and sf variables in the c callstack
sm_object ***ptr_array = (sm_object ***)sm_stack_empty_top(sms_callstack);
for (int i = 0; i < sm_stack_size(sms_callstack); i++)
if (*ptr_array[i])
*ptr_array[i] = sm_meet_object(*ptr_array[i]);
// sm_object ***ptr_array = (sm_object ***)sm_stack_empty_top(sms_callstack);
// for (int i = 0; i < sm_stack_size(sms_callstack); i++)
// if (*ptr_array[i])
// *ptr_array[i] = sm_meet_object(*ptr_array[i]);

// Parser output never gets saved. Ptrs would get broken, so set it to a literal
// TODO: parser output goes into its own heap
if (sm_global_parser_output(NULL))
sm_global_parser_output(sm_meet_object(sm_global_parser_output(NULL)));
// sm_global_parser_output((sm_object *)sms_false);
Expand Down

0 comments on commit c2e4d52

Please sign in to comment.