From 51a1e71c269f298fba18b620c68a0b1b15d236e9 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Sun, 24 Jul 2022 19:08:13 -0700 Subject: Improve the match syntax for constants. I guess you can pattern match using quote as a literal. That's pretty cool. --- csc/encoding.csc | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'csc/encoding.csc') 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)))) -- cgit v1.3.1