mescc: Use records for mes too.
* module/language/c99/info.mes: Use info.scm records, remove simplistic list data structures.
This commit is contained in:
parent
c096a81cb5
commit
72a4f7eba2
|
@ -1,7 +1,7 @@
|
|||
;;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;; Copyright © 2016,2017,2018 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; This file is part of Mes.
|
||||
;;;
|
||||
|
@ -20,100 +20,9 @@
|
|||
|
||||
;;; 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))))
|
||||
(mes-use-module (srfi srfi-9))
|
||||
(define define-immutable-record-type define-record-type)
|
||||
|
||||
(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)))))
|
||||
|
||||
(define (make-type type size pointer description)
|
||||
(list 'type* type size pointer description))
|
||||
(define (type? o) (and (pair? o) (eq? (car o) 'type*)))
|
||||
(define type:type cadr)
|
||||
(define type:size caddr)
|
||||
(define type:pointer cadddr)
|
||||
(define caddddr (compose cadddr cdr))
|
||||
(define type:description caddddr)
|
||||
|
||||
(define (make-global type pointer value)
|
||||
(list 'global* type pointer value))
|
||||
(define (global? o) (and (pair? o) (eq? (car o) 'global*)))
|
||||
(define global:type cadr)
|
||||
(define global:pointer caddr)
|
||||
(define global:value cadddr)
|
||||
|
||||
(define (make-local type pointer id)
|
||||
(list 'local* type pointer id))
|
||||
(define (local? o) (and (pair? o) (eq? (car o) 'local*)))
|
||||
(define local:type cadr)
|
||||
(define local:pointer caddr)
|
||||
(define local:id cadddr)
|
||||
(include-from-path "language/c99/info.scm")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
;;; -*-scheme-*-
|
||||
|
||||
;;; Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;; Copyright © 2016,2017,2018 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; This file is part of Mes.
|
||||
;;;
|
||||
|
@ -65,7 +65,9 @@
|
|||
(guile-2)
|
||||
(guile
|
||||
(use-modules (ice-9 syncase)))
|
||||
(mes))
|
||||
(mes
|
||||
(mes-use-module (mes optargs))
|
||||
(mes-use-module (mes pmatch))))
|
||||
|
||||
(define-immutable-record-type <info>
|
||||
(make-<info> types constants functions globals locals function text break continue)
|
||||
|
|
Loading…
Reference in a new issue