From eb6e4a13390ed7013bcd2c08f9661c1d6baaf955 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 30 Nov 2019 14:16:05 -0800 Subject: 5785 - initial skeleton for parsing fn bodies All tests passing again. We have big gaping holes for type- and var-management. We're going to work on the latter first. --- apps/mu | Bin 63180 -> 63284 bytes apps/mu.subx | 26 +++++++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/apps/mu b/apps/mu index 1aae0007..71db0eb1 100755 Binary files a/apps/mu and b/apps/mu differ diff --git a/apps/mu.subx b/apps/mu.subx index d29821a3..6e092331 100644 --- a/apps/mu.subx +++ b/apps/mu.subx @@ -1924,6 +1924,8 @@ parse-mu-stmt: # line : (address stream) -> result/eax : (address stmt) # var result/edi : (address stmt) (allocate Heap *Stmt-size) 89/<- %edi 0/r32/eax + # result->tag = 1/stmt + c7 0/subop/copy *edi 1/imm32/stmt1 # Stmt-tag { (stmt-has-outputs? *(ebp+8)) 3d/compare-eax-and 0/imm32 @@ -2069,6 +2071,10 @@ parse-var: # ad: allocation-descriptor, name: (address slice) -> result/eax: (a 89/<- %ecx 0/r32/eax (allocate *(ebp+8) *Var-size) # => eax 89/<- *eax 1/r32/ecx # Var-name + # var->type = int + c7 0/subop/copy *(eax+4) 1/imm32/int-type # Var-type + # var->stack-offset = 8 + c7 0/subop/copy *(eax+0xc) 8/imm32 # Var-stack-offset $parse-var:end: # . restore registers 59/pop-to-ecx @@ -2423,8 +2429,16 @@ emit-subx-block: # out : (address buffered-file), block : (address block) { $emit-subx-block:stmt: 81 7/subop/compare %esi 0/imm32 - 74/jump-if-equal break/disp8 + 0f 84/jump-if-equal break/disp32 (write-buffered *(ebp+8) "{\n") + { + 81 7/subop/compare %esi 0/imm32 + 74/jump-if-equal break/disp8 + (emit-subx-statement *(ebp+8) *esi 0 Primitives 0) # TODO: initialize vars and functions + (write-buffered *(ebp+8) Newline) + 8b/-> *(esi+4) 6/r32/esi # List-next + eb/jump loop/disp8 + } (write-buffered *(ebp+8) "}\n") } $emit-subx-block:end: @@ -2973,22 +2987,24 @@ $mu-stmt-matches-primitive?:check-inouts: { 81 7/subop/compare %esi 0/imm32 75/jump-if-not-equal break/disp8 +$mu-stmt-matches-primitive?:stmt-inout-is-null: { 81 7/subop/compare %edi 0/imm32 75/jump-if-not-equal break/disp8 # return true - b8/copy-to-eax 1/imm32 + b8/copy-to-eax 1/imm32/true e9/jump $mu-stmt-matches-primitive?:end/disp32 } # return false - b8/copy-to-eax 0/imm32 + b8/copy-to-eax 0/imm32/false e9/jump $mu-stmt-matches-primitive?:end/disp32 } # if (curr2 == 0) return false { 81 7/subop/compare %edi 0/imm32 75/jump-if-not-equal break/disp8 - b8/copy-to-eax 0/imm32 +$mu-stmt-matches-primitive?:prim-inout-is-null: + b8/copy-to-eax 0/imm32/false e9/jump $mu-stmt-matches-primitive?:end/disp32 } # if (curr != curr2) return false @@ -2996,7 +3012,7 @@ $mu-stmt-matches-primitive?:check-inouts: (operand-matches-primitive? *esi *edi) # => eax 3d/compare-eax-and 0/imm32 75/jump-if-not-equal break/disp8 - b8/copy-to-eax 0/imm32 + b8/copy-to-eax 0/imm32/false e9/jump $mu-stmt-matches-primitive?:end/disp32 } # curr=curr->next -- cgit 1.4.1-2-gfad0 bc92c97cf529d6a51972be350e8ee1b2c'>836d13db ^
4a943d4e ^
eb45b315 ^
4a943d4e ^


83c67014 ^
4a943d4e ^



83c67014 ^
c82d149b ^
4a943d4e ^







836d13db ^
bc9f26de ^
0c6c7ff7 ^

631de5d9 ^


222c31db ^

bb62d65e ^


c442a5ad ^
bb62d65e ^


1a62e61d ^
c442a5ad ^
f7ff8585 ^
222c31db ^
836d13db ^

c442a5ad ^
836d13db ^

222c31db ^
bb62d65e ^
c442a5ad ^
836d13db ^
bb62d65e ^
631de5d9 ^
836d13db ^
4a943d4e ^





83c67014 ^
4a943d4e ^



83c67014 ^
c82d149b ^
4a943d4e ^







0e87e934 ^
4a943d4e ^



83c67014 ^
4a943d4e ^



83c67014 ^
c82d149b ^
4a943d4e ^







d1df4aca ^


4a943d4e ^





83c67014 ^
4a943d4e ^



83c67014 ^
c82d149b ^
4a943d4e ^








d1df4aca ^







4a943d4e ^





83c67014 ^
4a943d4e ^



83c67014 ^
c82d149b ^
4a943d4e ^








d1df4aca ^




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155