git.fiddlerwoaroof.com
Browse code

feat(types): update typechecker a tiny bit

fiddlerwoaroof authored on 27/01/2022 23:54:35
Showing 1 changed files
... ...
@@ -2,12 +2,40 @@
2 2
   (:use :cl))
3 3
 (in-package :the-type)
4 4
 
5
+(defclass binding ()
6
+  ((%type :initarg :type :accessor type-binding)
7
+   (%value :initarg :value :accessor value-binding)))
8
+
5 9
 (defclass environment ()
6 10
   ((%vars :initarg :vars :initform (make-hash-table))
7
-   (%)))
11
+   (%funcs :initarg :funcs :initform (make-hash-table))))
12
+
13
+(defparameter *the-env* (make-instance 'environment))
14
+
15
+(defmacro define-function-binding (name env (&key return-type) (&rest args) &body body)
16
+  `(setf (gethash ',name (funcs ,env)
17
+                  )))
18
+
19
+(progn
20
+  (setf (gethash '+ (funcs *the-env*))
21
+        #'+)
22
+  (setf (gethash '+ (funcs *the-env*))
23
+        #'+)
24
+  )
8 25
 
9
-(dolist (item list result)
10
-  item)
26
+(defun annotate-function-call (function-type call-form)
27
+  (mapcar (lambda (type-element call-element)
28
+            (list type-element call-element))
29
+          function-type call-form))
11 30
 
12
-(defun format-dolist (dolist-form)
13
-  kj)
31
+(defun check-function-type (function args)
32
+  (let ((type-sig (case function
33
+                    ('+ '(number number))
34
+                    ('* '(number number))
35
+                    ('length '(string)))))
36
+    (when (= (length type-sig) (length args))
37
+      )))
38
+(defun check-types (form)
39
+  (typecase form
40
+    (cons (check-function-type (car form) (cdr form)))
41
+    (t t)))