Move ARM number stack pointer to r14.
[sbcl/nyef.git] / src / pcl / compiler-support.lisp
blobabc9466613f36f00990eba095f53c624d70b6fa6
1 ;;;; things which the main SBCL compiler needs to know about the
2 ;;;; implementation of CLOS
3 ;;;;
4 ;;;; (Our CLOS is derived from PCL, which was implemented in terms of
5 ;;;; portable high-level Common Lisp. But now that it no longer needs
6 ;;;; to be portable, we can make some special hacks to support it
7 ;;;; better.)
9 ;;;; This software is part of the SBCL system. See the README file for more
10 ;;;; information.
12 ;;;; This software is derived from software originally released by Xerox
13 ;;;; Corporation. Copyright and release statements follow. Later modifications
14 ;;;; to the software are in the public domain and are provided with
15 ;;;; absolutely no warranty. See the COPYING and CREDITS files for more
16 ;;;; information.
18 ;;;; copyright information from original PCL sources:
19 ;;;;
20 ;;;; Copyright (c) 1985, 1986, 1987, 1988, 1989, 1990 Xerox Corporation.
21 ;;;; All rights reserved.
22 ;;;;
23 ;;;; Use and copying of this software and preparation of derivative works based
24 ;;;; upon this software are permitted. Any distribution of this software or
25 ;;;; derivative works must comply with all applicable United States export
26 ;;;; control laws.
27 ;;;;
28 ;;;; This software is made available AS IS, and Xerox Corporation makes no
29 ;;;; warranty about the software, its performance or its conformity to any
30 ;;;; specification.
32 (in-package "SB-C")
34 ;;;; very low-level representation of instances with meta-class
35 ;;;; STANDARD-CLASS
37 (defknown sb-pcl::pcl-instance-p (t) boolean
38 (movable foldable flushable explicit-check))
40 (deftransform sb-pcl::pcl-instance-p ((object))
41 (let* ((otype (lvar-type object))
42 (standard-object (specifier-type 'standard-object)))
43 (cond
44 ;; Flush tests whose result is known at compile time.
45 ((csubtypep otype standard-object) t)
46 ((not (types-equal-or-intersect otype standard-object)) nil)
48 `(layout-for-std-class-p (layout-of object))))))
50 (defun sb-pcl::safe-code-p (&optional env)
51 (let* ((lexenv (or env (make-null-lexenv)))
52 (policy (lexenv-policy lexenv)))
53 (eql (cdr (assoc 'safety policy)) 3)))
55 (declaim (ftype function sb-pcl::parse-specialized-lambda-list))
56 (define-source-context defmethod (name &rest stuff)
57 (let ((arg-pos (position-if #'listp stuff)))
58 (if arg-pos
59 `(defmethod ,name ,@(subseq stuff 0 arg-pos)
60 ,(handler-case
61 (nth-value 2 (sb-pcl::parse-specialized-lambda-list
62 (elt stuff arg-pos)))
63 (error () "<illegal syntax>")))
64 `(defmethod ,name "<illegal syntax>"))))
66 (defvar sb-pcl::*internal-pcl-generalized-fun-name-symbols* nil)
68 (defmacro define-internal-pcl-function-name-syntax (name (var) &body body)
69 `(progn
70 (define-function-name-syntax ,name (,var) ,@body)
71 (pushnew ',name sb-pcl::*internal-pcl-generalized-fun-name-symbols*)))
73 (define-internal-pcl-function-name-syntax sb-pcl::slot-accessor (list)
74 (when (= (length list) 4)
75 (destructuring-bind (class slot rwb) (cdr list)
76 (when (and (member rwb '(sb-pcl::reader sb-pcl::writer sb-pcl::boundp))
77 (symbolp slot)
78 (symbolp class))
79 (values t slot)))))
81 (define-internal-pcl-function-name-syntax sb-pcl::fast-method (list)
82 (valid-function-name-p (cadr list)))
84 (define-internal-pcl-function-name-syntax sb-pcl::slow-method (list)
85 (valid-function-name-p (cadr list)))
87 (declaim (ftype function sb-pcl::std-instance-p sb-pcl::fsc-instance-p))
88 (define-internal-pcl-function-name-syntax sb-pcl::ctor (list)
89 (let ((class-or-name (cadr list)))
90 (cond
91 ((symbolp class-or-name)
92 (values (valid-function-name-p class-or-name) nil))
93 ((or (sb-pcl::std-instance-p class-or-name)
94 (sb-pcl::fsc-instance-p class-or-name))
95 (values t nil)))))