From 0048e6f07edab290677e046aeee9251c2bc6e660 Mon Sep 17 00:00:00 2001 From: redbrain Date: Tue, 14 Sep 2010 23:44:27 +0100 Subject: [PATCH] fixed many errors and cleaned up includes --- gcc/python/Make-lang.in | 12 +++++----- gcc/python/config-lang.in | 7 +++++- gcc/python/py-decl.c | 13 +++++------ gcc/python/py-lang.c | 41 ++++++++++++++++------------------ gcc/python/py-lexer.l | 17 +++++--------- gcc/python/py-parser.y | 11 ++++----- gcc/python/py-runtime.c | 12 +++++----- gcc/python/{runtime.h => py-runtime.h} | 0 gcc/python/py-stmt.c | 18 +++++++-------- 9 files changed, 64 insertions(+), 67 deletions(-) rename gcc/python/{runtime.h => py-runtime.h} (100%) diff --git a/gcc/python/Make-lang.in b/gcc/python/Make-lang.in index 1d83bdc530b..804e3b30c23 100644 --- a/gcc/python/Make-lang.in +++ b/gcc/python/Make-lang.in @@ -33,13 +33,13 @@ FLEX_C_FLAGS := -g -O2 -fomit-frame-pointer -gtoggle -DIN_GCC -W -Wall -Wwrite-s GPY_CFLAGS := -std=gnu99 -I${srcdir}/python py-lexer.o: $(srcdir)/python/py-lexer.l parser.o - $(FLEX) --outfile=lex.py.c $(srcdir)/python/lexer.l + $(FLEX) --outfile=lex.py.c $(srcdir)/python/py-lexer.l $(CC) $(GPY_CFLAGS) $(FLEX_C_FLAGS) $(INCLUDES) \ $(LDFLAGS) -c -o $@ lex.py.c py-parser.o: $(srcdir)/python/py-parser.y $(BISON) -v --debug --verbose --defines=y.py.h --output=y.py.c \ - $(srcdir)/python/parser.y + $(srcdir)/python/py-parser.y $(CC) $(GPY_CFLAGS) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ $(LDFLAGS) -c -o $@ y.py.c @@ -49,19 +49,19 @@ py-lang.o: $(srcdir)/python/py-lang.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H $(CC) $(GPY_CFLAGS) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ $(LDFLAGS) -c -o $@ $(srcdir)/python/py-lang.c -py-stmt.o: $(srcdir)/python/pypy.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ +py-stmt.o: $(srcdir)/python/py-stmt.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ $(FLAGS_H) toplev.h $(GGC_H) $(TREE_H) $(DIAGNOSTIC_H) input.h options.h opts.h \ gt-python-py-lang.h gtype-python.h $(CC) $(GPY_CFLAGS) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ $(LDFLAGS) -c -o $@ $(srcdir)/python/py-stmt.c -py-tree.o: $(srcdir)/python/expression.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ +py-decl.o: $(srcdir)/python/py-decl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ $(FLAGS_H) toplev.h $(GGC_H) $(TREE_H) $(DIAGNOSTIC_H) input.h options.h opts.h \ gt-python-py-lang.h gtype-python.h $(CC) $(GPY_CFLAGS) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ - $(LDFLAGS) -c -o $@ $(srcdir)/python/py-tree.c + $(LDFLAGS) -c -o $@ $(srcdir)/python/py-decl.c -py-vec.o: $(srcdir)/python/hashtab.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ +py-vec.o: $(srcdir)/python/py-vec.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ $(FLAGS_H) toplev.h $(GGC_H) $(TREE_H) $(DIAGNOSTIC_H) input.h options.h opts.h \ gt-python-py-lang.h gtype-python.h $(CC) $(GPY_CFLAGS) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ diff --git a/gcc/python/config-lang.in b/gcc/python/config-lang.in index 12b4c3e8f16..5e009adb0d7 100644 --- a/gcc/python/config-lang.in +++ b/gcc/python/config-lang.in @@ -15,6 +15,11 @@ #. language="python" + compilers="gpy1\$(exeext)" + +build_by_default="no" + target_libs=target-libgpython -gtfiles="\$(srcdir)/python/py-lang.c \$(srcdir)/python/expression.c \$(srcdir)/python/symbols.h" + +gtfiles="\$(srcdir)/python/py-lang.c \$(srcdir)/python/py-decl.c \$(srcdir)/python/py-dot.h" diff --git a/gcc/python/py-decl.c b/gcc/python/py-decl.c index 458f0d1a039..884c14a9850 100644 --- a/gcc/python/py-decl.c +++ b/gcc/python/py-decl.c @@ -20,7 +20,6 @@ along with GCC; see the file COPYING3. If not see #include "coretypes.h" #include "opts.h" #include "tree.h" -#include "tree-iterator.h" #include "gimple.h" #include "toplev.h" #include "debug.h" @@ -31,7 +30,6 @@ along with GCC; see the file COPYING3. If not see #include "langhooks.h" #include "langhooks-def.h" #include "target.h" -#include "cgraph.h" #include #include @@ -39,11 +37,12 @@ along with GCC; see the file COPYING3. If not see #include "vec.h" #include "hashtab.h" -#include "gpy.h" -#include "opcodes.def" -#include "symbols.h" -#include "pypy-tree.h" -#include "runtime.h" +#include "gpython.h" +#include "py-dot-codes.def" +#include "py-dot.h" +#include "py-vec.h" +#include "py-tree.h" +#include "py-runtime.h" VEC(tree,gc) * gpy_fold_primitive( const gpy_symbol_obj * const sym ) { diff --git a/gcc/python/py-lang.c b/gcc/python/py-lang.c index 946349e3bc4..60aa8f6acd5 100644 --- a/gcc/python/py-lang.c +++ b/gcc/python/py-lang.c @@ -37,7 +37,12 @@ along with GCC; see the file COPYING3. If not see #include "vec.h" #include "hashtab.h" -#include "gpy.h" +#include "gpython.h" +#include "py-dot-codes.def" +#include "py-dot.h" +#include "py-vec.h" +#include "py-tree.h" +#include "py-runtime.h" /* Language-dependent contents of a type. */ struct GTY(()) lang_type { @@ -76,23 +81,8 @@ static bool gpy_langhook_init( void ) { gpy_init_tbls( ); - build_common_tree_nodes( false ); - - /* The sizetype may be "unsigned long" or "unsigned long long". */ - if( TYPE_MODE (long_unsigned_type_node) == ptr_mode ) - { - size_type_node = long_unsigned_type_node; - } - else if( TYPE_MODE (long_long_unsigned_type_node) == ptr_mode ) - { - size_type_node = long_long_unsigned_type_node; - } - else - { - size_type_node = long_unsigned_type_node; - } - set_sizetype( size_type_node ); + build_common_tree_nodes( false ); build_common_tree_nodes_2( 0 ); void_list_node = build_tree_list( NULL_TREE, void_type_node ); @@ -213,10 +203,6 @@ static void gpy_langhook_write_globals( void ) { debug("write globals!\n"); - - if( seen_error( ) ) - return; - gpy_write_globals( ); } @@ -257,6 +243,18 @@ void __gpy_debug__( const char * file, unsigned int lineno, va_end( args ); } +/* The attribute table might be used for the GCC attribute syntax, e.g. + * __attribute__((unused)), but this feature isn't yet used in gcalc + */ +const struct attribute_spec python_attribute_table[] = { + { NULL, 0, 0, false, false, false, NULL } +}; + + +/* The language hooks data structure. This is the main interface between the GCC front-end + * and the GCC middle-end/back-end. A list of language hooks could be found in + * /langhooks.h + */ #undef LANG_HOOKS_NAME #undef LANG_HOOKS_INIT #undef LANG_HOOKS_INIT_OPTIONS @@ -291,4 +289,3 @@ struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; #include "gt-python-py-lang.h" #include "gtype-python.h" -#include "symbols.h" diff --git a/gcc/python/py-lexer.l b/gcc/python/py-lexer.l index ee497389ad5..9ede61282d9 100644 --- a/gcc/python/py-lexer.l +++ b/gcc/python/py-lexer.l @@ -15,12 +15,6 @@ You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see . */ -/** - * The lexer the lexical tokens which are important get parsed here! - * - * IMPORTANT: We now requite Flex to generate the lexer now! - **/ - #include "config.h" #include "system.h" #include "ansidecl.h" @@ -44,11 +38,12 @@ along with GCC; see the file COPYING3. If not see #include "vec.h" #include "hashtab.h" -#include "gpy.h" -#include "opcodes.def" -#include "symbols.h" -#include "pypy-tree.h" -#include "runtime.h" +#include "gpython.h" +#include "py-dot-codes.def" +#include "py-dot.h" +#include "py-vec.h" +#include "py-tree.h" +#include "py-runtime.h" #include "y.py.h" diff --git a/gcc/python/py-parser.y b/gcc/python/py-parser.y index 55e731c0d11..58779a84ad9 100644 --- a/gcc/python/py-parser.y +++ b/gcc/python/py-parser.y @@ -42,11 +42,12 @@ along with GCC; see the file COPYING3. If not see #include "vec.h" #include "hashtab.h" -#include "gpy.h" -#include "opcodes.def" -#include "symbols.h" -#include "pypy-tree.h" -#include "runtime.h" +#include "gpython.h" +#include "py-dot-codes.def" +#include "py-dot.h" +#include "py-vec.h" +#include "py-tree.h" +#include "py-runtime.h" static VEC( gpy_sym,gc ) * gpy_symbol_stack; diff --git a/gcc/python/py-runtime.c b/gcc/python/py-runtime.c index e13de65b7e9..bb4807f06a1 100644 --- a/gcc/python/py-runtime.c +++ b/gcc/python/py-runtime.c @@ -20,7 +20,6 @@ along with GCC; see the file COPYING3. If not see #include "coretypes.h" #include "opts.h" #include "tree.h" -#include "tree-iterator.h" #include "gimple.h" #include "toplev.h" #include "debug.h" @@ -31,7 +30,6 @@ along with GCC; see the file COPYING3. If not see #include "langhooks.h" #include "langhooks-def.h" #include "target.h" -#include "cgraph.h" #include #include @@ -39,10 +37,12 @@ along with GCC; see the file COPYING3. If not see #include "vec.h" #include "hashtab.h" -#include "gpy.h" -#include "symbols.h" -#include "runtime.h" -#include "opcodes.def" +#include "gpython.h" +#include "py-dot-codes.def" +#include "py-dot.h" +#include "py-vec.h" +#include "py-tree.h" +#include "py-runtime.h" tree gpy_builtin_get_init_call( void ) { diff --git a/gcc/python/runtime.h b/gcc/python/py-runtime.h similarity index 100% rename from gcc/python/runtime.h rename to gcc/python/py-runtime.h diff --git a/gcc/python/py-stmt.c b/gcc/python/py-stmt.c index 74f0d99582f..f46c6bc136d 100644 --- a/gcc/python/py-stmt.c +++ b/gcc/python/py-stmt.c @@ -20,7 +20,6 @@ along with GCC; see the file COPYING3. If not see #include "coretypes.h" #include "opts.h" #include "tree.h" -#include "tree-iterator.h" #include "gimple.h" #include "toplev.h" #include "debug.h" @@ -31,6 +30,8 @@ along with GCC; see the file COPYING3. If not see #include "langhooks.h" #include "langhooks-def.h" #include "target.h" + +#include "tree-iterator.h" #include "cgraph.h" #include @@ -39,11 +40,12 @@ along with GCC; see the file COPYING3. If not see #include "vec.h" #include "hashtab.h" -#include "gpy.h" -#include "opcodes.def" -#include "symbols.h" -#include "pypy-tree.h" -#include "runtime.h" +#include "gpython.h" +#include "py-dot-codes.def" +#include "py-dot.h" +#include "py-vec.h" +#include "py-tree.h" +#include "py-runtime.h" static gpy_symbol_obj * gpy_process_AST_Align( gpy_symbol_obj ** ); static void gpy_finish_type( tree ); @@ -673,11 +675,9 @@ void gpy_write_globals( void ) } /* Need to generate table of gpy_callable_def_t[] and gpy_type_obj_def_t[] */ - // @ see fortran/trans-decl.c 4358 - VEC(constructor_elt,gc) *array_data = NULL; - for( ) + for( ;; ) { VEC(constructor_elt,gc) *struct_data; const char * ident = NULL; -- 2.11.4.GIT