diff options
| author | Rose Hogenson <rhogenson@posteo.net> | 2022-08-22 20:07:06 -0700 |
|---|---|---|
| committer | Rose Hogenson <rhogenson@posteo.net> | 2022-08-22 20:07:06 -0700 |
| commit | dc8a480c65fabf35b99398120aeccca8f2874c6d (patch) | |
| tree | 5137f282745f622fc69c799c4e95d694c47c0095 /lib/csc/encoding.csc | |
| parent | Simplify the heap. (diff) | |
| download | chromatopelma-dc8a480c65fabf35b99398120aeccca8f2874c6d.tar.zst | |
Add a few primitive list operations.
Diffstat (limited to 'lib/csc/encoding.csc')
| -rw-r--r-- | lib/csc/encoding.csc | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/csc/encoding.csc b/lib/csc/encoding.csc index aceedc8..099beaf 100644 --- a/lib/csc/encoding.csc +++ b/lib/csc/encoding.csc @@ -1,6 +1,7 @@ (define-library (csc encoding) (export encode) (import (scheme base) + (csc format) (only (csc loop) loop return) @@ -10,10 +11,10 @@ ; The format of unboxed constants is described in bytecocde/src/data.rs. ; Boxed values are represented by a pointer to an array on the heap. The ; first position in the array is an integer code indicating what type the - ; object is. Vectors have code 0, codes for other types are not stable. - ; Vectors are represented as an array, the first element of which is the - ; integer 0 (the type code), the second element is the vector length, and - ; the remaining slots hold the array values. + ; object is. Vectors have code 0, pairs have code 2, and codes for other + ; types are not stable. Vectors are represented as an array, the first + ; element of which is the integer 0 (the type code), the second element is + ; the vector length, and the remaining slots hold the array values. (define (low-byte w n) @@ -185,6 +186,15 @@ (arg->le-bytes w dest) (arg->le-bytes w x) (arg->le-bytes w y)) + (('cons dest x y) + (make-opcode w 18 (is-const? x) (is-const? y)) + (arg->le-bytes w dest) + (arg->le-bytes w x) + (arg->le-bytes w y)) + (('len dest l) + (make-opcode w 19 (is-const? l) #f) + (arg->le-bytes w dest) + (arg->le-bytes w l)) (_ (error "invalid opcode" opcode)))) |
