summaryrefslogtreecommitdiff
path: root/src/ast.lisp
blob: 9987ddfc435c07a2972bed8eb5ab021266e23638 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(defpackage #:sarcasm.ast
  (:use #:cl #:sarcasm.types)
  (:import-from #:sarcasm.util #:def/class)
  (:local-nicknames
   (#:a #:alexandria-2)
   (#:util #:sarcasm.util)
   (#:instr #:sarcasm.instr)))

(in-package #:sarcasm.ast)

;;; TYPES


;;; MODULE-STRUCTURES

(def/class instr ()
  ((name :prefix :type keyword)
   (code :prefix :type (vector byte))
   (type :prefix :type stack-effect-type)))

(def/class numeric-instr (instr))

(def/class func ()
  (type :prefix :type typeidx)
  (locals :type (vector valtype))
  (body :prefix :type expr))

;;; MODULES

(def/class module ()
  (types funcs tables mems globals elems datas imports exports
         :type vector :initform (vector))
  (start :type (or null t)            ; TODO: what is this value type?
         :initform nil))