From f31e94a9058d76d818934dc61f25e42cbc1446d9 Mon Sep 17 00:00:00 2001 From: Bart Botta <00003b@gmail.com> Date: Sun, 23 Nov 2008 05:27:01 -0600 Subject: [PATCH] rename as3 -> avm2 since we don't actually deal with actionscript anywhere --- asm/asm.lisp | 18 +-- asm/{as3-asm.asd => avm2-asm.asd} | 2 +- asm/context.lisp | 34 ++--- asm/opcodes.lisp | 32 ++-- asm/package.lisp | 4 +- asm/peephole.lisp | 6 +- compile/{as3-compile.asd => avm2-compile.asd} | 4 +- compile/compiler-context.lisp | 2 +- compile/compiler.lisp | 2 +- compile/defun.lisp | 12 +- compile/ffi.lisp | 10 +- compile/low-level.lisp | 2 +- compile/math-ops.lisp | 2 +- compile/package.lisp | 2 +- compile/special-forms.lisp | 22 +-- compile/swfclass.lisp | 4 +- file/write.lisp | 212 +++++++++++++------------- lib/{as3-lib.asd => avm2-lib.asd} | 4 +- lib/cl-conses.lisp | 2 +- lib/cl.lisp | 2 +- lib/library-packages.lisp | 2 +- lib/player-class-decl.lisp | 2 +- lib/player-classes.lisp | 2 +- lib/player-lib.lisp | 2 +- lib/sicl-conditionals.lisp | 2 +- lib/sicl-iteration.lisp | 2 +- test/roots.lisp | 2 +- test/test.lisp | 2 +- 28 files changed, 197 insertions(+), 197 deletions(-) rename asm/{as3-asm.asd => avm2-asm.asd} (97%) rename compile/{as3-compile.asd => avm2-compile.asd} (86%) rename lib/{as3-lib.asd => avm2-lib.asd} (85%) diff --git a/asm/asm.lisp b/asm/asm.lisp index d41cbb3..bf089d7 100644 --- a/asm/asm.lisp +++ b/asm/asm.lisp @@ -1,4 +1,4 @@ -(in-package :as3-asm) +(in-package :avm2-asm) ;;; for now just using keywords as opcode names... @@ -185,7 +185,7 @@ (decode-variable-length '(#b1)) ; 1 (decode-variable-length '(#b10010110 #b11)) -(defun as3-disassemble (sequence &key (start 0)) +(defun avm2-disassemble (sequence &key (start 0)) (loop for length = (length sequence) with op = nil @@ -241,12 +241,12 @@ (aref (,pool *assembler-context*) value) (list :id value)))))) - (make-interner asm-intern-string lookup-string as3-string strings) - ;; fixme: as3-intern-* can break if first thing interned is wrong type - (make-interner asm-intern-int lookup-int as3-intern-int ints) - (make-interner asm-intern-uint lookup-uint as3-intern-uint uints) - (make-interner asm-intern-double lookup-double as3-intern-double doubles) - (make-interner asm-intern-namespace lookup-namespace as3-ns-intern namespaces)) + (make-interner asm-intern-string lookup-string avm2-string strings) + ;; fixme: avm2-intern-* can break if first thing interned is wrong type + (make-interner asm-intern-int lookup-int avm2-intern-int ints) + (make-interner asm-intern-uint lookup-uint avm2-intern-uint uints) + (make-interner asm-intern-double lookup-double avm2-intern-double doubles) + (make-interner asm-intern-namespace lookup-namespace avm2-ns-intern namespaces)) ;; (asm-intern-string "foo") ;; (asm-intern-string '(:id 2)) ;; (asm-intern-string :id) @@ -292,7 +292,7 @@ (if (eql package (find-package :keyword)) (setf package "") (setf package (string-downcase (or (package-name package) "")))) - (values (as3-asm::qname package sym) sym))) + (values (avm2-asm::qname package sym) sym))) (defun asm-intern-multiname (mn) (typecase mn diff --git a/asm/as3-asm.asd b/asm/avm2-asm.asd similarity index 97% rename from asm/as3-asm.asd rename to asm/avm2-asm.asd index 4339032..2d52bab 100644 --- a/asm/as3-asm.asd +++ b/asm/avm2-asm.asd @@ -1,5 +1,5 @@ -(defsystem :as3-asm +(defsystem :avm2-asm :depends-on ("ieee-floats") :components ((:file "package") (:file "peephole") diff --git a/asm/context.lisp b/asm/context.lisp index 75dffd9..40a37c0 100644 --- a/asm/context.lisp +++ b/asm/context.lisp @@ -1,14 +1,14 @@ -(in-package :as3-asm) +(in-package :avm2-asm) -(defclass as3sym () +(defclass avm2sym () ((string-id :initform nil :initarg string-id :accessor string-id) (namespace-id :initform nil :initarg namespace-id :accessor namespace-id) (method-id :initform nil :initarg method-id :accessor method-id) (class-id :initform nil :initarg class-id :accessor class-id))) (defclass assembler-context () - ;; as3 constant pools are 1 based, so we start them at 1 here, and + ;; avm2 constant pools are 1 based, so we start them at 1 here, and ;; skip the first entry on write ((ints :initform (make-array 32 :fill-pointer 1 :adjustable t) :reader ints) (uints :initform (make-array 32 :fill-pointer 1 :adjustable t) :reader uints) @@ -35,9 +35,9 @@ (defparameter *assembler-context* (make-instance 'assembler-context)) -(defparameter *empty-sym* (make-instance 'as3sym 'string-id 1 'namespace-id 1 +(defparameter *empty-sym* (make-instance 'avm2sym 'string-id 1 'namespace-id 1 'method-id 1 'class-id 1)) -(defun as3-intern (string-designator) +(defun avm2-intern (string-designator) (let ((string (and string-designator (string string-designator)))) (if (or (not string) #+()(string= string "")) *empty-sym* @@ -51,11 +51,11 @@ ;;(format t "interning ~a = ~d ~%" string j) (vector-push-extend string (strings *assembler-context*)) (setf (gethash string (string-intern-hash *assembler-context*)) - (make-instance 'as3sym 'string-id j)))))))) -(defun as3-string (s) - (string-id (as3-intern s))) + (make-instance 'avm2sym 'string-id j)))))))) +(defun avm2-string (s) + (string-id (avm2-intern s))) -(defun as3-intern-int (int) +(defun avm2-intern-int (int) ;;fixme: write a real version of this ;;(format t "intern int ~a ~%" int) (loop with a = (ints *assembler-context*) @@ -66,7 +66,7 @@ (length a) (vector-push-extend int a))))) -(defun as3-intern-uint (int) +(defun avm2-intern-uint (int) ;;fixme: write a real version of this (loop with a = (uints *assembler-context*) for i from 1 below (length a) @@ -76,7 +76,7 @@ (length a) (vector-push-extend int a))))) -(defun as3-intern-double (double) +(defun avm2-intern-double (double) ;;fixme: write a real version of this (loop with a = (doubles *assembler-context*) with d = (float double 1d0) @@ -97,8 +97,8 @@ (defparameter +static-protected-ns+ #x1a) (defparameter +private-ns+ #x05) -(defun as3-ns-intern (string-designator &key (kind +package-namespace+)) - (let ((sym (as3-intern string-designator))) +(defun avm2-ns-intern (string-designator &key (kind +package-namespace+)) + (let ((sym (avm2-intern string-designator))) (if (namespace-id sym) (namespace-id sym) (prog1 @@ -120,8 +120,8 @@ (defparameter +multiname-la+ #x1c) (defun intern-multiname (kind ns name) - (let* ((ns (as3-ns-intern ns)) - (name (as3-string name)) + (let* ((ns (avm2-ns-intern ns)) + (name (avm2-string name)) (mn (list kind ns name)) (id (gethash mn (multiname-hash *assembler-context*)))) (if id @@ -150,7 +150,7 @@ ;;; fixme: probably should make an effort to avoid duplicates or something? -(defun as3-class (name-mn super-mn flags interfaces instance-init traits class-init &key protected-ns class-traits ) +(defun avm2-class (name-mn super-mn flags interfaces instance-init traits class-init &key protected-ns class-traits ) (let ((class-id (length (classes *assembler-context*)))) (vector-push-extend (list name-mn super-mn flags interfaces instance-init traits protected-ns) @@ -159,7 +159,7 @@ (classes *assembler-context*)) class-id)) -(defun as3-method (name param-types return-type flags &key option-params pnames body) +(defun avm2-method (name param-types return-type flags &key option-params pnames body) (let ((method-id (length (method-infos *assembler-context*)))) (when body (setf flags (logior flags (flags body)))) (vector-push-extend (list name param-types return-type flags option-params pnames) diff --git a/asm/opcodes.lisp b/asm/opcodes.lisp index e7fdf1e..e96e31d 100644 --- a/asm/opcodes.lisp +++ b/asm/opcodes.lisp @@ -1,16 +1,16 @@ -(in-package :as3-asm) +(in-package :avm2-asm) (defun runtime-name-count (index) "some opcodes need extra args when passed a runtime multiname, check for that here and return count of extra args" - (let* ((mn (aref (as3-asm::multinames as3-asm::*assembler-context*) index)) + (let* ((mn (aref (avm2-asm::multinames avm2-asm::*assembler-context*) index)) (kind (car mn))) (cond - ((or (= kind as3-asm::+rt-qname+) - (= kind as3-asm::+rt-qname-a+)) + ((or (= kind avm2-asm::+rt-qname+) + (= kind avm2-asm::+rt-qname-a+)) 1) - ((or (= kind as3-asm::+rt-qname-l+) - (= kind as3-asm::+rt-qname-la+)) + ((or (= kind avm2-asm::+rt-qname-l+) + (= kind avm2-asm::+rt-qname-la+)) 2) (t 0)))) @@ -174,7 +174,7 @@ for that here and return count of extra args" #+nil(format t "~{ ~x ~}~% " - (as3-asm:assemble '((get-local-0) + (avm2-asm:assemble '((get-local-0) (push-scope) (return-void)))) ;; D0 30 47 @@ -183,8 +183,8 @@ for that here and return count of extra args" #+nil (let ((*assembler-context* (make-instance 'assembler-context))) ;; intern some names so the code compiles - (as3-intern "") - (as3-ns-intern "") + (avm2-intern "") + (avm2-ns-intern "") (qname "a" "b") (qname "b" "b") (qname "c" "b") @@ -216,8 +216,8 @@ for that here and return count of extra args" #+nil (let ((*assembler-context* (make-instance 'assembler-context))) ;; intern some names so the code compiles - (as3-intern "") - (as3-ns-intern "") + (avm2-intern "") + (avm2-ns-intern "") (qname "a" "b") (qname "b" "b") (qname "c" "b") @@ -247,15 +247,15 @@ for that here and return count of extra args" #+nil (let ((*assembler-context* (make-instance 'assembler-context))) ;; intern some names so the code compiles - (as3-intern "") - (as3-ns-intern "") + (avm2-intern "") + (avm2-ns-intern "") (qname "a" "b") (qname "b" "b") (qname "c" "b") (qname "d" "b") (qname "e" "b") (format t "~{ ~s~%~}~% " - (as3-disassemble + (avm2-disassemble (assemble '((:get-local-0) (:push-scope) (:get-local-0) @@ -280,7 +280,7 @@ for that here and return count of extra args" #+nil (format t "~{ ~s~%~}" - (as3-disassemble #(#xD0 #x30 #xD0 #x49 #x00 #x5D #x03 #x4A #x03 #x00 + (avm2-disassemble #(#xD0 #x30 #xD0 #x49 #x00 #x5D #x03 #x4A #x03 #x00 #x80 #x03 #xD5 #xD1 #x2C #x07 #x2C #x07 #xA0 #x61 #x04 #x5D #x05 #xD1 #x4F #x05 #x01 #x47))) @@ -306,6 +306,6 @@ for that here and return count of extra args" #+nil (format t "~{ ~s~%~}" - (as3-disassemble + (avm2-disassemble #( #xD0 #x30 #xD0 #x49 #x00 #x5D #x03 #x4A #x03 #x00 #x80 #x03 #xD5 #xD1 #x2C #x07 #x2C #x07 #xA0 #x61 #x04 #x5D #x05 #xD1 #x4F #x05 #x01 #x47) )) diff --git a/asm/package.lisp b/asm/package.lisp index a3a9bfb..94f8f25 100644 --- a/asm/package.lisp +++ b/asm/package.lisp @@ -2,12 +2,12 @@ (defpackage :3b-swf (:use :cl)) -(defpackage #:as3-asm +(defpackage #:avm2-asm (:use #:cl) (:export #:assemble #:assemble-method-body)) -(defpackage #:as3-opcodes +(defpackage #:avm2-opcodes (:use :cl) (:export #:breakpoint diff --git a/asm/peephole.lisp b/asm/peephole.lisp index 44ef327..99791ed 100644 --- a/asm/peephole.lisp +++ b/asm/peephole.lisp @@ -1,6 +1,6 @@ -(in-package :as3-asm) +(in-package :avm2-asm) -;;;; simple peephole optimizer for as3 asm, to handle some obvious cases +;;;; simple peephole optimizer for avm2 asm, to handle some obvious cases ;;;; of redundant code in the compiler ;;;; ex. (peephole '((:pushnull) (:pop))) -> () @@ -20,7 +20,7 @@ (defun peephole (forms) - "as3 asm peephole optimizer, pass in list of asm forms, returns + "avm2 asm peephole optimizer, pass in list of asm forms, returns optimized version" ;; quick hack peephole optimizer, for simple stuff like pushnull+pop, etc ;; get/setlocal 1 diff --git a/compile/as3-compile.asd b/compile/avm2-compile.asd similarity index 86% rename from compile/as3-compile.asd rename to compile/avm2-compile.asd index 0f053dd..b562e67 100644 --- a/compile/as3-compile.asd +++ b/compile/avm2-compile.asd @@ -1,6 +1,6 @@ -(asdf:defsystem :as3-compile - :depends-on ("as3-asm") +(asdf:defsystem :avm2-compile + :depends-on ("avm2-asm") :components ((:file "package") (:file "compiler-context") (:file "compiler") diff --git a/compile/compiler-context.lisp b/compile/compiler-context.lisp index 91c8e48..4aa5453 100644 --- a/compile/compiler-context.lisp +++ b/compile/compiler-context.lisp @@ -1,4 +1,4 @@ -(in-package :as3-compiler) +(in-package :avm2-compiler) ;;; copied from old code, not used yet... diff --git a/compile/compiler.lisp b/compile/compiler.lisp index 44d44ba..5bbd385 100644 --- a/compile/compiler.lisp +++ b/compile/compiler.lisp @@ -1,4 +1,4 @@ -(in-package :as3-compiler) +(in-package :avm2-compiler) ;;; (defclass compiler-context () diff --git a/compile/defun.lisp b/compile/defun.lisp index e06714a..e4d40df 100644 --- a/compile/defun.lisp +++ b/compile/defun.lisp @@ -1,4 +1,4 @@ -(in-package :as3-compiler) +(in-package :avm2-compiler) ;;;; defun and similar @@ -28,7 +28,7 @@ (push ;; function data: ;; swf name in format suitable for passing to asm (string/'(qname...)) - ;; args to as3-method: + ;; args to avm2-method: ;; name id? ;; list of arg types (probably all T/* for now) ;; return type @@ -36,7 +36,7 @@ ;; list of assembly ;; ? (list - (as3-asm::symbol-to-qname-list name) + (avm2-asm::symbol-to-qname-list name) 0 ;; name in method struct? (loop for i in args collect 0) ;; arg types, 0 = t/*/any 0 0 ;; return type = any, flags = 0 @@ -47,14 +47,14 @@ )) ;;(format t "~{~s~%~}" (sixth (find-swf-function 'floor))) -;;(format t "~{~s~%~}" (as3-asm::as3-disassemble (as3-asm:assemble (sixth (find-swf-function 'random))))) +;;(format t "~{~s~%~}" (avm2-asm::avm2-disassemble (avm2-asm:assemble (sixth (find-swf-function 'random))))) (defun old-%swf-defun (name args body &key method constructor) (when (symbolp name) - (setf name (as3-asm::symbol-to-qname name))) + (setf name (avm2-asm::symbol-to-qname name))) (with-lambda-context (:args args) (let* ((mid - (as3-asm::as3-method 0 + (avm2-asm::avm2-method 0 (loop for i in args collect 0 ) ;; 0 = * (any type) 0 0 :body diff --git a/compile/ffi.lisp b/compile/ffi.lisp index d679c80..1d2ea1d 100644 --- a/compile/ffi.lisp +++ b/compile/ffi.lisp @@ -1,4 +1,4 @@ -(in-package :as3-compiler) +(in-package :avm2-compiler) @@ -143,7 +143,7 @@ (:construct-prop ,name ,arg-count) (:coerce ,name)))) -;; (as3-asm:assemble (scompile '(%new flash.text:Text-Field 0))) -;; (as3-asm:assemble (scompile '(%new "flash.text:TextField" 0))) -;; (as3-asm:assemble (scompile '(%new "flash.text::TextField" 0))) -;; (as3-asm:assemble (scompile '(%new (:qname "flash.text" "TextField") 0))) +;; (avm2-asm:assemble (scompile '(%new flash.text:Text-Field 0))) +;; (avm2-asm:assemble (scompile '(%new "flash.text:TextField" 0))) +;; (avm2-asm:assemble (scompile '(%new "flash.text::TextField" 0))) +;; (avm2-asm:assemble (scompile '(%new (:qname "flash.text" "TextField") 0))) diff --git a/compile/low-level.lisp b/compile/low-level.lisp index 1f07cc8..e751207 100644 --- a/compile/low-level.lisp +++ b/compile/low-level.lisp @@ -1,4 +1,4 @@ -(in-package :as3-compiler) +(in-package :avm2-compiler) ;;;; misc low level operators, mostly just renaming asm opcodes ;;; might not actually need most of these now, use %asm instead? diff --git a/compile/math-ops.lisp b/compile/math-ops.lisp index c886788..4aa5dcf 100644 --- a/compile/math-ops.lisp +++ b/compile/math-ops.lisp @@ -1,4 +1,4 @@ -(in-package :as3-compiler) +(in-package :avm2-compiler) ;;; expand multiple arg math/comparison ops into chained binary ops diff --git a/compile/package.lisp b/compile/package.lisp index 5994bd7..430b16b 100644 --- a/compile/package.lisp +++ b/compile/package.lisp @@ -1,5 +1,5 @@ -(defpackage #:as3-compiler +(defpackage #:avm2-compiler (:use #:cl) (:export )) \ No newline at end of file diff --git a/compile/special-forms.lisp b/compile/special-forms.lisp index c75bacc..5c17c03 100644 --- a/compile/special-forms.lisp +++ b/compile/special-forms.lisp @@ -1,4 +1,4 @@ -(in-package :as3-compiler) +(in-package :avm2-compiler) ;;;; special forms (and probably some things that are techically ;;;; macros/functions according to CL, but implemented directly here @@ -163,7 +163,7 @@ ;; (with-lambda-context () (scompile '(tagbody foo (go baz) bar 1 baz 2))) -#+nil(define-special %when (cond label) +(define-special %when (cond label) ;; (%when cond label) `(,@(scompile cond) (:if-true ,label) @@ -200,7 +200,7 @@ (define-special if (cond true-branch false-branch) `(,@(scompile `(%if ,cond :if-false ,true-branch ,false-branch)))) -;; (as3-asm::with-assembler-context (as3-asm::code (as3-asm:assemble-method-body (scompile '(when :true 1)) ))) +;; (avm2-asm::with-assembler-context (avm2-asm::code (avm2-asm:assemble-method-body (scompile '(when :true 1)) ))) (define-special %inc-local-i (var) @@ -446,10 +446,10 @@ call with %flet-call, which sets up hidden return label arg #+nil -(as3-asm::as3-disassemble - (as3-asm::code - (as3-asm::with-assembler-context - (as3-asm::assemble-method-body +(avm2-asm::avm2-disassemble + (avm2-asm::code + (avm2-asm::with-assembler-context + (avm2-asm::assemble-method-body (with-simple-lambda-context () (append '((:%label foo)) @@ -460,10 +460,10 @@ call with %flet-call, which sets up hidden return label arg #+nil -(as3-asm::as3-disassemble - (as3-asm::code - (as3-asm::with-assembler-context - (as3-asm::assemble-method-body +(avm2-asm::avm2-disassemble + (avm2-asm::code + (avm2-asm::with-assembler-context + (avm2-asm::assemble-method-body (dump-defun-asm () (let ((s2 "<")) (block foo (unwind-protect diff --git a/compile/swfclass.lisp b/compile/swfclass.lisp index c9264a3..d3049f5 100644 --- a/compile/swfclass.lisp +++ b/compile/swfclass.lisp @@ -1,10 +1,10 @@ -(in-package :as3-compiler) +(in-package :avm2-compiler) ;;;; code for defining vm level classes (defmacro def-swf-class (name ns super (&rest properties) ((&rest constructor-args) &body constructor)) `(setf (gethash ',name (classes *symbol-table*)) - (list ',(as3-asm::symbol-to-qname-list name) + (list ',(avm2-asm::symbol-to-qname-list name) ',ns ',super ',properties diff --git a/file/write.lisp b/file/write.lisp index 595a2d0..065dba8 100644 --- a/file/write.lisp +++ b/file/write.lisp @@ -1,4 +1,4 @@ -(in-package :as3-compiler) +(in-package :avm2-compiler) ;;; code to write out abc tag/hard coded simple .swf file to seekable ;;; stream or file @@ -84,43 +84,43 @@ (defgeneric write-generic (data &optional *standard-output*)) -(defmethod write-generic ((trait as3-asm::trait-info) &optional (*standard-output* *standard-output*)) +(defmethod write-generic ((trait avm2-asm::trait-info) &optional (*standard-output* *standard-output*)) #+nil(format *trace-output* "trait-data : ~s ~s~%" - (as3-asm::name trait) - (as3-asm::trait-data trait)) - (write-u30 (as3-asm::name trait)) - (write-generic (as3-asm::trait-data trait)) - (when (not (zerop (logand #x40 (as3-asm::kind (as3-asm::trait-data trait))))) - (write-counted-sequence 'write-u30 (as3-asm::metadata trait)))) - -(defmethod write-generic ((td as3-asm::trait-data-slot/const) &optional (*standard-output* *standard-output*)) + (avm2-asm::name trait) + (avm2-asm::trait-data trait)) + (write-u30 (avm2-asm::name trait)) + (write-generic (avm2-asm::trait-data trait)) + (when (not (zerop (logand #x40 (avm2-asm::kind (avm2-asm::trait-data trait))))) + (write-counted-sequence 'write-u30 (avm2-asm::metadata trait)))) + +(defmethod write-generic ((td avm2-asm::trait-data-slot/const) &optional (*standard-output* *standard-output*)) #+nil(format *trace-output* "trait-data-slot/const :~s ~s ~s ~s ~s~%" - (as3-asm::kind td) - ( as3-asm::slot-id td) - ( as3-asm::type-name td) - (as3-asm::vindex td) - (as3-asm::vkind td)) - (write-u8 (as3-asm::kind td)) - (write-u30 (as3-asm::slot-id td)) - (write-u30 (as3-asm::type-name td)) - (write-u30 (as3-asm::vindex td)) - (unless (zerop (as3-asm::vindex td)) - (write-u8 (as3-asm::vkind td)))) - -(defmethod write-generic ((td as3-asm::trait-data-class) &optional (*standard-output* *standard-output*)) - (write-u8 (as3-asm::kind td)) - (write-u30 (as3-asm::slot-id td)) - (write-u30 (as3-asm::classi td))) - -(defmethod write-generic ((td as3-asm::trait-data-function) &optional (*standard-output* *standard-output*)) - (write-u8 (as3-asm::kind td)) - (write-u30 (as3-asm::slot-id td)) - (write-u30 (as3-asm::fn td))) - -(defmethod write-generic ((td as3-asm::trait-data-method/get/set) &optional (*standard-output* *standard-output*)) - (write-u8 (as3-asm::kind td)) - (write-u30 (as3-asm::slot-id td)) - (write-u30 (as3-asm::method-id td))) + (avm2-asm::kind td) + ( avm2-asm::slot-id td) + ( avm2-asm::type-name td) + (avm2-asm::vindex td) + (avm2-asm::vkind td)) + (write-u8 (avm2-asm::kind td)) + (write-u30 (avm2-asm::slot-id td)) + (write-u30 (avm2-asm::type-name td)) + (write-u30 (avm2-asm::vindex td)) + (unless (zerop (avm2-asm::vindex td)) + (write-u8 (avm2-asm::vkind td)))) + +(defmethod write-generic ((td avm2-asm::trait-data-class) &optional (*standard-output* *standard-output*)) + (write-u8 (avm2-asm::kind td)) + (write-u30 (avm2-asm::slot-id td)) + (write-u30 (avm2-asm::classi td))) + +(defmethod write-generic ((td avm2-asm::trait-data-function) &optional (*standard-output* *standard-output*)) + (write-u8 (avm2-asm::kind td)) + (write-u30 (avm2-asm::slot-id td)) + (write-u30 (avm2-asm::fn td))) + +(defmethod write-generic ((td avm2-asm::trait-data-method/get/set) &optional (*standard-output* *standard-output*)) + (write-u8 (avm2-asm::kind td)) + (write-u30 (avm2-asm::slot-id td)) + (write-u30 (avm2-asm::method-id td))) (defun write-namespace (namespace &optional (stream *standard-output*)) @@ -182,7 +182,7 @@ (write-u30 name) (write-u30 super-name) (write-u8 flags) - (when (not (zerop (logand flags as3-asm::+class-protected-ns+))) + (when (not (zerop (logand flags avm2-asm::+class-protected-ns+))) (write-u30 protected-ns)) (write-counted-sequence 'write-u30 interfaces) (write-u30 iinit) @@ -205,32 +205,32 @@ (write-counted-sequence 'write-generic (cdr script))) (defun write-method-body (method-body &optional (*standard-output* *standard-output*)) - (write-u30 (as3-asm::method-id method-body)) - (write-u30 (as3-asm::max-stack method-body)) - (write-u30 (1+ (as3-asm::local-count method-body))) - (write-u30 (as3-asm::init-scope-depth method-body)) - (write-u30 (as3-asm::max-scope-depth method-body)) - (write-counted-sequence 'write-u8 (as3-asm::code method-body)) - (write-counted-sequence 'write-generic (as3-asm::exceptions method-body)) - (write-counted-sequence 'write-generic (as3-asm::traits method-body))) + (write-u30 (avm2-asm::method-id method-body)) + (write-u30 (avm2-asm::max-stack method-body)) + (write-u30 (1+ (avm2-asm::local-count method-body))) + (write-u30 (avm2-asm::init-scope-depth method-body)) + (write-u30 (avm2-asm::max-scope-depth method-body)) + (write-counted-sequence 'write-u8 (avm2-asm::code method-body)) + (write-counted-sequence 'write-generic (avm2-asm::exceptions method-body)) + (write-counted-sequence 'write-generic (avm2-asm::traits method-body))) -(defmethod write-generic ((ei as3-asm::exception-info) &optional (*standard-output* *standard-output*)) - (write-u30 (as3-asm::from ei)) - (write-u30 (as3-asm::to ei)) - (write-u30 (as3-asm::target ei)) - (write-u30 (as3-asm::exc-type ei)) - (write-u30 (as3-asm::var-name ei))) +(defmethod write-generic ((ei avm2-asm::exception-info) &optional (*standard-output* *standard-output*)) + (write-u30 (avm2-asm::from ei)) + (write-u30 (avm2-asm::to ei)) + (write-u30 (avm2-asm::target ei)) + (write-u30 (avm2-asm::exc-type ei)) + (write-u30 (avm2-asm::var-name ei))) -(defun write-abc-file (&optional (data as3-asm::*assembler-context*) (*standard-output* *standard-output*)) +(defun write-abc-file (&optional (data avm2-asm::*assembler-context*) (*standard-output* *standard-output*)) (with-accessors - ((ints as3-asm::ints) (uints as3-asm::uints) (doubles as3-asm::doubles) - (strings as3-asm::strings) (namespaces as3-asm::namespaces) - (ns-sets as3-asm::ns-sets) (multinames as3-asm::multinames) - (method-infos as3-asm::method-infos) (metadata as3-asm::metadata) - (classes as3-asm::classes) (instances as3-asm::instances) - (scripts as3-asm::scripts) (method-bodies as3-asm::method-bodies)) + ((ints avm2-asm::ints) (uints avm2-asm::uints) (doubles avm2-asm::doubles) + (strings avm2-asm::strings) (namespaces avm2-asm::namespaces) + (ns-sets avm2-asm::ns-sets) (multinames avm2-asm::multinames) + (method-infos avm2-asm::method-infos) (metadata avm2-asm::metadata) + (classes avm2-asm::classes) (instances avm2-asm::instances) + (scripts avm2-asm::scripts) (method-bodies avm2-asm::method-bodies)) data (write-u16 16) ;minor version @@ -319,7 +319,7 @@ (write-0-terminated-string frame-label stream)) ;; AS3 tag - (write-as3-tag as3-asm::*assembler-context* "frame" stream) + (write-as3-tag avm2-asm::*assembler-context* "frame" stream) ;; SymbolClass tag, tag=76 length=8 ;;(write-u16 #x1308 stream) ;;tag+length ;; NumSymbols=#x0001 Tag[1] = #x0000 Name[1]="foo"#x0 @@ -355,19 +355,19 @@ (defun new-class+scopes (class-id) ;; fixme: allow class lookup instead of using class-id directly? - #+nil(format t "cid = ~a classes=~s~%" class-id (as3-asm::classes as3-asm::*assembler-context*)) - #+nil(format t " instances = ~s~%" (as3-asm::instances as3-asm::*assembler-context*)) - (let* ((class (aref (as3-asm::classes as3-asm::*assembler-context*) class-id)) - (inst (aref (as3-asm::instances as3-asm::*assembler-context*) class-id))) + #+nil(format t "cid = ~a classes=~s~%" class-id (avm2-asm::classes avm2-asm::*assembler-context*)) + #+nil(format t " instances = ~s~%" (avm2-asm::instances avm2-asm::*assembler-context*)) + (let* ((class (aref (avm2-asm::classes avm2-asm::*assembler-context*) class-id)) + (inst (aref (avm2-asm::instances avm2-asm::*assembler-context*) class-id))) (declare (ignorable class)) (destructuring-bind (name-mn super-mn flags interfaces instance-init traits protected-ns) inst (declare (ignorable name-mn super-mn flags interfaces instance-init traits protected-ns)) #+nil(format t "cid = ~a name-mn = ~a=~a super-mn = ~a=~a ~%" - class-id name-mn (as3-asm::qname-string name-mn) - super-mn (as3-asm::qname-string super-mn)) - ;;(format t " supers = ~s~%" (reverse (super-names (as3-asm::qname-string super-mn)))) - (let ((supers (reverse (super-names (as3-asm::qname-string super-mn))))) + class-id name-mn (avm2-asm::qname-string name-mn) + super-mn (avm2-asm::qname-string super-mn)) + ;;(format t " supers = ~s~%" (reverse (super-names (avm2-asm::qname-string super-mn)))) + (let ((supers (reverse (super-names (avm2-asm::qname-string super-mn))))) `((:get-scope-object 0) ,@(loop for i in supers append (push-lex-scope i)) @@ -383,32 +383,32 @@ #+nil(format t "--assemble-function ~s :~%" name) (destructuring-bind (n nid argtypes return-type flags asm) (find-swf-function name) - (let ((mid (as3-asm::as3-method nid argtypes return-type flags - :body (as3-asm::assemble-method-body asm)))) + (let ((mid (avm2-asm::avm2-method nid argtypes return-type flags + :body (avm2-asm::assemble-method-body asm)))) (push (list n mid) (function-names *compiler-context*))))) (defun assemble-class (name ns super properties constructor) - (let* ((constructor-mid (as3-asm::as3-method + (let* ((constructor-mid (avm2-asm::avm2-method 0 ;; name (loop for i in (first constructor) collect 0) ;; constructor arg types 0 0 :body - (as3-asm::assemble-method-body + (avm2-asm::assemble-method-body (%compile-defun (first constructor) (second constructor) t t)))) ;; fixme: probably should make this configurable at some point - (class-init (as3-asm::as3-method 0 nil 0 0 ;; meta-class init + (class-init (avm2-asm::avm2-method 0 nil 0 0 ;; meta-class init :body - (as3-asm::assemble-method-body + (avm2-asm::assemble-method-body `((:get-local-0) (:push-scope) (:return-void)) :init-scope 0))) - (junk (as3-asm::as3-ns-intern ns)) - (class (as3-asm::as3-class - (as3-asm::asm-intern-multiname name) - (as3-asm::asm-intern-multiname + (junk (avm2-asm::avm2-ns-intern ns)) + (class (avm2-asm::avm2-class + (avm2-asm::asm-intern-multiname name) + (avm2-asm::asm-intern-multiname (or (car (find-swf-class super)) super)) ;; todo: add interfaces @@ -417,15 +417,15 @@ (loop for i in properties collect (make-instance - 'as3-asm::trait-info - 'as3-asm::name (as3-asm::asm-intern-multiname i) - 'as3-asm::trait-data - (make-instance 'as3-asm::trait-data-slot/const - 'as3-asm::kind 0 - 'as3-asm::slot-id 0 ;; auto-assign - 'as3-asm::type-name 0 ;; */t - 'as3-asm::vindex 0 ;; no value - 'as3-asm::vkind 0 ;; no value + 'avm2-asm::trait-info + 'avm2-asm::name (avm2-asm::asm-intern-multiname i) + 'avm2-asm::trait-data + (make-instance 'avm2-asm::trait-data-slot/const + 'avm2-asm::kind 0 + 'avm2-asm::slot-id 0 ;; auto-assign + 'avm2-asm::type-name 0 ;; */t + 'avm2-asm::vindex 0 ;; no value + 'avm2-asm::vkind 0 ;; no value ))) class-init :protected-ns junk @@ -442,12 +442,12 @@ (let ((script-init (gensym)) (i (gensym))) - `(let ((as3-asm::*assembler-context* (make-instance 'as3-asm::assembler-context)) + `(let ((avm2-asm::*assembler-context* (make-instance 'avm2-asm::assembler-context)) (*compiler-context* (make-instance 'compiler-context)) (*symbol-table* (make-instance 'symbol-table :inherit (list *cl-symbol-table*)))) ;; fixme: add these to assembler-context constructor or something - (as3-asm::as3-intern "") - (as3-asm::as3-ns-intern "") + (avm2-asm::avm2-intern "") + (avm2-asm::avm2-ns-intern "") #+nil(format t "==-== body~%") ;; compile the body code ,@body @@ -472,13 +472,13 @@ #+nil(format t "==-== boilerplate~%") ;; script boilerplate (let ((,script-init - (as3-asm::as3-method + (avm2-asm::avm2-method 0 () 0 0 :body - (as3-asm::assemble-method-body + (avm2-asm::assemble-method-body `((:get-local-0) (:push-scope) - ,@(loop for ,i below (length (as3-asm::classes as3-asm::*assembler-context*)) + ,@(loop for ,i below (length (avm2-asm::classes avm2-asm::*assembler-context*)) append (new-class+scopes ,i)) (:return-void)))))) #+nil(format t "==-== boilerplate2~%") @@ -486,24 +486,24 @@ `(,,script-init ,@(loop for i in (class-names *compiler-context*) ;;do (format t "-=c-~s~%" i) - collect (make-instance 'as3-asm::trait-info - 'as3-asm::name - (as3-asm::asm-intern-multiname (first i)) - 'as3-asm::trait-data - (make-instance 'as3-asm::trait-data-class - 'as3-asm::slot-id 0 - 'as3-asm::classi (second i)))) + collect (make-instance 'avm2-asm::trait-info + 'avm2-asm::name + (avm2-asm::asm-intern-multiname (first i)) + 'avm2-asm::trait-data + (make-instance 'avm2-asm::trait-data-class + 'avm2-asm::slot-id 0 + 'avm2-asm::classi (second i)))) ,@(loop for i in (function-names *compiler-context*) ;;do (format t "-=f-~s~%" i) - collect (make-instance 'as3-asm::trait-info - 'as3-asm::name + collect (make-instance 'avm2-asm::trait-info + 'avm2-asm::name (if (numberp (first i)) (first i) - (as3-asm::asm-intern-multiname (first i))) - 'as3-asm::trait-data (make-instance 'as3-asm::trait-data-method/get/set - 'as3-asm::slot-id 0 - 'as3-asm::method (second i))))) - (as3-asm::scripts as3-asm::*assembler-context*))) + (avm2-asm::asm-intern-multiname (first i))) + 'avm2-asm::trait-data (make-instance 'avm2-asm::trait-data-method/get/set + 'avm2-asm::slot-id 0 + 'avm2-asm::method (second i))))) + (avm2-asm::scripts avm2-asm::*assembler-context*))) (when *break-compile* (break)) #+nil(format t "==-== write~%") diff --git a/lib/as3-lib.asd b/lib/avm2-lib.asd similarity index 85% rename from lib/as3-lib.asd rename to lib/avm2-lib.asd index 246096a..416aeba 100644 --- a/lib/as3-lib.asd +++ b/lib/avm2-lib.asd @@ -1,6 +1,6 @@ -(asdf:defsystem :as3-lib - :depends-on ("as3-compile") +(asdf:defsystem :avm2-lib + :depends-on ("avm2-compile") :components ((:file "library-packages") (:file "player-class-decl") (:file "player-classes") diff --git a/lib/cl-conses.lisp b/lib/cl-conses.lisp index e3143ba..eb6d5c0 100644 --- a/lib/cl-conses.lisp +++ b/lib/cl-conses.lisp @@ -1,4 +1,4 @@ -(in-package #:as3-compiler) +(in-package #:avm2-compiler) ;;; implement functions/macros from CL package ;;; diff --git a/lib/cl.lisp b/lib/cl.lisp index d99f4a5..18e2d50 100644 --- a/lib/cl.lisp +++ b/lib/cl.lisp @@ -1,4 +1,4 @@ -(in-package #:as3-compiler) +(in-package #:avm2-compiler) ;;; implement functions/macros from CL package ;;; diff --git a/lib/library-packages.lisp b/lib/library-packages.lisp index de58e82..ab40f68 100644 --- a/lib/library-packages.lisp +++ b/lib/library-packages.lisp @@ -1,4 +1,4 @@ -(in-package #:as3-compiler) +(in-package #:avm2-compiler) ;;(defpackage #:flash) diff --git a/lib/player-class-decl.lisp b/lib/player-class-decl.lisp index f5c357b..a34121c 100644 --- a/lib/player-class-decl.lisp +++ b/lib/player-class-decl.lisp @@ -1,4 +1,4 @@ -(in-package :as3-compiler) +(in-package :avm2-compiler) ;; wrapping the whole file in a let makes it take too long to compile, so ;;; we save and restore *symbol-table* for now diff --git a/lib/player-classes.lisp b/lib/player-classes.lisp index 65af7bf..abdf364 100644 --- a/lib/player-classes.lisp +++ b/lib/player-classes.lisp @@ -1,4 +1,4 @@ -(in-package #:as3-compiler) +(in-package #:avm2-compiler) ;; Object * diff --git a/lib/player-lib.lisp b/lib/player-lib.lisp index 50bb599..f161074 100644 --- a/lib/player-lib.lisp +++ b/lib/player-lib.lisp @@ -1,4 +1,4 @@ -(in-package :as3-compiler) +(in-package :avm2-compiler) ;;; top level globals/static/whatever functions that didn't get added by the ;;; automatic reflection stuff in player-class-decl.lisp diff --git a/lib/sicl-conditionals.lisp b/lib/sicl-conditionals.lisp index ebcf6b1..5bd4c4c 100644 --- a/lib/sicl-conditionals.lisp +++ b/lib/sicl-conditionals.lisp @@ -1,4 +1,4 @@ -(in-package #:as3-compiler) +(in-package #:avm2-compiler) ;;; pieces of sicl/conditionals.lisp that work so far diff --git a/lib/sicl-iteration.lisp b/lib/sicl-iteration.lisp index 20fd24c..b748de7 100644 --- a/lib/sicl-iteration.lisp +++ b/lib/sicl-iteration.lisp @@ -1,4 +1,4 @@ -(in-package #:as3-compiler) +(in-package #:avm2-compiler) ;;; pieces of sicl/iteration.lisp that work so far diff --git a/test/roots.lisp b/test/roots.lisp index 6b23ce4..2f1b3ca 100644 --- a/test/roots.lisp +++ b/test/roots.lisp @@ -1,4 +1,4 @@ -(in-package :as3-compiler) +(in-package :avm2-compiler) ;;; sample from old version. works but needs more refactoring (define-special %to-double (a) diff --git a/test/test.lisp b/test/test.lisp index 7ee9f4e..e32988b 100644 --- a/test/test.lisp +++ b/test/test.lisp @@ -1,4 +1,4 @@ -(in-package :as3-compiler) +(in-package :avm2-compiler) ;;; random tests for various features, need to figure out how to ;;; automate these at some point -- 2.11.4.GIT