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.
This commit is contained in:
Jan Nieuwenhuizen 2016-10-22 19:36:54 +02:00
parent bd7beddcda
commit 27247383d7
3 changed files with 55 additions and 32 deletions

View File

@ -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

51
define.c Normal file
View File

@ -0,0 +1,51 @@
/* -*-comment-start: "//";comment-end:""-*-
* Mes --- Maxwell Equations of Software
* Copyright © 2016 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/>.
*/
#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)
{
}

35
mes.c
View File

@ -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)
{