pretty-print.c (pp_base_indent): Rename from pp_indent.
* pretty-print.c (pp_base_indent): Rename from pp_indent. * c-pretty-print.h (pp_c_pretty_print_flag)s: New datatype. (struct c_pretty_print_info): Add more fields. (pp_c_left_paren): Move to c-pretty-print.c. (pp_c_right_paren): Likewise. (pp_c_left_brace): Likewise. (pp_c_right_brace): Likewise. (pp_c_left_bracket): Likewise. (pp_c_right_bracket): Likewise. (pp_c_declarator): Declare. (pp_c_direct_declarator): Likewise. (pp_c_specifier_qualifier_list): Likewise. (pp_c_type_id): Likewise. * c-pretty-print.c (pp_c_cv_qualifier): Change prootype. Rework.. (pp_c_type_qualifier_list): New. (pp_c_pointer): Likewise. (pp_c_parameter_type_list): Likewise. (pp_c_function_definition): Likewise. (pp_c_id_expression): Likewise. (pp_c_simple_type_specifier): Tidy. (pp_c_unary_expression): Likewise. (pp_c_expression): Likewise. (pp_c_pretty_printer_init): Likewise. (pp_c_specifier_qualifier_list): Rework.. (pp_c_abstract_declarator): Likewise. (pp_c_postfix_expression): Likewise. (pp_c_primary_expression): Likewise. (pp_c_cast_expression): Likewise. (pp_c_direct_abstract_declarator): Likewise. (pp_c_storage_class_specifier): Likewise. (pp_c_function_specifier): Likewise. (pp_c_declaration_specifiers): Likewise. (pp_c_direct_declarator): Likewise. (pp_c_declarator): Likewise. (pp_c_declaration): Likewise. (pp_c_statement): Likewise. (pp_c_integer_constant): Rename from pp_c_integer_literal. (pp_c_character_constant): Rename from pp_c_character_literal. (pp_c_bool_constant): Rename from pp_c_bool_literal. (pp_c_enumeration_constant): Rename from pp_c_enumerator. (pp_c_floating_constant): Rename from pp_c_real_literal. (pp_c_constant): Rename from pp_c_literal. * c-lang.c: Include diagnostic.h and c-pretty-print.h (LANG_HOOKS_INITIALIZE_DIAGNOSTITCS): Define. (c_initialize_diagnostics): New. * Makefile.in (c-lang.o): Update dependency. cp/ * error.c (dump_expr): Tidy. * cxx-pretty-print.c (pp_cxx_nonconsecutive_character): New. (pp_cxx_begin_template_argument_list): Likewise. (pp_cxx_end_template_argument_list): Likewise. (is_destructor_name): Likewise. (pp_cxx_unqualified_id): Likewise. (pp_cxx_qualified_id): Likewise. (pp_cxx_id_expression): Likewise. (pp_cxx_new_expression): Likewise. (pp_cxx_delete_expression): Likewise. (pp_cxx_pm_expression): Likewise. (pp_cxx_type_specifier): Rework. (pp_cxx_type_id): Likewise. (pp_cxx_primary_expression): Likewise. (pp_cxx_postfix_expression): Likewise. (pp_cxx_unary_expression): Likewise. (pp_cxx_multiplicative_expression): Likewise. (pp_cxx_conditional_expression): Likewise. (pp_cxx_assignment_expression): Likewise. (pp_cxx_pretty_printer_init): Tidy. From-SVN: r70299
This commit is contained in:
parent
bae39a73be
commit
4b780675e4
|
@ -1,3 +1,52 @@
|
|||
2003-08-10 Gabriel Dos Reis <gdr@integrable-solutions.net>
|
||||
|
||||
* pretty-print.c (pp_base_indent): Rename from pp_indent.
|
||||
* c-pretty-print.h (pp_c_pretty_print_flag)s: New datatype.
|
||||
(struct c_pretty_print_info): Add more fields.
|
||||
(pp_c_left_paren): Move to c-pretty-print.c.
|
||||
(pp_c_right_paren): Likewise.
|
||||
(pp_c_left_brace): Likewise.
|
||||
(pp_c_right_brace): Likewise.
|
||||
(pp_c_left_bracket): Likewise.
|
||||
(pp_c_right_bracket): Likewise.
|
||||
(pp_c_declarator): Declare.
|
||||
(pp_c_direct_declarator): Likewise.
|
||||
(pp_c_specifier_qualifier_list): Likewise.
|
||||
(pp_c_type_id): Likewise.
|
||||
* c-pretty-print.c (pp_c_cv_qualifier): Change prootype. Rework..
|
||||
(pp_c_type_qualifier_list): New.
|
||||
(pp_c_pointer): Likewise.
|
||||
(pp_c_parameter_type_list): Likewise.
|
||||
(pp_c_function_definition): Likewise.
|
||||
(pp_c_id_expression): Likewise.
|
||||
(pp_c_simple_type_specifier): Tidy.
|
||||
(pp_c_unary_expression): Likewise.
|
||||
(pp_c_expression): Likewise.
|
||||
(pp_c_pretty_printer_init): Likewise.
|
||||
(pp_c_specifier_qualifier_list): Rework..
|
||||
(pp_c_abstract_declarator): Likewise.
|
||||
(pp_c_postfix_expression): Likewise.
|
||||
(pp_c_primary_expression): Likewise.
|
||||
(pp_c_cast_expression): Likewise.
|
||||
(pp_c_direct_abstract_declarator): Likewise.
|
||||
(pp_c_storage_class_specifier): Likewise.
|
||||
(pp_c_function_specifier): Likewise.
|
||||
(pp_c_declaration_specifiers): Likewise.
|
||||
(pp_c_direct_declarator): Likewise.
|
||||
(pp_c_declarator): Likewise.
|
||||
(pp_c_declaration): Likewise.
|
||||
(pp_c_statement): Likewise.
|
||||
(pp_c_integer_constant): Rename from pp_c_integer_literal.
|
||||
(pp_c_character_constant): Rename from pp_c_character_literal.
|
||||
(pp_c_bool_constant): Rename from pp_c_bool_literal.
|
||||
(pp_c_enumeration_constant): Rename from pp_c_enumerator.
|
||||
(pp_c_floating_constant): Rename from pp_c_real_literal.
|
||||
(pp_c_constant): Rename from pp_c_literal.
|
||||
* c-lang.c: Include diagnostic.h and c-pretty-print.h
|
||||
(LANG_HOOKS_INITIALIZE_DIAGNOSTITCS): Define.
|
||||
(c_initialize_diagnostics): New.
|
||||
* Makefile.in (c-lang.o): Update dependency.
|
||||
|
||||
2003-08-10 Nathan Sidwell <nathan@codesourcery.com>
|
||||
|
||||
* c-typeck.c (digest_init): Add conversion for VECTOR_TYPEs.
|
||||
|
|
|
@ -1280,7 +1280,8 @@ c-decl.o : c-decl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
|
|||
$(LANGHOOKS_DEF_H)
|
||||
c-typeck.o : c-typeck.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(C_TREE_H) \
|
||||
$(TARGET_H) flags.h intl.h output.h $(EXPR_H) $(RTL_H) toplev.h $(TM_P_H)
|
||||
c-lang.o : c-lang.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(C_TREE_H) \
|
||||
c-lang.o : c-lang.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
|
||||
$(C_TREE_H) $(C_PRETTY_PRINT_H) $(DIAGNOSTIC_H) \
|
||||
$(GGC_H) langhooks.h $(LANGHOOKS_DEF_H) $(C_COMMON_H) gtype-c.h
|
||||
c-lex.o : c-lex.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
|
||||
$(RTL_H) debug.h $(C_TREE_H) $(C_COMMON_H) real.h c-incpath.h cppdefault.h \
|
||||
|
|
20
gcc/c-lang.c
20
gcc/c-lang.c
|
@ -30,6 +30,10 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|||
#include "ggc.h"
|
||||
#include "langhooks.h"
|
||||
#include "langhooks-def.h"
|
||||
#include "diagnostic.h"
|
||||
#include "c-pretty-print.h"
|
||||
|
||||
static void c_initialize_diagnostics (diagnostic_context *);
|
||||
|
||||
enum c_language_kind c_language = clk_c;
|
||||
|
||||
|
@ -43,6 +47,8 @@ enum c_language_kind c_language = clk_c;
|
|||
#define LANG_HOOKS_FINISH c_common_finish
|
||||
#undef LANG_HOOKS_INIT_OPTIONS
|
||||
#define LANG_HOOKS_INIT_OPTIONS c_common_init_options
|
||||
#undef LANG_HOOKS_INITIALIZE_DIAGNOSTITCS
|
||||
#define LANG_HOOKS_INITIALIZE_DIAGNOSTITCS c_initialize_diagnostics
|
||||
#undef LANG_HOOKS_HANDLE_OPTION
|
||||
#define LANG_HOOKS_HANDLE_OPTION c_common_handle_option
|
||||
#undef LANG_HOOKS_MISSING_ARGUMENT
|
||||
|
@ -218,4 +224,18 @@ finish_file (void)
|
|||
c_objc_common_finish_file ();
|
||||
}
|
||||
|
||||
static void
|
||||
c_initialize_diagnostics (diagnostic_context *context)
|
||||
{
|
||||
pretty_printer *base = context->printer;
|
||||
c_pretty_printer pp = xmalloc (sizeof *pp);
|
||||
memcpy (pp_base (pp), base, sizeof (pretty_printer));
|
||||
pp_c_pretty_printer_init (pp);
|
||||
context->printer = (pretty_printer *) pp;
|
||||
|
||||
/* It is safe to free this object because it was previously malloc()'d. */
|
||||
free (base);
|
||||
}
|
||||
|
||||
|
||||
#include "gtype-c.h"
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -27,6 +27,13 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|||
#include "pretty-print.h"
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
pp_c_flag_abstract = 1 << 1,
|
||||
pp_c_flag_last_bit = 2
|
||||
} pp_c_pretty_print_flags;
|
||||
|
||||
|
||||
/* The data type used to bundle information necessary for pretty-printing
|
||||
a C or C++ entity. */
|
||||
typedef struct c_pretty_print_info *c_pretty_printer;
|
||||
|
@ -41,18 +48,24 @@ struct c_pretty_print_info
|
|||
Not used yet. */
|
||||
int *offset_list;
|
||||
|
||||
pp_flags flags;
|
||||
|
||||
/* These must be overridden by each of the C and C++ front-end to
|
||||
reflect their understanding of syntactic productions when they differ. */
|
||||
c_pretty_print_fn declaration;
|
||||
c_pretty_print_fn declaration_specifiers;
|
||||
c_pretty_print_fn type_specifier;
|
||||
c_pretty_print_fn declarator;
|
||||
c_pretty_print_fn abstract_declarator;
|
||||
c_pretty_print_fn type_specifier;
|
||||
c_pretty_print_fn direct_declarator;
|
||||
c_pretty_print_fn parameter_declaration;
|
||||
c_pretty_print_fn type_id;
|
||||
c_pretty_print_fn function_specifier;
|
||||
c_pretty_print_fn storage_class_specifier;
|
||||
|
||||
c_pretty_print_fn statement;
|
||||
|
||||
c_pretty_print_fn id_expression;
|
||||
c_pretty_print_fn primary_expression;
|
||||
c_pretty_print_fn postfix_expression;
|
||||
c_pretty_print_fn unary_expression;
|
||||
|
@ -65,78 +78,50 @@ struct c_pretty_print_info
|
|||
#undef pp_base
|
||||
#define pp_base(PP) (&pp_c_base (PP)->base)
|
||||
|
||||
#define pp_c_left_paren(PPI) \
|
||||
do { \
|
||||
pp_left_paren (PPI); \
|
||||
pp_c_base (PPI)->base.padding = pp_none; \
|
||||
} while (0)
|
||||
#define pp_c_right_paren(PPI) \
|
||||
do { \
|
||||
pp_right_paren (PPI); \
|
||||
pp_c_base (PPI)->base.padding = pp_none; \
|
||||
} while (0)
|
||||
#define pp_c_left_bracket(PPI) \
|
||||
do { \
|
||||
pp_left_bracket (PPI); \
|
||||
pp_c_base (PPI)->base.padding = pp_none; \
|
||||
} while (0)
|
||||
#define pp_c_right_bracket(PPI) \
|
||||
do { \
|
||||
pp_right_bracket (PPI); \
|
||||
pp_c_base (PPI)->base.padding = pp_none; \
|
||||
} while (0)
|
||||
#define pp_c_whitespace(PPI) \
|
||||
do { \
|
||||
pp_space (PPI); \
|
||||
pp_c_base (PPI)->base.padding = pp_none; \
|
||||
} while (0)
|
||||
#define pp_c_maybe_whitespace(PPI) \
|
||||
do { \
|
||||
if (pp_c_base (PPI)->base.padding != pp_none) \
|
||||
pp_c_whitespace (PPI); \
|
||||
} while (0)
|
||||
#define pp_c_identifier(PPI, ID) \
|
||||
do { \
|
||||
pp_c_maybe_whitespace (PPI); \
|
||||
pp_identifier (PPI, ID); \
|
||||
pp_c_base (PPI)->base.padding = pp_before; \
|
||||
} while (0)
|
||||
|
||||
#define pp_c_tree_identifier(PPI, ID) \
|
||||
pp_c_identifier (PPI, IDENTIFIER_POINTER (ID))
|
||||
|
||||
#define pp_declaration(PPI, T) \
|
||||
(*pp_c_base (PPI)->declaration) (pp_c_base (PPI), T)
|
||||
pp_c_base (PPI)->declaration (pp_c_base (PPI), T)
|
||||
#define pp_declaration_specifiers(PPI, D) \
|
||||
(*pp_c_base (PPI)->declaration_specifiers) (pp_c_base (PPI), D)
|
||||
pp_c_base (PPI)->declaration_specifiers (pp_c_base (PPI), D)
|
||||
#define pp_abstract_declarator(PP, D) \
|
||||
pp_c_base (PP)->abstract_declarator (pp_c_base (PP), D)
|
||||
#define pp_type_specifier(PPI, D) \
|
||||
(*pp_c_base (PPI)->type_specifier) (pp_c_base (PPI), D)
|
||||
pp_c_base (PPI)->type_specifier (pp_c_base (PPI), D)
|
||||
#define pp_declarator(PPI, D) \
|
||||
(*pp_c_base (PPI)->declarator) (pp_c_base (PPI), D)
|
||||
pp_c_base (PPI)->declarator (pp_c_base (PPI), D)
|
||||
#define pp_direct_declarator(PPI, D) \
|
||||
(*pp_c_base (PPI)->direct_declarator) (pp_c_base (PPI), D)
|
||||
pp_c_base (PPI)->direct_declarator (pp_c_base (PPI), D)
|
||||
#define pp_parameter_declaration(PPI, T) \
|
||||
(*pp_c_base (PPI)->parameter_declaration) (pp_c_base (PPI), T)
|
||||
pp_c_base (PPI)->parameter_declaration (pp_c_base (PPI), T)
|
||||
#define pp_type_id(PPI, D) \
|
||||
(*pp_c_base (PPI)->type_id) (pp_c_base (PPI), D)
|
||||
pp_c_base (PPI)->type_id (pp_c_base (PPI), D)
|
||||
#define pp_function_specifier(PP, D) \
|
||||
pp_c_base (PP)->function_specifier (pp_c_base (PP), D)
|
||||
#define pp_storage_class_specifier(PP, D) \
|
||||
pp_c_base (PP)->storage_class_specifier (pp_c_base (PP), D);
|
||||
|
||||
#define pp_statement(PPI, S) \
|
||||
(*pp_c_base (PPI)->statement) (pp_c_base (PPI), S)
|
||||
pp_c_base (PPI)->statement (pp_c_base (PPI), S)
|
||||
|
||||
#define pp_id_expression(PP, E) \
|
||||
pp_c_base (PP)->id_expression (pp_c_base (PP), E)
|
||||
#define pp_primary_expression(PPI, E) \
|
||||
(*pp_c_base (PPI)->primary_expression) (pp_c_base (PPI), E)
|
||||
pp_c_base (PPI)->primary_expression (pp_c_base (PPI), E)
|
||||
#define pp_postfix_expression(PPI, E) \
|
||||
(*pp_c_base (PPI)->postfix_expression) (pp_c_base (PPI), E)
|
||||
pp_c_base (PPI)->postfix_expression (pp_c_base (PPI), E)
|
||||
#define pp_unary_expression(PPI, E) \
|
||||
(*pp_c_base (PPI)->unary_expression) (pp_c_base (PPI), E)
|
||||
pp_c_base (PPI)->unary_expression (pp_c_base (PPI), E)
|
||||
#define pp_initializer(PPI, E) \
|
||||
(*pp_c_base (PPI)->initializer) (pp_c_base (PPI), E)
|
||||
pp_c_base (PPI)->initializer (pp_c_base (PPI), E)
|
||||
#define pp_multiplicative_expression(PPI, E) \
|
||||
(*pp_c_base (PPI)->multiplicative_expression) (pp_c_base (PPI), E)
|
||||
pp_c_base (PPI)->multiplicative_expression (pp_c_base (PPI), E)
|
||||
#define pp_conditional_expression(PPI, E) \
|
||||
(*pp_c_base (PPI)->conditional_expression) (pp_c_base (PPI), E)
|
||||
pp_c_base (PPI)->conditional_expression (pp_c_base (PPI), E)
|
||||
#define pp_assignment_expression(PPI, E) \
|
||||
(*pp_c_base (PPI)->assignment_expression) (pp_c_base (PPI), E)
|
||||
pp_c_base (PPI)->assignment_expression (pp_c_base (PPI), E)
|
||||
|
||||
|
||||
/* Returns the c_pretty_printer base object of PRETTY-PRINTER. This
|
||||
|
@ -146,22 +131,28 @@ struct c_pretty_print_info
|
|||
extern void pp_c_pretty_printer_init (c_pretty_printer);
|
||||
|
||||
/* Declarations. */
|
||||
void pp_c_function_definition (c_pretty_printer, tree);
|
||||
void pp_c_attributes (c_pretty_printer, tree);
|
||||
void pp_c_cv_qualifier (c_pretty_printer, int);
|
||||
void pp_c_type_qualifier_list (c_pretty_printer, tree);
|
||||
void pp_c_parameter_declaration_clause (c_pretty_printer, tree);
|
||||
void pp_c_declaration (c_pretty_printer, tree);
|
||||
void pp_c_declarator (c_pretty_printer, tree);
|
||||
void pp_c_direct_declarator (c_pretty_printer, tree);
|
||||
void pp_c_specifier_qualifier_list (c_pretty_printer, tree);
|
||||
void pp_c_type_id (c_pretty_printer, tree);
|
||||
/* Statements. */
|
||||
void pp_c_statement (c_pretty_printer, tree);
|
||||
/* Expressions. */
|
||||
void pp_c_expression (c_pretty_printer, tree);
|
||||
void pp_c_logical_or_expression (c_pretty_printer, tree);
|
||||
void pp_c_expression_list (c_pretty_printer, tree);
|
||||
void pp_c_unary_expression (c_pretty_printer, tree);
|
||||
void pp_c_cast_expression (c_pretty_printer, tree);
|
||||
void pp_c_postfix_expression (c_pretty_printer, tree);
|
||||
void pp_c_initializer (c_pretty_printer, tree);
|
||||
void pp_c_literal (c_pretty_printer, tree);
|
||||
void pp_c_constant (c_pretty_printer, tree);
|
||||
void pp_c_id_expression (c_pretty_printer, tree);
|
||||
void pp_c_identifier (c_pretty_printer, const char *);
|
||||
void pp_c_string_literal (c_pretty_printer, tree);
|
||||
void pp_c_real_literal (c_pretty_printer, tree);
|
||||
void pp_c_integer_literal (c_pretty_printer, tree);
|
||||
|
||||
#endif /* GCC_C_PRETTY_PRINTER */
|
||||
|
|
|
@ -1,3 +1,26 @@
|
|||
2003-08-10 Gabriel Dos Reis <gdr@integrable-solutions.net>
|
||||
|
||||
* error.c (dump_expr): Tidy.
|
||||
* cxx-pretty-print.c (pp_cxx_nonconsecutive_character): New.
|
||||
(pp_cxx_begin_template_argument_list): Likewise.
|
||||
(pp_cxx_end_template_argument_list): Likewise.
|
||||
(is_destructor_name): Likewise.
|
||||
(pp_cxx_unqualified_id): Likewise.
|
||||
(pp_cxx_qualified_id): Likewise.
|
||||
(pp_cxx_id_expression): Likewise.
|
||||
(pp_cxx_new_expression): Likewise.
|
||||
(pp_cxx_delete_expression): Likewise.
|
||||
(pp_cxx_pm_expression): Likewise.
|
||||
(pp_cxx_type_specifier): Rework.
|
||||
(pp_cxx_type_id): Likewise.
|
||||
(pp_cxx_primary_expression): Likewise.
|
||||
(pp_cxx_postfix_expression): Likewise.
|
||||
(pp_cxx_unary_expression): Likewise.
|
||||
(pp_cxx_multiplicative_expression): Likewise.
|
||||
(pp_cxx_conditional_expression): Likewise.
|
||||
(pp_cxx_assignment_expression): Likewise.
|
||||
(pp_cxx_pretty_printer_init): Tidy.
|
||||
|
||||
2003-08-10 Nathan Sidwell <nathan@codesourcery.com>
|
||||
|
||||
* cp-tree.h (TMPL_ARGS_HAVE_MULTIPLE_LEVELS): non-NULL
|
||||
|
|
|
@ -26,7 +26,28 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|||
#include "real.h"
|
||||
#include "cxx-pretty-print.h"
|
||||
#include "cp-tree.h"
|
||||
|
||||
static void pp_cxx_unqualified_id (cxx_pretty_printer *, tree);
|
||||
static void pp_cxx_qualified_id (cxx_pretty_printer *, tree);
|
||||
static void pp_cxx_assignment_expression (cxx_pretty_printer *, tree);
|
||||
static void pp_cxx_template_argument_list (cxx_pretty_printer *, tree);
|
||||
|
||||
|
||||
static inline void
|
||||
pp_cxx_nonconsecutive_character (cxx_pretty_printer *pp, int c)
|
||||
{
|
||||
const char *p = pp_last_position_in_text (pp);
|
||||
|
||||
if (p != NULL && *p == c)
|
||||
pp_space (pp);
|
||||
pp_character (pp, c);
|
||||
}
|
||||
|
||||
#define pp_cxx_begin_template_argument_list(PP) \
|
||||
pp_cxx_nonconsecutive_character (PP, '<')
|
||||
#define pp_cxx_end_template_argument_list(PP) \
|
||||
pp_cxx_nonconsecutive_character (PP, '>')
|
||||
|
||||
/* Declarations. */
|
||||
|
||||
void
|
||||
|
@ -40,23 +61,55 @@ pp_cxx_declaration_specifiers (cxx_pretty_printer *pp, tree t)
|
|||
{
|
||||
pp_unsupported_tree (pp, t);
|
||||
}
|
||||
/* type-specifier:
|
||||
simple-type-specifier
|
||||
class-specifier
|
||||
enum-specifier
|
||||
elaborated-type-specifier
|
||||
cv-qualifer */
|
||||
|
||||
static void
|
||||
pp_cxx_type_specifier (cxx_pretty_printer *pp, tree t)
|
||||
{
|
||||
pp_unsupported_tree (pp, t);
|
||||
pp_c_type_qualifier_list (pp_c_base (pp), t);
|
||||
|
||||
switch (TREE_CODE (t))
|
||||
{
|
||||
case TEMPLATE_DECL:
|
||||
case TYPE_DECL:
|
||||
if (pp->enclosing_scope != DECL_CONTEXT (t))
|
||||
pp_cxx_qualified_id (pp, t);
|
||||
else
|
||||
pp_cxx_unqualified_id (pp, t);
|
||||
break;
|
||||
|
||||
case TYPEOF_TYPE:
|
||||
pp_c_identifier (pp_c_base (pp), "__typeof__");
|
||||
pp_left_paren (pp);
|
||||
pp_c_expression (pp_c_base (pp), TYPE_FIELDS (t));
|
||||
pp_right_paren (pp);
|
||||
break;
|
||||
|
||||
default:
|
||||
pp_c_specifier_qualifier_list (pp_c_base (pp), t);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pp_cxx_declarator (cxx_pretty_printer *pp, tree t)
|
||||
{
|
||||
pp_unsupported_tree (pp, t);
|
||||
switch (TREE_CODE (t))
|
||||
{
|
||||
default:
|
||||
pp_c_declarator (pp_c_base (pp), t);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pp_cxx_direct_declarator (cxx_pretty_printer *pp, tree t)
|
||||
{
|
||||
pp_unsupported_tree (pp, t);
|
||||
pp_c_direct_declarator (pp_c_base (pp), t);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -65,12 +118,78 @@ pp_cxx_parameter_declaration (cxx_pretty_printer *pp, tree t)
|
|||
pp_unsupported_tree (pp, t);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* type-id:
|
||||
type-specifier-seq abstract-declarator(opt) */
|
||||
static void
|
||||
pp_cxx_type_id (cxx_pretty_printer *pp, tree t)
|
||||
{
|
||||
pp_flags saved_flags = pp_c_base (pp)->flags;
|
||||
pp_c_base (pp)->flags |= pp_c_flag_abstract;
|
||||
|
||||
switch (TREE_CODE (t))
|
||||
{
|
||||
case TYPE_DECL:
|
||||
case UNION_TYPE:
|
||||
case RECORD_TYPE:
|
||||
case ENUMERAL_TYPE:
|
||||
case TYPENAME_TYPE:
|
||||
case BOUND_TEMPLATE_TEMPLATE_PARM:
|
||||
case UNBOUND_CLASS_TEMPLATE:
|
||||
case TEMPLATE_TEMPLATE_PARM:
|
||||
case TEMPLATE_TYPE_PARM:
|
||||
case TEMPLATE_PARM_INDEX:
|
||||
case TEMPLATE_DECL:
|
||||
case TYPEOF_TYPE:
|
||||
case TEMPLATE_ID_EXPR:
|
||||
/* FIXME: Should be pp_cxx_type_specifier_seq. */
|
||||
pp_cxx_type_specifier (pp, t);
|
||||
pp_cxx_declarator (pp, t);
|
||||
break;
|
||||
|
||||
default:
|
||||
pp_c_type_id (pp_c_base (pp), t);
|
||||
break;
|
||||
}
|
||||
|
||||
pp_c_base (pp)->flags = saved_flags;
|
||||
}
|
||||
|
||||
static void
|
||||
pp_cxx_initializer (cxx_pretty_printer *pp, tree t)
|
||||
{
|
||||
pp_unsupported_tree (pp, t);
|
||||
}
|
||||
|
||||
/* template-argument-list:
|
||||
template-argument
|
||||
template-argument-list, template-argument
|
||||
|
||||
template-argument:
|
||||
assignment-expression
|
||||
type-id
|
||||
template-name */
|
||||
static void
|
||||
pp_cxx_template_argument_list (cxx_pretty_printer *pp, tree t)
|
||||
{
|
||||
int i;
|
||||
if (t == NULL)
|
||||
return;
|
||||
for (i = 0; i < TREE_VEC_LENGTH (t); ++i)
|
||||
{
|
||||
tree arg = TREE_VEC_ELT (t, i);
|
||||
if (i != 0)
|
||||
pp_separate_with (pp, ',');
|
||||
if (TYPE_P (arg) || (TREE_CODE (arg) == TEMPLATE_DECL
|
||||
&& TYPE_P (DECL_TEMPLATE_RESULT (arg))))
|
||||
pp_cxx_type_id (pp, arg);
|
||||
else
|
||||
pp_c_expression (pp_c_base (pp), arg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Statements. */
|
||||
|
||||
void
|
||||
|
@ -81,52 +200,470 @@ pp_cxx_statement (cxx_pretty_printer *pp, tree t)
|
|||
|
||||
/* Expressions. */
|
||||
|
||||
static inline bool
|
||||
is_destructor_name (tree name)
|
||||
{
|
||||
return name == complete_dtor_identifier
|
||||
|| name == base_dtor_identifier
|
||||
|| name == deleting_dtor_identifier;
|
||||
}
|
||||
|
||||
/* unqualified-id:
|
||||
identifier
|
||||
operator-function-id
|
||||
conversion-function-id
|
||||
~ class-name
|
||||
template-id */
|
||||
static void
|
||||
pp_cxx_unqualified_id (cxx_pretty_printer *pp, tree t)
|
||||
{
|
||||
enum tree_code code = TREE_CODE (t);
|
||||
switch (code)
|
||||
{
|
||||
case VAR_DECL:
|
||||
case PARM_DECL:
|
||||
case CONST_DECL:
|
||||
case TYPE_DECL:
|
||||
case FUNCTION_DECL:
|
||||
case NAMESPACE_DECL:
|
||||
case FIELD_DECL:
|
||||
case LABEL_DECL:
|
||||
case USING_DECL:
|
||||
t = DECL_NAME (t);
|
||||
|
||||
case IDENTIFIER_NODE:
|
||||
if (IDENTIFIER_TYPENAME_P (t))
|
||||
{
|
||||
pp_c_identifier (pp_c_base (pp), "operator");
|
||||
/* FIXME: should be pp_cxx_type_specifier_seq */
|
||||
pp_cxx_type_specifier (pp, TREE_TYPE (t));
|
||||
/* FIXME: should be pp_cxx_conversion_declarator. */
|
||||
pp_cxx_type_id (pp, TREE_TYPE (t));
|
||||
}
|
||||
else if (IDENTIFIER_OPNAME_P (t))
|
||||
{
|
||||
const char *name = operator_name_info[TREE_CODE (t)].name;
|
||||
pp_c_identifier (pp_c_base (pp), "operator");
|
||||
if (ISALPHA (name[0]))
|
||||
pp_space (pp);
|
||||
pp_base (pp)->padding = pp_none;
|
||||
pp_c_identifier (pp_c_base (pp), name);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_destructor_name (t))
|
||||
{
|
||||
pp_complement (pp);
|
||||
t = constructor_name (TREE_TYPE (t));
|
||||
}
|
||||
pp_c_tree_identifier (pp_c_base (pp), t);
|
||||
}
|
||||
break;
|
||||
|
||||
case TEMPLATE_ID_EXPR:
|
||||
pp_cxx_unqualified_id (pp, TREE_OPERAND (t, 0));
|
||||
pp_less (pp);
|
||||
pp_cxx_template_argument_list (pp, TREE_OPERAND (t, 1));
|
||||
pp_greater (pp);
|
||||
break;
|
||||
|
||||
default:
|
||||
pp_unsupported_tree (pp, t);
|
||||
}
|
||||
}
|
||||
|
||||
/* qualified-id:
|
||||
nested-name-specifier template(opt) unqualified-id */
|
||||
static void
|
||||
pp_cxx_qualified_id (cxx_pretty_printer *pp, tree t)
|
||||
{
|
||||
switch (TREE_CODE (t))
|
||||
{
|
||||
case PTRMEM_CST:
|
||||
pp_cxx_qualified_id (pp, PTRMEM_CST_CLASS (t));
|
||||
pp_colon_colon (pp);
|
||||
pp_cxx_unqualified_id (pp, PTRMEM_CST_MEMBER (t));
|
||||
break;
|
||||
|
||||
case OFFSET_REF:
|
||||
case SCOPE_REF:
|
||||
pp_cxx_qualified_id (pp, TREE_OPERAND (t, 0));
|
||||
pp_colon_colon (pp);
|
||||
pp_cxx_unqualified_id (pp, TREE_OPERAND (t, 1));
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
tree scope = DECL_CONTEXT (t);
|
||||
if (scope == pp->enclosing_scope)
|
||||
pp_cxx_unqualified_id (pp, t);
|
||||
else
|
||||
{
|
||||
pp_cxx_qualified_id (pp, scope);
|
||||
pp_colon_colon (pp);
|
||||
if (TYPE_P (scope) && dependent_type_p (scope)
|
||||
&& TREE_CODE (t) == TEMPLATE_DECL)
|
||||
pp_c_identifier (pp_c_base (pp), "template");
|
||||
pp_cxx_unqualified_id (pp, t);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* id-expression:
|
||||
unaqualified-id
|
||||
qualified-id */
|
||||
static inline void
|
||||
pp_cxx_id_expression (cxx_pretty_printer *pp, tree t)
|
||||
{
|
||||
if (pp_c_base (pp)->flags
|
||||
& (pp_cxx_flag_qualified_id | pp_cxx_flag_global_scope))
|
||||
pp_cxx_qualified_id (pp, t);
|
||||
else
|
||||
pp_cxx_unqualified_id (pp, t);
|
||||
}
|
||||
|
||||
/* primary-expression:
|
||||
literal
|
||||
this
|
||||
:: identifier
|
||||
:: operator-function-id
|
||||
:: qualifier-id
|
||||
( expression )
|
||||
id-expression */
|
||||
static void
|
||||
pp_cxx_primary_expression (cxx_pretty_printer *pp, tree t)
|
||||
{
|
||||
pp_unsupported_tree (pp, t);
|
||||
switch (TREE_CODE (t))
|
||||
{
|
||||
case STRING_CST:
|
||||
case INTEGER_CST:
|
||||
case REAL_CST:
|
||||
pp_c_constant (pp_c_base (pp), t);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (pp_c_base (pp)->flags & pp_cxx_flag_qualified_id)
|
||||
pp_cxx_qualified_id (pp, t);
|
||||
else
|
||||
{
|
||||
if (pp_c_base (pp)->flags & pp_cxx_flag_global_scope)
|
||||
pp_colon_colon (pp);
|
||||
pp_cxx_unqualified_id (pp, t);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* postfix-expression:
|
||||
primary-expression
|
||||
postfix-expression [ expression ]
|
||||
postfix-expression ( expression-list(opt) )
|
||||
simple-type-specifier ( expression-list(opt) )
|
||||
typename ::(opt) nested-name-specifier identifier ( expression-list(opt) )
|
||||
typename ::(opt) nested-name-specifier template(opt)
|
||||
template-id ( expression-list(opt) )
|
||||
postfix-expression . template(opt) ::(opt) id-expression
|
||||
postfix-expression -> template(opt) ::(opt) id-expression
|
||||
postfix-expression . pseudo-destructor-name
|
||||
postfix-expression -> pseudo-destructor-name
|
||||
postfix-expression ++
|
||||
postfix-expression --
|
||||
dynamic_cast < type-id > ( expression )
|
||||
static_cast < type-id > ( expression )
|
||||
reinterpret_cast < type-id > ( expression )
|
||||
const_cast < type-id > ( expression )
|
||||
typeid ( expression )
|
||||
typeif ( type-id ) */
|
||||
|
||||
static void
|
||||
pp_cxx_postfix_expression (cxx_pretty_printer *pp, tree t)
|
||||
{
|
||||
pp_unsupported_tree (pp, t);
|
||||
enum tree_code code = TREE_CODE (t);
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case DYNAMIC_CAST_EXPR:
|
||||
case STATIC_CAST_EXPR:
|
||||
case REINTERPRET_CAST_EXPR:
|
||||
case CONST_CAST_EXPR:
|
||||
if (code == DYNAMIC_CAST_EXPR)
|
||||
pp_identifier (pp, "dynamic_cast");
|
||||
else if (code == STATIC_CAST_EXPR)
|
||||
pp_identifier (pp, "static_cast");
|
||||
else if (code == REINTERPRET_CAST_EXPR)
|
||||
pp_identifier (pp, "reinterpret_cast");
|
||||
else
|
||||
pp_identifier (pp, "const_cast");
|
||||
pp_cxx_begin_template_argument_list (pp);
|
||||
pp_cxx_type_id (pp, TREE_TYPE (t));
|
||||
pp_cxx_end_template_argument_list (pp);
|
||||
pp_left_paren (pp);
|
||||
pp_c_expression (pp_c_base (pp), TREE_OPERAND (t, 0));
|
||||
pp_right_paren (pp);
|
||||
break;
|
||||
|
||||
case EMPTY_CLASS_EXPR:
|
||||
pp_cxx_type_id (pp, TREE_TYPE (t));
|
||||
pp_left_paren (pp);
|
||||
pp_right_paren (pp);
|
||||
break;
|
||||
|
||||
case TYPEID_EXPR:
|
||||
t = TREE_OPERAND (t, 0);
|
||||
pp_c_identifier (pp_c_base (pp), "typeid");
|
||||
pp_left_paren (pp);
|
||||
if (TYPE_P (t))
|
||||
pp_cxx_type_id (pp, t);
|
||||
else
|
||||
pp_c_expression (pp_c_base (pp), t);
|
||||
pp_right_paren (pp);
|
||||
break;
|
||||
|
||||
case PSEUDO_DTOR_EXPR:
|
||||
pp_cxx_postfix_expression (pp, TREE_OPERAND (t, 0));
|
||||
pp_dot (pp);
|
||||
pp_cxx_qualified_id (pp, TREE_OPERAND (t, 1));
|
||||
pp_colon_colon (pp);
|
||||
pp_complement (pp);
|
||||
pp_cxx_unqualified_id (pp, TREE_OPERAND (t, 2));
|
||||
break;
|
||||
|
||||
default:
|
||||
pp_c_postfix_expression (pp_c_base (pp), t);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* new-expression:
|
||||
::(opt) new new-placement(opt) new-type-id new-initializer(opt)
|
||||
::(opt) new new-placement(opt) ( type-id ) new-initializer(opt)
|
||||
|
||||
new-placement:
|
||||
( expression-list )
|
||||
|
||||
new-type-id:
|
||||
type-specifier-seq new-declarator(opt)
|
||||
|
||||
new-declarator:
|
||||
ptr-operator new-declarator(opt)
|
||||
direct-new-declarator
|
||||
|
||||
direct-new-declarator
|
||||
[ expression ]
|
||||
direct-new-declarator [ constant-expression ]
|
||||
|
||||
new-initializer:
|
||||
( expression-list(opt) ) */
|
||||
static void
|
||||
pp_cxx_new_expression (cxx_pretty_printer *pp, tree t)
|
||||
{
|
||||
enum tree_code code = TREE_CODE (t);
|
||||
switch (code)
|
||||
{
|
||||
case NEW_EXPR:
|
||||
case VEC_NEW_EXPR:
|
||||
if (NEW_EXPR_USE_GLOBAL (t))
|
||||
pp_colon_colon (pp);
|
||||
pp_c_identifier (pp_c_base (pp), "new");
|
||||
if (TREE_OPERAND (t, 0))
|
||||
{
|
||||
pp_left_paren (pp);
|
||||
pp_c_expression_list (pp_c_base (pp), TREE_OPERAND (t, 0));
|
||||
pp_right_paren (pp);
|
||||
pp_space (pp);
|
||||
}
|
||||
/* FIXME: array-types are built with one more element. */
|
||||
pp_cxx_type_id (pp, TREE_OPERAND (t, 1));
|
||||
if (TREE_OPERAND (t, 2))
|
||||
{
|
||||
pp_left_paren (pp);
|
||||
t = TREE_OPERAND (t, 2);
|
||||
if (TREE_CODE (t) == TREE_LIST)
|
||||
pp_c_expression_list (pp_c_base (pp), t);
|
||||
else if (t == void_zero_node)
|
||||
; /* OK, empty initializer list. */
|
||||
else
|
||||
pp_c_expression (pp_c_base (pp), t);
|
||||
pp_right_paren (pp);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
pp_unsupported_tree (pp, t);
|
||||
}
|
||||
}
|
||||
|
||||
/* delete-expression:
|
||||
::(opt) delete cast-expression
|
||||
::(opt) delete [ ] cast-expression */
|
||||
static void
|
||||
pp_cxx_delete_expression (cxx_pretty_printer *pp, tree t)
|
||||
{
|
||||
enum tree_code code = TREE_CODE (t);
|
||||
switch (code)
|
||||
{
|
||||
case DELETE_EXPR:
|
||||
case VEC_DELETE_EXPR:
|
||||
if (DELETE_EXPR_USE_GLOBAL (t))
|
||||
pp_colon_colon (pp);
|
||||
pp_c_identifier (pp_c_base (pp), "delete");
|
||||
if (code == VEC_DELETE_EXPR)
|
||||
{
|
||||
pp_left_bracket (pp);
|
||||
pp_right_bracket (pp);
|
||||
}
|
||||
pp_c_cast_expression (pp_c_base (pp), TREE_OPERAND (t, 0));
|
||||
break;
|
||||
|
||||
default:
|
||||
pp_unsupported_tree (pp, t);
|
||||
}
|
||||
}
|
||||
|
||||
/* unary-expression:
|
||||
postfix-expression
|
||||
++ cast-expression
|
||||
-- cast-expression
|
||||
unary-operator cast-expression
|
||||
sizeof unary-expression
|
||||
sizeof ( type-id )
|
||||
new-expression
|
||||
delete-expression
|
||||
|
||||
unary-operator: one of
|
||||
* & + - !
|
||||
|
||||
GNU extensions:
|
||||
__alignof__ unary-expression
|
||||
__alignof__ ( type-id ) */
|
||||
static void
|
||||
pp_cxx_unary_expression (cxx_pretty_printer *pp, tree t)
|
||||
{
|
||||
pp_unsupported_tree (pp, t);
|
||||
enum tree_code code = TREE_CODE (t);
|
||||
switch (code)
|
||||
{
|
||||
case NEW_EXPR:
|
||||
case VEC_NEW_EXPR:
|
||||
pp_cxx_new_expression (pp, t);
|
||||
break;
|
||||
|
||||
case DELETE_EXPR:
|
||||
case VEC_DELETE_EXPR:
|
||||
pp_cxx_delete_expression (pp, t);
|
||||
break;
|
||||
|
||||
default:
|
||||
pp_c_unary_expression (pp_c_base (pp), t);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* pm-expression:
|
||||
cast-expression
|
||||
pm-expression .* cast-expression
|
||||
pm-expression ->* cast-expression */
|
||||
static void
|
||||
pp_cxx_initializer (cxx_pretty_printer *pp, tree t)
|
||||
pp_cxx_pm_expression (cxx_pretty_printer *pp, tree t)
|
||||
{
|
||||
pp_unsupported_tree (pp, t);
|
||||
switch (TREE_CODE (t))
|
||||
{
|
||||
/* Handle unfortunate OFFESET_REF overloading here. */
|
||||
case OFFSET_REF:
|
||||
if (TYPE_P (TREE_OPERAND (t, 0)))
|
||||
{
|
||||
pp_cxx_qualified_id (pp, t);
|
||||
break;
|
||||
}
|
||||
/* else fall through */
|
||||
case MEMBER_REF:
|
||||
case DOTSTAR_EXPR:
|
||||
pp_cxx_pm_expression (pp, TREE_OPERAND (t, 0));
|
||||
pp_dot (pp);
|
||||
pp_star(pp);
|
||||
pp_c_cast_expression (pp_c_base (pp), TREE_OPERAND (t, 1));
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
pp_c_cast_expression (pp_c_base (pp), t);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* multiplicative-expression:
|
||||
pm-expression
|
||||
multiplicative-expression * pm-expression
|
||||
multiplicative-expression / pm-expression
|
||||
multiplicative-expression % pm-expression */
|
||||
static void
|
||||
pp_cxx_multiplicatice_expression (cxx_pretty_printer *pp, tree t)
|
||||
pp_cxx_multiplicative_expression (cxx_pretty_printer *pp, tree e)
|
||||
{
|
||||
pp_unsupported_tree (pp, t);
|
||||
enum tree_code code = TREE_CODE (e);
|
||||
switch (code)
|
||||
{
|
||||
case MULT_EXPR:
|
||||
case TRUNC_DIV_EXPR:
|
||||
case TRUNC_MOD_EXPR:
|
||||
pp_cxx_multiplicative_expression (pp, TREE_OPERAND (e, 0));
|
||||
pp_space (pp);
|
||||
if (code == MULT_EXPR)
|
||||
pp_star (pp);
|
||||
else if (code == TRUNC_DIV_EXPR)
|
||||
pp_slash (pp);
|
||||
else
|
||||
pp_modulo (pp);
|
||||
pp_space (pp);
|
||||
pp_cxx_pm_expression (pp, TREE_OPERAND (e, 1));
|
||||
break;
|
||||
|
||||
default:
|
||||
pp_cxx_pm_expression (pp, e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* conditional-expression:
|
||||
logical-or-expression
|
||||
logical-or-expression ? expression : assignment-expression */
|
||||
static void
|
||||
pp_cxx_conditional_expression (cxx_pretty_printer *pp, tree t)
|
||||
pp_cxx_conditional_expression (cxx_pretty_printer *pp, tree e)
|
||||
{
|
||||
pp_unsupported_tree (pp, t);
|
||||
if (TREE_CODE (e) == COND_EXPR)
|
||||
{
|
||||
pp_c_logical_or_expression (pp_c_base (pp), TREE_OPERAND (e, 0));
|
||||
pp_space (pp);
|
||||
pp_question (pp);
|
||||
pp_space (pp);
|
||||
pp_c_expression (pp_c_base (pp), TREE_OPERAND (e, 1));
|
||||
pp_space (pp);
|
||||
pp_cxx_assignment_expression (pp, TREE_OPERAND (e, 2));
|
||||
}
|
||||
else
|
||||
pp_c_logical_or_expression (pp_c_base (pp), e);
|
||||
}
|
||||
|
||||
/* assignment-expression:
|
||||
conditional-expression
|
||||
logical-or-expression assignment-operator assignment-expression
|
||||
|
||||
assignment-expression: one of
|
||||
= *= /= %= += -= >>= <<= &= ^= |= */
|
||||
static void
|
||||
pp_cxx_assignment_expression (cxx_pretty_printer *pp, tree t)
|
||||
pp_cxx_assignment_expression (cxx_pretty_printer *pp, tree e)
|
||||
{
|
||||
pp_unsupported_tree (pp, t);
|
||||
}
|
||||
|
||||
void
|
||||
pp_cxx_expression (cxx_pretty_printer *pp, tree t)
|
||||
{
|
||||
pp_unsupported_tree (pp, t);
|
||||
if (TREE_CODE (e) == MODIFY_EXPR)
|
||||
{
|
||||
pp_c_logical_or_expression (pp_c_base (pp), TREE_OPERAND (e, 0));
|
||||
pp_space (pp);
|
||||
pp_equal (pp);
|
||||
pp_space (pp);
|
||||
pp_cxx_assignment_expression (pp, TREE_OPERAND (e, 1));
|
||||
}
|
||||
else
|
||||
pp_cxx_conditional_expression (pp, e);
|
||||
}
|
||||
|
||||
|
||||
|
@ -146,11 +683,12 @@ pp_cxx_pretty_printer_init (cxx_pretty_printer *pp)
|
|||
pp->c_base.parameter_declaration = (pp_fun) pp_cxx_parameter_declaration;
|
||||
pp->c_base.type_id = (pp_fun) pp_cxx_type_id;
|
||||
pp->c_base.statement = (pp_fun) pp_cxx_statement;
|
||||
pp->c_base.id_expression = (pp_fun) pp_cxx_id_expression;
|
||||
pp->c_base.primary_expression = (pp_fun) pp_cxx_primary_expression;
|
||||
pp->c_base.postfix_expression = (pp_fun) pp_cxx_postfix_expression;
|
||||
pp->c_base.unary_expression = (pp_fun) pp_cxx_unary_expression;
|
||||
pp->c_base.initializer = (pp_fun) pp_cxx_initializer;
|
||||
pp->c_base.multiplicative_expression = (pp_fun) pp_cxx_multiplicatice_expression;
|
||||
pp->c_base.multiplicative_expression = (pp_fun) pp_cxx_multiplicative_expression;
|
||||
pp->c_base.conditional_expression = (pp_fun) pp_cxx_conditional_expression;
|
||||
pp->c_base.assignment_expression = (pp_fun) pp_cxx_assignment_expression;
|
||||
pp->enclosing_scope = NULL;
|
||||
|
|
|
@ -27,6 +27,14 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|||
#undef pp_c_base
|
||||
#define pp_c_base(PP) (&(PP)->c_base)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
/* Ask for an qualified-id. */
|
||||
pp_cxx_flag_qualified_id = 1 << pp_c_flag_last_bit,
|
||||
pp_cxx_flag_global_scope = 1 << (pp_c_flag_last_bit + 1)
|
||||
|
||||
} cxx_pretty_printer_flags;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct c_pretty_print_info c_base;
|
||||
|
@ -38,7 +46,6 @@ void pp_cxx_pretty_printer_init (cxx_pretty_printer *);
|
|||
|
||||
void pp_cxx_declaration (cxx_pretty_printer *, tree);
|
||||
void pp_cxx_statement (cxx_pretty_printer *, tree);
|
||||
void pp_cxx_expression (cxx_pretty_printer *, tree);
|
||||
|
||||
|
||||
#endif /* GCC_CXX_PRETTY_PRINT_H */
|
||||
|
|
|
@ -1331,38 +1331,9 @@ dump_expr (tree t, int flags)
|
|||
break;
|
||||
|
||||
case INTEGER_CST:
|
||||
{
|
||||
tree type = TREE_TYPE (t);
|
||||
my_friendly_assert (type != 0, 81);
|
||||
|
||||
/* If it's an enum, output its tag, rather than its value. */
|
||||
if (TREE_CODE (type) == ENUMERAL_TYPE)
|
||||
{
|
||||
tree values = TYPE_VALUES (type);
|
||||
|
||||
for (; values;
|
||||
values = TREE_CHAIN (values))
|
||||
if (tree_int_cst_equal (TREE_VALUE (values), t))
|
||||
break;
|
||||
|
||||
if (values)
|
||||
pp_tree_identifier (cxx_pp, TREE_PURPOSE (values));
|
||||
else
|
||||
{
|
||||
/* Value must have been cast. */
|
||||
pp_left_paren (cxx_pp);
|
||||
dump_type (type, flags);
|
||||
pp_right_paren (cxx_pp);
|
||||
pp_c_integer_literal (pp_c_base (cxx_pp), t);
|
||||
}
|
||||
}
|
||||
else
|
||||
pp_c_integer_literal (pp_c_base (cxx_pp), t);
|
||||
}
|
||||
break;
|
||||
|
||||
case STRING_CST:
|
||||
case REAL_CST:
|
||||
pp_c_real_literal (pp_c_base (cxx_pp), t);
|
||||
pp_c_constant (pp_c_base (cxx_pp), t);
|
||||
break;
|
||||
|
||||
case PTRMEM_CST:
|
||||
|
@ -1372,10 +1343,6 @@ dump_expr (tree t, int flags)
|
|||
pp_tree_identifier (cxx_pp, DECL_NAME (PTRMEM_CST_MEMBER (t)));
|
||||
break;
|
||||
|
||||
case STRING_CST:
|
||||
pp_c_string_literal (pp_c_base (cxx_pp), t);
|
||||
break;
|
||||
|
||||
case COMPOUND_EXPR:
|
||||
pp_left_paren (cxx_pp);
|
||||
dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
|
||||
|
|
|
@ -90,19 +90,6 @@ pp_clear_state (pretty_printer *pp)
|
|||
pp_indentation (pp) = 0;
|
||||
}
|
||||
|
||||
/* Insert enough spaces into the output area of PRETTY-PRINTER to bring
|
||||
the column position to the current indentation level, assuming that a
|
||||
newline has just been written to the buffer. */
|
||||
static void
|
||||
pp_indent (pretty_printer *pp)
|
||||
{
|
||||
int n = pp_indentation (pp);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n; ++i)
|
||||
pp_space (pp);
|
||||
}
|
||||
|
||||
/* Flush the formatted text of PRETTY-PRINTER onto the attached stream. */
|
||||
static inline void
|
||||
pp_write_text_to_stream (pretty_printer *pp)
|
||||
|
@ -164,6 +151,19 @@ pp_append_r (pretty_printer *pp, const char *start, int length)
|
|||
pp->buffer->line_length += length;
|
||||
}
|
||||
|
||||
/* Insert enough spaces into the output area of PRETTY-PRINTER to bring
|
||||
the column position to the current indentation level, assuming that a
|
||||
newline has just been written to the buffer. */
|
||||
void
|
||||
pp_base_indent (pretty_printer *pp)
|
||||
{
|
||||
int n = pp_indentation (pp);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n; ++i)
|
||||
pp_space (pp);
|
||||
}
|
||||
|
||||
/* Format a message pointed to by TEXT. The following format specifiers are
|
||||
recognized as being client independent:
|
||||
%d, %i: (signed) integer in base ten.
|
||||
|
@ -399,7 +399,7 @@ pp_base_emit_prefix (pretty_printer *pp)
|
|||
case DIAGNOSTICS_SHOW_PREFIX_ONCE:
|
||||
if (pp->emitted_prefix)
|
||||
{
|
||||
pp_indent (pp);
|
||||
pp_base_indent (pp);
|
||||
break;
|
||||
}
|
||||
pp_indentation (pp) += 3;
|
||||
|
|
|
@ -108,8 +108,6 @@ struct pretty_print_info
|
|||
|
||||
/* The prefix for each new line. */
|
||||
const char *prefix;
|
||||
|
||||
pp_flags flags;
|
||||
|
||||
/* Where to put whitespace around the entity being formatted. */
|
||||
pp_padding padding;
|
||||
|
@ -202,6 +200,8 @@ struct pretty_print_info
|
|||
do { \
|
||||
pp_indentation (PP) += N; \
|
||||
pp_newline (PP); \
|
||||
pp_base_indent (pp_base (PP)); \
|
||||
pp_needs_newline (PP) = false; \
|
||||
} while (0)
|
||||
#define pp_separate_with(PP, C) \
|
||||
do { \
|
||||
|
@ -251,6 +251,7 @@ extern void pp_base_flush (pretty_printer *);
|
|||
extern void pp_base_format_text (pretty_printer *, text_info *);
|
||||
extern void pp_base_format_verbatim (pretty_printer *, text_info *);
|
||||
|
||||
extern void pp_base_indent (pretty_printer *);
|
||||
extern void pp_base_newline (pretty_printer *);
|
||||
extern void pp_base_character (pretty_printer *, int);
|
||||
extern void pp_base_string (pretty_printer *, const char *);
|
||||
|
|
Loading…
Reference in New Issue