]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Use emit instead of accept and accept_children in code generator
authorJürg Billeter <j@bitron.ch>
Sat, 7 Aug 2010 14:50:40 +0000 (16:50 +0200)
committerJürg Billeter <j@bitron.ch>
Tue, 10 Aug 2010 07:02:53 +0000 (09:02 +0200)
80 files changed:
codegen/valaccodearraymodule.vala
codegen/valaccodeassignmentmodule.vala
codegen/valaccodebasemodule.vala
codegen/valaccodecontrolflowmodule.vala
codegen/valaccodememberaccessmodule.vala
codegen/valaccodemethodcallmodule.vala
codegen/valaccodemethodmodule.vala
codegen/valadbusclientmodule.vala
codegen/valadbusservermodule.vala
codegen/valadovaarraymodule.vala
codegen/valadovaassignmentmodule.vala
codegen/valadovabasemodule.vala
codegen/valadovacontrolflowmodule.vala
codegen/valadovaerrormodule.vala
codegen/valadovamemberaccessmodule.vala
codegen/valadovamethodcallmodule.vala
codegen/valadovaobjectmodule.vala
codegen/valadovavaluemodule.vala
codegen/valagasyncmodule.vala
codegen/valagdbusclientmodule.vala
codegen/valagdbusservermodule.vala
codegen/valagerrormodule.vala
codegen/valagobjectmodule.vala
codegen/valagsignalmodule.vala
vala/valaaddressofexpression.vala
vala/valaarraycreationexpression.vala
vala/valaassignment.vala
vala/valabaseaccess.vala
vala/valabinaryexpression.vala
vala/valablock.vala
vala/valabooleanliteral.vala
vala/valabreakstatement.vala
vala/valacastexpression.vala
vala/valacatchclause.vala
vala/valacharacterliteral.vala
vala/valacodegenerator.vala
vala/valacodenode.vala
vala/valacontinuestatement.vala
vala/valadeclarationstatement.vala
vala/valadeletestatement.vala
vala/valaelementaccess.vala
vala/valaemptystatement.vala
vala/valaexpressionstatement.vala
vala/valaforeachstatement.vala
vala/valaifstatement.vala
vala/valainitializerlist.vala
vala/valaintegerliteral.vala
vala/valalambdaexpression.vala
vala/valalistliteral.vala
vala/valalockstatement.vala
vala/valaloop.vala
vala/valamapliteral.vala
vala/valamemberaccess.vala
vala/valamemberinitializer.vala
vala/valamethodcall.vala
vala/valanamedargument.vala
vala/valanullliteral.vala
vala/valaobjectcreationexpression.vala
vala/valapointerindirection.vala
vala/valapostfixexpression.vala
vala/valarealliteral.vala
vala/valareferencetransferexpression.vala
vala/valaregexliteral.vala
vala/valareturnstatement.vala
vala/valasetliteral.vala
vala/valasizeofexpression.vala
vala/valasliceexpression.vala
vala/valastatementlist.vala
vala/valastringliteral.vala
vala/valaswitchlabel.vala
vala/valaswitchsection.vala
vala/valaswitchstatement.vala
vala/valathrowstatement.vala
vala/valatrystatement.vala
vala/valatuple.vala
vala/valatypecheck.vala
vala/valatypeofexpression.vala
vala/valaunaryexpression.vala
vala/valaunlockstatement.vala
vala/valayieldstatement.vala

index 21c9651aac4e4a794188440cfa69f02895da2394..c2c2daff040d6b1e85f803091893dfc650bf2a3d 100644 (file)
@@ -1,6 +1,6 @@
 /* valaccodearraymodule.vala
  *
- * Copyright (C) 2006-2009  Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
  * Copyright (C) 2006-2008  Raffaele Sandrini
  *
  * This library is free software; you can redistribute it and/or
@@ -43,8 +43,6 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
        }
 
        public override void visit_array_creation_expression (ArrayCreationExpression expr) {
-               expr.accept_children (codegen);
-
                var array_type = expr.target_type as ArrayType;
                if (array_type != null && array_type.fixed_length) {
                        // no heap allocation for fixed-length arrays
@@ -400,8 +398,6 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
        }
 
        public override void visit_element_access (ElementAccess expr) {
-               expr.accept_children (codegen);
-
                List<Expression> indices = expr.get_indices ();
                int rank = indices.size;
 
@@ -442,8 +438,6 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
        }
 
        public override void visit_slice_expression (SliceExpression expr) {
-               expr.accept_children (codegen);
-
                var ccontainer = (CCodeExpression) expr.container.ccodenode;
                var cstart = (CCodeExpression) expr.start.ccodenode;
                var cstop = (CCodeExpression) expr.stop.ccodenode;
@@ -1004,10 +998,6 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
                var array_type = (ArrayType) array.value_type;
                var element = binary.right;
 
-               array.accept (codegen);
-               element.target_type = array_type.element_type.copy ();
-               element.accept (codegen);
-
                var value_param = new FormalParameter ("value", element.target_type);
 
                var ccall = new CCodeFunctionCall (new CCodeIdentifier (generate_array_add_wrapper (array_type)));
index a4054de2beb9e67a463af545a8394901ee304d5d..1a9dca1b636c6a305927178e64694abdf7b7f0e9 100644 (file)
@@ -1,6 +1,6 @@
 /* valaccodeassignmentmodule.vala
  *
- * Copyright (C) 2006-2009  Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
  * Copyright (C) 2006-2008  Raffaele Sandrini
  *
  * This library is free software; you can redistribute it and/or
@@ -232,8 +232,6 @@ public class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
        }
 
        public override void visit_assignment (Assignment assignment) {
-               assignment.right.accept (codegen);
-
                if (assignment.left.error || assignment.right.error) {
                        assignment.error = true;
                        return;
index a30d6de530d4758db97c7ef1fb48d4179d3770e1..19e18c789896c539582fc0326f3ddc3eee82710b 100644 (file)
@@ -693,7 +693,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
                                        flag_shift += 1;
                                }
                        } else {
-                               ev.value.accept (codegen);
+                               ev.value.emit (codegen);
                                c_ev = new CCodeEnumValue (ev.get_cname (), (CCodeExpression) ev.value.ccodenode);
                        }
                        c_ev.deprecated = ev.deprecated;
@@ -782,11 +782,11 @@ public class Vala.CCodeBaseModule : CCodeModule {
                        return;
                }
 
-               c.accept_children (codegen);
-
                if (!c.external) {
                        generate_type_declaration (c.type_reference, decl_space);
 
+                       c.value.emit (codegen);
+
                        var initializer_list = c.value as InitializerList;
                        if (initializer_list != null) {
                                var cdecl = new CCodeDeclaration (c.type_reference.get_const_cname ());
@@ -916,7 +916,9 @@ public class Vala.CCodeBaseModule : CCodeModule {
 
                check_type (f.variable_type);
 
-               f.accept_children (codegen);
+               if (f.initializer != null) {
+                       f.initializer.emit (codegen);
+               }
 
                var cl = f.parent_symbol as Class;
                bool is_gtypeinstance = (cl != null && !cl.is_compact);
@@ -1366,7 +1368,13 @@ public class Vala.CCodeBaseModule : CCodeModule {
 
                bool returns_real_struct = acc.readable && prop.property_type.is_real_non_null_struct_type ();
 
-               acc.accept_children (codegen);
+               if (acc.result_var != null) {
+                       acc.result_var.accept (codegen);
+               }
+
+               if (acc.body != null) {
+                       acc.body.emit (codegen);
+               }
 
                var t = (TypeSymbol) prop.parent_symbol;
 
@@ -1612,7 +1620,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
                bool old_method_inner_error = current_method_inner_error;
                current_method_inner_error = false;
 
-               d.accept_children (codegen);
+               d.body.emit (codegen);
 
                if (d.binding == MemberBinding.STATIC && !in_plugin) {
                        Report.error (d.source_reference, "static destructors are only supported for dynamic types");
@@ -1707,7 +1715,9 @@ public class Vala.CCodeBaseModule : CCodeModule {
                var old_symbol = current_symbol;
                current_symbol = b;
 
-               b.accept_children (codegen);
+               foreach (Statement stmt in b.get_statements ()) {
+                       stmt.emit (codegen);
+               }
 
                var local_vars = b.get_local_variables ();
                foreach (LocalVariable local in local_vars) {
@@ -2003,7 +2013,11 @@ public class Vala.CCodeBaseModule : CCodeModule {
        public override void visit_local_variable (LocalVariable local) {
                check_type (local.variable_type);
 
-               local.accept_children (codegen);
+               if (local.initializer != null) {
+                       local.initializer.emit (codegen);
+
+                       visit_end_full_expression (local.initializer);
+               }
 
                generate_type_declaration (local.variable_type, source_declarations);
 
@@ -2212,8 +2226,6 @@ public class Vala.CCodeBaseModule : CCodeModule {
        }
 
        public override void visit_initializer_list (InitializerList list) {
-               list.accept_children (codegen);
-
                if (list.target_type.data_type is Struct) {
                        /* initializer is used as struct initializer */
                        var st = (Struct) list.target_type.data_type;
@@ -3164,8 +3176,6 @@ public class Vala.CCodeBaseModule : CCodeModule {
        }
 
        public override void visit_expression_statement (ExpressionStatement stmt) {
-               stmt.accept_children (codegen);
-
                if (stmt.expression.error) {
                        stmt.error = true;
                        return;
@@ -3317,7 +3327,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
                stmt.ccodenode = cfrag;
        }
 
-       public virtual bool variable_accessible_in_finally (LocalVariable local) {
+       public bool variable_accessible_in_finally (LocalVariable local) {
                if (current_try == null) {
                        return false;
                }
@@ -3338,23 +3348,6 @@ public class Vala.CCodeBaseModule : CCodeModule {
        }
 
        public override void visit_return_statement (ReturnStatement stmt) {
-               // avoid unnecessary ref/unref pair
-               if (stmt.return_expression != null) {
-                       var local = stmt.return_expression.symbol_reference as LocalVariable;
-                       if (current_return_type.value_owned
-                           && local != null && local.variable_type.value_owned
-                           && !local.captured
-                           && !variable_accessible_in_finally (local)) {
-                               /* return expression is local variable taking ownership and
-                                * current method is transferring ownership */
-
-                               // don't ref expression
-                               stmt.return_expression.value_type.value_owned = true;
-                       }
-               }
-
-               stmt.accept_children (codegen);
-
                Symbol return_expression_symbol = null;
 
                if (stmt.return_expression != null) {
@@ -3367,9 +3360,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
                                /* return expression is local variable taking ownership and
                                 * current method is transferring ownership */
 
-                               // don't unref variable
                                return_expression_symbol = local;
-                               return_expression_symbol.active = false;
                        }
                }
 
@@ -3540,8 +3531,6 @@ public class Vala.CCodeBaseModule : CCodeModule {
        }
 
        public override void visit_delete_statement (DeleteStatement stmt) {
-               stmt.accept_children (codegen);
-
                var pointer_type = (PointerType) stmt.expression.value_type;
                DataType type = pointer_type;
                if (pointer_type.base_type.data_type != null && pointer_type.base_type.data_type.is_reference_type ()) {
@@ -4140,8 +4129,6 @@ public class Vala.CCodeBaseModule : CCodeModule {
        }
 
        public override void visit_object_creation_expression (ObjectCreationExpression expr) {
-               expr.accept_children (codegen);
-
                CCodeExpression instance = null;
                CCodeExpression creation_expr = null;
 
@@ -4298,7 +4285,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
                                /* evaluate default expression here as the code
                                 * generator might not have visited the formal
                                 * parameter yet */
-                               param.initializer.accept (codegen);
+                               param.initializer.emit (codegen);
                        
                                carg_map.set (get_param_pos (param.cparameter_position), (CCodeExpression) param.initializer.ccodenode);
                                i++;
@@ -4483,8 +4470,6 @@ public class Vala.CCodeBaseModule : CCodeModule {
        }
 
        public override void visit_unary_expression (UnaryExpression expr) {
-               expr.accept_children (codegen);
-
                CCodeUnaryOperator op;
                if (expr.operator == UnaryOperator.PLUS) {
                        op = CCodeUnaryOperator.PLUS;
@@ -4675,8 +4660,6 @@ public class Vala.CCodeBaseModule : CCodeModule {
        }
        
        public override void visit_named_argument (NamedArgument expr) {
-               expr.accept_children (codegen);
-
                expr.ccodenode = expr.inner.ccodenode;
        }
 
@@ -4697,8 +4680,6 @@ public class Vala.CCodeBaseModule : CCodeModule {
        }
 
        public override void visit_reference_transfer_expression (ReferenceTransferExpression expr) {
-               expr.accept_children (codegen);
-
                /* (tmp = var, var = null, tmp) */
                var ccomma = new CCodeCommaExpression ();
                var temp_decl = get_temp_variable (expr.value_type, true, expr, false);
@@ -4712,8 +4693,6 @@ public class Vala.CCodeBaseModule : CCodeModule {
        }
 
        public override void visit_binary_expression (BinaryExpression expr) {
-               expr.accept_children (codegen);
-
                var cleft = (CCodeExpression) expr.left.ccodenode;
                var cright = (CCodeExpression) expr.right.ccodenode;
 
@@ -5587,7 +5566,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 
        public CCodeNode? get_ccodenode (CodeNode node) {
                if (node.ccodenode == null) {
-                       node.accept (codegen);
+                       node.emit (codegen);
                }
                return node.ccodenode;
        }
index 8132c9d6e5e81936b59ebae75f0b905dfd3439ef..b6d9ca537510ec7d632e1447d3959b2d5b4d94a3 100644 (file)
@@ -30,7 +30,10 @@ public class Vala.CCodeControlFlowModule : CCodeMethodModule {
        }
 
        public override void visit_if_statement (IfStatement stmt) {
-               stmt.accept_children (codegen);
+               stmt.true_statement.emit (codegen);
+               if (stmt.false_statement != null) {
+                       stmt.false_statement.emit (codegen);
+               }
 
                if (stmt.false_statement != null) {
                        stmt.ccodenode = new CCodeIfStatement ((CCodeExpression) stmt.condition.ccodenode, (CCodeStatement) stmt.true_statement.ccodenode, (CCodeStatement) stmt.false_statement.ccodenode);
@@ -189,7 +192,9 @@ public class Vala.CCodeControlFlowModule : CCodeMethodModule {
        }
 
        public override void visit_switch_statement (SwitchStatement stmt) {
-               stmt.accept_children (codegen);
+               foreach (SwitchSection section in stmt.get_sections ()) {
+                       section.emit (codegen);
+               }
 
                if (stmt.expression.value_type.compatible (string_type)) {
                        visit_string_switch_statement (stmt);
@@ -220,16 +225,16 @@ public class Vala.CCodeControlFlowModule : CCodeMethodModule {
                create_temp_decl (stmt, stmt.expression.temp_vars);
        }
 
-       public override void visit_switch_section (SwitchSection section) {
-               visit_block (section);
-       }
-
        public override void visit_switch_label (SwitchLabel label) {
-               label.accept_children (codegen);
+               if (label.expression != null) {
+                       label.expression.emit (codegen);
+
+                       codegen.visit_end_full_expression (label.expression);
+               }
        }
 
        public override void visit_loop (Loop stmt) {
-               stmt.accept_children (codegen);
+               stmt.body.emit (codegen);
 
                if (context.profile == Profile.GOBJECT) {
                        stmt.ccodenode = new CCodeWhileStatement (new CCodeConstant ("TRUE"), (CCodeStatement) stmt.body.ccodenode);
@@ -240,11 +245,7 @@ public class Vala.CCodeControlFlowModule : CCodeMethodModule {
        }
 
        public override void visit_foreach_statement (ForeachStatement stmt) {
-               stmt.element_variable.active = true;
-               stmt.collection_variable.active = true;
-               if (stmt.iterator_variable != null) {
-                       stmt.iterator_variable.active = true;
-               }
+               stmt.body.emit (codegen);
 
                visit_block (stmt);
 
index 52ea34daf88d3ce8597040038aa5feaf46512b72..6e8ff0c638b12783ec4733c621882044ce111a8b 100644 (file)
@@ -30,8 +30,6 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
        }
 
        public override void visit_member_access (MemberAccess expr) {
-               expr.accept_children (codegen);
-
                CCodeExpression pub_inst = null;
                DataType base_type = null;
        
@@ -368,6 +366,20 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
                                expr.ccodenode = new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (get_block_id (block))), get_variable_cname (local.name));
                        } else {
                                expr.ccodenode = get_variable_cexpression (local.name);
+
+                               if (expr.parent_node is ReturnStatement &&
+                                   current_return_type.value_owned &&
+                                   local.variable_type.value_owned &&
+                                   !variable_accessible_in_finally (local)) {
+                                       /* return expression is local variable taking ownership and
+                                        * current method is transferring ownership */
+
+                                       // don't ref expression
+                                       expr.value_type.value_owned = true;
+
+                                       // don't unref variable
+                                       local.active = false;
+                               }
                        }
                } else if (expr.symbol_reference is FormalParameter) {
                        var p = (FormalParameter) expr.symbol_reference;
index 2f2306bac33366f6618ee74f02d31aa649286cb7..c1187003ef81ed37df81229814427020f87fc5b1 100644 (file)
@@ -30,8 +30,6 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
        }
 
        public override void visit_method_call (MethodCall expr) {
-               expr.accept_children (codegen);
-
                // the bare function call
                var ccall = new CCodeFunctionCall ((CCodeExpression) expr.call.ccodenode);
 
index 2bf57854b99494aebaa2164bd0006bf270308154..71836cf350327dc67c94482fdaf07067e63a2866 100644 (file)
@@ -316,7 +316,29 @@ public class Vala.CCodeMethodModule : CCodeStructModule {
                if (m.binding == MemberBinding.CLASS || m.binding == MemberBinding.STATIC) {
                        in_static_or_class_context = true;
                }
-               m.accept_children (codegen);
+
+
+               foreach (FormalParameter param in m.get_parameters ()) {
+                       param.accept (codegen);
+               }
+
+               if (m.result_var != null) {
+                       m.result_var.accept (codegen);
+               }
+
+               foreach (Expression precondition in m.get_preconditions ()) {
+                       precondition.emit (codegen);
+               }
+
+               foreach (Expression postcondition in m.get_postconditions ()) {
+                       postcondition.emit (codegen);
+               }
+
+               if (m.body != null) {
+                       m.body.emit (codegen);
+               }
+
+
                in_static_or_class_context = false;
 
                if (m is CreationMethod) {
index cb9ff5d5f40bcb6a385a8cb7e0a353022e512b6d..9593ff62641aacc9d0d01a256005570ebf23136b 100644 (file)
@@ -927,11 +927,11 @@ public class Vala.DBusClientModule : DBusModule {
                Expression object_path = args.get (1);
 
                var ccall = new CCodeFunctionCall (new CCodeIdentifier (type.type_symbol.get_lower_case_cprefix () + "dbus_proxy_new"));
-               connection.accept (codegen);
+               connection.emit (codegen);
                ccall.add_argument ((CCodeExpression) connection.ccodenode);
-               bus_name.accept (codegen);
+               bus_name.emit (codegen);
                ccall.add_argument ((CCodeExpression) bus_name.ccodenode);
-               object_path.accept (codegen);
+               object_path.emit (codegen);
                ccall.add_argument ((CCodeExpression) object_path.ccodenode);
                expr.ccodenode = ccall;
        }
@@ -1413,11 +1413,11 @@ public class Vala.DBusClientModule : DBusModule {
                if (proxy_get_all) {
                        var ma = expr.call as MemberAccess;
                        var instance = ma.inner;
-                       instance.accept (codegen);
+                       instance.emit (codegen);
 
                        var args = expr.get_argument_list ();
                        Expression interface_name = args.get (0);
-                       interface_name.accept (codegen);
+                       interface_name.emit (codegen);
 
                        var ccall = new CCodeFunctionCall (new CCodeIdentifier (generate_get_all_function (mtype.method_symbol)));
                        ccall.add_argument ((CCodeExpression) instance.ccodenode);
@@ -1441,7 +1441,7 @@ public class Vala.DBusClientModule : DBusModule {
                quark_call.add_argument (new CCodeConstant ("\"ValaDBusInterfaceProxyType\""));
 
                var qdata_call = new CCodeFunctionCall (new CCodeIdentifier ("g_type_get_qdata"));
-               type.accept (codegen);
+               type.emit (codegen);
                qdata_call.add_argument ((CCodeExpression) type.ccodenode);
                qdata_call.add_argument (quark_call);
 
@@ -1450,16 +1450,16 @@ public class Vala.DBusClientModule : DBusModule {
                var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_object_new"));
                ccall.add_argument (get_type_call);
                ccall.add_argument (new CCodeConstant ("\"connection\""));
-               connection.accept (codegen);
+               connection.emit (codegen);
                ccall.add_argument ((CCodeExpression) connection.ccodenode);
                ccall.add_argument (new CCodeConstant ("\"name\""));
-               bus_name.accept (codegen);
+               bus_name.emit (codegen);
                ccall.add_argument ((CCodeExpression) bus_name.ccodenode);
                ccall.add_argument (new CCodeConstant ("\"path\""));
-               object_path.accept (codegen);
+               object_path.emit (codegen);
                ccall.add_argument ((CCodeExpression) object_path.ccodenode);
                ccall.add_argument (new CCodeConstant ("\"interface\""));
-               interface_name.accept (codegen);
+               interface_name.emit (codegen);
                ccall.add_argument ((CCodeExpression) interface_name.ccodenode);
                ccall.add_argument (new CCodeConstant ("NULL"));
                expr.ccodenode = ccall;
index 54f6474dcca776aca02c5b322b1ce61e2886ca16..a872303042034509829682afb6ee8981e6cdb0fd 100644 (file)
@@ -1637,8 +1637,6 @@ public class Vala.DBusServerModule : DBusClientModule {
 
                add_dbus_helpers ();
 
-               expr.accept_children (codegen);
-
                var ma = (MemberAccess) expr.call;
 
                var raw_conn = new CCodeFunctionCall (new CCodeIdentifier ("dbus_g_connection_get_connection"));
index d8b4e51ea8d6ec84ae85de6c1ce6148ecc0826ed..c532d174e495e2d6311dbe3f41c67b729a8b01f1 100644 (file)
@@ -33,8 +33,6 @@ internal class Vala.DovaArrayModule : DovaMethodCallModule {
        }
 
        public override void visit_array_creation_expression (ArrayCreationExpression expr) {
-               expr.accept_children (codegen);
-
                var array_type = expr.target_type as ArrayType;
                if (array_type != null && array_type.fixed_length) {
                        // no heap allocation for fixed-length arrays
@@ -67,8 +65,6 @@ internal class Vala.DovaArrayModule : DovaMethodCallModule {
        }
 
        public override void visit_element_access (ElementAccess expr) {
-               expr.accept_children (codegen);
-
                List<Expression> indices = expr.get_indices ();
 
                var ccontainer = (CCodeExpression) expr.container.ccodenode;
index 17fcfc563451481880b68a04cd7f13d9fffcfb86..f1667de6c755474c52ec6b06fa9c9a2b507cba13 100644 (file)
@@ -175,8 +175,6 @@ internal class Vala.DovaAssignmentModule : DovaMemberAccessModule {
        }
 
        public override void visit_assignment (Assignment assignment) {
-               assignment.right.accept (codegen);
-
                if (assignment.left.error || assignment.right.error) {
                        assignment.error = true;
                        return;
index 79a8198e8c68cab48e64bb4666e9265e18becd36..cbb85c62ec62e37aa02c875a0e2f76f10c62e5c3 100644 (file)
@@ -376,7 +376,7 @@ internal class Vala.DovaBaseModule : CCodeModule {
                        if (ev.value == null) {
                                cenum.add_value (new CCodeEnumValue (ev.get_cname ()));
                        } else {
-                               ev.value.accept (codegen);
+                               ev.value.emit (codegen);
                                cenum.add_value (new CCodeEnumValue (ev.get_cname (), (CCodeExpression) ev.value.ccodenode));
                        }
                }
@@ -400,9 +400,9 @@ internal class Vala.DovaBaseModule : CCodeModule {
                        return;
                }
 
-               c.accept_children (codegen);
-
                if (!c.external) {
+                       c.value.emit (codegen);
+
                        if (c.value is InitializerList) {
                                var cdecl = new CCodeDeclaration (c.type_reference.get_const_cname ());
                                var arr = "";
@@ -456,7 +456,9 @@ internal class Vala.DovaBaseModule : CCodeModule {
        }
 
        public override void visit_field (Field f) {
-               f.accept_children (codegen);
+               if (f.initializer != null) {
+                       f.initializer.emit (codegen);
+               }
 
                var cl = f.parent_symbol as Class;
 
@@ -591,7 +593,6 @@ internal class Vala.DovaBaseModule : CCodeModule {
        }
 
        public override void visit_formal_parameter (FormalParameter p) {
-               p.accept_children (codegen);
        }
 
        public override void visit_property (Property prop) {
@@ -656,7 +657,7 @@ internal class Vala.DovaBaseModule : CCodeModule {
        }
 
        public override void visit_destructor (Destructor d) {
-               d.accept_children (codegen);
+               d.body.emit (codegen);
 
                CCodeFragment cfrag = new CCodeFragment ();
 
@@ -707,7 +708,9 @@ internal class Vala.DovaBaseModule : CCodeModule {
                var old_symbol = current_symbol;
                current_symbol = b;
 
-               b.accept_children (codegen);
+               foreach (Statement stmt in b.get_statements ()) {
+                       stmt.emit (codegen);
+               }
 
                var local_vars = b.get_local_variables ();
                foreach (LocalVariable local in local_vars) {
@@ -954,7 +957,11 @@ internal class Vala.DovaBaseModule : CCodeModule {
        }
 
        public override void visit_local_variable (LocalVariable local) {
-               local.accept_children (codegen);
+               if (local.initializer != null) {
+                       local.initializer.emit (codegen);
+
+                       visit_end_full_expression (local.initializer);
+               }
 
                generate_type_declaration (local.variable_type, source_declarations);
 
@@ -999,8 +1006,6 @@ internal class Vala.DovaBaseModule : CCodeModule {
        }
 
        public override void visit_initializer_list (InitializerList list) {
-               list.accept_children (codegen);
-
                if (list.target_type.data_type is Struct) {
                        /* initializer is used as struct initializer */
                        var st = (Struct) list.target_type.data_type;
@@ -1310,8 +1315,6 @@ internal class Vala.DovaBaseModule : CCodeModule {
        }
 
        public override void visit_expression_statement (ExpressionStatement stmt) {
-               stmt.accept_children (codegen);
-
                if (stmt.expression.error) {
                        stmt.error = true;
                        return;
@@ -1467,8 +1470,6 @@ internal class Vala.DovaBaseModule : CCodeModule {
        }
 
        public override void visit_return_statement (ReturnStatement stmt) {
-               stmt.accept_children (codegen);
-
                var cfrag = new CCodeFragment ();
 
                // free local variables
@@ -1480,8 +1481,6 @@ internal class Vala.DovaBaseModule : CCodeModule {
        }
 
        public override void visit_delete_statement (DeleteStatement stmt) {
-               stmt.accept_children (codegen);
-
                var pointer_type = (PointerType) stmt.expression.value_type;
                DataType type = pointer_type;
                if (pointer_type.base_type.data_type != null && pointer_type.base_type.data_type.is_reference_type ()) {
@@ -1744,8 +1743,6 @@ internal class Vala.DovaBaseModule : CCodeModule {
        }
 
        public override void visit_object_creation_expression (ObjectCreationExpression expr) {
-               expr.accept_children (codegen);
-
                CCodeExpression instance = null;
                CCodeExpression creation_expr = null;
 
@@ -1837,7 +1834,7 @@ internal class Vala.DovaBaseModule : CCodeModule {
                                /* evaluate default expression here as the code
                                 * generator might not have visited the formal
                                 * parameter yet */
-                               param.initializer.accept (codegen);
+                               param.initializer.emit (codegen);
 
                                creation_call.add_argument ((CCodeExpression) param.initializer.ccodenode);
                                i++;
@@ -1944,8 +1941,6 @@ internal class Vala.DovaBaseModule : CCodeModule {
        }
 
        public override void visit_unary_expression (UnaryExpression expr) {
-               expr.accept_children (codegen);
-
                CCodeUnaryOperator op;
                if (expr.operator == UnaryOperator.PLUS) {
                        op = CCodeUnaryOperator.PLUS;
@@ -2036,8 +2031,6 @@ internal class Vala.DovaBaseModule : CCodeModule {
        }
 
        public override void visit_reference_transfer_expression (ReferenceTransferExpression expr) {
-               expr.accept_children (codegen);
-
                /* (tmp = var, var = null, tmp) */
                var ccomma = new CCodeCommaExpression ();
                var temp_decl = get_temp_variable (expr.value_type, true, expr);
@@ -2051,8 +2044,6 @@ internal class Vala.DovaBaseModule : CCodeModule {
        }
 
        public override void visit_binary_expression (BinaryExpression expr) {
-               expr.accept_children (codegen);
-
                var cleft = (CCodeExpression) expr.left.ccodenode;
                var cright = (CCodeExpression) expr.right.ccodenode;
 
@@ -2441,7 +2432,7 @@ internal class Vala.DovaBaseModule : CCodeModule {
 
        public CCodeNode? get_ccodenode (CodeNode node) {
                if (node.ccodenode == null) {
-                       node.accept (codegen);
+                       node.emit (codegen);
                }
                return node.ccodenode;
        }
index ab142cb85a639452e79be090bd865ed8dc71cb7d..f75368c30698f0bad31d3b857d70e1171b150137 100644 (file)
@@ -26,7 +26,10 @@ internal class Vala.DovaControlFlowModule : DovaMethodModule {
        }
 
        public override void visit_if_statement (IfStatement stmt) {
-               stmt.accept_children (codegen);
+               stmt.true_statement.emit (codegen);
+               if (stmt.false_statement != null) {
+                       stmt.false_statement.emit (codegen);
+               }
 
                if (stmt.false_statement != null) {
                        stmt.ccodenode = new CCodeIfStatement ((CCodeExpression) stmt.condition.ccodenode, (CCodeStatement) stmt.true_statement.ccodenode, (CCodeStatement) stmt.false_statement.ccodenode);
@@ -38,7 +41,9 @@ internal class Vala.DovaControlFlowModule : DovaMethodModule {
        }
 
        public override void visit_switch_statement (SwitchStatement stmt) {
-               stmt.accept_children (codegen);
+               foreach (SwitchSection section in stmt.get_sections ()) {
+                       section.emit (codegen);
+               }
 
                var cswitch = new CCodeSwitchStatement ((CCodeExpression) stmt.expression.ccodenode);
                stmt.ccodenode = cswitch;
@@ -68,16 +73,16 @@ internal class Vala.DovaControlFlowModule : DovaMethodModule {
                create_temp_decl (stmt, stmt.expression.temp_vars);
        }
 
-       public override void visit_switch_section (SwitchSection section) {
-               visit_block (section);
-       }
-
        public override void visit_switch_label (SwitchLabel label) {
-               label.accept_children (codegen);
+               if (label.expression != null) {
+                       label.expression.emit (codegen);
+
+                       codegen.visit_end_full_expression (label.expression);
+               }
        }
 
        public override void visit_loop (Loop stmt) {
-               stmt.accept_children (codegen);
+               stmt.body.emit (codegen);
 
                stmt.ccodenode = new CCodeWhileStatement (new CCodeConstant ("true"), (CCodeStatement) stmt.body.ccodenode);
        }
index 13c6936078a99eb11c173bc5f7ba372abe9a273f..ecee398e3d7ffcc41f4d4c9dbb418171fcf08a2a 100644 (file)
@@ -33,8 +33,6 @@ internal class Vala.DovaErrorModule : DovaDelegateModule {
        }
 
        public override void visit_throw_statement (ThrowStatement stmt) {
-               stmt.accept_children (codegen);
-
                var cfrag = new CCodeFragment ();
 
                // method will fail
@@ -242,15 +240,15 @@ internal class Vala.DovaErrorModule : DovaDelegateModule {
                }
 
                if (stmt.finally_body != null) {
-                       stmt.finally_body.accept (codegen);
+                       stmt.finally_body.emit (codegen);
                }
 
                is_in_catch = false;
-               stmt.body.accept (codegen);
+               stmt.body.emit (codegen);
                is_in_catch = true;
 
                foreach (CatchClause clause in stmt.get_catch_clauses ()) {
-                       clause.accept (codegen);
+                       clause.emit (codegen);
                }
 
                current_try = old_try;
@@ -278,13 +276,9 @@ internal class Vala.DovaErrorModule : DovaDelegateModule {
        }
 
        public override void visit_catch_clause (CatchClause clause) {
-               if (clause.error_variable != null) {
-                       clause.error_variable.active = true;
-               }
-
                generate_type_declaration (clause.error_type, source_declarations);
 
-               clause.accept_children (codegen);
+               clause.body.emit (codegen);
 
                var cfrag = new CCodeFragment ();
                cfrag.append (new CCodeLabel (clause.clabel_name));
index 3785932bba73e7eec03b617e2fc0ec8f602d2663..58fb664d8dfca5b38ec8b72062ffa10ebd3b6664 100644 (file)
@@ -28,8 +28,6 @@ internal class Vala.DovaMemberAccessModule : DovaControlFlowModule {
        }
 
        public override void visit_member_access (MemberAccess expr) {
-               expr.accept_children (codegen);
-
                CCodeExpression pub_inst = null;
                DataType base_type = null;
 
index ed4d571339269ae80d9d4177b952c9a8afabd9a7..aab0f3b47dd929919c2167f4973f6ab85839cc12 100644 (file)
@@ -26,8 +26,6 @@ internal class Vala.DovaMethodCallModule : DovaAssignmentModule {
        }
 
        public override void visit_method_call (MethodCall expr) {
-               expr.accept_children (codegen);
-
                // the bare function call
                var ccall = new CCodeFunctionCall ((CCodeExpression) expr.call.ccodenode);
 
index 175a176ff80a63342491dd39aad47e4128597ebc..ed1f9334f4fc39945e98e8f1180bfa027a85fc3b 100644 (file)
@@ -1144,7 +1144,13 @@ internal class Vala.DovaObjectModule : DovaArrayModule {
 
                var prop = (Property) acc.prop;
 
-               acc.accept_children (codegen);
+               if (acc.result_var != null) {
+                       acc.result_var.accept (codegen);
+               }
+
+               if (acc.body != null) {
+                       acc.body.emit (codegen);
+               }
 
                // do not declare overriding properties and interface implementations
                if (prop.is_abstract || prop.is_virtual
@@ -1383,7 +1389,27 @@ internal class Vala.DovaObjectModule : DovaArrayModule {
                variable_name_map = new HashMap<string,string> (str_hash, str_equal);
                current_try = null;
 
-               m.accept_children (codegen);
+
+               foreach (FormalParameter param in m.get_parameters ()) {
+                       param.accept (codegen);
+               }
+
+               if (m.result_var != null) {
+                       m.result_var.accept (codegen);
+               }
+
+               foreach (Expression precondition in m.get_preconditions ()) {
+                       precondition.emit (codegen);
+               }
+
+               foreach (Expression postcondition in m.get_postconditions ()) {
+                       postcondition.emit (codegen);
+               }
+
+               if (m.body != null) {
+                       m.body.emit (codegen);
+               }
+
 
                current_symbol = old_symbol;
                next_temp_var_id = old_next_temp_var_id;
index cabf73b6f1671f1c8e7fed16d27706c5d73f1dce..ac3b6141e5fb4cddeb47eab82e39daa0eceec2ad 100644 (file)
@@ -539,8 +539,6 @@ internal class Vala.DovaValueModule : DovaObjectModule {
        }
 
        public override void visit_list_literal (ListLiteral expr) {
-               expr.accept_children (codegen);
-
                var ce = new CCodeCommaExpression ();
                int length = expr.get_expressions ().size;
 
@@ -575,8 +573,6 @@ internal class Vala.DovaValueModule : DovaObjectModule {
        }
 
        public override void visit_set_literal (SetLiteral expr) {
-               expr.accept_children (codegen);
-
                var ce = new CCodeCommaExpression ();
                int length = expr.get_expressions ().size;
 
@@ -611,8 +607,6 @@ internal class Vala.DovaValueModule : DovaObjectModule {
        }
 
        public override void visit_map_literal (MapLiteral expr) {
-               expr.accept_children (codegen);
-
                var key_ce = new CCodeCommaExpression ();
                var value_ce = new CCodeCommaExpression ();
                int length = expr.get_keys ().size;
@@ -661,8 +655,6 @@ internal class Vala.DovaValueModule : DovaObjectModule {
        }
 
        public override void visit_tuple (Tuple tuple) {
-               tuple.accept_children (codegen);
-
                var type_array_type = new ArrayType (new PointerType (new VoidType ()), 1, tuple.source_reference);
                type_array_type.inline_allocated = true;
                type_array_type.fixed_length = true;
index 9be065710dca505adc53bd4cbf7e06d0908ff8b4..c2c1fd9b557cc2e86008cee1f4bccbadee99b919 100644 (file)
@@ -576,8 +576,6 @@ public class Vala.GAsyncModule : GSignalModule {
                        return;
                }
 
-               stmt.accept_children (codegen);
-
                if (stmt.yield_expression.error) {
                        stmt.error = true;
                        return;
index cd4a0ff02cb5a18b25649ca7d951cd306a5efe7d..6e19674a1178068dd5437480679a1d80eed9d794 100644 (file)
@@ -263,19 +263,19 @@ public class Vala.GDBusClientModule : GDBusModule {
 
                var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_initable_new"));
                ccall.add_argument (new CCodeIdentifier ("%s_PROXY".printf (iface.get_type_id ())));
-               cancellable.accept (codegen);
+               cancellable.emit (codegen);
                ccall.add_argument ((CCodeExpression) cancellable.ccodenode);
                ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_variable_cexpression ("_inner_error_")));
                ccall.add_argument (new CCodeConstant ("\"g-flags\""));
                ccall.add_argument (new CCodeConstant ("G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES"));
                ccall.add_argument (new CCodeConstant ("\"g-name\""));
-               name.accept (codegen);
+               name.emit (codegen);
                ccall.add_argument ((CCodeExpression) name.ccodenode);
                ccall.add_argument (new CCodeConstant ("\"g-bus-type\""));
-               bus_type.accept (codegen);
+               bus_type.emit (codegen);
                ccall.add_argument ((CCodeExpression) bus_type.ccodenode);
                ccall.add_argument (new CCodeConstant ("\"g-object-path\""));
-               object_path.accept (codegen);
+               object_path.emit (codegen);
                ccall.add_argument ((CCodeExpression) object_path.ccodenode);
                ccall.add_argument (new CCodeConstant ("\"g-interface-name\""));
                ccall.add_argument (new CCodeConstant ("\"%s\"".printf (get_dbus_name (iface))));
index 2680a86815c1a0fe4ed97f0c93d94acaeb0f8082..a5760e797a7622c1578a915428c561ab454dbecf 100644 (file)
@@ -1030,8 +1030,6 @@ public class Vala.GDBusServerModule : GDBusClientModule {
                        return;
                }
 
-               expr.accept_children (codegen);
-
                var ma = (MemberAccess) expr.call;
                var type_arg = (ObjectType) ma.get_type_arguments ().get (0);
 
index b86cfa6765f7e211252e6ed204cf6671d2b1046d..deca24bd6c2ae0c83ba472334c323f4888adf081 100644 (file)
@@ -1,6 +1,6 @@
 /* valagerrormodule.vala
  *
- * Copyright (C) 2008-2009  Jürg Billeter
+ * Copyright (C) 2008-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -43,7 +43,7 @@ public class Vala.GErrorModule : CCodeDelegateModule {
                        if (ecode.value == null) {
                                cenum.add_value (new CCodeEnumValue (ecode.get_cname ()));
                        } else {
-                               ecode.value.accept (codegen);
+                               ecode.value.emit (codegen);
                                cenum.add_value (new CCodeEnumValue (ecode.get_cname (), (CCodeExpression) ecode.value.ccodenode));
                        }
                }
@@ -85,8 +85,6 @@ public class Vala.GErrorModule : CCodeDelegateModule {
        }
 
        public override void visit_throw_statement (ThrowStatement stmt) {
-               stmt.accept_children (codegen);
-
                var cfrag = new CCodeFragment ();
 
                // method will fail
@@ -333,15 +331,15 @@ public class Vala.GErrorModule : CCodeDelegateModule {
                }
 
                if (stmt.finally_body != null) {
-                       stmt.finally_body.accept (codegen);
+                       stmt.finally_body.emit (codegen);
                }
 
                is_in_catch = false;
-               stmt.body.accept (codegen);
+               stmt.body.emit (codegen);
                is_in_catch = true;
 
                foreach (CatchClause clause in stmt.get_catch_clauses ()) {
-                       clause.accept (codegen);
+                       clause.emit (codegen);
                }
 
                current_try = old_try;
@@ -369,10 +367,6 @@ public class Vala.GErrorModule : CCodeDelegateModule {
        }
 
        public override void visit_catch_clause (CatchClause clause) {
-               if (clause.error_variable != null) {
-                       clause.error_variable.active = true;
-               }
-
                current_method_inner_error = true;
 
                var error_type = (ErrorType) clause.error_type;
@@ -380,7 +374,7 @@ public class Vala.GErrorModule : CCodeDelegateModule {
                        generate_error_domain_declaration (error_type.error_domain, source_declarations);
                }
 
-               clause.accept_children (codegen);
+               clause.body.emit (codegen);
 
                var cfrag = new CCodeFragment ();
                cfrag.append (new CCodeLabel (clause.clabel_name));
index d1c2eea29fc3074c6c9b43d09223cf2208858edb..d6ce29d1301e3e16dba02b5441a890507bcf5c46 100644 (file)
@@ -458,7 +458,7 @@ public class Vala.GObjectModule : GTypeModule {
                } else {
                        in_constructor = true;
                }
-               c.accept_children (codegen);
+               c.body.emit (codegen);
                in_static_or_class_context = false;
 
                in_constructor = false;
index d62b30d8d514715a3a6314562451815bdc6eec63..8d09f301eca9934c6af699ca539028f86bc57c71 100644 (file)
@@ -1,6 +1,6 @@
 /* valagsignalmodule.vala
  *
- * Copyright (C) 2006-2009  Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
  * Copyright (C) 2006-2008  Raffaele Sandrini
  *
  * This library is free software; you can redistribute it and/or
@@ -460,7 +460,6 @@ public class Vala.GSignalModule : GObjectModule {
                        // detailed signal emission
                        var sig = (Signal) expr.symbol_reference;
                        var ma = (MemberAccess) expr.container;
-                       expr.accept_children (codegen);
 
                        var detail_expr = expr.get_indices ().get (0) as StringLiteral;
                        string signal_detail = detail_expr.eval ();
@@ -504,8 +503,6 @@ public class Vala.GSignalModule : GObjectModule {
 
        public override void visit_assignment (Assignment assignment) {
                if (assignment.left.symbol_reference is Signal) {
-                       assignment.right.accept (codegen);
-
                        if (assignment.left.error || assignment.right.error) {
                                assignment.error = true;
                                return;
@@ -519,8 +516,6 @@ public class Vala.GSignalModule : GObjectModule {
 
        public override void visit_member_access (MemberAccess expr) {
                if (expr.symbol_reference is Signal) {
-                       expr.accept_children (codegen);
-
                        CCodeExpression pub_inst = null;
        
                        if (expr.inner != null) {
@@ -571,9 +566,6 @@ public class Vala.GSignalModule : GObjectModule {
                var signal_access = ((MemberAccess) expr.call).inner;
                var handler = expr.get_argument_list ().get (0);
 
-               signal_access.accept (codegen);
-               handler.accept (codegen);
-
                bool disconnect = (method_type.method_symbol.name == "disconnect");
                bool after = (method_type.method_symbol.name == "connect_after");
 
index ad00968d8a982696c6138633dac992c4a2612d7c..c6804d6d88ea36648a68c5b2604bac2835416201 100644 (file)
@@ -1,6 +1,6 @@
 /* valaaddressofexpression.vala
  *
- * Copyright (C) 2007-2008  Jürg Billeter
+ * Copyright (C) 2007-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -98,4 +98,12 @@ public class Vala.AddressofExpression : Expression {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               inner.emit (codegen);
+
+               codegen.visit_addressof_expression (this);
+
+               codegen.visit_expression (this);
+       }
 }
index 80f4367cbad988e9c8584a76c811ae2ce5a91021..d8d0f2c087fd81f6ef03cb08f914d75e07e7ac00 100644 (file)
@@ -244,4 +244,18 @@ public class Vala.ArrayCreationExpression : Expression {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               foreach (Expression e in sizes) {
+                       e.emit (codegen);
+               }
+
+               if (initializer_list != null) {
+                       initializer_list.emit (codegen);
+               }
+
+               codegen.visit_array_creation_expression (this);
+
+               codegen.visit_expression (this);
+       }
 }
index bcbe96a21353f64fbfa5fae1039dbf95ab456a03..3f7e592413a1cb11739ddbad9f7e2f4fdf80ffca 100644 (file)
@@ -443,6 +443,37 @@ public class Vala.Assignment : Expression {
                return !error;
        }
 
+       public override void emit (CodeGenerator codegen) {
+               var ma = left as MemberAccess;
+               var ea = left as ElementAccess;
+               var pi = left as PointerIndirection;
+               if (ma != null) {
+                       var field = ma.symbol_reference as Field;
+                       var property = ma.symbol_reference as Property;
+
+                       bool instance = (field != null && field.binding == MemberBinding.INSTANCE)
+                               || (property != null && property.binding == MemberBinding.INSTANCE);
+
+                       if (instance) {
+                               ma.inner.emit (codegen);
+                       }
+               } else if (ea != null) {
+                       ea.container.emit (codegen);
+
+                       foreach (var index in ea.get_indices ()) {
+                               index.emit (codegen);
+                       }
+               } else if (pi != null) {
+                       pi.inner.emit (codegen);
+               }
+
+               right.emit (codegen);
+
+               codegen.visit_assignment (this);
+
+               codegen.visit_expression (this);
+       }
+
        public override void get_defined_variables (Collection<LocalVariable> collection) {
                right.get_defined_variables (collection);
                left.get_defined_variables (collection);
index b434f568b9e28f04658a81ed4209baaeac289e2b..e03baf7723b31204ade9e56ed4f20f0de623bbef 100644 (file)
@@ -90,4 +90,10 @@ public class Vala.BaseAccess : Expression {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               codegen.visit_base_access (this);
+
+               codegen.visit_expression (this);
+       }
 }
index f2652f956cb92191efb952fb2af536bff2e703d0..ccbdf07d6bf632f2cbb5135c19b7b98824e5abb6 100644 (file)
@@ -306,6 +306,8 @@ public class Vala.BinaryExpression : Expression {
                                return false;
                        }
 
+                       right.target_type = array_type.element_type.copy ();
+
                        value_type = array_type.copy ();
                        value_type.value_owned = true;
                } else if (operator == BinaryOperator.PLUS
@@ -486,6 +488,15 @@ public class Vala.BinaryExpression : Expression {
                return !error;
        }
 
+       public override void emit (CodeGenerator codegen) {
+               left.emit (codegen);
+               right.emit (codegen);
+
+               codegen.visit_binary_expression (this);
+
+               codegen.visit_expression (this);
+       }
+
        public override void get_defined_variables (Collection<LocalVariable> collection) {
                left.get_defined_variables (collection);
                right.get_defined_variables (collection);
index 5b570a75444a589d2d63b8e92539c8954bfa1b67..64cbfaab73f05009a1a49c8c9f25c268a62da4c2 100644 (file)
@@ -154,6 +154,10 @@ public class Vala.Block : Symbol, Statement {
                return !error;
        }
 
+       public override void emit (CodeGenerator codegen) {
+               codegen.visit_block (this);
+       }
+
        public void insert_before (Statement stmt, Statement new_stmt) {
                for (int i = 0; i < statement_list.size; i++) {
                        var stmt_list = statement_list[i] as StatementList;
index bf0842fba097f546740c6053103ec917d9f9fe44..e0279447fc0fb238c67418ff7fa6ca61dd7f6c97 100644 (file)
@@ -1,6 +1,6 @@
 /* valabooleanliteral.vala
  *
- * Copyright (C) 2006-2008  Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -72,4 +72,10 @@ public class Vala.BooleanLiteral : Literal {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               codegen.visit_boolean_literal (this);
+
+               codegen.visit_expression (this);
+       }
 }
index 97e93df09dba0e78981891c203ec5b382c7831eb..3f69c851f71764ce1e0dceb7f902ac95c6de1590 100644 (file)
@@ -1,6 +1,6 @@
 /* valabreakstatement.vala
  *
- * Copyright (C) 2006-2007  Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -39,4 +39,8 @@ public class Vala.BreakStatement : CodeNode, Statement {
        public override void accept (CodeVisitor visitor) {
                visitor.visit_break_statement (this);
        }
+
+       public override void emit (CodeGenerator codegen) {
+               codegen.visit_break_statement (this);
+       }
 }
index a17f09f3285fbbec9b2b6c54dc06029e34658518..536fe1490d273f0ac62944c0389345639f4db9de 100644 (file)
@@ -147,6 +147,14 @@ public class Vala.CastExpression : Expression {
                return !error;
        }
 
+       public override void emit (CodeGenerator codegen) {
+               inner.emit (codegen);
+
+               codegen.visit_cast_expression (this);
+
+               codegen.visit_expression (this);
+       }
+
        public override void get_defined_variables (Collection<LocalVariable> collection) {
                inner.get_defined_variables (collection);
        }
index efe71d0766759523f81da258afdccb994907a408..b6d742eab9e877bdce7033cf085d3c68bfd08b4d 100644 (file)
@@ -1,6 +1,6 @@
 /* valacatchclause.vala
  *
- * Copyright (C) 2007-2009  Jürg Billeter
+ * Copyright (C) 2007-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -139,6 +139,14 @@ public class Vala.CatchClause : CodeNode {
                return !error;
        }
 
+       public override void emit (CodeGenerator codegen) {
+               if (error_variable != null) {
+                       error_variable.active = true;
+               }
+
+               codegen.visit_catch_clause (this);
+       }
+
        public override void get_defined_variables (Collection<LocalVariable> collection) {
                if (error_variable != null) {
                        collection.add (error_variable);
index c69eeb5e4825779310aaa69039f1e059b430d553..0de991872de2ae53b642fa42f347dd4b9a2d0a57 100644 (file)
@@ -102,4 +102,10 @@ public class Vala.CharacterLiteral : Literal {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               codegen.visit_character_literal (this);
+
+               codegen.visit_expression (this);
+       }
 }
index 43ce9011fec0ae4d462e4c3b3b990a86148ecf4c..39442abf972ef24aaa2a014b1b4684aefc1ea06b 100644 (file)
@@ -1,6 +1,6 @@
 /* valacodegenerator.vala
  *
- * Copyright (C) 2007-2008  Jürg Billeter
+ * Copyright (C) 2007-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -20,8 +20,6 @@
  *     Jürg Billeter <j@bitron.ch>
  */
 
-using GLib;
-
 /**
  * Abstract code visitor generating code.
  */
index f3ae4a4b8b17df4fa462d285660a147176716e5a..4b0584d7b869a2b0560fd9fd0e95e24da85c6e44 100644 (file)
@@ -145,6 +145,9 @@ public abstract class Vala.CodeNode {
                return true;
        }
 
+       public virtual void emit (CodeGenerator codegen) {
+       }
+
        public virtual void replace_type (DataType old_type, DataType new_type) {
        }
 
index 8ca4111c8fbfdec041c0064bd4a862f0dbdc72d6..1de109dbf726a0a5ae42c718aaa567231c74771e 100644 (file)
@@ -1,6 +1,6 @@
 /* valacontinuestatement.vala
  *
- * Copyright (C) 2006-2007  Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -39,4 +39,8 @@ public class Vala.ContinueStatement : CodeNode, Statement {
        public override void accept (CodeVisitor visitor) {
                visitor.visit_continue_statement (this);
        }
+
+       public override void emit (CodeGenerator codegen) {
+               codegen.visit_continue_statement (this);
+       }
 }
index 344000e62745a633f4991d2a0077bce30eb4cbb0..51d80fc00f76e1ce0c2cc1504242e880d7294636 100644 (file)
@@ -1,6 +1,6 @@
 /* valadeclarationstatement.vala
  *
- * Copyright (C) 2006-2009  Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -85,6 +85,10 @@ public class Vala.DeclarationStatement : CodeNode, Statement {
                return !error;
        }
 
+       public override void emit (CodeGenerator codegen) {
+               codegen.visit_declaration_statement (this);
+       }
+
        public override void get_defined_variables (Collection<LocalVariable> collection) {
                var local = declaration as LocalVariable;
                if (local != null) {
index e9840843764c269e27efbc449538a33527291517..ce76bfd4262ab30d5327097edc2744ca41121d30 100644 (file)
@@ -1,6 +1,6 @@
 /* valadeletestatement.vala
  *
- * Copyright (C) 2008  Jürg Billeter
+ * Copyright (C) 2008-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -20,8 +20,6 @@
  *     Jürg Billeter <j@bitron.ch>
  */
 
-using GLib;
-
 /**
  * Represents a delete statement e.g. "delete a".
  */
@@ -63,4 +61,10 @@ public class Vala.DeleteStatement : CodeNode, Statement {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               expression.emit (codegen);
+
+               codegen.visit_delete_statement (this);
+       }
 }
index 3622a1ddc4f56ec465407bfd5bba98e42e26a56d..42c386fdcd0b75c7b4c29db82c9b9ad606569d63 100644 (file)
@@ -234,6 +234,17 @@ public class Vala.ElementAccess : Expression {
                return !error;
        }
 
+       public override void emit (CodeGenerator codegen) {
+               container.emit (codegen);
+               foreach (Expression e in indices) {
+                       e.emit (codegen);
+               }
+
+               codegen.visit_element_access (this);
+
+               codegen.visit_expression (this);
+       }
+
        public override void get_defined_variables (Collection<LocalVariable> collection) {
                container.get_defined_variables (collection);
                foreach (Expression index in indices) {
index 8b6826d0ed6f73ff86433dedf2e52b8deded5900..1cc6ae0aa03540949263b8e2f68426b9f8aed2ad 100644 (file)
@@ -1,6 +1,6 @@
 /* valaemptystatement.vala
  *
- * Copyright (C) 2006-2007  Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -39,4 +39,8 @@ public class Vala.EmptyStatement : CodeNode, Statement {
        public override void accept (CodeVisitor visitor) {
                visitor.visit_empty_statement (this);
        }
+
+       public override void emit (CodeGenerator codegen) {
+               codegen.visit_empty_statement (this);
+       }
 }
index 50d0debc949a0d88a7930f538524d980f2a35b0e..c6450c01b9e2df255820700bb2e29381f4caa82d 100644 (file)
@@ -85,6 +85,12 @@ public class Vala.ExpressionStatement : CodeNode, Statement {
                return !error;
        }
 
+       public override void emit (CodeGenerator codegen) {
+               expression.emit (codegen);
+
+               codegen.visit_expression_statement (this);
+       }
+
        public override void get_defined_variables (Collection<LocalVariable> collection) {
                expression.get_defined_variables (collection);
        }
index 07a38dbec1551d34ca4772ff05dc5e7cc77b93d1..bc0cf3d079451c4f94bc2ec382e2dc16746303cf 100644 (file)
@@ -348,6 +348,24 @@ public class Vala.ForeachStatement : Block {
                return !error;
        }
 
+       public override void emit (CodeGenerator codegen) {
+               if (use_iterator) {
+                       base.emit (codegen);
+                       return;
+               }
+
+               collection.emit (codegen);
+               codegen.visit_end_full_expression (collection);
+
+               element_variable.active = true;
+               collection_variable.active = true;
+               if (iterator_variable != null) {
+                       iterator_variable.active = true;
+               }
+
+               codegen.visit_foreach_statement (this);
+       }
+
        public override void get_defined_variables (Collection<LocalVariable> collection) {
                collection.add (element_variable);
        }
index 0804bb466339f2804a240bac296e8ed582d12f94..8cb1bac292f1b5bc7d0ce951dd0945e404632c44 100644 (file)
@@ -139,4 +139,12 @@ public class Vala.IfStatement : CodeNode, Statement {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               condition.emit (codegen);
+
+               codegen.visit_end_full_expression (condition);
+
+               codegen.visit_if_statement (this);
+       }
 }
index c415ff2182f16450989f3219ca5099d1e12b1b5b..5028caf27110ae8115a46241a9ba594161e60dc5 100644 (file)
@@ -1,6 +1,6 @@
 /* valainitializerlist.vala
  *
- * Copyright (C) 2006-2009  Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
  * Copyright (C) 2006-2008  Raffaele Sandrini
  *
  * This library is free software; you can redistribute it and/or
@@ -198,4 +198,12 @@ public class Vala.InitializerList : Expression {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               foreach (Expression expr in initializers) {
+                       expr.emit (codegen);
+               }
+
+               codegen.visit_initializer_list (this);
+       }
 }
index 815c4e308413a8d543f20fc7eeafd355b202f214..297eb3e4266d65e7286a8712b10743018a039e96 100644 (file)
@@ -131,4 +131,10 @@ public class Vala.IntegerLiteral : Literal {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               codegen.visit_integer_literal (this);
+
+               codegen.visit_expression (this);
+       }
 }
index 34130d47bea35cb5211ce528d54603a34d496a05..d71c4b55c967776f8044bb9c92a1d44d70d9c5a3 100644 (file)
@@ -235,6 +235,12 @@ public class Vala.LambdaExpression : Expression {
                return !error;
        }
 
+       public override void emit (CodeGenerator codegen) {
+               codegen.visit_lambda_expression (this);
+
+               codegen.visit_expression (this);
+       }
+
        public override void get_used_variables (Collection<LocalVariable> collection) {
                // require captured variables to be initialized
                if (method.closure) {
index bee7431ccafebe4feaa9fb18433c1a934bae1c38..f816550cbfbe63a8dcad2bf9813449e9da5abe2a 100644 (file)
@@ -115,4 +115,14 @@ public class Vala.ListLiteral : Literal {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               foreach (Expression expr in expression_list) {
+                       expr.emit (codegen);
+               }
+
+               codegen.visit_list_literal (this);
+
+               codegen.visit_expression (this);
+       }
 }
index da9a0be94706d70b4a95c029744f8371669c1c83..39ad4e049aa324eec63435dacafbdb293809dbae 100644 (file)
@@ -1,7 +1,8 @@
 /* valalockstatement.vala
  *
  * Copyright (C) 2009  Jiří Zárevúcky
- * Copyright (C) 2006-2007  Raffaele Sandrini, Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
+ * Copyright (C) 2006-2007  Raffaele Sandrini
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -100,4 +101,9 @@ public class Vala.LockStatement : CodeNode, Statement {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               resource.emit (codegen);
+               codegen.visit_lock_statement (this);
+       }
 }
index a0281e9cd1cf1a80ea2b430367efc2a091f917e5..e73174d7b5d11236dab11edada1a24ba6a68d121 100644 (file)
@@ -1,6 +1,6 @@
 /* valaloop.vala
  *
- * Copyright (C) 2009  Jürg Billeter
+ * Copyright (C) 2009-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -74,5 +74,9 @@ public class Vala.Loop : CodeNode, Statement {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               codegen.visit_loop (this);
+       }
 }
 
index 677a5db3d4157abd1e881b979b59db2aab36f0e3..9d4fe10640c7bfb0a83750c611fe8756a19c2585 100644 (file)
@@ -125,4 +125,15 @@ public class Vala.MapLiteral : Literal {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               for (int i = 0; i < keys.size; i++) {
+                       keys[i].emit (codegen);
+                       values[i].emit (codegen);
+               }
+
+               codegen.visit_map_literal (this);
+
+               codegen.visit_expression (this);
+       }
 }
index bc9717ff0ff3f77ded631f8c97e90d7754f31de5..443e67b4d638fd895aa99d1554a5d286d2467047 100644 (file)
@@ -784,6 +784,16 @@ public class Vala.MemberAccess : Expression {
                return !error;
        }
 
+       public override void emit (CodeGenerator codegen) {
+               if (inner != null) {
+                       inner.emit (codegen);
+               }
+
+               codegen.visit_member_access (this);
+
+               codegen.visit_expression (this);
+       }
+
        public override void get_defined_variables (Collection<LocalVariable> collection) {
                if (inner != null) {
                        inner.get_defined_variables (collection);
index 2057e3181de6029396e6eaafe5c1f34401d8f60d..afcb230e4d3a538551c691ac30fca8ff94a73a68 100644 (file)
@@ -1,6 +1,6 @@
 /* valamemberinitializer.vala
  *
- * Copyright (C) 2007-2009  Jürg Billeter
+ * Copyright (C) 2007-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -72,6 +72,10 @@ public class Vala.MemberInitializer : CodeNode {
                return initializer.check (analyzer);
        }
 
+       public override void emit (CodeGenerator codegen) {
+               initializer.emit (codegen);
+       }
+
        public override void replace_expression (Expression old_node, Expression new_node) {
                if (initializer == old_node) {
                        initializer = new_node;
index af41a66a73951607655f66e5183a28963be0b7b0..a493c56cd0c7feda28d3bbd5af80bbf8a0cb13a8 100644 (file)
@@ -706,6 +706,25 @@ public class Vala.MethodCall : Expression {
                return !error;
        }
 
+       public override void emit (CodeGenerator codegen) {
+               var method_type = call.value_type as MethodType;
+
+               if (method_type != null && method_type.method_symbol.parent_symbol is Signal) {
+                       var signal_access = ((MemberAccess) call).inner;
+                       signal_access.emit (codegen);
+               } else {
+                       call.emit (codegen);
+               }
+
+               foreach (Expression expr in argument_list) {
+                       expr.emit (codegen);
+               }
+
+               codegen.visit_method_call (this);
+
+               codegen.visit_expression (this);
+       }
+
        public override void get_defined_variables (Collection<LocalVariable> collection) {
                call.get_defined_variables (collection);
 
index f758fbb48c7b1fce0603a2178114cc23d463ddc6..6b676498282b2ec17e7d9d5a46e979d381864f00 100644 (file)
@@ -81,6 +81,14 @@ public class Vala.NamedArgument : Expression {
                return !error;
        }
 
+       public override void emit (CodeGenerator codegen) {
+               inner.emit (codegen);
+
+               codegen.visit_named_argument (this);
+
+               codegen.visit_expression (this);
+       }
+
        public override void get_defined_variables (Collection<LocalVariable> collection) {
                inner.get_defined_variables (collection);
        }
index a82217dc5305ef3031ce72aab537d527e6fb7617..94be504d199a67748c8839e340d691e139aae40a 100644 (file)
@@ -1,6 +1,6 @@
 /* valanullliteral.vala
  *
- * Copyright (C) 2006-2008  Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -61,4 +61,10 @@ public class Vala.NullLiteral : Literal {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               codegen.visit_null_literal (this);
+
+               codegen.visit_expression (this);
+       }
 }
index 1a3ecc79b2e37e9032035b4ff30cd68732fd75bb..d7cc00822e3a388f4ea3ce5da441416d0e745508 100644 (file)
@@ -429,6 +429,20 @@ public class Vala.ObjectCreationExpression : Expression {
                return !error;
        }
 
+       public override void emit (CodeGenerator codegen) {
+               foreach (Expression arg in argument_list) {
+                       arg.emit (codegen);
+               }
+
+               foreach (MemberInitializer init in object_initializer) {
+                       init.emit (codegen);
+               }
+
+               codegen.visit_object_creation_expression (this);
+
+               codegen.visit_expression (this);
+       }
+
        public override void get_defined_variables (Collection<LocalVariable> collection) {
                foreach (Expression arg in argument_list) {
                        arg.get_defined_variables (collection);
index fa5b7596fc64194a1b81d37eb261386bfcbb7211..17295e4a57a9ce3ab9e2274593873ff5eba4ef0e 100644 (file)
@@ -1,6 +1,6 @@
 /* valapointerindirection.vala
  *
- * Copyright (C) 2007-2008  Jürg Billeter
+ * Copyright (C) 2007-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -101,6 +101,14 @@ public class Vala.PointerIndirection : Expression {
                return !error;
        }
 
+       public override void emit (CodeGenerator codegen) {
+               inner.emit (codegen);
+
+               codegen.visit_pointer_indirection (this);
+
+               codegen.visit_expression (this);
+       }
+
        public override void get_defined_variables (Collection<LocalVariable> collection) {
                inner.get_defined_variables (collection);
        }
index b9d6af13f1680050d524274c2eee51846aa47c42..ee531510e2ce80e3c2c9b914ea50822f780726c6 100644 (file)
@@ -1,6 +1,6 @@
 /* valapostfixexpression.vala
  *
- * Copyright (C) 2006-2009  Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -125,4 +125,12 @@ public class Vala.PostfixExpression : Expression {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               inner.emit (codegen);
+
+               codegen.visit_postfix_expression (this);
+
+               codegen.visit_expression (this);
+       }
 }
index bd4c19a41ed04a5027aac3439027e9f0be9f471a..f45560f9fe3ea9c68d5a05b215d8a8b343700592 100644 (file)
@@ -85,4 +85,10 @@ public class Vala.RealLiteral : Literal {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               codegen.visit_real_literal (this);
+
+               codegen.visit_expression (this);
+       }
 }
index e09d06b3884db310bd60b56a0fe1cc9dc656dfa6..945593fb79032ce96cfc81d7c94d15c4171f4a14 100644 (file)
@@ -1,6 +1,6 @@
 /* valareferencetransferexpression.vala
  *
- * Copyright (C) 2007-2008  Jürg Billeter
+ * Copyright (C) 2007-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -115,6 +115,14 @@ public class Vala.ReferenceTransferExpression : Expression {
                return !error;
        }
 
+       public override void emit (CodeGenerator codegen) {
+               inner.emit (codegen);
+
+               codegen.visit_reference_transfer_expression (this);
+
+               codegen.visit_expression (this);
+       }
+
        public override void get_defined_variables (Collection<LocalVariable> collection) {
                inner.get_defined_variables (collection);
        }
index eb1edd53acd5523f47bbad232ade83d0993a1077..8e4cdc62bc5db63b1ceb0cb667201b3a060b7413 100644 (file)
@@ -1,6 +1,7 @@
 /* valaregexliteral.vala
  *
  * Copyright (C) 2010  Jukka-Pekka Iivonen
+ * Copyright (C) 2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -85,5 +86,11 @@ public class Vala.RegexLiteral : Literal {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               codegen.visit_regex_literal (this);
+
+               codegen.visit_expression (this);
+       }
 }
 
index 399ca696ef9fa7e3f1938384e1d6e879d0c69d03..b8b2e83232b13260228f9751ba441121ba84c959 100644 (file)
@@ -1,6 +1,6 @@
 /* valareturnstatement.vala
  *
- * Copyright (C) 2006-2009  Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -148,6 +148,16 @@ public class Vala.ReturnStatement : CodeNode, Statement {
                return !error;
        }
 
+       public override void emit (CodeGenerator codegen) {
+               if (return_expression != null) {
+                       return_expression.emit (codegen);
+
+                       codegen.visit_end_full_expression (return_expression);
+               }
+
+               codegen.visit_return_statement (this);
+       }
+
        public override void get_defined_variables (Collection<LocalVariable> collection) {
                if (return_expression != null) {
                        return_expression.get_defined_variables (collection);
index fdbb44ff8841ae36eaf3d669d3a6a0aafdace54b..42be178d594c9d656171b3dfba5f8c4963e08d83 100644 (file)
@@ -99,4 +99,14 @@ public class Vala.SetLiteral : Literal {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               foreach (Expression expr in expression_list) {
+                       expr.emit (codegen);
+               }
+
+               codegen.visit_set_literal (this);
+
+               codegen.visit_expression (this);
+       }
 }
index 57866e3ba5893d101aec1eacff8ff06866f48d84..d7b2c04ab2696ee6425cf70a40ed4eba3eb8737c 100644 (file)
@@ -1,6 +1,6 @@
 /* valasizeofexpression.vala
  *
- * Copyright (C) 2006-2009  Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -82,4 +82,10 @@ public class Vala.SizeofExpression : Expression {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               codegen.visit_sizeof_expression (this);
+
+               codegen.visit_expression (this);
+       }
 }
index 7713f738d5b16cd7cb1c673d266223ed0d8508a6..77c574397219c856d1c0203d7110e7e5e4e1fb78 100644 (file)
@@ -1,7 +1,7 @@
 /* valasliceexpression.vala
  *
  * Copyright (C) 2009 Robin Sonefors
- * Copyright (C) 2009 Jürg Billeter
+ * Copyright (C) 2009-2010 Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -163,6 +163,17 @@ public class Vala.SliceExpression : Expression {
                return !error;
        }
 
+       public override void emit (CodeGenerator codegen) {
+               container.emit (codegen);
+
+               start.emit (codegen);
+               stop.emit (codegen);
+
+               codegen.visit_slice_expression (this);
+
+               codegen.visit_expression (this);
+       }
+
        public override void get_defined_variables (Collection<LocalVariable> collection) {
                container.get_defined_variables (collection);
                start.get_defined_variables (collection);
index 91d9d9325eaeea48c72db4c9638315b38e4b48e3..934227a1a7485f1e9d712b29fedee5cc9a5cbb44 100644 (file)
@@ -1,6 +1,6 @@
 /* valastatementlist.vala
  *
- * Copyright (C) 2008  Jürg Billeter
+ * Copyright (C) 2008-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -53,4 +53,10 @@ public class Vala.StatementList : CodeNode, Statement {
                        stmt.accept (visitor);
                }
        }
+
+       public override void emit (CodeGenerator codegen) {
+               foreach (Statement stmt in list) {
+                       stmt.emit (codegen);
+               }
+       }
 }
index 318c2189e60a785089fa608c620ef2e0666326e0..2a1cbc79f4d0153474ceadc88654f620b1bfdf99 100644 (file)
@@ -88,4 +88,10 @@ public class Vala.StringLiteral : Literal {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               codegen.visit_string_literal (this);
+
+               codegen.visit_expression (this);
+       }
 }
index 67fcdc25ed41de70b0531aea84ad7974b708287e..2a15d96c0706aff991c15355ecfdf21e222a87e1 100644 (file)
@@ -1,6 +1,6 @@
 /* valaswitchlabel.vala
  *
- * Copyright (C) 2006-2009  Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -86,4 +86,8 @@ public class Vala.SwitchLabel : CodeNode {
 
                return true;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               codegen.visit_switch_label (this);
+       }
 }
index 944035c24080dfb8f575b54847222e0a987345de..c8faae5649e7c2434b9c254d0741a2facefcaed1 100644 (file)
@@ -117,4 +117,12 @@ public class Vala.SwitchSection : Block {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               foreach (SwitchLabel label in labels) {
+                       label.emit (codegen);
+               }
+
+               base.emit (codegen);
+       }
 }
index be38a296406c66833740fc413ed10faa3841b8a6..1fbcb164900b440538a90e6df569e8fdfcf0a4ff 100644 (file)
@@ -140,4 +140,12 @@ public class Vala.SwitchStatement : CodeNode, Statement {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               expression.emit (codegen);
+
+               codegen.visit_end_full_expression (expression);
+
+               codegen.visit_switch_statement (this);
+       }
 }
index f9465407295f2f4d4033b8ab69b017a8a4e5c7b9..444df3cd99fece04afec79130b30cdb3af7e09f6 100644 (file)
@@ -113,6 +113,16 @@ public class Vala.ThrowStatement : CodeNode, Statement {
                return !error;
        }
 
+       public override void emit (CodeGenerator codegen) {
+               if (error_expression != null) {
+                       error_expression.emit (codegen);
+
+                       codegen.visit_end_full_expression (error_expression);
+               }
+
+               codegen.visit_throw_statement (this);
+       }
+
        public override void get_defined_variables (Collection<LocalVariable> collection) {
                error_expression.get_defined_variables (collection);
        }
index 540af3e059fcdfff34c189a818b828b976365820..e5d3b2e2b1456615f76c3b16e53dc67a95fa9ef0 100644 (file)
@@ -147,4 +147,8 @@ public class Vala.TryStatement : CodeNode, Statement {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               codegen.visit_try_statement (this);
+       }
 }
index 75d22c4f790845abbcf921c2e593074de8d075cf..2fcc45d2d8624e65421bbe77e07599f43ed8ba07 100644 (file)
@@ -89,4 +89,14 @@ public class Vala.Tuple : Expression {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               foreach (Expression expr in expression_list) {
+                       expr.emit (codegen);
+               }
+
+               codegen.visit_tuple (this);
+
+               codegen.visit_expression (this);
+       }
 }
index 7097ab877b2acc926f3530e8414749ba77af0725..4e002dc080baf633897e07cd4ba2f08a748e57a4 100644 (file)
@@ -1,6 +1,6 @@
 /* valatypecheck.vala
  *
- * Copyright (C) 2006-2009  Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -112,4 +112,12 @@ public class Vala.TypeCheck : Expression {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               expression.emit (codegen);
+
+               codegen.visit_type_check (this);
+
+               codegen.visit_expression (this);
+       }
 }
index 99d9145e3d5ba401fd2cb2ba87542fd590c5ea79..2a31ec098fa7d5404d9f06b11d1ac61363ed02a3 100644 (file)
@@ -1,6 +1,6 @@
 /* valatypeofexpression.vala
  *
- * Copyright (C) 2006-2009  Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -82,4 +82,10 @@ public class Vala.TypeofExpression : Expression {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               codegen.visit_typeof_expression (this);
+
+               codegen.visit_expression (this);
+       }
 }
index d2d38ddd5379c547d0ead3c8fe76197f6d919019..c137cb2f3272ce9713c26bba4198e706a4b4b378 100644 (file)
@@ -234,6 +234,14 @@ public class Vala.UnaryExpression : Expression {
                return !error;
        }
 
+       public override void emit (CodeGenerator codegen) {
+               inner.emit (codegen);
+
+               codegen.visit_unary_expression (this);
+
+               codegen.visit_expression (this);
+       }
+
        public override void get_defined_variables (Collection<LocalVariable> collection) {
                inner.get_defined_variables (collection);
                if (operator == UnaryOperator.OUT || operator == UnaryOperator.REF) {
index e0ae1a034e6e85822dd96e8468989b139158fa5d..f86295582726074651284f31b7d815e496f03556 100644 (file)
@@ -1,6 +1,7 @@
 /* valaunlockstatement.vala
  *
- * Copyright (C) 2009  Jiří Zárevúcky, Jürg Billeter
+ * Copyright (C) 2009-2010  Jürg Billeter
+ * Copyright (C) 2009  Jiří Zárevúcky
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -67,4 +68,9 @@ public class Vala.UnlockStatement : CodeNode, Statement {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               resource.emit (codegen);
+               codegen.visit_unlock_statement (this);
+       }
 }
index ca4d0d6fb159e858625936d883d4213be37aaf20..be526a1dea6152e11b7fcc69015fb2d020f8d4d4 100644 (file)
@@ -1,6 +1,6 @@
 /* valayieldstatement.vala
  *
- * Copyright (C) 2008  Jürg Billeter
+ * Copyright (C) 2008-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -77,5 +77,15 @@ public class Vala.YieldStatement : CodeNode, Statement {
 
                return !error;
        }
+
+       public override void emit (CodeGenerator codegen) {
+               if (yield_expression != null) {
+                       yield_expression.emit (codegen);
+
+                       codegen.visit_end_full_expression (yield_expression);
+               }
+
+               codegen.visit_yield_statement (this);
+       }
 }