commit 777279fcc84604834942c681f7a3eda44101b913
parent 36a7b15516f0cb36b74288a218d6fc5c4ddc92a4
Author: Andres Navarro <canavarro82@gmail.com>
Date: Fri, 29 Apr 2011 20:28:17 -0300
Added source code info as irritant in read and token errors.
Diffstat:
3 files changed, 16 insertions(+), 23 deletions(-)
diff --git a/src/kread.c b/src/kread.c
@@ -58,21 +58,17 @@ typedef enum {
*/
void kread_error(klisp_State *K, char *str)
{
- /* clear up before throwing */
- ks_tbclear(K);
- ks_sclear(K);
- clear_shared_dict(K);
-
- /* this is needed because it would be too complicated to
- pop manually on each kind of error */
- krooted_tvs_clear(K);
- krooted_vars_clear(K);
+ /* all cleaning is done in throw
+ (stacks, shared_dict, rooted objs) */
- /* save the source code info on the port anyways */
+ /* save the source code info on the port */
kport_update_source_info(K->curr_port, K->ktok_source_info.line,
K->ktok_source_info.col);
- klispE_throw_simple(K, str);
+ /* include the source info in the error */
+ TValue si = ktok_get_source_info(K);
+ krooted_tvs_push(K, si); /* will be popped by throw */
+ klispE_throw_with_irritants(K, str, si);
}
/*
diff --git a/src/ktoken.c b/src/ktoken.c
@@ -136,19 +136,17 @@ void clear_shared_dict(klisp_State *K)
void ktok_error(klisp_State *K, char *str)
{
- /* clear up before throwing */
- ks_tbclear(K);
- ks_sclear(K);
- clear_shared_dict(K);
-
- krooted_tvs_clear(K);
- krooted_vars_clear(K);
+ /* all cleaning is done in throw
+ (stacks, shared_dict, rooted objs) */
- /* save the source code info on the port anyways */
+ /* save the last source code info on the port */
kport_update_source_info(K->curr_port, K->ktok_source_info.line,
K->ktok_source_info.col);
- klispE_throw_simple(K, str);
+ /* include the source info in the error */
+ TValue si = ktok_get_source_info(K);
+ krooted_tvs_push(K, si); /* will be popped by throw */
+ klispE_throw_with_irritants(K, str, si);
}
/*
diff --git a/src/kwrite.c b/src/kwrite.c
@@ -46,9 +46,8 @@
void kwrite_error(klisp_State *K, char *msg)
{
- /* clear up before throwing */
- ks_tbclear(K);
- ks_sclear(K);
+ /* all cleaning is done in throw
+ (stacks, shared_dict, rooted objs) */
klispE_throw_simple(K, msg);
}