1 ;;; -*- Mode: Lisp; Package: Maxima; Syntax: Common-Lisp; Base: 10 -*- ;;;;
2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3 ;;; The data in this file contains enhancements. ;;;;;
5 ;;; Copyright (c) 1984,1987 by William Schelter,University of Texas ;;;;;
6 ;;; All rights reserved ;;;;;
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 ;;; Macros for TRANSL source compilation. ;;;
10 ;;; (c) Copyright 1980 Massachusetts Institute of Technology ;;;
11 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15 (macsyma-module transm macro
)
17 (defmacro def%tr
(name lambda-list
&body body
&aux definition
)
19 (if (and (null body
) (symbolp lambda-list
))
20 `(def-same%tr
,name
,lambda-list
)
21 `(defun-prop (,name translate
) ,lambda-list
22 (block ,name
,@body
))))
23 `(eval-when (:compile-toplevel
:execute
:load-toplevel
)
26 (defmacro def-same%tr
(name same-as
)
27 ;; right now MUST be used in the SAME file.
29 (or (get ',same-as
'translate
)
30 (maxima-error "DEF-SAME%TR: ~a has no TRANSLATE property, so I can't make an alias." ',same-as
))
33 ;;; declarations for the TRANSL PACKAGE.
36 ;; The warning and error subsystem.
37 (special tr-abort
; set this T if you want to abort.
38 *translation-msgs-files
*) ; the stream to print messages to.
40 (special *pre-transl-forms
* ; push onto this, gets output first into the transl file.
41 *warned-un-declared-vars
*
44 warned-undefined-variables
49 *untranslated-functions-called
*
52 (defmacro bind-transl-state
(&rest forms
)
53 ;; this binds all transl state variables to NIL.
54 ;; and binds user-settable variables to themselves.
55 ;; $TR_NUMER for example can be set to TRUE while translating
56 ;; a file, yet will only affect that file.
57 ;; Called in 3 places, for compactness maybe this should be a PROGV
58 ;; which references a list of variables?
59 `(let (*warned-un-declared-vars
*
62 warned-undefined-variables
74 (defun tr-format (sstring &rest argl
&aux strs
)
75 (if (consp *translation-msgs-files
*)
76 (setq strs
*translation-msgs-files
*)
77 (setq strs
(list *translation-msgs-files
*)))
79 do
(apply #'mformat v sstring argl
)))
81 ;; to use in mixing maxima and lisp
86 (bind-transl-state (translate-macexpr-toplevel (second u
)))))
88 (defmacro maset
(val ar
&rest inds
)
89 (if (or (eq ar
'mqapply
)
90 (and (consp ar
) (member 'mqapply ar
:test
#'eq
)))
91 `(marrayset ,val
,(car inds
) ,@(cdr inds
))
94 (setf ,ar
(make-equal-hash-table ,(if (cdr inds
) t nil
))))
95 (maset1 ,val
,ar
,@inds
))))
97 (defmacro maref
(ar &rest inds
)
98 (cond ((or (eql ar
'mqapply
)(and (consp ar
) (member 'mqapply ar
:test
#'eq
)))
99 `(marrayref ,(first inds
) ,@(cdr inds
)))
100 ((consp ar
)`(marrayref ,ar
,(first inds
) ,@(cdr inds
)))
102 `(maref1 ,ar
,@inds
))))