You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(backend): Implement an anf tree and anf mapper (#12)
* feat: Refactor locations out of expressions
Locations and expressions were overly intertwined this would have led to issues differentiating between sets and gets when performing codegen.
* chore: Update tests
* feat: Implement anf mapper and tree
Copy file name to clipboardExpand all lines: Codegen.md
+6-10Lines changed: 6 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,9 +41,9 @@ Statements are going to be lowered within a function to wasm instructions.
41
41
### Assignments
42
42
Assignments are pretty simple we need to compile the left hand side which is the location accessor to become a `global.get` if we are working on an array we are going to need to set a memory address.
43
43
44
-
We are then either going to use `WasmI32.store` for arrays or `local.set` for local variables or `local.set` for global variables `global.set`
44
+
We are then either going to use `WasmI32.store` for arrays or `local.set` for local variables or `local.set` for global variables `global.set`
45
45
46
-
### Expression Statetements
46
+
### Expression Statements
47
47
These compile pretty simply as we compile the expression like normal and just `(drop)` the result if there is one.
48
48
49
49
### If Statements
@@ -70,13 +70,13 @@ This is going to compile to a wasm call pretty cleanly
70
70
This is going to compile pretty cleanly into a wasm instruction we are going to need to use the signature and operator to determine what instruction to use from a lookup table.
71
71
72
72
### Prefix Node
73
-
This is going to be done just like binops but with different instructions. I think for not we have a few option for compiling the simplest one is probably bitwise. It's also ussually the fastest
73
+
This is going to be done just like binops but with different instructions. I think for not we have a few option for compiling the simplest one is probably bitwise. It's also usually the fastest.
74
74
75
75
### New Class Node
76
76
This isn't going to be compiled if it was we would store some sort of record in linear memory that points to everything.
77
77
78
78
### New Array Node
79
-
This is going to probably use a very primtive bump allocator to compile some instructions that write a simple data structure to memory probably something like ```<arrayTypeID>, <size>, ...<values>````
79
+
This is going to probably use a very primitive bump allocator to compile some instructions that write a simple data structure to memory probably something like `<arrayTypeID>, <size>, ...<values>`
80
80
81
81
### LocationNode
82
82
I think we still need todo some thoughts here but it's essentially going to be come a local.get or local.set depending on the use, this is probably going to be compiled in a somewhat context aware manner.
@@ -97,14 +97,10 @@ This is going to become a `(i32.const <value>)`
97
97
This is also going to become a `(i32.const <value>)` we will make no distinction between a character and an integer at runtime.
98
98
99
99
### String
100
-
This is only going to be compiledin one place the values will go into data sections and we will copy from the data section into memory passing around the pointer.
100
+
This is only going to be compiled one place the values will go into data sections and we will copy from the data section into memory passing around the pointer.
101
101
102
102
### BooleanNode
103
103
This is going to compile to a `(i32.const <value>)` with `1` for `true` and `0` for `false`.
104
104
105
105
### NullNode
106
-
This is going to compile to a `(i32.const 0)` most likely though I need to consider this a bit more.
107
-
108
-
109
-
#### Other Notes
110
-
* We can't modify parameters so we are going to need to not allow assignments on parameters this can be done in the typechecker.
106
+
This is going to compile to a `(i32.const 0)` most likely though I need to consider this a bit more.
0 commit comments