klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

commit 83b40d9230948d6e2c169cac135702aca8a1af9c
parent 2f1bd9c3bbd1a8bb7eacd718b6572ba73d827e3e
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Wed, 13 Jul 2011 14:48:05 -0300

Added error port to the state structure.

Diffstat:
Msrc/kstate.c | 4++++
Msrc/kstate.h | 4+++-
2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/kstate.c b/src/kstate.c @@ -91,6 +91,7 @@ klisp_State *klisp_newstate (klisp_Alloc f, void *ud) { /* these are init later */ K->kd_in_port_key = KINERT; K->kd_out_port_key = KINERT; + K->kd_error_port_key = KINERT; /* strict arithmetic dynamic key */ /* this is init later */ @@ -196,8 +197,11 @@ klisp_State *klisp_newstate (klisp_Alloc f, void *ud) { false, stdin); TValue out_port = kmake_std_port(K, kstring_new_b_imm(K, "*STDOUT*"), true, stdout); + TValue error_port = kmake_std_port(K, kstring_new_b_imm(K, "*STDERR*"), + true, stderr); K->kd_in_port_key = kcons(K, KTRUE, in_port); K->kd_out_port_key = kcons(K, KTRUE, out_port); + K->kd_error_port_key = kcons(K, KTRUE, error_port); /* strict arithmetic key, (starts as false) */ K->kd_strict_arith_key = kcons(K, KTRUE, KFALSE); diff --git a/src/kstate.h b/src/kstate.h @@ -103,9 +103,10 @@ struct klisp_State { FILE *curr_in; FILE *curr_out; - /* for current-input-port, current-output-port */ + /* for current-input-port, current-output-port, current-error-port */ TValue kd_in_port_key; TValue kd_out_port_key; + TValue kd_error_port_key; /* for strict-arithmetic */ TValue kd_strict_arith_key; @@ -498,6 +499,7 @@ void do_interception(klisp_State *K, TValue *xparams, TValue obj); /* TODO: use these where appropriate */ #define kcurr_input_port(K) (tv2pair((K)->kd_in_port_key)->cdr) #define kcurr_output_port(K) (tv2pair((K)->kd_out_port_key)->cdr) +#define kcurr_error_port(K) (tv2pair((K)->kd_error_port_key)->cdr) #define kcurr_strict_arithp(K) bvalue(tv2pair((K)->kd_strict_arith_key)->cdr) #endif