add pic_compile
This commit is contained in:
parent
293fef5235
commit
655eb7a3bd
|
@ -152,7 +152,7 @@ pic_value pic_load(pic_state *, const char *);
|
|||
|
||||
pic_value pic_apply(pic_state *pic, struct pic_proc *, pic_value);
|
||||
pic_value pic_apply_argv(pic_state *pic, struct pic_proc *, size_t, ...);
|
||||
struct pic_proc *pic_codegen(pic_state *, pic_value);
|
||||
struct pic_proc *pic_compile(pic_state *, pic_value);
|
||||
pic_value pic_macroexpand(pic_state *, pic_value);
|
||||
|
||||
void pic_in_library(pic_state *, pic_value);
|
||||
|
|
|
@ -69,6 +69,9 @@ struct pic_irep {
|
|||
size_t clen, ilen, plen;
|
||||
};
|
||||
|
||||
pic_value pic_analyze(pic_state *, pic_value);
|
||||
struct pic_irep *pic_codegen(pic_state *pic, pic_value obj);
|
||||
|
||||
void pic_dump_irep(pic_state *, struct pic_irep *);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
|
1286
src/codegen.c
1286
src/codegen.c
File diff suppressed because it is too large
Load Diff
|
@ -27,7 +27,7 @@ pic_load(pic_state *pic, const char *fn)
|
|||
for (i = 0; i < n; ++i, vs = pic_cdr(pic, vs)) {
|
||||
v = pic_car(pic, vs);
|
||||
|
||||
proc = pic_codegen(pic, v);
|
||||
proc = pic_compile(pic, v);
|
||||
if (proc == NULL) {
|
||||
pic_error(pic, "load: compilation failure");
|
||||
}
|
||||
|
|
|
@ -317,7 +317,7 @@ macroexpand(pic_state *pic, pic_value expr, struct pic_senv *senv)
|
|||
for (exprs = pic_cddr(pic, expr); ! pic_nil_p(exprs); exprs = pic_cdr(pic, exprs)) {
|
||||
v = pic_car(pic, exprs);
|
||||
|
||||
proc = pic_codegen(pic, v);
|
||||
proc = pic_compile(pic, v);
|
||||
if (proc == NULL) {
|
||||
abort();
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ macroexpand(pic_state *pic, pic_value expr, struct pic_senv *senv)
|
|||
}
|
||||
|
||||
val = pic_cadr(pic, pic_cdr(pic, expr));
|
||||
proc = pic_codegen(pic, val);
|
||||
proc = pic_compile(pic, val);
|
||||
if (pic->errmsg) {
|
||||
printf("macroexpand error: %s\n", pic->errmsg);
|
||||
abort();
|
||||
|
@ -406,7 +406,7 @@ macroexpand(pic_state *pic, pic_value expr, struct pic_senv *senv)
|
|||
pic_error(pic, "syntax error");
|
||||
}
|
||||
|
||||
proc = pic_codegen(pic, val);
|
||||
proc = pic_compile(pic, val);
|
||||
if (pic->errmsg) {
|
||||
printf("macroexpand error: %s\n", pic->errmsg);
|
||||
abort();
|
||||
|
|
|
@ -122,7 +122,7 @@ repl(pic_state *pic)
|
|||
#endif
|
||||
|
||||
/* eval */
|
||||
proc = pic_codegen(pic, v);
|
||||
proc = pic_compile(pic, v);
|
||||
if (proc == NULL) {
|
||||
printf("compilation error: %s\n", pic->errmsg);
|
||||
pic->errmsg = NULL;
|
||||
|
@ -183,7 +183,7 @@ exec_file(pic_state *pic, const char *fname)
|
|||
|
||||
v = pic_car(pic, vs);
|
||||
|
||||
proc = pic_codegen(pic, v);
|
||||
proc = pic_compile(pic, v);
|
||||
if (proc == NULL) {
|
||||
fputs(pic->errmsg, stderr);
|
||||
fprintf(stderr, "fatal error: %s compilation failure\n", fname);
|
||||
|
@ -223,7 +223,7 @@ exec_string(pic_state *pic, const char *str)
|
|||
for (i = 0; i < n; ++i) {
|
||||
v = pic_car(pic, vs);
|
||||
|
||||
proc = pic_codegen(pic, v);
|
||||
proc = pic_compile(pic, v);
|
||||
if (proc == NULL) {
|
||||
goto abort;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue