diff options
author | redbrain <redbrain@crules.org> | 2010-07-10 04:23:44 +0100 |
---|---|---|
committer | redbrain <redbrain@crules.org> | 2010-07-10 04:23:44 +0100 |
commit | e385b1664c6ad27082fa49ce9d35b02e32d21f55 (patch) | |
tree | d918d843be6c1bec3daa09fbc5fdc23ed2e75d6a /libgpython | |
parent | ad2fae245d31e36ba5e0b866565a97f98976aa68 (diff) | |
download | gcc-e385b1664c6ad27082fa49ce9d35b02e32d21f55.tar.gz |
seperate out code
Diffstat (limited to 'libgpython')
-rw-r--r-- | libgpython/Makefile.am | 4 | ||||
-rw-r--r-- | libgpython/Makefile.in | 13 | ||||
-rw-r--r-- | libgpython/include/gpython/garbage.h | 2 | ||||
-rw-r--r-- | libgpython/include/gpython/gpython.h | 78 | ||||
-rw-r--r-- | libgpython/include/gpython/objects.h | 99 | ||||
-rw-r--r-- | libgpython/runtime/backend.c | 1 | ||||
-rw-r--r-- | libgpython/runtime/obj_integer.c | 3 | ||||
-rw-r--r-- | libgpython/runtime/py_garbage.c | 1 | ||||
-rw-r--r-- | libgpython/runtime/vectors.c | 1 |
9 files changed, 118 insertions, 84 deletions
diff --git a/libgpython/Makefile.am b/libgpython/Makefile.am index 1216e7bcd12..225ae445cd4 100644 --- a/libgpython/Makefile.am +++ b/libgpython/Makefile.am @@ -8,11 +8,13 @@ AM_YFLAGS = -d --verbose library_includedir=$(includedir)/gpython library_include_HEADERS = include/gpython/gpython.h \ include/gpython/vectors.h \ -include/gpython/garbage.h +include/gpython/garbage.h \ +include/gpython/objects.h libgpython_la_CFLAGS = -DPYHON -DSHARED libgpython_la_LDFLAGS = -release 0.0.1 libgpython_la_SOURCES = runtime/py_runtime.c \ runtime/py_garbage.c \ +runtime/vectors.c \ runtime/obj_integer.c \ runtime/backend.c diff --git a/libgpython/Makefile.in b/libgpython/Makefile.in index 35883058ba2..ff4a3e7fcf9 100644 --- a/libgpython/Makefile.in +++ b/libgpython/Makefile.in @@ -81,8 +81,8 @@ am__installdirs = "$(DESTDIR)$(libdir)" \ LTLIBRARIES = $(lib_LTLIBRARIES) libgpython_la_LIBADD = am_libgpython_la_OBJECTS = libgpython_la-py_runtime.lo \ - libgpython_la-py_garbage.lo libgpython_la-obj_integer.lo \ - libgpython_la-backend.lo + libgpython_la-py_garbage.lo libgpython_la-vectors.lo \ + libgpython_la-obj_integer.lo libgpython_la-backend.lo libgpython_la_OBJECTS = $(am_libgpython_la_OBJECTS) libgpython_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(libgpython_la_CFLAGS) \ @@ -252,6 +252,7 @@ libgpython_la_CFLAGS = -DPYHON -DSHARED libgpython_la_LDFLAGS = -release 0.0.1 libgpython_la_SOURCES = runtime/py_runtime.c \ runtime/py_garbage.c \ +runtime/vectors.c \ runtime/obj_integer.c \ runtime/backend.c @@ -355,6 +356,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgpython_la-obj_integer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgpython_la-py_garbage.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgpython_la-py_runtime.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgpython_la-vectors.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -391,6 +393,13 @@ libgpython_la-py_garbage.lo: runtime/py_garbage.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgpython_la_CFLAGS) $(CFLAGS) -c -o libgpython_la-py_garbage.lo `test -f 'runtime/py_garbage.c' || echo '$(srcdir)/'`runtime/py_garbage.c +libgpython_la-vectors.lo: runtime/vectors.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgpython_la_CFLAGS) $(CFLAGS) -MT libgpython_la-vectors.lo -MD -MP -MF $(DEPDIR)/libgpython_la-vectors.Tpo -c -o libgpython_la-vectors.lo `test -f 'runtime/vectors.c' || echo '$(srcdir)/'`runtime/vectors.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libgpython_la-vectors.Tpo $(DEPDIR)/libgpython_la-vectors.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='runtime/vectors.c' object='libgpython_la-vectors.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgpython_la_CFLAGS) $(CFLAGS) -c -o libgpython_la-vectors.lo `test -f 'runtime/vectors.c' || echo '$(srcdir)/'`runtime/vectors.c + libgpython_la-obj_integer.lo: runtime/obj_integer.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgpython_la_CFLAGS) $(CFLAGS) -MT libgpython_la-obj_integer.lo -MD -MP -MF $(DEPDIR)/libgpython_la-obj_integer.Tpo -c -o libgpython_la-obj_integer.lo `test -f 'runtime/obj_integer.c' || echo '$(srcdir)/'`runtime/obj_integer.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libgpython_la-obj_integer.Tpo $(DEPDIR)/libgpython_la-obj_integer.Plo diff --git a/libgpython/include/gpython/garbage.h b/libgpython/include/gpython/garbage.h index 5c19076e0ad..d3961768e60 100644 --- a/libgpython/include/gpython/garbage.h +++ b/libgpython/include/gpython/garbage.h @@ -21,8 +21,6 @@ extern gpy_vector_t * gpy_primitives; extern gpy_vector_t * gpy_namespace_vec; extern gpy_vector_t * gpy_garbage_vec; -extern void gpy_rr_init_primitives( gpy_hash_tab_t * const ); - extern void gpy_garbage_inoke( void ); extern void gpy_garbage_mark_obj__( gpy_object_state_t const ); diff --git a/libgpython/include/gpython/gpython.h b/libgpython/include/gpython/gpython.h index 983bef0f264..5f1fa8aabb7 100644 --- a/libgpython/include/gpython/gpython.h +++ b/libgpython/include/gpython/gpython.h @@ -48,78 +48,6 @@ along with GCC; see the file COPYING3. If not see # define __gpy_nonnull #endif -typedef struct gpy_rr_object_state_t { - char * obj_t_ident; - signed long ref_count; - void * self; -} gpy_rr_object_state_t ; - -#define Gpy_Object_State_Init( x ) \ - x = gpy_malloc( sizeof(gpy_rr_object_state_t) ); \ - debug("object created at <%p>!\n", (void*)x ); \ - x->obj_t_ident = NULL; x->ref_count = 0; \ - x->self = NULL; - -#define Gpy_Object_State_Init_Ctx( x,y ) \ - x = gpy_malloc( sizeof(gpy_rr_object_state_t) ); \ - x->obj_t_ident = NULL; x->ref_count = 0; \ - x->self = NULL; \ - gpy_vec_push( y->vector[y->length-1]->symbols, x ); \ - debug("object created at <%p> within conext <%p>!", \ - (void *)x, (void*)y->vector[y->length-1]->symbols ); - -typedef gpy_rr_object_state_t * gpy_object_state_t; -#define NULL_OBJ_STATE NULL - -typedef gpy_object_state_t (*binary_op)( gpy_object_state_t, - gpy_object_state_t ); - -enum GPY_LIT_T { TYPE_INTEGER, TYPE_STRING, TYPE_NONE }; - -typedef struct gpy_rr_literal_t { - enum GPY_LIT_T type; - union { - int integer; - char * string; - /* ... */ - } literal ; -} gpy_literal_t ; - -#define Gpy_Lit_Init( x ) \ - x = gpy_malloc( sizeof(gpy_literal_t) ); \ - x->type = TYPE_NONE; \ - x->literal.integer = 0; - -typedef struct gpy_number_prot_t -{ - bool init; - - binary_op n_add; - binary_op n_sub; - binary_op n_div; - binary_op n_mul; - binary_op n_pow; - - binary_op n_let; - binary_op n_lee; - binary_op n_get; - binary_op n_gee; - binary_op n_eee; - binary_op n_nee; - binary_op n_orr; - binary_op n_and; - -} gpy_num_prot_t ; - -typedef struct gpy_type_obj_def_t { - char * identifier; - size_t builtin_type_size; - void * (*init_hook)( gpy_literal_t * ); - void (*destroy_hook)( void * ); - void (*print_hook)( void * , FILE * , bool ); - const struct gpy_number_prot_t * binary_protocol; -} gpy_type_obj_def_t ; - #ifdef DEBUG # define gpy_assert( expr ) \ ((expr) ? (void) 0 : gpy_assertion_failed( #expr, __LINE__, \ @@ -178,10 +106,4 @@ __gpy_fatal__( const char *, unsigned , extern void gpy_assertion_failed( const char * , unsigned , const char * , const char * ); -extern void gpy_rr_init_runtime( void ); -extern gpy_object_state_t gpy_rr_fold_integer( int ); - -extern void gpy_obj_integer_mod_init( void ); -extern void gpy_rr_init_primitives( void ); - #endif //__GCC_GPYTHON_H__ diff --git a/libgpython/include/gpython/objects.h b/libgpython/include/gpython/objects.h new file mode 100644 index 00000000000..d25930a84f6 --- /dev/null +++ b/libgpython/include/gpython/objects.h @@ -0,0 +1,99 @@ +/* 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/>. */ + +#ifndef __GCC_OBJECTS_H__ +#define __GCC_OBJECTS_H__ + +typedef struct gpy_rr_object_state_t { + char * obj_t_ident; + signed long ref_count; + void * self; +} gpy_rr_object_state_t ; + +#define Gpy_Object_State_Init( x ) \ + x = gpy_malloc( sizeof(gpy_rr_object_state_t) ); \ + debug("object created at <%p>!\n", (void*)x ); \ + x->obj_t_ident = NULL; x->ref_count = 0; \ + x->self = NULL; + +#define Gpy_Object_State_Init_Ctx( x,y ) \ + x = gpy_malloc( sizeof(gpy_rr_object_state_t) ); \ + x->obj_t_ident = NULL; x->ref_count = 0; \ + x->self = NULL; \ + gpy_vec_push( y->vector[y->length-1]->symbols, x ); \ + debug("object created at <%p> within conext <%p>!", \ + (void *)x, (void*)y->vector[y->length-1]->symbols ); + +typedef gpy_rr_object_state_t * gpy_object_state_t; +#define NULL_OBJ_STATE NULL + +typedef gpy_object_state_t (*binary_op)( gpy_object_state_t, + gpy_object_state_t ); + +enum GPY_LIT_T { TYPE_INTEGER, TYPE_STRING, TYPE_NONE }; + +typedef struct gpy_rr_literal_t { + enum GPY_LIT_T type; + union { + int integer; + char * string; + /* ... */ + } literal ; +} gpy_literal_t ; + +#define Gpy_Lit_Init( x ) \ + x = gpy_malloc( sizeof(gpy_literal_t) ); \ + x->type = TYPE_NONE; \ + x->literal.integer = 0; + +typedef struct gpy_number_prot_t +{ + bool init; + + binary_op n_add; + binary_op n_sub; + binary_op n_div; + binary_op n_mul; + binary_op n_pow; + + binary_op n_let; + binary_op n_lee; + binary_op n_get; + binary_op n_gee; + binary_op n_eee; + binary_op n_nee; + binary_op n_orr; + binary_op n_and; + +} gpy_num_prot_t ; + +typedef struct gpy_type_obj_def_t { + char * identifier; + size_t builtin_type_size; + void * (*init_hook)( gpy_literal_t * ); + void (*destroy_hook)( void * ); + void (*print_hook)( void * , FILE * , bool ); + const struct gpy_number_prot_t * binary_protocol; +} gpy_type_obj_def_t ; + +extern void gpy_rr_init_runtime( void ); +extern gpy_object_state_t gpy_rr_fold_integer( int ); + +extern void gpy_rr_init_primitives( void ); + +extern void gpy_obj_integer_mod_init( gpy_vector_t * const ); + +#endif //__GCC_OBJECTS_H__ diff --git a/libgpython/runtime/backend.c b/libgpython/runtime/backend.c index 0a15f2edd99..ee7fe0ba770 100644 --- a/libgpython/runtime/backend.c +++ b/libgpython/runtime/backend.c @@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see #include <stdbool.h> #include <gpython/gpython.h> +#include <gpython/objects.h> #include <gpython/vectors.h> #include <gpython/garbage.h> diff --git a/libgpython/runtime/obj_integer.c b/libgpython/runtime/obj_integer.c index 33682d59eff..5206c90fa64 100644 --- a/libgpython/runtime/obj_integer.c +++ b/libgpython/runtime/obj_integer.c @@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see #include <mpfr.h> #include <gpython/gpython.h> +#include <gpython/objects.h> #include <gpython/vectors.h> #include <gpython/garbage.h> @@ -125,7 +126,7 @@ const struct gpy_type_obj_def_t integer_obj = { &integer_binary_ops, }; -void gpy_obj_integer_mod_init( gpy_vector_t * vec ) +void gpy_obj_integer_mod_init( gpy_vector_t * const vec ) { gpy_vec_push( vec, &integer_obj ); } diff --git a/libgpython/runtime/py_garbage.c b/libgpython/runtime/py_garbage.c index 6dc94f6236e..f0e8c2d311d 100644 --- a/libgpython/runtime/py_garbage.c +++ b/libgpython/runtime/py_garbage.c @@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see #include <mpfr.h> #include <gpython/gpython.h> +#include <gpython/objects.h> #include <gpython/vectors.h> #include <gpython/garbage.h> diff --git a/libgpython/runtime/vectors.c b/libgpython/runtime/vectors.c index c50e50462ff..5450f0670ff 100644 --- a/libgpython/runtime/vectors.c +++ b/libgpython/runtime/vectors.c @@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see #include <stdbool.h> #include <gpython/gpython.h> +#include <gpython/objects.h> #include <gpython/vectors.h> #include <gpython/garbage.h> |