Skip to content

Commit 98569b8

Browse files
committed
Port to ECL
1 parent 10884a8 commit 98569b8

File tree

3 files changed

+43
-22
lines changed

3 files changed

+43
-22
lines changed

runtime/classes.lisp

+19-12
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ otherwise work well.")
817817
(excl::dump-lisp-source x)))
818818

819819
(defmethod py-function-name ((x function))
820+
(declare (ignorable x))
820821
#+allegro (format nil "~A" (excl::func_name x))
821822
#-allegro (call-next-method))
822823

@@ -3171,27 +3172,32 @@ invocation form.\"")
31713172
(defgeneric py-class-of (x)
31723173

31733174
;; Lisp objects lead to their proxy class
3174-
(:method ((x hash-table)) (ltv-find-class 'dict))
3175-
(:method ((x integer)) (ltv-find-class 'py-int ))
3176-
(:method ((x real)) (ltv-find-class 'py-float ))
3177-
(:method ((x complex)) (ltv-find-class 'py-complex))
3178-
(:method ((x string)) (ltv-find-class 'py-string ))
3179-
(:method ((x vector)) (ltv-find-class 'py-list ))
3175+
(:method ((x hash-table)) (declare (ignorable x)) (ltv-find-class 'dict))
3176+
(:method ((x integer)) (declare (ignorable x)) (ltv-find-class 'py-int ))
3177+
(:method ((x real)) (declare (ignorable x)) (ltv-find-class 'py-float ))
3178+
(:method ((x complex)) (declare (ignorable x)) (ltv-find-class 'py-complex))
3179+
(:method ((x string)) (declare (ignorable x)) (ltv-find-class 'py-string ))
3180+
(:method ((x vector)) (declare (ignorable x)) (ltv-find-class 'py-list ))
31803181
(:method ((x list)) (cond ((null x)
31813182
(break "PY-CLASS-OF of NIL"))
31823183
((and (listp (car x)) (symbolp (caar x)))
31833184
(ltv-find-class 'py-alist))
31843185
(t
31853186
(ltv-find-class 'py-tuple))))
3186-
(:method ((x symbol)) (ltv-find-class 'py-symbol ))
3187-
(:method ((x function)) (ltv-find-class 'py-function))
3188-
(:method ((x py-function)) (ltv-find-class 'py-function))
3189-
(:method ((x package)) (ltv-find-class 'lisp-package))
3187+
(:method ((x symbol)) (declare (ignorable x))
3188+
(ltv-find-class 'py-symbol ))
3189+
(:method ((x function)) (declare (ignorable x))
3190+
(ltv-find-class 'py-function))
3191+
(:method ((x py-function)) (declare (ignorable x))
3192+
(ltv-find-class 'py-function))
3193+
(:method ((x package)) (declare (ignorable x))
3194+
(ltv-find-class 'lisp-package))
31903195

31913196
#+(or)(:method ((x py-type)) (ltv-find-class 'py-type))
31923197

31933198
(:method ((x py-meta-type)) ;; metatypes (including `type')
31943199
;; fake being of type `type'
3200+
(declare (ignorable x))
31953201
(ltv-find-class 'py-type))
31963202

31973203
(:method ((x py-type)) (class-of x))
@@ -3341,12 +3347,12 @@ finished; F will then not be called again."
33413347
;; XXX Speed up slot value lookup by using
33423348
;; MOP:SLOT-DEFINITION-LOCATION, MOP:STANDARD-INSTANCE-ACCESS.
33433349
(:method ((f null) &rest args)
3344-
(declare (ignore args) (dynamic-extent args))
3350+
(declare (ignore args) (ignorable f) (dynamic-extent args))
33453351
(error "PY-CALL of NIL"))
33463352

33473353
(:method ((f class) &rest args)
33483354
(declare (dynamic-extent args)
3349-
(ignorable args)
3355+
(ignorable f args)
33503356
(optimize (speed 3) (safety 0) (debug 0)))
33513357
#-clpython-exceptions-are-python-objects
33523358
(when (subtypep f '{Exception})
@@ -4025,6 +4031,7 @@ Returns one of (-1, 0, 1): -1 iff x < y; 0 iff x == y; 1 iff x > y")
40254031
(setf (get x 'py-hash) hash))))
40264032

40274033
(defmethod py-repr ((x (eql nil)))
4034+
(declare (ignorable x))
40284035
"#<the symbol NIL>")
40294036

40304037
#||

runtime/dictattr.lisp

+23-9
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,25 @@
6868
#+allegro 'excl::name
6969
#+ccl 'ccl::name
7070
#+cmu 'pcl::name
71+
#+ecl 'clos::name
7172
#+lispworks 'clos::name
7273
#+sbcl 'sb-pcl::name
73-
#-(or allegro ccl cmu lispworks sbcl)
74+
#-(or allegro ccl cmu ecl lispworks sbcl)
7475
(break "Define slot name containing class name, for this implementation."))
7576

7677
(eval-when (:compile-toplevel :load-toplevel :execute)
78+
79+
(defconstant +use-standard-instance-access+
80+
#+ #1=ecl nil
81+
#+ #2=(or allegro ccl cmu lispworks sbcl) t
82+
#- (or #1# #2#) (break "Define +use-standard-instance-access+"))
83+
84+
(register-feature :clpython-use-standard-instance-access +use-standard-instance-access+)
85+
7786
(defconstant +use-standard-instance-access-setf+
78-
#+allegro t
79-
#+ccl t
80-
#+cmu nil ;; CMUCL lacks (SETF PCL:STANDARD-INSTANCE-ACCESS)
81-
#+lispworks t
82-
#+sbcl t
83-
#-(or allegro ccl cmu lispworks sbcl) (error "Define +use-standard-instance-access-setf+ ~
87+
#+(or allegro ccl lispworks sbcl) t
88+
#+(or cmu ecl) nil ;; these lack (SETF STANDARD-INSTANCE-ACCESS)
89+
#-(or allegro ccl cmu ecl lispworks sbcl) (break "Define +use-standard-instance-access-setf+ ~
8490
for this implementation"))
8591

8692
(register-feature :clpython-use-standard-instance-access-setf +use-standard-instance-access-setf+))
@@ -109,15 +115,23 @@ for this implementation"))
109115

110116
(defun class.raw-dict (class)
111117
"Given a class, return its dict. Only intended for classes corresponding to Python (meta)types."
112-
(#.+standard-instance-access-func+ class +py-class-dict-slot-index+))
118+
#+clpython-use-standard-instance-access
119+
(#.+standard-instance-access-func+ class +py-class-dict-slot-index+)
120+
#-clpython-use-standard-instance-access
121+
(slot-value class 'dict))
113122

123+
#+clpython-use-standard-instance-access
114124
(define-compiler-macro class.raw-dict (class)
115125
`(#.+standard-instance-access-func+ ,class +py-class-dict-slot-index+))
116126

117127
(defun class.raw-classname (class)
118128
"Given a class, return its classname. Only intended for classes corresponding to Python (meta)types."
119-
(#.+standard-instance-access-func+ class +py-class-classname-slot-index+))
129+
#+clpython-use-standard-instance-access
130+
(#.+standard-instance-access-func+ class +py-class-classname-slot-index+)
131+
#-clpython-use-standard-instance-access
132+
(slot-value class +py-class-classname-slot-name+))
120133

134+
#+clpython-use-standard-instance-access
121135
(define-compiler-macro class.raw-classname (class)
122136
`(#.+standard-instance-access-func+ ,class +py-class-classname-slot-index+))
123137

runtime/metaclass.lisp

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
nil)
2828

2929
(defgeneric has-dict (x)
30-
(:method ((x dict-mixin)) t)
30+
(:method ((x dict-mixin)) (declare (ignorable x)) t)
3131
(:method (x) (declare (ignore x)) nil))
3232

3333
(defclass py-meta-type (dict-mixin standard-class)

0 commit comments

Comments
 (0)