GCC Middle and Back End API Reference
godump.c File Reference

Data Structures

struct  macro_hash_value
struct  godump_container


static hashval_t macro_hash_hashval ()
static int macro_hash_eq ()
static void macro_hash_del ()
static int string_hash_eq ()
static void go_define ()
static void go_undef ()
static void go_decl ()
static void go_function_decl ()
static void go_global_decl ()
static void go_type_decl ()
static void go_append_string ()
static bool go_format_type (struct godump_container *container, tree type, bool use_type_name, bool is_func_ok)
static void go_output_type ()
static void go_output_fndecl ()
static void go_output_typedef ()
static void go_output_var ()
static int go_print_macro ()
static void keyword_hash_init ()
static bool find_dummy_types ()
static void go_finish ()
struct gcc_debug_hooksdump_go_spec_init ()


static struct gcc_debug_hooks go_debug_hooks
static struct gcc_debug_hooksreal_debug_hooks
static FILE * go_dump_file
static vec< tree, va_gc > * queue
static htab_t macro_hash
static const char *const keywords []

Function Documentation

struct gcc_debug_hooks* dump_go_spec_init ( )
   Set up our hooks.  
static bool find_dummy_types ( )
   Traversing the pot_dummy_types and seeing which types are present
   in the global types hash table and creating dummy definitions if
   not found.  This function is invoked by pointer_set_traverse.  
static void go_append_string ( )
   Append an IDENTIFIER_NODE to OB.  

References godump_container::invalid_hash, and gdbhooks::TYPE_DECL.

static void go_decl ( )
   A function or variable decl.  

Referenced by go_undef().

static void go_define ( )
   A macro definition.  
     Skip macro functions.  
     For simplicity, we force all names to be hidden by adding an
     initial underscore, and let the user undo this as needed.  
               The start of an identifier.  Technically we should also
               worry about UTF-8 identifiers, but they are not a
               problem for practical uses of -fdump-go-spec so we
               don't worry about them.  
                   This is a reference to a name which was not defined
                   as a macro.  
             Fall through.  
                   Go doesn't use any of these trailing type
               We'll pick up the exponent, if any, as an
             Always OK, not part of an operand, presumed to start an
             OK if we don't need an operand, and presumed to indicate
             an operand.  
             Always OK, but not part of an operand.  
             Must be a binary operator.  
             Must be a binary operator.  
                 Must be a binary operator.  
                 Must be a unary operator.  
             Must be a binary operand, may be << or >> or <= or >=.  
             Must be a unary operand, must be translated for Go.  
                       Go octal characters are always 3
                       Go hex characters are always 2 digits.  
static void go_finish ( )
   Output symbols.  
     To emit dummy definitions.  

References error().

static bool go_format_type ( struct godump_container container,
tree  type,
bool  use_type_name,
bool  is_func_ok 
   Write the Go version of TYPE to CONTAINER->TYPE_OBSTACK.
   USE_TYPE_NAME is true if we can simply use a type name here without
   needing to define it.  IS_FUNC_OK is true if we can output a func
   type here; the "func" keyword will already have been added.  Return
   true if the type can be represented in Go, false otherwise.  
             The pointer here can be used without the struct or union
             definition.  So this struct or union is a potential dummy
                   Start variable name with an underscore if a keyword.  
                   Do not expand type if a record or union type or a
                   function pointer.  
               Only output the first successful field of a union, and
               hope for the best.  
           Go has no way to write a type which is a function but not a
           pointer to a function.  

Referenced by go_output_typedef().

static void go_function_decl ( )
   A function decl.  
static void go_global_decl ( )
   A global variable decl.  
static void go_output_fndecl ( )
   Output a function declaration.  
static void go_output_type ( )
   Output the type which was built on the type obstack, and then free

Referenced by go_output_typedef().

static void go_output_typedef ( )
   Output a typedef or something like a struct definition.  
     If we have an enum type, output the enum constants
             Sometimes a name will be defined as both an enum constant
             and a macro.  Avoid duplicate definition errors by
             treating enum constants as macros.  
         If type defined already, skip.  
          If type defined already, skip.  

References godump_container::decls_seen, go_dump_file, go_format_type(), go_output_type(), HOST_WIDE_INT_PRINT_DEC, int_size_in_bytes(), godump_container::invalid_hash, pointer_set_insert(), type(), and godump_container::type_hash.

static void go_output_var ( )
   Output a variable.  
         There is already a type with this name, probably from a
         struct tag.  Prefer the type to the variable.  
     Sometimes an extern variable is declared with an unknown struct
static int go_print_macro ( )
   Output the final value of a preprocessor macro or enum constant.
   This is called via htab_traverse_noresize.  
static void go_type_decl ( )
   A type declaration.  
static void go_undef ( )
   A macro undef.  

References gcc_debug_hooks::global_decl, and go_decl().

static void keyword_hash_init ( )
static void macro_hash_del ( )
   Free values deleted from the macro hash table.  
static int macro_hash_eq ( )
   Compare values in the macro hash table for equality.  
static hashval_t macro_hash_hashval ( )
   Calculate the hash value for an entry in the macro hash table.  
static int string_hash_eq ( )
   For the string hash tables.  

Variable Documentation

struct gcc_debug_hooks go_debug_hooks

Output Go language descriptions of types. Copyright (C) 2008-2013 Free Software Foundation, Inc. Written by Ian Lance Taylor iant@.nosp@m.goog.nosp@m.le.co.nosp@m.m.

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/.

   This file is used during the build process to emit Go language
   descriptions of declarations from C header files.  It uses the
   debug info hooks to emit the descriptions.  The Go language
   descriptions then become part of the Go runtime support

   All global names are output with a leading underscore, so that they
   are all hidden in Go.  
   We dump this information from the debug hooks.  This gives us a
   stable and maintainable API to hook into.  In order to work
   correctly when -g is used, we build our own hooks structure which
   wraps the hooks we need to change.  
   Our debug hooks.  This is initialized by dump_go_spec_init.  
FILE* go_dump_file
   The file where we should write information.  

Referenced by go_output_typedef().

const char* const keywords[]
Initial value:
"__asm__", "break", "case", "chan", "const", "continue", "default",
"defer", "else", "fallthrough", "for", "func", "go", "goto", "if",
"import", "interface", "map", "package", "range", "return", "select",
"struct", "switch", "type", "var"
   Build a hash table with the Go keywords.  
htab_t macro_hash
   A hash table of macros we have seen.  
vec<tree, va_gc>* queue
   A queue of decls to output.  
struct gcc_debug_hooks* real_debug_hooks
   The real debug hooks.