Permalink
Browse files

load library.scm before contribs

  • Loading branch information...
nyuichi committed Apr 15, 2017
1 parent 69ab7e4 commit 1adcd26d854365ff0c12db7439f9f165f5faa403
View
@@ -1,34 +1,7 @@
LIBPICRIN_SRCS = \
lib/blob.c\
lib/bool.c\
lib/char.c\
lib/cont.c\
lib/data.c\
lib/debug.c\
lib/dict.c\
lib/error.c\
lib/gc.c\
lib/number.c\
lib/pair.c\
lib/port.c\
lib/proc.c\
lib/record.c\
lib/state.c\
lib/string.c\
lib/symbol.c\
lib/var.c\
lib/vector.c\
lib/weak.c\
lib/ext/boot.c\
lib/ext/lib.c\
lib/ext/file.c\
lib/ext/load.c\
lib/ext/read.c\
lib/ext/write.c
LIBPICRIN_OBJS = $(LIBPICRIN_SRCS:.c=.o)
PICRIN_SRCS = \
src/main.c\
src/init_lib.c\
src/lib.c\
src/load_piclib.c\
src/init_contrib.c
PICRIN_OBJS = \
@@ -45,40 +18,48 @@ REPL_ISSUE_TESTS = $(wildcard t/issue/*.sh)
TEST_RUNNER = picrin
CFLAGS += -I./lib/include -Wall -Wextra
CFLAGS += -I./lib/include -I./include -Wall -Wextra
LDFLAGS += -lm
prefix ?= /usr/local
include $(sort $(wildcard contrib/*/nitro.mk))
all: CFLAGS += -O2 -g -DNDEBUG=1
all: picrin
all: bootstrap picrin
debug: CFLAGS += -O0 -g
debug: picrin
debug: bootstrap picrin
tiny-picrin: CFLAGS += -O0 -g -DPIC_USE_LIBRARY=0
tiny-picrin: $(LIBPICRIN_OBJS) src/tiny-main.o
$(CC) $(CFLAGS) -o $@ $(LIBPICRIN_OBJS) src/tiny-main.o $(LDFLAGS)
bootstrap: bin/picrin-bootstrap
include $(sort $(wildcard contrib/*/nitro.mk))
bin/picrin-bootstrap:
test -f bin/picrin-bootstrap || { $(MAKE) lib/mini-picrin && mv lib/mini-picrin bin/picrin-bootstrap; }
lib/mini-picrin:
$(MAKE) -C lib mini-picrin
lib/libpicrin.a:
$(MAKE) -C lib libpicrin.a
picrin: $(PICRIN_OBJS) $(CONTRIB_OBJS) $(LIBPICRIN_OBJS)
$(CC) $(CFLAGS) -o $@ $(PICRIN_OBJS) $(CONTRIB_OBJS) $(LIBPICRIN_OBJS) $(LDFLAGS)
ext: lib/ext/eval.c
lib/ext/eval.c: piclib/eval.scm
bin/picrin-bootstrap -c piclib/eval.scm | bin/picrin-bootstrap tools/mkeval.scm > lib/ext/eval.c
picrin: $(PICRIN_OBJS) $(CONTRIB_OBJS) ext lib/libpicrin.a
$(CC) $(CFLAGS) -o $@ $(PICRIN_OBJS) $(CONTRIB_OBJS) lib/libpicrin.a $(LDFLAGS)
src/init_lib.c: piclib/library.scm
cat piclib/library.scm | bin/picrin-bootstrap tools/mklib.scm > src/init_lib.c
src/load_piclib.c: $(CONTRIB_LIBS)
perl tools/mkloader.pl $(CONTRIB_LIBS) > $@
src/init_contrib.c:
perl tools/mkinit.pl $(CONTRIB_INITS) > $@
# FIXME: Undefined symbols error for _emyg_atod and _emyg_dtoa
# libpicrin.so: $(LIBPICRIN_OBJS)
# $(CC) -shared $(CFLAGS) -o $@ $(LIBPICRIN_OBJS) $(LDFLAGS)
lib/ext/boot.c: piclib/compile.scm piclib/library.scm
cat piclib/compile.scm piclib/library.scm | bin/picrin-bootstrap tools/mkboot.scm > lib/ext/boot.c
$(LIBPICRIN_OBJS) $(PICRIN_OBJS) $(CONTRIB_OBJS): lib/include/picrin.h lib/include/picrin/*.h lib/khash.h lib/object.h lib/state.h
$(PICRIN_OBJS) $(CONTRIB_OBJS): lib/include/*.h lib/include/picrin/*.h lib/*.h include/picrin/*.h
doc: docs/*.rst docs/contrib.rst
$(MAKE) -C docs html
@@ -95,8 +76,8 @@ test: test-contribs test-nostdlib test-issue
test-contribs: picrin $(CONTRIB_TESTS)
test-nostdlib: lib/ext/boot.c
$(CC) -I./lib -I./lib/include -D'PIC_USE_LIBC=0' -D'PIC_USE_STDIO=0' -D'PIC_USE_WRITE=0' -D'PIC_USE_LIBRARY=0' -D'PIC_USE_EVAL=0' -ffreestanding -nostdlib -Os -fPIC -shared -std=c89 -pedantic -Wall -Wextra -Werror -o libpicrin-tiny.so $(LIBPICRIN_SRCS) etc/libc_polyfill.c -fno-stack-protector
test-nostdlib: ext
$(CC) -I./lib/include -Os -DPIC_USE_LIBC=0 -DPIC_USE_CALLCC=0 -DPIC_USE_FILE=0 -DPIC_USE_READ=0 -DPIC_USE_WRITE=0 -DPIC_USE_EVAL=0 -nostdlib -ffreestanding -fno-stack-protector -shared -pedantic -std=c89 -Wall -Wextra -Werror -o libpicrin-tiny.so $(wildcard lib/*.c)
strip libpicrin-tiny.so
ls -lh libpicrin-tiny.so
rm -f libpicrin-tiny.so
@@ -120,11 +101,11 @@ install: all
install -c picrin $(prefix)/bin/picrin
clean:
$(MAKE) -C lib clean
$(RM) picrin
$(RM) src/load_piclib.c src/init_contrib.c lib/ext/boot.c
$(RM) libpicrin.so libpicrin-tiny.so
$(RM) $(LIBPICRIN_OBJS)
$(RM) src/load_piclib.c src/init_contrib.c src/init_lib.c
$(RM) libpicrin-tiny.so
$(RM) $(PICRIN_OBJS)
$(RM) $(CONTRIB_OBJS)
.PHONY: all install clean push test test-r7rs test-contribs test-issue test-picrin-issue test-repl-issue doc $(CONTRIB_TESTS) $(REPL_ISSUE_TESTS)
.PHONY: all bootstrap ext install clean push test test-r7rs test-contribs test-issue test-picrin-issue test-repl-issue doc $(CONTRIB_TESTS) $(REPL_ISSUE_TESTS)
View
No changes.
View
Binary file not shown.
View
@@ -1,5 +1,6 @@
#include "picrin.h"
#include "picrin/extra.h"
#include "picrin/lib.h"
#include <math.h>
View
@@ -2,7 +2,6 @@ CONTRIB_INITS += r7rs
CONTRIB_SRCS += \
contrib/20.r7rs/src/r7rs.c\
contrib/20.r7rs/src/file.c\
contrib/20.r7rs/src/load.c\
contrib/20.r7rs/src/system.c\
contrib/20.r7rs/src/time.c
View

This file was deleted.

Oops, something went wrong.
@@ -23,10 +23,12 @@ pic_load_load(pic_state *pic)
port = pic_fopen(pic, fp, "r");
pic_try {
pic_value form;
size_t ai = pic_enter(pic);
while (! pic_eof_p(pic, form = pic_read(pic, port))) {
while (1) {
pic_value form = pic_funcall(pic, "read", 1, port);
if (pic_eof_p(pic, form))
break;
pic_funcall(pic, "eval", 1, form);
pic_leave(pic, ai);
}
@@ -4,15 +4,13 @@
#include "picrin.h"
void pic_nitro_init_file(pic_state *);
void pic_nitro_init_load(pic_state *);
void pic_nitro_init_system(pic_state *);
void pic_nitro_init_time(pic_state *);
void
pic_nitro_init_r7rs(pic_state *pic)
{
pic_nitro_init_file(pic);
pic_nitro_init_load(pic);
pic_nitro_init_system(pic);
pic_nitro_init_time(pic);
@@ -1,5 +1,6 @@
#include "picrin.h"
#include "picrin/extra.h"
#include "picrin/lib.h"
double genrand_real3(void);
@@ -7,6 +7,7 @@ forget to use the C++ extern "C" to get it to compile.
*/
#include "picrin.h"
#include "picrin/extra.h"
#include "picrin/lib.h"
#include <editline/readline.h>
@@ -1,5 +1,6 @@
#include "picrin.h"
#include "picrin/extra.h"
#include "picrin/lib.h"
#include <regex.h>
View
@@ -0,0 +1,24 @@
/**
* See Copyright Notice in picrin.h
*/
#ifndef PICRIN_LIB_H
#define PICRIN_LIB_H
#if defined(__cplusplus)
extern "C" {
#endif
/*
* library
*/
void pic_deflibrary(pic_state *, const char *lib);
void pic_in_library(pic_state *, const char *lib);
void pic_export(pic_state *, int n, ...);
#if defined(__cplusplus)
}
#endif
#endif
View
@@ -39,20 +39,15 @@ LIBPICRIN_HEADERS = \
CFLAGS += -I./include -Wall -Wextra -g
mini-picrin: $(LIBPICRIN_OBJS) ext/main.o
$(CC) $(CFLAGS) -o $@ ext/main.o $(LIBPICRIN_OBJS)
mini-picrin: ext/main.o libpicrin.a
$(CC) $(CFLAGS) -o $@ ext/main.o libpicrin.a
libpicrin.so: CFLAGS += -fPIC
libpicrin.so: $(LIBPICRIN_OBJS)
$(CC) $(CFLAGS) -shared -o $@ $(LIBPICRIN_OBJS) $(LDFLAGS)
libpicrin.so.minimal: $(LIBPICRIN_SRCS)
$(CC) -I./include -Os -DPIC_USE_LIBC=0 -DPIC_USE_CALLCC=0 -DPIC_USE_FILE=0 -DPIC_USE_READ=0 -DPIC_USE_WRITE=0 -DPIC_USE_EVAL=0 -nostdlib -ffreestanding -fno-stack-protector -shared -o $@ $(LIBPICRIN_SRCS) $(LDFLAGS)
strip $@
libpicrin.a: $(LIBPICRIN_OBJS)
$(AR) $(ARFLAGS) $@ $(LIBPICRIN_OBJS)
$(LIBPICRIN_OBJS): $(LIBPICRIN_HEADERS)
clean:
$(RM) $(LIBPICRIN_OBJS) ext/main.o mini-picrin libpicrin.so libpicrin.so.minimal
$(RM) $(LIBPICRIN_OBJS) ext/main.o mini-picrin libpicrin.a
.PHONY: clean
View
@@ -41,7 +41,7 @@ cont_call(pic_state *pic)
}
pic->cxt = cxt;
PIC_LONGJMP(cxt->jmp, 1);
longjmp(cxt->jmp, 1);
PIC_UNREACHABLE();
}
@@ -42,10 +42,9 @@
# include <setjmp.h>
# define PIC_JMPBUF jmp_buf
# define PIC_SETJMP(buf) setjmp(buf)
# define PIC_LONGJMP(buf, val) longjmp((buf), (val))
#else
# define PIC_JMPBUF char
# define PIC_SETJMP(buf) 0
# define PIC_SETJMP(buf) ((void)(buf), 0)
#endif
#ifndef PIC_ABORT
View
@@ -56,9 +56,10 @@ assemble(pic_state *pic, pic_value as)
i = 0;
/* TODO: validate operands */
pic_for_each (r, codes, it) {
pic_value op;
if (! pic_pair_p(pic, r))
continue;
pic_value op = pic_car(pic, r);
op = pic_car(pic, r);
if (pic_eq_p(pic, op, pic_intern_lit(pic, "HALT"))) {
code[i++] = OP_HALT;
}
View
@@ -92,7 +92,7 @@ enum {
OP_LOADF = 0x0A, /* 0x0A 0x** OP_LOADF dest */
OP_LOADN = 0x0B, /* 0x0B 0x** OP_LOADN dest */
OP_LOADU = 0x0C, /* 0x0C 0x** OP_LOADU dest */
OP_LOADI = 0x0D, /* 0x0D 0x** 0x** OP_LOADI dest i */
OP_LOADI = 0x0D /* 0x0D 0x** 0x** OP_LOADI dest i */
};
typedef unsigned char code_t;
Oops, something went wrong.

0 comments on commit 1adcd26

Please sign in to comment.