mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-23 04:52:42 -08:00
by spaces. A custom script was used to insert/replace Emacs and ViM per-file editor settings according to their type and the new ECL coding style.
40 lines
1.4 KiB
Common Lisp
40 lines
1.4 KiB
Common Lisp
;;;; -*- Mode: Lisp; Syntax: Common-Lisp; indent-tabs-mode: nil; Package: C -*-
|
|
;;;; vim: set filetype=lisp tabstop=8 shiftwidth=2 expandtab:
|
|
|
|
;;;;
|
|
;;;; Copyright (c) 2010, Juan Jose Garcia-Ripoll.
|
|
;;;;
|
|
;;;; This program is free software; you can redistribute it and/or
|
|
;;;; modify it under the terms of the GNU Library General Public
|
|
;;;; License as published by the Free Software Foundation; either
|
|
;;;; version 2 of the License, or (at your option) any later version.
|
|
;;;;
|
|
;;;; See file '../Copyright' for full details.
|
|
;;;;
|
|
;;;; CMPOPT-CONSTANTS Constant expressions.
|
|
;;;;
|
|
|
|
(in-package "COMPILER")
|
|
|
|
(defun constant-expression-p (form &optional (env *cmp-env*))
|
|
(or (constantp form env)
|
|
(and (consp form)
|
|
(let ((head (car form)))
|
|
(or (member head '(IF OR AND NULL NOT PROGN))
|
|
(and (get-sysprop head 'pure)
|
|
(inline-possible head))))
|
|
(loop for c in (rest form)
|
|
always (constant-expression-p c env)))))
|
|
|
|
(defun extract-constant-value (form &optional failure (env *cmp-env*))
|
|
(if (constant-expression-p form env)
|
|
(handler-case (cmp-eval form env)
|
|
(error (c) failure))
|
|
failure))
|
|
|
|
(defun constant-value-p (form &optional (env *cmp-env*))
|
|
(if (constant-expression-p form env)
|
|
(handler-case
|
|
(values t (cmp-eval form env))
|
|
(error (c) (values nil form)))
|
|
(values nil form)))
|