Commit 603ba3bb authored by Juergen Nickelsen's avatar Juergen Nickelsen
Browse files

finished commenting builtins.c; new TODO regarding error handling;

made time and measure return the value of the evaluated forms; made
errset return the error message as a string; renamed get_symbol(_z)
to intern(_z)
parent d9b2b2f2
......@@ -2,6 +2,10 @@
*: to do; +: done; -: rejected; @: in progress
* error handling: have some information in the interpreter context
(to be) that says if an error shall be printed or not and
things; it is saved, changed, and later restored e. g. by errset.
* a more useful tracing facility (eval, bindings, gc, gctraverse,
gcprotect, objects (new), ...)
......
This diff is collapsed.
......@@ -212,7 +212,7 @@ obp_t autoload(obp_t fun, obp_t out_port, int level)
ERROR(out_port, ERR_NOAUTOL, fun, "load triggered error");
}
Lfunction_t *newfunc =
AS(AS(get_symbol(func->name, func->namelen), SYMBOL)->function,
AS(AS(intern(func->name, func->namelen), SYMBOL)->function,
FUNCTION);
if (!newfunc) {
ERROR(out_port, ERR_NOAUTOL, fun, "function undefined");
......
......@@ -312,13 +312,13 @@ void init_io(void)
protect(the_Stderr);
the_Stdin = new_port("*stdin*", stdin, -1, 0, STREAM_PORT, 1, 0);
AS(get_symbol_z(STDIN_PORT_NAME), SYMBOL)->value = the_Stdin;
AS(intern_z(STDIN_PORT_NAME), SYMBOL)->value = the_Stdin;
the_Stdout = new_port("*stdout*", stdout, -1, 0, STREAM_PORT, 0, 1);
AS(get_symbol_z(STDOUT_PORT_NAME), SYMBOL)->value = the_Stdout;
AS(intern_z(STDOUT_PORT_NAME), SYMBOL)->value = the_Stdout;
the_Stderr = new_port("*stderr*", stderr, -1, 0, STREAM_PORT, 0, 1);
AS(get_symbol_z(STDERR_PORT_NAME), SYMBOL)->value = the_Stderr;
AS(intern_z(STDERR_PORT_NAME), SYMBOL)->value = the_Stderr;
UNPROTECT;
}
......
......@@ -300,7 +300,7 @@ void free_strbuf(obp_t ob)
/**
* Makes a new symbol. To be called _only_ by get_symbol()!
* Makes a new symbol. To be called _only_ by intern()!
*/
static obp_t new_symbol(obp_t name)
{
......@@ -318,7 +318,7 @@ static obp_t new_symbol(obp_t name)
/**
* Get the symbol with the specified name. Is created if it does not exist.
*/
obp_t get_symbol(char *name, int namelen)
obp_t intern(char *name, int namelen)
{
obp_t s_name = new_string(name, namelen);
obp_t symbol = hashmap_get(symbols_map, s_name);
......@@ -332,9 +332,9 @@ obp_t get_symbol(char *name, int namelen)
/**
* Get an symbol with the specified name from a zero-terminated string.
*/
obp_t get_symbol_z(char *name)
obp_t intern_z(char *name)
{
return get_symbol(name, strlen(name));
return intern(name, strlen(name));
}
......@@ -439,15 +439,15 @@ void init_objects(void)
symbols = new_map(EQ_EQV, 0);
symbols_map = AS(symbols, MAP)->map;
the_Nil = get_symbol_z(NIL_NAME);
the_Nil = intern_z(NIL_NAME);
AS(the_Nil, SYMBOL)->value = the_Nil;
the_Nil->immutable = 1;
the_T = get_symbol_z(T_NAME);
the_T = intern_z(T_NAME);
AS(the_T, SYMBOL)->value = the_T;
the_T->immutable = 1;
the_Lambda = get_symbol_z(LAMBDA_NAME);
the_Mu = get_symbol_z(SPECIAL_NAME);
the_Lambda = intern_z(LAMBDA_NAME);
the_Mu = intern_z(SPECIAL_NAME);
global_Env = new_map(EQ_EQ, 0);
hashmap_put(AS(global_Env, MAP)->map, the_Nil, the_Nil);
......
......@@ -282,12 +282,12 @@ void init_objects(void);
/**
* Get a symbol with the specified name. Is created if it does not exist.
*/
obp_t get_symbol(char *name, int namelen);
obp_t intern(char *name, int namelen);
/**
* Get a symbol with the specified name from a zero-terminated string.
*/
obp_t get_symbol_z(char *name);
obp_t intern_z(char *name);
/**
* Return the list of all symbols.
......
......@@ -313,7 +313,7 @@ token_t make_atom(l_state_t state, reader_t rdr)
rdr->tok_atom = new_integer(value);
return T_ISATOM;
}
rdr->tok_atom = get_symbol(s, len);
rdr->tok_atom = intern(s, len);
return T_ISATOM;
}
}
......@@ -436,7 +436,7 @@ obp_t do_special(char *name, reader_t rdr)
rdr->name, rdr->lineno, rdr->column);
}
argpair = new_pair(arg, the_Nil);
retval = new_pair(get_symbol_z(name), argpair);
retval = new_pair(intern_z(name), argpair);
EXIT:
UNPROTECT;
return retval;
......
......@@ -27,7 +27,7 @@ obp_t throw_error(obp_t out_port, short code, obp_t ob, char *format, ...)
obp_t errstr = get_port_string(port);
obp_t error = new_signal(SIG_LERROR, code, ob, errstr);
va_end(arglist);
AS(get_symbol_z(LAST_ERROR_NAME), SYMBOL)->value =
AS(intern_z(LAST_ERROR_NAME), SYMBOL)->value =
new_signal(SIG_UERROR, code, ob, errstr);
print_error(error, out_port);
return error;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment