From 27247383d757e4b56d87f1ffb1fc5232b576f5b1 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sat, 22 Oct 2016 19:36:54 +0200 Subject: [PATCH] Move define, define-macro to define.c. * mes.c (define, define-macro): Move to define.c * define.c: New file. * GNUmakefile (mes.o): Depend on define snarf output. --- GNUmakefile | 1 + define.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ mes.c | 35 +++-------------------------------- 3 files changed, 55 insertions(+), 32 deletions(-) create mode 100644 define.c diff --git a/GNUmakefile b/GNUmakefile index a5fbe16e..094f820e 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -24,6 +24,7 @@ all: mes mes.o: mes.c mes.o: mes.c mes.environment.h mes.environment.i mes.symbols.i +mes.o: define.c define.environment.h define.environment.i mes.o: quasiquote.c quasiquote.environment.h quasiquote.environment.i mes.o: type.c type.environment.h type.environment.i diff --git a/define.c b/define.c new file mode 100644 index 00000000..f05d908b --- /dev/null +++ b/define.c @@ -0,0 +1,51 @@ +/* -*-comment-start: "//";comment-end:""-*- + * Mes --- Maxwell Equations of Software + * Copyright © 2016 Jan Nieuwenhuizen + * + * 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 . + */ + +#if !BOOT +scm * +define (scm *x, scm *a) +{ + scm *e; + scm *name = cadr (x); + if (name->type != PAIR) + e = builtin_eval (caddr (x), cons (cons (cadr (x), cadr (x)), a)); + else { + name = car (name); + scm *p = pairlis (cadr (x), cadr (x), a); + e = builtin_eval (make_lambda (cdadr (x), cddr (x)), p); + } + if (eq_p (car (x), &symbol_define_macro) == &scm_t) + e = make_macro (name, e); + scm *entry = cons (name, e); + scm *aa = cons (entry, &scm_nil); + set_cdr_x (aa, cdr (a)); + set_cdr_x (a, aa); + scm *cl = assq (&scm_closure, a); + set_cdr_x (cl, aa); + return entry; +} +#else // BOOT +scm*define (scm *x, scm *a){} +#endif + +scm * +define_macro (scm *x, scm *a) +{ +} diff --git a/mes.c b/mes.c index 84a7cabe..288c1db5 100644 --- a/mes.c +++ b/mes.c @@ -63,6 +63,7 @@ typedef struct scm_t { scm temp_number = {NUMBER, .name="nul", .value=0}; #include "type.environment.h" +#include "define.environment.h" #include "quasiquote.environment.h" #include "mes.environment.h" @@ -193,6 +194,7 @@ quasisyntax (scm *x) } #include "type.c" +#include "define.c" #include "quasiquote.c" //Library functions @@ -1307,6 +1309,7 @@ mes_environment () ///((internal)) a = cons (cons (&symbol_syntax, &scm_syntax), a); #include "mes.environment.i" +#include "define.environment.i" #include "type.environment.i" a = cons (cons (&scm_closure, a), a); @@ -1325,38 +1328,6 @@ make_closure (scm *args, scm *body, scm *a) return cons (&scm_closure, cons (cons (&scm_circular, a), cons (args, body))); } -#if !BOOT -scm * -define (scm *x, scm *a) -{ - scm *e; - scm *name = cadr (x); - if (name->type != PAIR) - e = builtin_eval (caddr (x), cons (cons (cadr (x), cadr (x)), a)); - else { - name = car (name); - scm *p = pairlis (cadr (x), cadr (x), a); - e = builtin_eval (make_lambda (cdadr (x), cddr (x)), p); - } - if (eq_p (car (x), &symbol_define_macro) == &scm_t) - e = make_macro (name, e); - scm *entry = cons (name, e); - scm *aa = cons (entry, &scm_nil); - set_cdr_x (aa, cdr (a)); - set_cdr_x (a, aa); - scm *cl = assq (&scm_closure, a); - set_cdr_x (cl, aa); - return entry; -} -#else // BOOT -scm*define (scm *x, scm *a){} -#endif - -scm * -define_macro (scm *x, scm *a) -{ -} - scm * lookup_macro (scm *x, scm *a) { -- 2.31.1