aboutsummaryrefslogtreecommitdiffstats
path: root/csc/encoding.csc
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-07-24 19:08:13 -0700
committerRose Hogenson <rhogenson@posteo.net>2022-07-24 19:08:13 -0700
commit51a1e71c269f298fba18b620c68a0b1b15d236e9 (patch)
tree10eb01e4afed9d636d7e20f36a676363a8359ad1 /csc/encoding.csc
parent192ab9c4e21bab8c08a640b349fa9630a9a672df (diff)
downloadchromatopelma-51a1e71c269f298fba18b620c68a0b1b15d236e9.tar.zst
Improve the match syntax for constants.
I guess you can pattern match using quote as a literal. That's pretty cool.
Diffstat (limited to 'csc/encoding.csc')
-rw-r--r--csc/encoding.csc38
1 files changed, 19 insertions, 19 deletions
diff --git a/csc/encoding.csc b/csc/encoding.csc
index 5c06bec..8dbd89c 100644
--- a/csc/encoding.csc
+++ b/csc/encoding.csc
@@ -35,25 +35,25 @@
(define (opcode-switch opcode)
(match opcode
- (((! 'const) n) (append (64->le-bytes 1010) (64->le-bytes n)))
- ((! 'add) (64->le-bytes 1020))
- ((! 'sub) (64->le-bytes 1030))
- ((! 'mul) (64->le-bytes 1040))
- ((! 'div) (64->le-bytes 1050))
- ((! 'mod) (64->le-bytes 1060))
- ((! 'alloc) (64->le-bytes 2010))
- (((! 'peek) n) (append (64->le-bytes 2020) (list n)))
- (((! 'poke) n) (append (64->le-bytes 2030) (list n)))
- ((! 'peekbyte) (64->le-bytes 2040))
- ((! 'pokebyte) (64->le-bytes 2050))
- ((! 'pop) (64->le-bytes 3010))
- (((! 'local) n) (append (64->le-bytes 3020) (list n)))
- (((! 'if) n) (append (64->le-bytes 4010) (64->le-bytes n)))
- (((! 'call) n) (append (64->le-bytes 4020) (list n)))
- ((! 'ret) (64->le-bytes 4030))
- ((! 'exit) (64->le-bytes 4040))
- ((! 'putc) (64->le-bytes 5010))
- ((! 'getc) (64->le-bytes 5020))
+ (('const n) (append (64->le-bytes 1010) (64->le-bytes n)))
+ ('add (64->le-bytes 1020))
+ ('sub (64->le-bytes 1030))
+ ('mul (64->le-bytes 1040))
+ ('div (64->le-bytes 1050))
+ ('mod (64->le-bytes 1060))
+ ('alloc (64->le-bytes 2010))
+ (('peek n) (append (64->le-bytes 2020) (list n)))
+ (('poke n) (append (64->le-bytes 2030) (list n)))
+ ('peekbyte (64->le-bytes 2040))
+ ('pokebyte (64->le-bytes 2050))
+ ('pop (64->le-bytes 3010))
+ (('local n) (append (64->le-bytes 3020) (list n)))
+ (('if n) (append (64->le-bytes 4010) (64->le-bytes n)))
+ (('call n) (append (64->le-bytes 4020) (list n)))
+ ('ret (64->le-bytes 4030))
+ ('exit (64->le-bytes 4040))
+ ('putc (64->le-bytes 5010))
+ ('getc (64->le-bytes 5020))
(_ (error "invalid opcode" opcode))))