Changeset 12843
- Timestamp:
- 08/01/10 10:23:51 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/generic-class-file/abcl/test/lisp/abcl/class-file.lisp
r12832 r12843 191 191 :flags '(:static)))) 192 192 (jvm::class-add-method file method) 193 (jvm::with-code-to-method ( method)193 (jvm::with-code-to-method (file method) 194 194 (jvm::emit 'return)) 195 195 (jvm::finalize-class-file file) … … 205 205 (method (jvm::!make-method "doNothing" :void nil))) 206 206 (jvm::class-add-method file method) 207 (jvm::with-code-to-method ( method)207 (jvm::with-code-to-method (file method) 208 208 (let ((label1 (gensym)) 209 209 (label2 (gensym)) … … 224 224 T) 225 225 226 227 ;;(deftest generate-method.2 228 ;; (let* ((class)))) 226 ;; generation of an ABCL-like function class 227 (deftest generate-method.3 228 (let* ((class (jvm::make-class-name "org.armedbear.lisp.gm_3")) 229 (file (jvm::!make-class-file class jvm::+lisp-primitive+ '(:public))) 230 ) 231 (let ((method (jvm::!make-method :constructor :void nil))) 232 (jvm::class-add-method file method) 233 (jvm::with-code-to-method (file method) 234 (jvm::emit 'aload 0) 235 (jvm::emit-getstatic jvm::+lisp+ "NIL" jvm::+lisp-object+) 236 (jvm::emit-getstatic jvm::+lisp+ "NIL" jvm::+lisp-object+) 237 (jvm::emit-invokespecial-init jvm::+lisp-primitive+ 238 (list jvm::+lisp-object+ 239 jvm::+lisp-object+)) 240 (jvm::emit 'return))) 241 (let ((method (jvm::!make-method "execute" jvm::+lisp-object+ nil))) 242 (jvm::class-add-method file method) 243 (jvm::with-code-to-method (file method) 244 (jvm::emit-getstatic jvm::+lisp+ "NIL" jvm::+lisp-object+) 245 (jvm::emit 'jvm::areturn))) 246 (jvm::finalize-class-file file) 247 (with-open-stream (stream (sys::%make-byte-array-output-stream)) 248 (jvm::!write-class-file file stream) 249 (funcall (sys::load-compiled-function (sys::%get-output-stream-bytes stream))))) 250 NIL) 251 252 ;; generation of an ABCL-like function class with static init function and 253 ;; static field 254 (deftest generate-method.4 255 (let* ((class (jvm::make-class-name "org.armedbear.lisp.gm_4")) 256 (file (jvm::!make-class-file class jvm::+lisp-primitive+ '(:public))) 257 ) 258 (jvm::class-add-field file (jvm::!make-field "N1" jvm::+lisp-object+ 259 :flags '(:static :private))) 260 (let ((method (jvm::!make-method :class-constructor :void nil :flags '(:static)))) 261 (jvm::class-add-method file method) 262 (jvm::with-code-to-method (file method) 263 (jvm::emit-getstatic jvm::+lisp+ "NIL" jvm::+lisp-object+) 264 (jvm::emit-putstatic class "N1" jvm::+lisp-object+) 265 (jvm::emit 'return))) 266 (let ((method (jvm::!make-method :constructor :void nil))) 267 (jvm::class-add-method file method) 268 (jvm::with-code-to-method (file method) 269 (jvm::emit 'aload 0) 270 (jvm::emit-getstatic class "N1" jvm::+lisp-object+) 271 (jvm::emit-getstatic class "N1" jvm::+lisp-object+) 272 (jvm::emit-invokespecial-init jvm::+lisp-primitive+ 273 (list jvm::+lisp-object+ 274 jvm::+lisp-object+)) 275 (jvm::emit 'return))) 276 (let ((method (jvm::!make-method "execute" jvm::+lisp-object+ nil))) 277 (jvm::class-add-method file method) 278 (jvm::with-code-to-method (file method) 279 (jvm::emit-getstatic class "N1" jvm::+lisp-object+) 280 (jvm::emit 'jvm::areturn))) 281 (jvm::finalize-class-file file) 282 (with-open-stream (stream (sys::%make-byte-array-output-stream)) 283 (jvm::!write-class-file file stream) 284 (funcall (sys::load-compiled-function (sys::%get-output-stream-bytes stream))))) 285 NIL) 286 287 288 ;; generation of ABCL-like function class with multiple 'execute' methods 289 (deftest generate-method.5 290 (let* ((class (jvm::make-class-name "org.armedbear.lisp.gm_5")) 291 (file (jvm::!make-class-file class jvm::+lisp-primitive+ '(:public))) 292 ) 293 (let ((method (jvm::!make-method :constructor :void nil))) 294 (jvm::class-add-method file method) 295 (jvm::with-code-to-method (file method) 296 (jvm::emit 'aload 0) 297 (jvm::emit-getstatic jvm::+lisp+ "NIL" jvm::+lisp-object+) 298 (jvm::emit-getstatic jvm::+lisp+ "NIL" jvm::+lisp-object+) 299 (jvm::emit-invokespecial-init jvm::+lisp-primitive+ 300 (list jvm::+lisp-object+ 301 jvm::+lisp-object+)) 302 (jvm::emit 'return))) 303 (let ((method (jvm::!make-method "execute" jvm::+lisp-object+ nil))) 304 (jvm::class-add-method file method) 305 (jvm::with-code-to-method (file method) 306 (jvm::emit-getstatic jvm::+lisp+ "NIL" jvm::+lisp-object+) 307 (jvm::emit 'jvm::areturn))) 308 (let ((method (jvm::!make-method "execute" jvm::+lisp-object+ 309 (list jvm::+lisp-object+)))) 310 (jvm::class-add-method file method) 311 (jvm::with-code-to-method (file method) 312 (jvm::emit-getstatic jvm::+lisp+ "T" jvm::+lisp-symbol+) 313 (jvm::emit 'jvm::areturn))) 314 (jvm::finalize-class-file file) 315 (with-open-stream (stream (sys::%make-byte-array-output-stream)) 316 (jvm::!write-class-file file stream) 317 (let* ((bytes (sys::%get-output-stream-bytes stream)) 318 (fn (sys::load-compiled-function bytes))) 319 (values (funcall fn) (funcall fn NIL))))) 320 NIL T) 321 322 ;; ;; generation of an ABCL-like function, with mixed output to constructor, 323 ;; ;; static initializer and function method(s) 324 ;; (deftest generate-method.6 325 ;; (let* ((class (jvm::make-class-name "org.armedbear.lisp.gm_6")) 326 ;; (file (jvm::!make-class-file class jvm::+lisp-primitive+ '(:public))) 327 ;; ) 328 ;; (let ((method (jvm::!make-method :constructor :void nil))) 329 ;; (jvm::class-add-method file method) 330 ;; (jvm::with-code-to-method (file method) 331 ;; (jvm::emit 'aload 0) 332 ;; (jvm::emit-getstatic jvm::+lisp+ "NIL" jvm::+lisp-object+) 333 ;; (jvm::emit-getstatic jvm::+lisp+ "NIL" jvm::+lisp-object+) 334 ;; (jvm::emit-invokespecial-init jvm::+lisp-primitive+ 335 ;; (list jvm::+lisp-object+ 336 ;; jvm::+lisp-object+)) 337 ;; (jvm::emit 'return))) 338 ;; (let ((method (jvm::!make-method "execute" jvm::+lisp-object+ nil))) 339 ;; (jvm::class-add-method file method) 340 ;; (jvm::with-code-to-method (file method) 341 ;; (jvm::emit-getstatic jvm::+lisp+ "NIL" jvm::+lisp-object+) 342 ;; (jvm::emit 'jvm::areturn))) 343 ;; (jvm::finalize-class-file file) 344 ;; (with-open-stream (stream (sys::%make-byte-array-output-stream)) 345 ;; (jvm::!write-class-file file stream) 346 ;; (ignore-errors (sys::load-compiled-function nil)) 347 ;; (funcall (sys::load-compiled-function (sys::%get-output-stream-bytes stream)))) 348 ;; T 349 ;; ) 350 ;; T) 351
Note: See TracChangeset
for help on using the changeset viewer.