1 /* valaccodegenerator.vala
3 * Copyright (C) 2006-2009 Jürg Billeter
4 * Copyright (C) 2006-2008 Raffaele Sandrini
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * Jürg Billeter <j@bitron.ch>
22 * Raffaele Sandrini <raffaele@sandrini.ch>
29 * Code visitor generating C Code.
31 public class Vala
.CCodeGenerator
: CodeGenerator
{
32 public CCodeModule head
;
34 public CCodeGenerator () {
37 public override void emit (CodeContext context
) {
38 if (context
.profile
== Profile
.GOBJECT
) {
39 /* included by inheritance
40 head = new CCodeBaseModule (this, head);
41 head = new CCodeStructModule (this, head);
42 head = new CCodeMethodModule (this, head);
43 head = new CCodeControlFlowModule (this, head);
44 head = new CCodeMemberAccessModule (this, head);
45 head = new CCodeAssignmentModule (this, head);
46 head = new CCodeMethodCallModule (this, head);
47 head = new CCodeArrayModule (this, head);
48 head = new CCodeDelegateModule (this, head);
49 head = new GErrorModule (this, head);
50 head = new GTypeModule (this, head);
51 head = new GObjectModule (this, head);
52 head = new GSignalModule (this, head);
53 head = new GAsyncModule (this, head);
54 head = new DBusClientModule (this, head);
56 head
= new
DBusServerModule (this
, head
);
58 /* included by inheritance
59 head = new CCodeBaseModule (this, head);
60 head = new CCodeStructModule (this, head);
61 head = new CCodeMethodModule (this, head);
62 head = new CCodeControlFlowModule (this, head);
63 head = new CCodeMemberAccessModule (this, head);
64 head = new CCodeAssignmentModule (this, head);
65 head = new CCodeMethodCallModule (this, head);
66 head = new CCodeArrayModule (this, head);
68 head
= new
CCodeDelegateModule (this
, head
);
76 public override void visit_source_file (SourceFile source_file
) {
77 head
.visit_source_file (source_file
);
80 public override void visit_class (Class cl
) {
81 head
.visit_class (cl
);
84 public override void visit_interface (Interface iface
) {
85 head
.visit_interface (iface
);
88 public override void visit_struct (Struct st
) {
89 head
.visit_struct (st
);
92 public override void visit_enum (Enum en
) {
96 public override void visit_error_domain (ErrorDomain edomain
) {
97 head
.visit_error_domain (edomain
);
100 public override void visit_delegate (Delegate d
) {
101 head
.visit_delegate (d
);
104 public override void visit_member (Member m
) {
105 head
.visit_member (m
);
108 public override void visit_constant (Constant c
) {
109 head
.visit_constant (c
);
112 public override void visit_field (Field f
) {
113 head
.visit_field (f
);
116 public override void visit_method (Method m
) {
117 head
.visit_method (m
);
120 public override void visit_creation_method (CreationMethod m
) {
121 head
.visit_creation_method (m
);
124 public override void visit_formal_parameter (FormalParameter p
) {
125 head
.visit_formal_parameter (p
);
128 public override void visit_property (Property prop
) {
129 head
.visit_property (prop
);
132 public override void visit_property_accessor (PropertyAccessor acc
) {
133 head
.visit_property_accessor (acc
);
136 public override void visit_signal (Signal sig
) {
137 head
.visit_signal (sig
);
140 public override void visit_constructor (Constructor c
) {
141 head
.visit_constructor (c
);
144 public override void visit_destructor (Destructor d
) {
145 head
.visit_destructor (d
);
148 public override void visit_block (Block b
) {
149 head
.visit_block (b
);
152 public override void visit_empty_statement (EmptyStatement stmt
) {
153 head
.visit_empty_statement (stmt
);
156 public override void visit_declaration_statement (DeclarationStatement stmt
) {
157 head
.visit_declaration_statement (stmt
);
160 public override void visit_local_variable (LocalVariable local
) {
161 head
.visit_local_variable (local
);
164 public override void visit_initializer_list (InitializerList list
) {
165 head
.visit_initializer_list (list
);
168 public override void visit_end_full_expression (Expression expr
) {
169 head
.visit_end_full_expression (expr
);
172 public override void visit_expression_statement (ExpressionStatement stmt
) {
173 head
.visit_expression_statement (stmt
);
176 public override void visit_if_statement (IfStatement stmt
) {
177 head
.visit_if_statement (stmt
);
180 public override void visit_switch_statement (SwitchStatement stmt
) {
181 head
.visit_switch_statement (stmt
);
184 public override void visit_switch_section (SwitchSection section
) {
185 head
.visit_switch_section (section
);
188 public override void visit_switch_label (SwitchLabel label
) {
189 head
.visit_switch_label (label
);
192 public override void visit_loop (Loop stmt
) {
193 head
.visit_loop (stmt
);
196 public override void visit_foreach_statement (ForeachStatement stmt
) {
197 head
.visit_foreach_statement (stmt
);
200 public override void visit_break_statement (BreakStatement stmt
) {
201 head
.visit_break_statement (stmt
);
204 public override void visit_continue_statement (ContinueStatement stmt
) {
205 head
.visit_continue_statement (stmt
);
208 public override void visit_return_statement (ReturnStatement stmt
) {
209 head
.visit_return_statement (stmt
);
212 public override void visit_yield_statement (YieldStatement stmt
) {
213 head
.visit_yield_statement (stmt
);
216 public override void visit_throw_statement (ThrowStatement stmt
) {
217 head
.visit_throw_statement (stmt
);
220 public override void visit_try_statement (TryStatement stmt
) {
221 head
.visit_try_statement (stmt
);
224 public override void visit_catch_clause (CatchClause clause
) {
225 head
.visit_catch_clause (clause
);
228 public override void visit_lock_statement (LockStatement stmt
) {
229 head
.visit_lock_statement (stmt
);
232 public override void visit_delete_statement (DeleteStatement stmt
) {
233 head
.visit_delete_statement (stmt
);
236 public override void visit_expression (Expression expr
) {
237 head
.visit_expression (expr
);
240 public override void visit_array_creation_expression (ArrayCreationExpression expr
) {
241 head
.visit_array_creation_expression (expr
);
244 public override void visit_boolean_literal (BooleanLiteral expr
) {
245 head
.visit_boolean_literal (expr
);
248 public override void visit_character_literal (CharacterLiteral expr
) {
249 head
.visit_character_literal (expr
);
252 public override void visit_integer_literal (IntegerLiteral expr
) {
253 head
.visit_integer_literal (expr
);
256 public override void visit_real_literal (RealLiteral expr
) {
257 head
.visit_real_literal (expr
);
260 public override void visit_string_literal (StringLiteral expr
) {
261 head
.visit_string_literal (expr
);
264 public override void visit_null_literal (NullLiteral expr
) {
265 head
.visit_null_literal (expr
);
268 public override void visit_member_access (MemberAccess expr
) {
269 head
.visit_member_access (expr
);
272 public override void visit_method_call (MethodCall expr
) {
273 head
.visit_method_call (expr
);
276 public override void visit_element_access (ElementAccess expr
) {
277 head
.visit_element_access (expr
);
280 public override void visit_base_access (BaseAccess expr
) {
281 head
.visit_base_access (expr
);
284 public override void visit_postfix_expression (PostfixExpression expr
) {
285 head
.visit_postfix_expression (expr
);
288 public override void visit_object_creation_expression (ObjectCreationExpression expr
) {
289 head
.visit_object_creation_expression (expr
);
292 public override void visit_sizeof_expression (SizeofExpression expr
) {
293 head
.visit_sizeof_expression (expr
);
296 public override void visit_typeof_expression (TypeofExpression expr
) {
297 head
.visit_typeof_expression (expr
);
300 public override void visit_unary_expression (UnaryExpression expr
) {
301 head
.visit_unary_expression (expr
);
304 public override void visit_cast_expression (CastExpression expr
) {
305 head
.visit_cast_expression (expr
);
308 public override void visit_pointer_indirection (PointerIndirection expr
) {
309 head
.visit_pointer_indirection (expr
);
312 public override void visit_addressof_expression (AddressofExpression expr
) {
313 head
.visit_addressof_expression (expr
);
316 public override void visit_reference_transfer_expression (ReferenceTransferExpression expr
) {
317 head
.visit_reference_transfer_expression (expr
);
320 public override void visit_binary_expression (BinaryExpression expr
) {
321 head
.visit_binary_expression (expr
);
324 public override void visit_type_check (TypeCheck expr
) {
325 head
.visit_type_check (expr
);
328 public override void visit_lambda_expression (LambdaExpression l
) {
329 head
.visit_lambda_expression (l
);
332 public override void visit_assignment (Assignment a
) {
333 head
.visit_assignment (a
);