stuff for defining avm classes, more CL(cons,car,cdr,if,case,typep,nil,etc)
[swf2/david.git] / lib / cl-conses.lisp
blobb0ece8dd163bad8e09664703673184407785f434
1 (in-package #:as3-compiler)
3 ;;; implement functions/macros from CL package
4 ;;;
5 ;;; most probably don't match CL semantics very closely yet...
7 ;;; conses dictionary (14.2)
8 ;;;
9 ;;; not sure what best internal rep for conses is,
10 ;;; could use anonymous object
11 ;;; 2 element array
12 ;;; instances of named class
13 ;;; ?
14 ;;;
15 ;;; named class is probably easiest to recognize for type checking
16 ;;; so trying that first
17 ;;; anon object with car and cdr properties might also be nice, and
18 ;;; just allow any object with those to be used as a 'cons', but
19 ;;; wouldn't match CL sematics very well
20 (let ((*symbol-table* *cl-symbol-table*))
21 ;; todo: probably should figure out how to make this final/sealed/etc.
22 (def-swf-class cons-type "cons" object (%car %cdr)
23 ((a b)
24 (%set-property this %car a)
25 (%set-property this %cdr b)))
27 (swf-defmemfun cons (a b)
28 (%asm (:find-property-strict cons-type)
29 (:get-local-1)
30 (:get-local-2)
31 (:construct-prop cons-type 2)))
33 (swf-defmemfun car (a)
34 (if (eq a :null)
35 :null
36 (%asm (:get-local-1)
37 (:get-property %car))))
38 (swf-defmemfun cdr (a)
39 (if (eq a :null)
40 :null
41 (if (%typep a cons-type)
42 (%asm (:get-local-1)
43 (:get-property %cdr))
44 (%error "type-error: unknown type cdr"))))