diff options
| author | redbrain <redbrain@crules.org> | 2010-08-08 05:15:34 +0100 |
|---|---|---|
| committer | redbrain <redbrain@crules.org> | 2010-08-08 05:15:34 +0100 |
| commit | 79f84bd447e7fe25f84b3182d51f2ec0e44b3abe (patch) | |
| tree | 1fd4ff42ef545d53af25554dea62d629f2c7dd7b /libgpython | |
| parent | 03257816f4573742aea851b18722dda26184334b (diff) | |
| download | gcc-79f84bd447e7fe25f84b3182d51f2ec0e44b3abe.tar.gz | |
lots of bug fixes and cleanups to all components
Diffstat (limited to 'libgpython')
| -rw-r--r-- | libgpython/include/gpython/garbage.h | 2 | ||||
| -rw-r--r-- | libgpython/runtime/obj_integer.c | 4 | ||||
| -rw-r--r-- | libgpython/runtime/py_garbage.c | 8 | ||||
| -rw-r--r-- | libgpython/runtime/py_runtime.c | 19 | ||||
| -rw-r--r-- | libgpython/runtime/vectors.c | 9 |
5 files changed, 32 insertions, 10 deletions
diff --git a/libgpython/include/gpython/garbage.h b/libgpython/include/gpython/garbage.h index 8a216bc6719..b102b1daaec 100644 --- a/libgpython/include/gpython/garbage.h +++ b/libgpython/include/gpython/garbage.h @@ -49,7 +49,7 @@ extern void gpy_garbage_free_obj( gpy_object_state_t * ); #define gpy_garbage_mark_obj( x ) \ gpy_assert( x ); \ - debug("marking garbage <%p> ref count <%l>!\n", \ + debug("marking garbage <%p> ref count <%i>!\n", \ (void*) x, x->ref_count ); \ gpy_garbage_mark_obj__( x ); diff --git a/libgpython/runtime/obj_integer.c b/libgpython/runtime/obj_integer.c index 8a935bfb5c7..3ac183abba5 100644 --- a/libgpython/runtime/obj_integer.c +++ b/libgpython/runtime/obj_integer.c @@ -32,7 +32,7 @@ along with GCC; see the file COPYING3. If not see #include <gpython/garbage.h> struct gpy_obj_integer_t { - long int Int; + int Int; }; void * gpy_obj_integer_init( gpy_literal_t * lit ) @@ -55,7 +55,7 @@ void gpy_obj_integer_destroy( void * self ) void gpy_obj_integer_print( void * self, FILE * fd, bool newline ) { struct gpy_obj_integer_t * si = (struct gpy_obj_integer_t *) self; - fprintf( fd, "%li", si->Int ); + fprintf( fd, "%i ", si->Int ); if( newline ) fprintf( fd, "\n" ); diff --git a/libgpython/runtime/py_garbage.c b/libgpython/runtime/py_garbage.c index 2b56c70b713..4b2e24a8d53 100644 --- a/libgpython/runtime/py_garbage.c +++ b/libgpython/runtime/py_garbage.c @@ -76,7 +76,7 @@ void gpy_garbage_invoke_sweep( gpy_vector_t * const context ) signed long ctx_l = context->length; if( context ) { - debug("sweeping context table for garbage length <%u>...\n", ctx_l); + debug("sweeping context table for garbage length <%i>...\n", ctx_l); gpy_context_t * ctx_idx = NULL; signed long idx = (ctx_l - 1); while( idx >= 0 ) @@ -84,14 +84,14 @@ void gpy_garbage_invoke_sweep( gpy_vector_t * const context ) ctx_idx = context->vector[ idx ]; void ** s_arr = ctx_idx->symbols->vector; - int i = 0; long len = (ctx_idx->symbols->length); - debug("vector length <%l>!\n", len ); + int i = 0; int len = (ctx_idx->symbols->length); + debug("vector length <%i>!\n", len ); for( ; i<len; ++i ) { gpy_object_state_t * o = (gpy_object_state_t *) s_arr[ i ]; if( o ) { - debug( "object <%p> has ref count <%l>!\n", + debug( "object <%p> has ref count <%i>!\n", (void *) o, o->ref_count ); // If no references remain diff --git a/libgpython/runtime/py_runtime.c b/libgpython/runtime/py_runtime.c index bfa5dca4aba..97a2bd8ee96 100644 --- a/libgpython/runtime/py_runtime.c +++ b/libgpython/runtime/py_runtime.c @@ -96,6 +96,9 @@ gpy_object_state_t * gpy_rr_fold_integer( int x ) return retval; } +/** + * int fd: we could use numbers 1,2 to denote stdout or stderr + **/ void gpy_rr_eval_print( int fd, int count, ... ) { va_list vl; int idx; @@ -109,8 +112,22 @@ void gpy_rr_eval_print( int fd, int count, ... ) { it = va_arg( vl, gpy_object_t ); gpy_assert( it ); - (*it->definition).print_hook( it, stdout, false ); + switch( fd ) + { + case 1: + (*it->definition).print_hook( it->self, stdout, false ); + break; + + case 2: + (*it->definition).print_hook( it->self, stderr, false ); + break; + + default: + fatal("invalid print file-descriptor <%i>!\n", fd ); + break; + } } + fprintf( stdout, "\n" ); va_end(vl); } diff --git a/libgpython/runtime/vectors.c b/libgpython/runtime/vectors.c index 8efb8cdb0aa..a48cebd7395 100644 --- a/libgpython/runtime/vectors.c +++ b/libgpython/runtime/vectors.c @@ -162,8 +162,13 @@ void gpy_vec_push( gpy_vector_t * const v, void * const s ) inline void * gpy_vec_pop( gpy_vector_t * const v ) { - register void * retval = v->vector[ v->length-1 ]; - v->length--; + register void * retval = NULL; + if( v->length > 0 ) + { + retval = v->vector[ v->length-1 ]; + v->length--; + } + return retval; } |
