From 1ff8ffb793a988de0bea7b3c7e663886801e9ce9 Mon Sep 17 00:00:00 2001 From: colin Date: Sat, 1 Jun 2024 11:06:53 -0700 Subject: Add: types.lisp, singletonc lasses, debugging instr.lisp --- src/ast.lisp | 60 +++--------------------------------------------------------- 1 file changed, 3 insertions(+), 57 deletions(-) (limited to 'src/ast.lisp') diff --git a/src/ast.lisp b/src/ast.lisp index eef5c05..9987ddf 100644 --- a/src/ast.lisp +++ b/src/ast.lisp @@ -1,70 +1,16 @@ (defpackage #:sarcasm.ast - (:use #:cl) + (:use #:cl #:sarcasm.types) (:import-from #:sarcasm.util #:def/class) (:local-nicknames (#:a #:alexandria-2) - (#:util #:sarcasm.util))) + (#:util #:sarcasm.util) + (#:instr #:sarcasm.instr))) (in-package #:sarcasm.ast) ;;; TYPES - -(deftype i32 () - '(integer 0 #.(expt 2 32))) - -(deftype i64 () - '(integer 0 #. (expt 2 64))) - -(deftype f32 () - 'single-float) - -(deftype f64 () - 'double-float) - -(deftype numtype () - '(or i32 i64 f32 f64)) - -(deftype typeidx () - 'i32) - -(deftype vectype () - '(bit-vector 128)) - -(deftype funcref () - 't) - -(deftype externref () - 't) - -(deftype reftype () - '(or funcref externref)) - -(deftype valtype () - '(or numtype vectype reftype)) - -(defun stack-effect-type-p (thing) - "A stack effect type is a two element list of lists of keywords. - -It describes the types of values consumed off the stack and returned -to the stack by instructions." - (and (listp thing) - (= 2 (length thing)) - (listp (first thing)) - (listp (second thing)) - (every #'keywordp (first thing)) - (every #'keywordp (second thing)))) - -(deftype stack-effect-type () - "This is not part of the standard grammar, but appears implicitly in -the WASM table of instructions found - - https://webassembly.github.io/spec/core/appendix/index-instructions.html - -In the `Type` column." - '(satisfies stack-effect-type-p)) - ;;; MODULE-STRUCTURES (def/class instr () -- cgit v1.2.3