This repository was archived by the owner on Nov 22, 2023. It is now read-only.
File tree 4 files changed +101
-4
lines changed
4 files changed +101
-4
lines changed Original file line number Diff line number Diff line change @@ -2728,9 +2728,10 @@ void ast_execute_function(symdecl* s){
2728
2728
ast_vm_stack_pop ();
2729
2729
}
2730
2730
for (i = 0 ; i < cur_stmt -> goto_scopediff ; i ++ ){
2731
- //debug_print("goto popping stacks...",0,0);
2732
2731
scope_executing_stack_pop ();
2733
2732
}
2733
+ scope_positions [n_scopes_executings - 1 ].is_in_loop = 0 ; //breaks out of the loop, is_in_loop is undone.
2734
+
2734
2735
//find our new position...
2735
2736
stmt_list = scope_executing_stack_gettop ()-> stmts ;
2736
2737
which_stmt = cur_stmt -> goto_where_in_scope ;
@@ -2747,6 +2748,7 @@ void ast_execute_function(symdecl* s){
2747
2748
//debug_print("goto popping stacks...",0,0);
2748
2749
scope_executing_stack_pop ();
2749
2750
}
2751
+
2750
2752
//TODO- make a symbol linkage.
2751
2753
i = cur_stmt -> symid ;
2752
2754
/*for(i = 0; i < (int64_t)nsymbols; i++)
@@ -2768,6 +2770,7 @@ void ast_execute_function(symdecl* s){
2768
2770
//debug_print("goto popping stacks...",0,0);
2769
2771
scope_executing_stack_pop ();
2770
2772
}
2773
+
2771
2774
//find our new position...
2772
2775
stmt_list = scope_executing_stack_gettop ()-> stmts ;
2773
2776
uint64_t pp1 ;
Original file line number Diff line number Diff line change @@ -1939,6 +1939,7 @@ int main(int argc, char** argv){
1939
1939
{
1940
1940
{
1941
1941
t = DUP_PATH_STRING (infilename , NULL );
1942
+ free (infilename );
1942
1943
}
1943
1944
if (!t ) {
1944
1945
puts ("\r\nCannot find file realpath!\n" );
Original file line number Diff line number Diff line change 1
1
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
Original file line number Diff line number Diff line change @@ -661,7 +661,9 @@ fn codegen switch_test(int a):
661
661
int j
662
662
//break
663
663
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
665
667
end
666
668
end
667
669
:getout
You can’t perform that action at this time.
0 commit comments