1 // ast-dump.h -- AST debug dump. -*- C++ -*-
3 // Copyright 2011 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
10 #include "string-dump.h"
13 class Expression_list
;
18 // This class implements fgo-dump-ast. the
19 // Abstract syntax tree dump of the Go program.
21 class Ast_dump_context
: public String_dump
24 Ast_dump_context(std::ostream
* out
= NULL
, bool dump_subblocks
= true);
26 // Initialize the dump context.
28 dump(Gogo
*, const char* basename
);
30 // Dump spaces to dumpfile as indentation.
34 // Increase current indentation for print_indent().
39 // Decrease current indentation for print_indent().
44 // Whether subblocks should be dumped or not.
47 { return this->dump_subblocks_
; }
49 // Get dump output stream.
52 { return *this->ostream_
;}
54 // Dump a Block to dump file.
58 // Dump a type to dump file.
60 dump_type(const Type
*);
62 // Dump an expression to dump file.
64 dump_expression(const Expression
*);
66 // Dump an expression list to dump file.
68 dump_expression_list(const Expression_list
*, bool as_pairs
= false);
70 // Dump a typed identifier to dump file.
72 dump_typed_identifier(const Typed_identifier
*);
74 // Dump a typed identifier list to dump file.
76 dump_typed_identifier_list(const Typed_identifier_list
*);
78 // Dump temporary variable name to dump file.
80 dump_temp_variable_name(const Statement
*);
82 // Dump unamed lable name to dump file.
84 dump_label_name(const Unnamed_label
*);
86 // Dump operator symbol to dump file.
88 dump_operator(Operator
);
90 // Implementation of String_dump interface.
92 write_c_string(const char*);
94 // Implements the String_dump interface.
96 write_string(const std::string
& s
);
98 // Dump statement to stream.
100 dump_to_stream(const Statement
*, std::ostream
*);
102 // Dump expression to stream.
104 dump_to_stream(const Expression
* expr
, std::ostream
* out
);
107 // Current indent level.
110 // Indentation offset.
111 static const int offset_
;
113 // Whether subblocks of composite statements should be dumped or not.
114 bool dump_subblocks_
;
116 // Stream on output dump file.
117 std::ostream
* ostream_
;
122 #endif // GO_AST_DUMP_H