diff options
author | redbrain <redbrain@gcc.gnu.org> | 2011-02-02 17:21:29 +0000 |
---|---|---|
committer | redbrain <redbrain@gcc.gnu.org> | 2011-02-02 17:21:29 +0000 |
commit | d4833373db1591ed6783925557780d3dab7852dc (patch) | |
tree | 76eff690060669686985e880e66b60624ade3541 /libgpython | |
parent | 135d70aad1e200d69c068363d8bc3585c62a30b1 (diff) | |
download | gcc-d4833373db1591ed6783925557780d3dab7852dc.tar.gz |
some more general refactoring and boiler plate stuff
Diffstat (limited to 'libgpython')
-rw-r--r-- | libgpython/autom4te.cache/requests | 120 | ||||
-rw-r--r-- | libgpython/include/gpython/garbage.h | 16 | ||||
-rw-r--r-- | libgpython/include/gpython/objects.h | 20 | ||||
-rw-r--r-- | libgpython/runtime/obj-integer.c | 13 | ||||
-rw-r--r-- | libgpython/runtime/py-garbage.c | 34 | ||||
-rw-r--r-- | libgpython/runtime/py-runtime.c | 34 | ||||
-rw-r--r-- | libgpython/runtime/py-utils.c | 49 |
7 files changed, 176 insertions, 110 deletions
diff --git a/libgpython/autom4te.cache/requests b/libgpython/autom4te.cache/requests index 569919f06ed..011d4791814 100644 --- a/libgpython/autom4te.cache/requests +++ b/libgpython/autom4te.cache/requests @@ -56,8 +56,8 @@ '_m4_warn' => 1, 'AC_LIBTOOL_OBJDIR' => 1, 'gl_FUNC_ARGZ' => 1, - 'LTOBSOLETE_VERSION' => 1, 'AM_SANITY_CHECK' => 1, + 'LTOBSOLETE_VERSION' => 1, 'AC_LIBTOOL_LANG_GCJ_CONFIG' => 1, 'AC_LIBTOOL_PROG_COMPILER_PIC' => 1, 'LT_LIB_M' => 1, @@ -72,16 +72,16 @@ 'LT_SYS_DLOPEN_DEPLIBS' => 1, '_LT_AC_LANG_F77' => 1, 'AC_LIBTOOL_CONFIG' => 1, - '_AM_SUBST_NOTMAKE' => 1, 'AC_LTDL_DLLIB' => 1, + '_AM_SUBST_NOTMAKE' => 1, '_AM_AUTOCONF_VERSION' => 1, 'AM_DISABLE_SHARED' => 1, '_LTDL_SETUP' => 1, - '_LT_AC_LANG_CXX' => 1, 'AM_PROG_LIBTOOL' => 1, - 'AC_LIB_LTDL' => 1, - '_LT_AC_FILE_LTDLL_C' => 1, + '_LT_AC_LANG_CXX' => 1, 'AM_PROG_LD' => 1, + '_LT_AC_FILE_LTDLL_C' => 1, + 'AC_LIB_LTDL' => 1, 'AU_DEFUN' => 1, 'AC_PROG_NM' => 1, 'AC_LIBTOOL_DLOPEN' => 1, @@ -105,31 +105,31 @@ 'AC_LTDL_OBJDIR' => 1, '_LT_PATH_TOOL_PREFIX' => 1, 'AC_LIBTOOL_RC' => 1, - '_LT_AC_PROG_ECHO_BACKSLASH' => 1, - 'AC_DISABLE_FAST_INSTALL' => 1, 'AM_SILENT_RULES' => 1, - '_LT_AC_TRY_DLOPEN_SELF' => 1, - '_LT_AC_SYS_LIBPATH_AIX' => 1, + 'AC_DISABLE_FAST_INSTALL' => 1, + '_LT_AC_PROG_ECHO_BACKSLASH' => 1, 'include' => 1, + '_LT_AC_SYS_LIBPATH_AIX' => 1, + '_LT_AC_TRY_DLOPEN_SELF' => 1, 'LT_AC_PROG_SED' => 1, 'AM_ENABLE_SHARED' => 1, 'LTDL_INSTALLABLE' => 1, '_LT_AC_LANG_GCJ_CONFIG' => 1, 'AC_ENABLE_SHARED' => 1, - 'AC_LIBTOOL_SYS_HARD_LINK_LOCKS' => 1, 'AC_ENABLE_STATIC' => 1, - '_LT_AC_TAGVAR' => 1, + 'AC_LIBTOOL_SYS_HARD_LINK_LOCKS' => 1, 'AM_PROG_CC_C_O' => 1, + '_LT_AC_TAGVAR' => 1, 'AC_LIBTOOL_LANG_F77_CONFIG' => 1, 'AM_CONDITIONAL' => 1, 'LT_LIB_DLLOAD' => 1, - 'LTVERSION_VERSION' => 1, 'LTDL_INIT' => 1, - 'AM_PROG_INSTALL_SH' => 1, + 'LTVERSION_VERSION' => 1, 'm4_include' => 1, + 'AM_PROG_INSTALL_SH' => 1, 'AC_PROG_EGREP' => 1, - 'AC_PATH_MAGIC' => 1, '_AC_AM_CONFIG_HEADER_HOOK' => 1, + 'AC_PATH_MAGIC' => 1, 'AC_LTDL_SYSSEARCHPATH' => 1, 'AM_MAKE_INCLUDE' => 1, '_LT_AC_TAGCONFIG' => 1, @@ -173,11 +173,11 @@ 'AM_PROG_NM' => 1, 'AC_LIBLTDL_CONVENIENCE' => 1, 'AC_DEPLIBS_CHECK_METHOD' => 1, - 'AC_LIBLTDL_INSTALLABLE' => 1, 'AM_SET_CURRENT_AUTOMAKE_VERSION' => 1, + 'AC_LIBLTDL_INSTALLABLE' => 1, 'AC_LTDL_ENABLE_INSTALL' => 1, - 'LT_PROG_GCJ' => 1, 'AC_LIBTOOL_SYS_DYNAMIC_LINKER' => 1, + 'LT_PROG_GCJ' => 1, 'AM_INIT_AUTOMAKE' => 1, 'AC_DISABLE_STATIC' => 1, 'LT_PATH_NM' => 1, @@ -185,25 +185,25 @@ '_LT_AC_LOCK' => 1, '_LT_AC_LANG_RC_CONFIG' => 1, 'LT_SYS_MODULE_PATH' => 1, - 'AC_LIBTOOL_POSTDEP_PREDEP' => 1, 'LT_WITH_LTDL' => 1, + 'AC_LIBTOOL_POSTDEP_PREDEP' => 1, 'AC_LTDL_SHLIBPATH' => 1, 'AM_AUX_DIR_EXPAND' => 1, - '_LT_AC_LANG_F77_CONFIG' => 1, 'AC_LIBTOOL_PROG_COMPILER_NO_RTTI' => 1, - '_LT_COMPILER_OPTION' => 1, + '_LT_AC_LANG_F77_CONFIG' => 1, '_AM_SET_OPTIONS' => 1, - 'AM_RUN_LOG' => 1, + '_LT_COMPILER_OPTION' => 1, '_AM_OUTPUT_DEPENDENCY_COMMANDS' => 1, - 'AC_LTDL_SYS_DLOPEN_DEPLIBS' => 1, - 'AC_LIBTOOL_SYS_OLD_ARCHIVE' => 1, + 'AM_RUN_LOG' => 1, 'AC_LIBTOOL_PICMODE' => 1, - 'AC_CHECK_LIBM' => 1, + 'AC_LIBTOOL_SYS_OLD_ARCHIVE' => 1, + 'AC_LTDL_SYS_DLOPEN_DEPLIBS' => 1, 'LT_PATH_LD' => 1, + 'AC_CHECK_LIBM' => 1, 'AC_LIBTOOL_SYS_LIB_STRIP' => 1, '_AM_MANGLE_OPTION' => 1, - 'AC_LIBTOOL_SYS_MAX_CMD_LEN' => 1, 'AC_LTDL_SYMBOL_USCORE' => 1, + 'AC_LIBTOOL_SYS_MAX_CMD_LEN' => 1, 'AM_SET_DEPDIR' => 1, '_LT_CC_BASENAME' => 1, '_LT_LIBOBJ' => 1 @@ -221,25 +221,25 @@ 'configure.ac' ], { - 'AM_PROG_F77_C_O' => 1, '_LT_AC_TAGCONFIG' => 1, - 'm4_pattern_forbid' => 1, + 'AM_PROG_F77_C_O' => 1, 'AC_INIT' => 1, - '_AM_COND_IF' => 1, + 'm4_pattern_forbid' => 1, 'AC_CANONICAL_TARGET' => 1, - 'AC_SUBST' => 1, + '_AM_COND_IF' => 1, 'AC_CONFIG_LIBOBJ_DIR' => 1, - 'AC_FC_SRCEXT' => 1, + 'AC_SUBST' => 1, 'AC_CANONICAL_HOST' => 1, + 'AC_FC_SRCEXT' => 1, 'AC_PROG_LIBTOOL' => 1, 'AM_INIT_AUTOMAKE' => 1, 'AC_CONFIG_SUBDIRS' => 1, 'AM_AUTOMAKE_VERSION' => 1, 'LT_CONFIG_LTDL_DIR' => 1, - 'AC_REQUIRE_AUX_FILE' => 1, 'AC_CONFIG_LINKS' => 1, - 'LT_SUPPORTED_TAG' => 1, + 'AC_REQUIRE_AUX_FILE' => 1, 'm4_sinclude' => 1, + 'LT_SUPPORTED_TAG' => 1, 'AM_MAINTAINER_MODE' => 1, 'AM_GNU_GETTEXT_INTL_SUBDIR' => 1, '_m4_warn' => 1, @@ -252,17 +252,17 @@ 'include' => 1, 'AM_GNU_GETTEXT' => 1, 'AC_LIBSOURCE' => 1, - 'AM_PROG_FC_C_O' => 1, 'AC_CANONICAL_BUILD' => 1, + 'AM_PROG_FC_C_O' => 1, 'AC_FC_FREEFORM' => 1, 'AH_OUTPUT' => 1, - '_AM_SUBST_NOTMAKE' => 1, 'AC_CONFIG_AUX_DIR' => 1, - 'm4_pattern_allow' => 1, - 'sinclude' => 1, + '_AM_SUBST_NOTMAKE' => 1, 'AM_PROG_CC_C_O' => 1, - 'AC_CANONICAL_SYSTEM' => 1, + 'sinclude' => 1, + 'm4_pattern_allow' => 1, 'AM_CONDITIONAL' => 1, + 'AC_CANONICAL_SYSTEM' => 1, 'AC_CONFIG_HEADERS' => 1, 'AC_DEFINE_TRACE_LITERAL' => 1, 'm4_include' => 1, @@ -323,8 +323,8 @@ '_m4_warn' => 1, 'AC_LIBTOOL_OBJDIR' => 1, 'gl_FUNC_ARGZ' => 1, - 'LTOBSOLETE_VERSION' => 1, 'AM_SANITY_CHECK' => 1, + 'LTOBSOLETE_VERSION' => 1, 'AC_LIBTOOL_LANG_GCJ_CONFIG' => 1, 'AC_LIBTOOL_PROG_COMPILER_PIC' => 1, 'LT_LIB_M' => 1, @@ -339,16 +339,16 @@ 'LT_SYS_DLOPEN_DEPLIBS' => 1, '_LT_AC_LANG_F77' => 1, 'AC_LIBTOOL_CONFIG' => 1, - '_AM_SUBST_NOTMAKE' => 1, 'AC_LTDL_DLLIB' => 1, + '_AM_SUBST_NOTMAKE' => 1, '_AM_AUTOCONF_VERSION' => 1, 'AM_DISABLE_SHARED' => 1, '_LTDL_SETUP' => 1, - '_LT_AC_LANG_CXX' => 1, 'AM_PROG_LIBTOOL' => 1, - 'AC_LIB_LTDL' => 1, - '_LT_AC_FILE_LTDLL_C' => 1, + '_LT_AC_LANG_CXX' => 1, 'AM_PROG_LD' => 1, + '_LT_AC_FILE_LTDLL_C' => 1, + 'AC_LIB_LTDL' => 1, 'AU_DEFUN' => 1, 'AC_PROG_NM' => 1, 'AC_LIBTOOL_DLOPEN' => 1, @@ -372,31 +372,31 @@ 'AC_LTDL_OBJDIR' => 1, '_LT_PATH_TOOL_PREFIX' => 1, 'AC_LIBTOOL_RC' => 1, - '_LT_AC_PROG_ECHO_BACKSLASH' => 1, - 'AC_DISABLE_FAST_INSTALL' => 1, 'AM_SILENT_RULES' => 1, - '_LT_AC_TRY_DLOPEN_SELF' => 1, - '_LT_AC_SYS_LIBPATH_AIX' => 1, + 'AC_DISABLE_FAST_INSTALL' => 1, + '_LT_AC_PROG_ECHO_BACKSLASH' => 1, 'include' => 1, + '_LT_AC_SYS_LIBPATH_AIX' => 1, + '_LT_AC_TRY_DLOPEN_SELF' => 1, 'LT_AC_PROG_SED' => 1, 'AM_ENABLE_SHARED' => 1, 'LTDL_INSTALLABLE' => 1, '_LT_AC_LANG_GCJ_CONFIG' => 1, 'AC_ENABLE_SHARED' => 1, - 'AC_LIBTOOL_SYS_HARD_LINK_LOCKS' => 1, 'AC_ENABLE_STATIC' => 1, - '_LT_AC_TAGVAR' => 1, + 'AC_LIBTOOL_SYS_HARD_LINK_LOCKS' => 1, 'AM_PROG_CC_C_O' => 1, + '_LT_AC_TAGVAR' => 1, 'AC_LIBTOOL_LANG_F77_CONFIG' => 1, 'AM_CONDITIONAL' => 1, 'LT_LIB_DLLOAD' => 1, - 'LTVERSION_VERSION' => 1, 'LTDL_INIT' => 1, - 'AM_PROG_INSTALL_SH' => 1, + 'LTVERSION_VERSION' => 1, 'm4_include' => 1, + 'AM_PROG_INSTALL_SH' => 1, 'AC_PROG_EGREP' => 1, - 'AC_PATH_MAGIC' => 1, '_AC_AM_CONFIG_HEADER_HOOK' => 1, + 'AC_PATH_MAGIC' => 1, 'AC_LTDL_SYSSEARCHPATH' => 1, 'AM_MAKE_INCLUDE' => 1, '_LT_AC_TAGCONFIG' => 1, @@ -440,11 +440,11 @@ 'AM_PROG_NM' => 1, 'AC_LIBLTDL_CONVENIENCE' => 1, 'AC_DEPLIBS_CHECK_METHOD' => 1, - 'AC_LIBLTDL_INSTALLABLE' => 1, 'AM_SET_CURRENT_AUTOMAKE_VERSION' => 1, + 'AC_LIBLTDL_INSTALLABLE' => 1, 'AC_LTDL_ENABLE_INSTALL' => 1, - 'LT_PROG_GCJ' => 1, 'AC_LIBTOOL_SYS_DYNAMIC_LINKER' => 1, + 'LT_PROG_GCJ' => 1, 'AM_INIT_AUTOMAKE' => 1, 'AC_DISABLE_STATIC' => 1, 'LT_PATH_NM' => 1, @@ -452,25 +452,25 @@ '_LT_AC_LOCK' => 1, '_LT_AC_LANG_RC_CONFIG' => 1, 'LT_SYS_MODULE_PATH' => 1, - 'AC_LIBTOOL_POSTDEP_PREDEP' => 1, 'LT_WITH_LTDL' => 1, + 'AC_LIBTOOL_POSTDEP_PREDEP' => 1, 'AC_LTDL_SHLIBPATH' => 1, 'AM_AUX_DIR_EXPAND' => 1, - '_LT_AC_LANG_F77_CONFIG' => 1, 'AC_LIBTOOL_PROG_COMPILER_NO_RTTI' => 1, - '_LT_COMPILER_OPTION' => 1, + '_LT_AC_LANG_F77_CONFIG' => 1, '_AM_SET_OPTIONS' => 1, - 'AM_RUN_LOG' => 1, + '_LT_COMPILER_OPTION' => 1, '_AM_OUTPUT_DEPENDENCY_COMMANDS' => 1, - 'AC_LTDL_SYS_DLOPEN_DEPLIBS' => 1, - 'AC_LIBTOOL_SYS_OLD_ARCHIVE' => 1, + 'AM_RUN_LOG' => 1, 'AC_LIBTOOL_PICMODE' => 1, - 'AC_CHECK_LIBM' => 1, + 'AC_LIBTOOL_SYS_OLD_ARCHIVE' => 1, + 'AC_LTDL_SYS_DLOPEN_DEPLIBS' => 1, 'LT_PATH_LD' => 1, + 'AC_CHECK_LIBM' => 1, 'AC_LIBTOOL_SYS_LIB_STRIP' => 1, '_AM_MANGLE_OPTION' => 1, - 'AC_LIBTOOL_SYS_MAX_CMD_LEN' => 1, 'AC_LTDL_SYMBOL_USCORE' => 1, + 'AC_LIBTOOL_SYS_MAX_CMD_LEN' => 1, 'AM_SET_DEPDIR' => 1, '_LT_CC_BASENAME' => 1, '_LT_LIBOBJ' => 1 diff --git a/libgpython/include/gpython/garbage.h b/libgpython/include/gpython/garbage.h index b102b1daaec..04aa519aaf8 100644 --- a/libgpython/include/gpython/garbage.h +++ b/libgpython/include/gpython/garbage.h @@ -21,18 +21,6 @@ extern gpy_vector_t * gpy_primitives; extern gpy_vector_t * gpy_namespace_vec; extern gpy_vector_t * gpy_garbage_vec; -#define Gpy_Incr_Ref( x ) \ - gpy_assert( x ); \ - debug("incrementing ref count on <%p>:<%i> to <%i>!\n", \ - (void*) x, x->ref_count, (x->ref_count + 1)); \ - x->ref_count++; - -#define Gpy_Decr_Ref( x ) \ - gpy_assert( x ); \ - debug("decrementing ref count on <%p>:<%i> to <%i>!\n", \ - (void*) x, x->ref_count, (x->ref_count - 1)); \ - x->ref_count--; - extern void gpy_rr_cleanup_final( void ); extern void gpy_rr_pop_context( void ); @@ -41,11 +29,11 @@ extern void gpy_rr_push_context( void ); extern void gpy_garbage_inoke( void ); -extern void gpy_garbage_mark_obj__( gpy_object_state_t * const ); +extern void gpy_garbage_mark_obj__( gpy_object_t * const ); extern void gpy_garbage_invoke_sweep( gpy_vector_t * const ); -extern void gpy_garbage_free_obj( gpy_object_state_t * ); +extern void gpy_garbage_free_obj( gpy_object_t * ); #define gpy_garbage_mark_obj( x ) \ gpy_assert( x ); \ diff --git a/libgpython/include/gpython/objects.h b/libgpython/include/gpython/objects.h index b104d45bd5b..ab620b8cdeb 100644 --- a/libgpython/include/gpython/objects.h +++ b/libgpython/include/gpython/objects.h @@ -102,9 +102,9 @@ typedef struct gpy_number_prot_t typedef struct gpy_type_obj_def_t { char * identifier; size_t builtin_type_size; - gpy_object_t * (*init_hook)( gpy_object_t ** ); - void (*destroy_hook)( gpy_object_t * ); - void (*print_hook)( gpy_object_t * , FILE * , bool ); + gpy_object_t * (*init_hook)(gpy_type_obj_def_t *, gpy_object_t **); + void (*destroy_hook)(gpy_object_t *); + void (*print_hook)(gpy_object_t * , FILE *, bool); struct gpy_number_prot_t * binary_protocol; struct gpy_builtin_method_def_t * methods; } gpy_type_obj_def_t ; @@ -122,16 +122,22 @@ typedef struct gpy_callable_def_t { x->obj_t_ident = NULL; x->ref_count = 0; \ x->self = NULL; x->definition = NULL; -#define Gpy_Object_State_Init_Ctx( x,y ) \ +#define Gpy_Object_Init_Ctx( x,y ) \ + \ Gpy_Object_State_Init( x ); \ gpy_vec_push( ((gpy_context_t*)(y->vector[y->length-1]))->symbols, x ); #define NULL_OBJ_STATE (gpy_object_state_t *) NULL #define NULL_OBJECT (gpy_object_t *) NULL -extern void gpy_rr_init_runtime( void ); -extern gpy_object_t * gpy_rr_fold_integer( int ); +extern void gpy_rr_init_runtime (void); +extern gpy_object_t * gpy_rr_fold_integer (int); -extern void gpy_rr_init_primitives( void ); +extern bool gpy_args_check_fmt (gpy_object_t **, const char *); +extern int gpy_args_lit_parse_int (gpy_object_t *); +extern gpy_object_t * gpy_create_object_state (gpy_type_obj_def_t *, + const void *); + +extern void gpy_rr_init_primitives (void); #endif //__GCC_OBJECTS_H__ diff --git a/libgpython/runtime/obj-integer.c b/libgpython/runtime/obj-integer.c index 12ed3c1cf37..fe4dd964bd9 100644 --- a/libgpython/runtime/obj-integer.c +++ b/libgpython/runtime/obj-integer.c @@ -45,10 +45,21 @@ class foo: Where program wise __init__ is called and the instance of the object is created as gpy_object_state_t * */ -gpy_object_t * gpy_obj_integer_init (gpy_object_t ** args) +gpy_object_t * gpy_obj_integer_init (gpy_type_obj_def_t * type, + gpy_object_t ** args) { gpy_object_t * retval = NULL_OBJECT; + bool check = gpy_args_check_fmt (args, "i."); + gpy_assert(check); + + int val = gpy_args_lit_parse_int (args[0]); + struct gpy_obj_integer_t * self = (struct gpy_obj_integer_t *) + gpy_malloc (sizeof(struct gpy_obj_integer_t)); + self->Int = val; + + retval = gpy_create_object_state (type,self); + return retval; } diff --git a/libgpython/runtime/py-garbage.c b/libgpython/runtime/py-garbage.c index 474a6663a57..d87a6b86895 100644 --- a/libgpython/runtime/py-garbage.c +++ b/libgpython/runtime/py-garbage.c @@ -35,15 +35,15 @@ along with GCC; see the file COPYING3. If not see gpy_vector_t * gpy_garbage_vec; -void gpy_garbage_invoke( void ) +void gpy_garbage_invoke (void) { if( gpy_garbage_vec ) { debug("garbage collector running...\n"); gpy_object_state_t * p_obj = NULL_OBJ_STATE; - while( (p_obj= (gpy_object_state_t *) - gpy_vec_pop( gpy_garbage_vec )) ) + while ((p_obj = (gpy_object_t *) + gpy_vec_pop( gpy_garbage_vec ))) { gpy_garbage_free_obj( p_obj ); } @@ -52,7 +52,7 @@ void gpy_garbage_invoke( void ) } } -void gpy_garbage_mark_obj__( gpy_object_state_t * const sym ) +void gpy_garbage_mark_obj__( gpy_object_t * const sym ) { if( sym ) { @@ -88,14 +88,15 @@ void gpy_garbage_invoke_sweep( gpy_vector_t * const context ) debug("vector length <%i>!\n", len ); for( ; i<len; ++i ) { - gpy_object_state_t * o = (gpy_object_state_t *) s_arr[ i ]; + gpy_object_t * o = (gpy_object_t *) s_arr[i]; + gpy_assert (o->T == TYPE_OBJECT_STATE); if( o ) { debug( "object <%p> has ref count <%i>!\n", - (void *) o, o->ref_count ); + (void *) o, o->o.object_state->ref_count ); // If no references remain - if( o->ref_count <= 0 ) + if( o->o.object_state->ref_count <= 0 ) { gpy_garbage_mark_obj( o ); s_arr[ i ] = NULL; @@ -108,15 +109,24 @@ void gpy_garbage_invoke_sweep( gpy_vector_t * const context ) gpy_garbage_invoke( ); } -void gpy_garbage_free_obj( gpy_object_state_t * x ) +void gpy_garbage_free_obj (gpy_object_state_t * x) { + gpy_assert(x); debug("deleting garbage object <%p>!\n", (void*)x ); - if( x ) + + switch (x->T) { - gpy_free( x->obj_t_ident ); - (*x->definition).destroy_hook( x->self ); - gpy_free( x ); + case TYPE_OBJECT_LIT: + break; + + case TYPE_OBJECT_STATE: + break; + + case TYPE_NULL: + break; } + + gpy_free(x); } /* Cleanup the program for exit! */ diff --git a/libgpython/runtime/py-runtime.c b/libgpython/runtime/py-runtime.c index 301bcc387c1..11286faae12 100644 --- a/libgpython/runtime/py-runtime.c +++ b/libgpython/runtime/py-runtime.c @@ -90,9 +90,6 @@ gpy_object_t * gpy_rr_fold_integer( int x ) { gpy_object_t * retval = NULL_OBJECT; - gpy_object_state_t * o = NULL_OBJ_STATE; - Gpy_Object_State_Init_Ctx( o, gpy_namespace_vec ); - gpy_object_t ** args = (gpy_object_t **) gpy_calloc(2, sizeof(gpy_object_t*)); @@ -162,18 +159,22 @@ void gpy_rr_eval_print( int fd, int count, ... ) } inline -void gpy_rr_incr_ref_count( gpy_object_state_t * x ) +void gpy_rr_incr_ref_count( gpy_object_t * x1 ) { - gpy_assert( x ); + gpy_assert( x->T == TYPE_OBJECT_STATE ); + gpy_object_state_t * x = x1->o.object_state; + debug("incrementing ref count on <%p>:<%i> to <%i>!\n", (void*) x, x->ref_count, (x->ref_count + 1) ); x->ref_count++; } inline -void gpy_rr_decr_ref_count( gpy_object_state_t * x ) +void gpy_rr_decr_ref_count( gpy_object_t * x1 ) { - gpy_assert( x ); + gpy_assert( x->T == TYPE_OBJECT_STATE ); + gpy_object_state_t * x = x1->o.object_state; + debug("decrementing ref count on <%p>:<%i> to <%i>!\n", (void*) x, x->ref_count, (x->ref_count - 1) ); x->ref_count--; @@ -198,8 +199,8 @@ void gpy_rr_pop_context( void ) unsigned int idx = 0; for( ; idx<(head->symbols->length); ++idx ) { - gpy_object_state_t * i = (gpy_object_state_t *) vec[ idx ]; - Gpy_Decr_Ref( i ); + gpy_object_t * i = (gpy_object_t *) vec[ idx ]; + gpy_rr_decr_ref_count(i); } gpy_garbage_invoke_sweep( gpy_namespace_vec ); @@ -210,6 +211,7 @@ void gpy_rr_pop_context( void ) straggler is something which will have a (ref_count > 0) after this set of decreasing references... */ + //.... gpy_context_t * popd = gpy_vec_pop( gpy_namespace_vec ); gpy_vec_free( popd->symbols ); @@ -235,21 +237,21 @@ void gpy_rr_finalize_block_decls( int n, ... ) va_end(vl); } -gpy_object_t * gpy_rr_fold_call(struct gpy_callable_def_t * callables, - const char * ident, int n_args, ... ) +gpy_object_t * gpy_rr_fold_call (struct gpy_callable_def_t * callables, + const char * ident, int n_args, ... ) { return NULL; } -gpy_object_t * -gpy_rr_eval_dot_operator( gpy_object_t * x, gpy_object_t * y ) +gpy_object_t * gpy_rr_eval_dot_operator (gpy_object_t * x, + gpy_object_t * y) { return NULL; } -gpy_object_t * -gpy_rr_eval_expression (gpy_object_t * x1, gpy_object_t * y1, - gpy_opcode_t op) +gpy_object_t * gpy_rr_eval_expression (gpy_object_t * x1, + gpy_object_t * y1, + gpy_opcode_t op) { char * op_str = NULL; gpy_object_t * retval = NULL; diff --git a/libgpython/runtime/py-utils.c b/libgpython/runtime/py-utils.c index e69de29bb2d..efc4a7b7259 100644 --- a/libgpython/runtime/py-utils.c +++ b/libgpython/runtime/py-utils.c @@ -0,0 +1,49 @@ +/* This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdbool.h> + +#include <gmp.h> +#include <mpfr.h> + +#include <gpython/gpython.h> +#include <gpython/objects.h> +#include <gpython/vectors.h> +#include <gpython/garbage.h> + +bool gpy_args_check_fmt (gpy_object_t ** args, const char * fmt) +{ + return false; +} + + +int gpy_args_lit_parse_int (gpy_object_t * arg) +{ + return -1; +} + +gpy_object_t * gpy_create_object_state (gpy_type_obj_def_t * type, + const void * self) +{ + return NULL; +} |