remove pic->file and pic->read

This commit is contained in:
Yuichi Nishiwaki 2015-07-02 08:50:10 +09:00
parent 111df69d1e
commit 4905aab416
6 changed files with 15 additions and 12 deletions

View File

@ -11,7 +11,7 @@ file_error(pic_state *pic, const char *msg)
{
struct pic_error *e;
e = pic_make_error(pic, pic->sFILE, msg, pic_nil_value());
e = pic_make_error(pic, pic_intern_cstr(pic, "file"), msg, pic_nil_value());
pic_raise(pic, pic_obj_value(e));
}

View File

@ -524,15 +524,12 @@ gc_mark_global_symbols(pic_state *pic)
M(sQUOTE); M(sQUASIQUOTE); M(sUNQUOTE); M(sUNQUOTE_SPLICING);
M(sSYNTAX_QUOTE); M(sSYNTAX_QUASIQUOTE); M(sSYNTAX_UNQUOTE); M(sSYNTAX_UNQUOTE_SPLICING);
M(sDEFINE_LIBRARY); M(sIMPORT); M(sEXPORT); M(sCOND_EXPAND);
M(sREAD); M(sFILE);
M(sCALL); M(sGREF); M(sLREF); M(sCREF);
M(uDEFINE); M(uLAMBDA); M(uIF); M(uBEGIN); M(uQUOTE); M(uSETBANG); M(uDEFINE_MACRO);
M(uDEFINE_LIBRARY); M(uIMPORT); M(uEXPORT); M(uCOND_EXPAND);
M(uCONS); M(uCAR); M(uCDR); M(uNILP);
M(uSYMBOLP); M(uPAIRP);
M(uADD); M(uSUB); M(uMUL); M(uDIV);
M(uEQ); M(uLT); M(uLE); M(uGT); M(uGE); M(uNOT);
M(uCONS); M(uCAR); M(uCDR); M(uNILP); M(uSYMBOLP); M(uPAIRP);
M(uADD); M(uSUB); M(uMUL); M(uDIV); M(uEQ); M(uLT); M(uLE); M(uGT); M(uGE); M(uNOT);
M(uVALUES); M(uCALL_WITH_VALUES);
}

View File

@ -99,7 +99,6 @@ struct pic_state {
pic_sym *sSYNTAX_QUOTE, *sSYNTAX_QUASIQUOTE, *sSYNTAX_UNQUOTE, *sSYNTAX_UNQUOTE_SPLICING;
pic_sym *sDEFINE_LIBRARY, *sIMPORT, *sEXPORT, *sCOND_EXPAND;
pic_sym *sGREF, *sCREF, *sLREF, *sCALL;
pic_sym *sREAD, *sFILE;
pic_sym *uDEFINE, *uLAMBDA, *uIF, *uBEGIN, *uQUOTE, *uSETBANG, *uDEFINE_MACRO;
pic_sym *uDEFINE_LIBRARY, *uIMPORT, *uEXPORT, *uCOND_EXPAND;

View File

@ -98,6 +98,16 @@ file_open(pic_state *pic, const char *name, const char *mode) {
}
}
PIC_NORETURN static void
file_error(pic_state *pic, const char *msg)
{
struct pic_error *e;
e = pic_make_error(pic, pic_intern_cstr(pic, "file"), msg, pic_nil_value());
pic_raise(pic, pic_obj_value(e));
}
struct pic_port *
pic_open_file(pic_state *pic, const char *name, int flags) {
struct pic_port *port;
@ -108,8 +118,7 @@ pic_open_file(pic_state *pic, const char *name, int flags) {
mode = 'w';
}
if ((file = file_open(pic, name, &mode)) == NULL) {
pic_str *msg = pic_format(pic, "could not open file '%s'", name);
pic_raise(pic, pic_obj_value(pic_make_error(pic, pic->sFILE, pic_str_cstr(pic, msg), pic_nil_value())));
file_error(pic, pic_str_cstr(pic, pic_format(pic, "could not open file '%s'", name)));
}
port = (struct pic_port *)pic_obj_alloc(pic, sizeof(struct pic_port), PIC_TT_PORT);

View File

@ -14,7 +14,7 @@ read_error(pic_state *pic, const char *msg)
{
struct pic_error *e;
e = pic_make_error(pic, pic->sREAD, msg, pic_nil_value());
e = pic_make_error(pic, pic_intern_cstr(pic, "read"), msg, pic_nil_value());
pic_raise(pic, pic_obj_value(e));
}

View File

@ -314,8 +314,6 @@ pic_open(pic_allocf allocf, void *userdata)
S(sEXPORT, "export");
S(sDEFINE_LIBRARY, "define-library");
S(sCOND_EXPAND, "cond-expand");
S(sREAD, "read");
S(sFILE, "file");
S(sCALL, "call");
S(sGREF, "gref");
S(sLREF, "lref");