mescc: Use records for Guile: preparation.
* module/language/c99/info.mes: New file.
* module/mes/M1.mes: Use it.
* scripts/mescc.mes: Use it.
* module/language/c99/compiler.mes: Use it. (<info>, <types>,
<constants>, <functions>, <globals>, <locals>, <function>, <text>,
<break>, <continue>, make, info?, .info, .types, .constants,
.functions, .globals, .locals, .function, .text, .break, .continue):
Remove.
* module/language/c99/info.scm: New file.
* module/language/c99/compiler.scm: Use it.
* guile/mescc.scm: Use it.
* module/mes/M1.scm: Use it.
2017-07-14 18:42:26 +00:00
|
|
|
;;; -*-scheme-*-
|
|
|
|
|
|
|
|
;;; Mes --- Maxwell Equations of Software
|
|
|
|
;;; Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
|
|
|
;;;
|
|
|
|
;;; This file is part of Mes.
|
|
|
|
;;;
|
|
|
|
;;; Mes is free software; you can redistribute it and/or modify it
|
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
;;; your option) any later version.
|
|
|
|
;;;
|
|
|
|
;;; Mes is distributed in the hope that it will be useful, but
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
;;;
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;;; info.mes defines a record-interface to simplistic list data
|
|
|
|
;;; structures.
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
(cond-expand
|
|
|
|
(guile-2)
|
|
|
|
(guile)
|
|
|
|
(mes
|
|
|
|
(mes-use-module (mes optargs))
|
|
|
|
(mes-use-module (mes pmatch))))
|
|
|
|
|
|
|
|
(define <info> '<info>)
|
|
|
|
(define <types> '<types>)
|
|
|
|
(define <constants> '<constants>)
|
|
|
|
(define <functions> '<functions>)
|
|
|
|
(define <globals> '<globals>)
|
|
|
|
(define <locals> '<locals>)
|
|
|
|
(define <function> '<function>)
|
|
|
|
(define <text> '<text>)
|
|
|
|
(define <break> '<break>)
|
|
|
|
(define <continue> '<continue>)
|
|
|
|
|
|
|
|
(define (.types o)
|
|
|
|
(pmatch o
|
|
|
|
((<info> . ,alist) (assq-ref alist <types>))))
|
|
|
|
|
|
|
|
(define (.constants o)
|
|
|
|
(pmatch o
|
|
|
|
((<info> . ,alist) (assq-ref alist <constants>))))
|
|
|
|
|
|
|
|
(define (.functions o)
|
|
|
|
(pmatch o
|
|
|
|
((<info> . ,alist) (assq-ref alist <functions>))))
|
|
|
|
|
|
|
|
(define (.globals o)
|
|
|
|
(pmatch o
|
|
|
|
((<info> . ,alist) (assq-ref alist <globals>))))
|
|
|
|
|
|
|
|
(define (.locals o)
|
|
|
|
(pmatch o
|
|
|
|
((<info> . ,alist) (assq-ref alist <locals>))))
|
|
|
|
|
|
|
|
(define (.function o)
|
|
|
|
(pmatch o
|
|
|
|
((<info> . ,alist) (assq-ref alist <function>))))
|
|
|
|
|
|
|
|
(define (.text o)
|
|
|
|
(pmatch o
|
|
|
|
((<info> . ,alist) (assq-ref alist <text>))))
|
|
|
|
|
|
|
|
(define (.break o)
|
|
|
|
(pmatch o
|
|
|
|
((<info> . ,alist) (assq-ref alist <break>))))
|
|
|
|
|
|
|
|
(define (.continue o)
|
|
|
|
(pmatch o
|
|
|
|
((<info> . ,alist) (assq-ref alist <continue>))))
|
|
|
|
|
|
|
|
(define (info? o)
|
|
|
|
(and (pair? o) (eq? (car o) <info>)))
|
|
|
|
|
|
|
|
(define* (make o #:key (types '()) (constants '()) (functions '()) (globals '()) (locals '()) (function #f) (text '()) (break '()) (continue '()))
|
|
|
|
(pmatch o
|
|
|
|
(<info> (list <info>
|
|
|
|
(cons <types> types)
|
|
|
|
(cons <constants> constants)
|
|
|
|
(cons <functions> functions)
|
|
|
|
(cons <globals> globals)
|
|
|
|
(cons <locals> locals)
|
|
|
|
(cons <function> function)
|
|
|
|
(cons <text> text)
|
|
|
|
(cons <break> break)
|
|
|
|
(cons <continue> continue)))))
|
2017-07-15 08:40:31 +00:00
|
|
|
|
|
|
|
(define (make-type type size pointer description)
|
|
|
|
(list type size pointer description))
|
|
|
|
|
|
|
|
(define type:type car)
|
|
|
|
(define type:size cadr)
|
|
|
|
(define type:pointer caddr)
|
|
|
|
(define type:description cadddr)
|
2017-07-15 09:24:14 +00:00
|
|
|
|
|
|
|
(define (make-global name type pointer value)
|
|
|
|
(cons name (list type pointer value)))
|
|
|
|
|
|
|
|
(define global:type car)
|
|
|
|
(define global:pointer cadr)
|
|
|
|
(define global:value caddr)
|
2017-07-15 09:46:13 +00:00
|
|
|
|
|
|
|
(define (make-local type pointer id)
|
|
|
|
(list type pointer id))
|
|
|
|
(define local:type car)
|
|
|
|
(define local:pointer cadr)
|
|
|
|
(define local:id caddr)
|