Skip to content
This repository was archived by the owner on Nov 22, 2023. It is now read-only.

Commit 7ffdc9e

Browse files
author
gek
committed
make push
1 parent 83dde2c commit 7ffdc9e

File tree

4 files changed

+101
-4
lines changed

4 files changed

+101
-4
lines changed

astexec.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -2728,9 +2728,10 @@ void ast_execute_function(symdecl* s){
27282728
ast_vm_stack_pop();
27292729
}
27302730
for(i = 0; i < cur_stmt->goto_scopediff; i++ ){
2731-
//debug_print("goto popping stacks...",0,0);
27322731
scope_executing_stack_pop();
27332732
}
2733+
scope_positions[n_scopes_executings-1].is_in_loop = 0; //breaks out of the loop, is_in_loop is undone.
2734+
27342735
//find our new position...
27352736
stmt_list = scope_executing_stack_gettop()->stmts;
27362737
which_stmt = cur_stmt->goto_where_in_scope;
@@ -2747,6 +2748,7 @@ void ast_execute_function(symdecl* s){
27472748
//debug_print("goto popping stacks...",0,0);
27482749
scope_executing_stack_pop();
27492750
}
2751+
27502752
//TODO- make a symbol linkage.
27512753
i = cur_stmt->symid;
27522754
/*for(i = 0; i < (int64_t)nsymbols; i++)
@@ -2768,6 +2770,7 @@ void ast_execute_function(symdecl* s){
27682770
//debug_print("goto popping stacks...",0,0);
27692771
scope_executing_stack_pop();
27702772
}
2773+
27712774
//find our new position...
27722775
stmt_list = scope_executing_stack_gettop()->stmts;
27732776
uint64_t pp1;

ctok.c

+1
Original file line numberDiff line numberDiff line change
@@ -1939,6 +1939,7 @@ int main(int argc, char** argv){
19391939
{
19401940
{
19411941
t = DUP_PATH_STRING(infilename, NULL);
1942+
free(infilename);
19421943
}
19431944
if(!t) {
19441945
puts("\r\nCannot find file realpath!\n");

featuretest.cbas

+93-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,94 @@
11

2-
//TEST 1: Can the metaprogramming library even compile?
3-
#include <meta>
2+
3+
4+
//TEST 2: compiletime math
5+
codegen int have_failed = 0;
6+
7+
fn codegen testmath:
8+
int a = 7
9+
int b = 23
10+
int c = a + b
11+
if(c != a + b)
12+
__builtin_puts("Failed integer addition test 1");
13+
have_failed = 1
14+
end
15+
16+
double q = 23
17+
double q2 = 23
18+
double q3 = q + q2
19+
if(q3 != q + q2)
20+
__builtin_puts("Failed double math test 1");
21+
have_failed = 1
22+
end
23+
24+
a = -23;
25+
b = 23;
26+
if(a + b != 0)
27+
__builtin_puts("Failed addition test 2- should be zero");
28+
have_failed = 1
29+
end
30+
byte* p = __builtin_malloc(512);
31+
if(p == 0)
32+
__builtin_puts("Failed malloc");
33+
have_failed = 1
34+
end
35+
__builtin_free(p);
36+
37+
38+
a = 27 % 3;
39+
if(a != 0)
40+
__builtin_puts("Failed modulo 1");
41+
have_failed = 1
42+
end
43+
a = 27 % 2;
44+
if(a != 1)
45+
__builtin_puts("Failed modulo 2");
46+
have_failed = 1
47+
end
48+
end
49+
50+
fn codegen test_loops:
51+
for(0,0,0)
52+
__builtin_puts("Failed for(0,0,0)");
53+
have_failed = 1
54+
end
55+
for(1,1,1)
56+
goto after_for_111
57+
end
58+
__builtin_puts("Failed for(1,1,1)");
59+
have_failed = 1;
60+
:after_for_111
61+
i64 i
62+
//if(1)
63+
for(i = 0, i < 20; i++)
64+
;
65+
__builtin_puts("You should see this print!");
66+
if(i == 3)
67+
break
68+
end
69+
end
70+
if(i != 3)
71+
__builtin_puts("Failed Loop Test 1");
72+
char[50] buf
73+
__builtin_utoa(buf, i);
74+
__builtin_puts(buf);
75+
have_failed = 1
76+
end
77+
//end
78+
79+
80+
81+
82+
end
83+
84+
85+
fn codegen codegen_main:
86+
__builtin_puts("TESTING BASIC ARITHMETIC");
87+
testmath();
88+
test_loops();
89+
if(!have_failed)
90+
__builtin_puts("Success!!!!");
91+
else
92+
__builtin_puts("------------FAILED--------------------");
93+
end
94+
end

tests/vm_test.cbas

+3-1
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,9 @@ fn codegen switch_test(int a):
661661
int j
662662
//break
663663
for(j = 0, j < 2, j++)
664-
__builtin_puts("I should print twice six times! Unless you put a break here:");continue break
664+
__builtin_puts("I should print twice six times! Unless you put a break here:");
665+
continue
666+
break
665667
end
666668
end
667669
:getout

0 commit comments

Comments
 (0)