From 5d54461f67dbb9926da3bfb05778f9ee819ace7f Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Fri, 14 Jul 2017 21:26:35 +0200 Subject: [PATCH] mescc: Use records for Guile: . * module/language/c99/info.scm (): Make immutable record. Update users. --- module/language/c99/info.scm | 88 +++++++----------------------------- 1 file changed, 16 insertions(+), 72 deletions(-) diff --git a/module/language/c99/info.scm b/module/language/c99/info.scm index c5bab0dd..72671d9a 100644 --- a/module/language/c99/info.scm +++ b/module/language/c99/info.scm @@ -24,19 +24,12 @@ (define-module (language c99 info) #:use-module (ice-9 optargs) + #:use-module (srfi srfi-9) + #:use-module (srfi srfi-9 gnu) #:use-module (system base pmatch) #:export ( - ;; - ;; - ;; - ;; - ;; - ;; - ;; - ;; - ;; - make + make- info? .info @@ -56,67 +49,18 @@ (use-modules (ice-9 syncase))) (mes)) -;;(include-from-path "language/c99/info.mes") - -(define ') -(define ') -(define ') -(define ') -(define ') -(define ') -(define ') -(define ') -(define ') -(define ') +(define-immutable-record-type + (make- types constants functions globals locals function text break continue) + info? + (types .types) + (constants .constants) + (functions .functions) + (globals .globals) + (locals .locals) + (function .function) + (text .text) + (break .break) + (continue .continue)) (define* (make o #:key (types '()) (constants '()) (functions '()) (globals '()) (locals '()) (function #f) (text '()) (break '()) (continue '())) - (pmatch o - ( (list - (cons types) - (cons constants) - (cons functions) - (cons globals) - (cons locals) - (cons function) - (cons text) - (cons break) - (cons continue))))) - -(define (.types o) - (pmatch o - (( . ,alist) (assq-ref alist )))) - -(define (.constants o) - (pmatch o - (( . ,alist) (assq-ref alist )))) - -(define (.functions o) - (pmatch o - (( . ,alist) (assq-ref alist )))) - -(define (.globals o) - (pmatch o - (( . ,alist) (assq-ref alist )))) - -(define (.locals o) - (pmatch o - (( . ,alist) (assq-ref alist )))) - -(define (.function o) - (pmatch o - (( . ,alist) (assq-ref alist )))) - -(define (.text o) - (pmatch o - (( . ,alist) (assq-ref alist )))) - -(define (.break o) - (pmatch o - (( . ,alist) (assq-ref alist )))) - -(define (.continue o) - (pmatch o - (( . ,alist) (assq-ref alist )))) - -(define (info? o) - (and (pair? o) (eq? (car o) ))) + (make- types constants functions globals locals function text break continue))