| 1 |
;;;; -*- Mode: Lisp; Syntax: Common-Lisp; indent-tabs-mode: nil; Package: C -*- |
| 2 |
;;;; vim: set filetype=lisp tabstop=8 shiftwidth=2 expandtab: |
| 3 |
|
| 4 |
;;;; |
| 5 |
;;;; Copyright (c) 2010, Juan Jose Garcia Ripoll |
| 6 |
;;;; Copyright (c) 2023, Daniel Kochmański |
| 7 |
;;;; |
| 8 |
;;;; See the file 'LICENSE' for the copyright details. |
| 9 |
;;;; |
| 10 |
|
| 11 |
;;;; C/C++ specific optimizer for the printer. |
| 12 |
|
| 13 |
(in-package "COMPILER") |
| 14 |
|
| 15 |
(define-c-inliner cl:princ (return-type expression &optional stream) |
| 16 |
(unless stream |
| 17 |
(setf stream (emit-inline-form (c1nil) nil))) |
| 18 |
(multiple-value-bind (foundp value) |
| 19 |
(loc-immediate-value-p expression) |
| 20 |
(cond |
| 21 |
((and foundp (characterp value)) |
| 22 |
(produce-inline-loc (list expression stream) |
| 23 |
'(:wchar :object) '(:wchar) |
| 24 |
"ecl_princ_char(#0,#1)" t t)) |
| 25 |
((and foundp (typep value 'base-string *cmp-env*) (< (length value) 80)) |
| 26 |
(produce-inline-loc (list expression stream) |
| 27 |
'(:object :object) '(:object) |
| 28 |
(concatenate 'string "(ecl_princ_str(" |
| 29 |
(c-inline-safe-string value) |
| 30 |
",#1),#0)") |
| 31 |
t t)) |
| 32 |
(t |
| 33 |
(produce-inline-loc (list expression stream) |
| 34 |
'(:object :object) '(:object) |
| 35 |
"ecl_princ(#0,#1)" t t))))) |