compiler: don't set btype_ too early for alias type
[official-gcc.git] / gcc / go / gofrontend / ast-dump.h
blob55c93693fe9131e1d0de9ece0d592571d0d22b6e
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.
7 #ifndef GO_AST_DUMP_H
8 #define GO_AST_DUMP_H
10 #include "string-dump.h"
12 class Expression;
13 class Expression_list;
14 class Named_object;
15 class Statement;
16 class Gogo;
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
23 public:
24 Ast_dump_context(std::ostream* out = NULL, bool dump_subblocks = true);
26 // Initialize the dump context.
27 void
28 dump(Gogo*, const char* basename);
30 // Dump spaces to dumpfile as indentation.
31 void
32 print_indent();
34 // Increase current indentation for print_indent().
35 void
36 indent()
37 { ++this->indent_;}
39 // Decrease current indentation for print_indent().
40 void
41 unindent()
42 { --this->indent_;}
44 // Whether subblocks should be dumped or not.
45 bool
46 dump_subblocks()
47 { return this->dump_subblocks_; }
49 // Get dump output stream.
50 std::ostream&
51 ostream()
52 { return *this->ostream_;}
54 // Dump a Block to dump file.
55 void
56 dump_block(Block*);
58 // Dump a type to dump file.
59 void
60 dump_type(const Type*);
62 // Dump an expression to dump file.
63 void
64 dump_expression(const Expression*);
66 // Dump an expression list to dump file.
67 void
68 dump_expression_list(const Expression_list*, bool as_pairs = false);
70 // Dump a typed identifier to dump file.
71 void
72 dump_typed_identifier(const Typed_identifier*);
74 // Dump a typed identifier list to dump file.
75 void
76 dump_typed_identifier_list(const Typed_identifier_list*);
78 // Dump temporary variable name to dump file.
79 void
80 dump_temp_variable_name(const Statement*);
82 // Dump unamed lable name to dump file.
83 void
84 dump_label_name(const Unnamed_label*);
86 // Dump operator symbol to dump file.
87 void
88 dump_operator(Operator);
90 // Implementation of String_dump interface.
91 void
92 write_c_string(const char*);
94 // Implements the String_dump interface.
95 void
96 write_string(const std::string& s);
98 // Dump statement to stream.
99 static void
100 dump_to_stream(const Statement*, std::ostream*);
102 // Dump expression to stream.
103 static void
104 dump_to_stream(const Expression* expr, std::ostream* out);
106 private:
107 // Current indent level.
108 int indent_;
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_;
119 Gogo* gogo_;
122 #endif // GO_AST_DUMP_H