1 (in-package :as3-compiler
)
5 (defun %swf-defun
(name args body
&key method constructor
)
6 (let* ((*current-lambda
* (make-lambda-context args
)))
9 ;; swf name in format suitable for passing to asm (string/'(qname...))
10 ;; args to as3-method:
12 ;; list of arg types (probably all T/* for now)
18 (as3-asm::symbol-to-qname-list name
)
19 0 ;; name in method struct?
20 (loop for i in args collect
0) ;; arg types, 0 = t/*/any
21 0 0 ;; return type = any, flags = 0
23 (if (or method constructor
)
32 `(,@(scompile `(progn ,@body
))
35 (scompile `(return (progn ,@body
))))))
36 (gethash name
(functions *symbol-table
*) (list))
40 ;;(format t "~{~s~%~}" (sixth (find-swf-function 'floor)))
41 ;;(format t "~{~s~%~}" (as3-asm::as3-disassemble (as3-asm:assemble (sixth (find-swf-function 'random)))))
43 (defun old-%swf-defun
(name args body
&key method constructor
)
45 (setf name
(as3-asm::symbol-to-qname name
)))
46 (let* ((*current-lambda
* (make-lambda-context args
))
48 (as3-asm::as3-method
0
49 (loop for i in args collect
0 ) ;; 0 = * (any type)
54 (if (or method constructor
)
63 `(,@(scompile `(progn ,@body
))
66 (scompile `(return (progn ,@body
)))))))))
68 (push (list name mid
) (function-names *compiler-context
*)))
71 (defmacro swf-defun
(name (&rest args
) &body body
)
72 `(%swf-defun
',name
',args
(list
74 if
(and (consp i
) (eql (car i
) 'cl
))
77 collect
(list 'quote i
)))))
79 (defmacro swf-constructor
(name (&rest args
) &body body
)
80 `(%swf-defun
',name
',args
(list
82 if
(and (consp i
) (eql (car i
) 'cl
))
85 collect
(list 'quote i
)))
88 (defmacro swf-defmemfun
(name (&rest args
) &body body
)
89 `(%swf-defun
',name
',args
(list
91 if
(and (consp i
) (eql (car i
) 'cl
))
94 collect
(list 'quote i
)))
97 (defmacro define-swf-class
(name super
(&rest options
) &body members
)
102 (defmacro swf-defmacro
(name (&rest args
) &body body
)
103 `(defmethod scompile-cons ((car (eql ',name
)) cdr
)
104 (destructuring-bind (,@args
) cdr