fix multi-line comments basic statement and expression handling support
authorJürg Billeter <j@bitron.ch>
Tue, 16 May 2006 20:46:25 +0000 (20:46 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Tue, 16 May 2006 20:46:25 +0000 (20:46 +0000)
2006-05-16  Jürg Billeter  <j@bitron.ch>

* vala/scanner.l: fix multi-line comments
* vala/valacodegenerator.vala: basic statement and expression handling
* vala/valacodevisitor.vala: support variable declaration
* vala/valasymbolbuilder.vala: adapt to visitor changes
* vala/valaclass.vala: remove members already available in Struct
* vala/valacodenode.vala: add ccodenode field
* vala/valadeclarationstatement.vala: visit declaration
* vala/valaexpressionstatement.vala: visit code containers after child
  elements
* vala/valalocalvariabledeclaration.vala: add accept method
* vala/valamethod.vala: add begin and end visit events
* vala/valanamespace.vala: add lower_case_cprefix
* vala/valastruct.vala: define get_upper_case_cname method
* vala/valatype.vala: declare get_upper_case_cname method
* vala/valatypereference.vala: add get_upper_case_cname method
* vala/valavariabledeclarator.vala: add accept method
* ccode/valaccodewriter.vala: formatting fixes
* ccode/valaccodeassignment.vala
* ccode/valaccodebinaryexpression.vala
* ccode/valaccodeblock.vala: use CCodeStatement
* ccode/valaccodeconstant.vala
* ccode/valaccodedeclarationstatement.vala
* ccode/valaccodeemptystatement.vala
* ccode/valaccodeexpression.vala
* ccode/valaccodeexpressionstatement.vala
* ccode/valaccodeforstatement.vala
* ccode/valaccodefunction.vala: formatting fixes
* ccode/valaccodefunctioncall.vala
* ccode/valaccodeidentifier.vala
* ccode/valaccodeifstatement.vala
* ccode/valaccodereturnstatement.vala
* ccode/valaccodestatement.vala
* ccode/valaccodestruct.vala: formatting fixes
* ccode/valaccodevariabledeclarator.vala
* bindings/GLib.vala: extend string types
* valac/context.c: resolve types in named argument list in object
  creation expression

svn path=/trunk/; revision=20

36 files changed:
vala/ChangeLog
vala/bindings/GLib.vala
vala/ccode/valaccodeassignment.vala [new file with mode: 0644]
vala/ccode/valaccodebinaryexpression.vala [new file with mode: 0644]
vala/ccode/valaccodeblock.vala
vala/ccode/valaccodeconstant.vala [new file with mode: 0644]
vala/ccode/valaccodedeclarationstatement.vala [new file with mode: 0644]
vala/ccode/valaccodeemptystatement.vala [new file with mode: 0644]
vala/ccode/valaccodeexpression.vala [new file with mode: 0644]
vala/ccode/valaccodeexpressionstatement.vala [new file with mode: 0644]
vala/ccode/valaccodeforstatement.vala [new file with mode: 0644]
vala/ccode/valaccodefunction.vala
vala/ccode/valaccodefunctioncall.vala [new file with mode: 0644]
vala/ccode/valaccodeidentifier.vala [new file with mode: 0644]
vala/ccode/valaccodeifstatement.vala [new file with mode: 0644]
vala/ccode/valaccodereturnstatement.vala [new file with mode: 0644]
vala/ccode/valaccodestatement.vala [new file with mode: 0644]
vala/ccode/valaccodestruct.vala
vala/ccode/valaccodevariabledeclarator.vala [new file with mode: 0644]
vala/ccode/valaccodewriter.vala
vala/vala/scanner.l
vala/vala/valaclass.vala
vala/vala/valacodegenerator.vala
vala/vala/valacodenode.vala
vala/vala/valacodevisitor.vala
vala/vala/valadeclarationstatement.vala
vala/vala/valaexpressionstatement.vala
vala/vala/valalocalvariabledeclaration.vala
vala/vala/valamethod.vala
vala/vala/valanamespace.vala
vala/vala/valastruct.vala
vala/vala/valasymbolbuilder.vala
vala/vala/valatype.vala
vala/vala/valatypereference.vala
vala/vala/valavariabledeclarator.vala
vala/valac/context.c

index 1a4c924..b08cb2d 100644 (file)
@@ -1,5 +1,45 @@
 2006-05-16  Jürg Billeter  <j@bitron.ch>
 
+       * vala/scanner.l: fix multi-line comments
+       * vala/valacodegenerator.vala: basic statement and expression handling
+       * vala/valacodevisitor.vala: support variable declaration
+       * vala/valasymbolbuilder.vala: adapt to visitor changes
+       * vala/valaclass.vala: remove members already available in Struct
+       * vala/valacodenode.vala: add ccodenode field
+       * vala/valadeclarationstatement.vala: visit declaration
+       * vala/valaexpressionstatement.vala: visit code containers after child
+         elements
+       * vala/valalocalvariabledeclaration.vala: add accept method
+       * vala/valamethod.vala: add begin and end visit events
+       * vala/valanamespace.vala: add lower_case_cprefix
+       * vala/valastruct.vala: define get_upper_case_cname method
+       * vala/valatype.vala: declare get_upper_case_cname method
+       * vala/valatypereference.vala: add get_upper_case_cname method
+       * vala/valavariabledeclarator.vala: add accept method
+       * ccode/valaccodewriter.vala: formatting fixes
+       * ccode/valaccodeassignment.vala
+       * ccode/valaccodebinaryexpression.vala
+       * ccode/valaccodeblock.vala: use CCodeStatement
+       * ccode/valaccodeconstant.vala
+       * ccode/valaccodedeclarationstatement.vala
+       * ccode/valaccodeemptystatement.vala
+       * ccode/valaccodeexpression.vala
+       * ccode/valaccodeexpressionstatement.vala
+       * ccode/valaccodeforstatement.vala
+       * ccode/valaccodefunction.vala: formatting fixes
+       * ccode/valaccodefunctioncall.vala
+       * ccode/valaccodeidentifier.vala
+       * ccode/valaccodeifstatement.vala
+       * ccode/valaccodereturnstatement.vala
+       * ccode/valaccodestatement.vala
+       * ccode/valaccodestruct.vala: formatting fixes
+       * ccode/valaccodevariabledeclarator.vala
+       * bindings/GLib.vala: extend string types
+       * valac/context.c: resolve types in named argument list in object
+         creation expression
+
+2006-05-16  Jürg Billeter  <j@bitron.ch>
+
        * vala/parser.y: fix unary expressions
        * vala/valacodegenerator.vala: add visit_block method
        * vala/valacodevisitor.vala: add visit methods for statements,
index ec1904e..ee8ad1e 100644 (file)
@@ -100,6 +100,10 @@ public struct string {
        public bool has_suffix (string suffix);
        [CCode (cname = "g_strdup_printf")]
        public ref string printf (string args);
+       [CCode (cname = "g_ascii_strup")]
+       public ref string up (long len /* = -1 */);
+       [CCode (cname = "g_ascii_strdown")]
+       public ref string down (long len /* = -1 */);
        [CCode (cname = "g_strconcat")]
        public ref string concat (string string2);
        [CCode (cname = "g_strdup")]
@@ -264,5 +268,13 @@ namespace GLib {
        [CCode (cname = "g_str_equal")]
        public static GLib.EqualFunc str_equal;
        
-       
+       [ReferenceType ()]
+       public struct String {
+               public static ref String new (string init);
+               public static void append_c (char c);
+               
+               public ref string str;
+               public long len;
+               public long allocated_len;
+       }
 }
diff --git a/vala/ccode/valaccodeassignment.vala b/vala/ccode/valaccodeassignment.vala
new file mode 100644 (file)
index 0000000..fc622d5
--- /dev/null
@@ -0,0 +1,40 @@
+/* valaccodeassignment.vala
+ *
+ * Copyright (C) 2006  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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+namespace Vala {
+       public class CCodeAssignment : CCodeExpression {
+               public readonly ref CCodeExpression left;
+               public readonly ref CCodeExpression right;
+               
+               public override void write (CCodeWriter writer) {
+                       if (left != null) {
+                               left.write (writer);
+                       }
+                       writer.write_string (" = ");
+                       if (right != null) {
+                               right.write (writer);
+                       }
+               }
+       }
+}
diff --git a/vala/ccode/valaccodebinaryexpression.vala b/vala/ccode/valaccodebinaryexpression.vala
new file mode 100644 (file)
index 0000000..ddaed5e
--- /dev/null
@@ -0,0 +1,39 @@
+/* valaccodebinaryexpression.vala
+ *
+ * Copyright (C) 2006  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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+namespace Vala {
+       public class CCodeBinaryExpression : CCodeExpression {
+               public readonly ref CCodeExpression left;
+               public readonly ref CCodeExpression right;
+               
+               public override void write (CCodeWriter writer) {
+                       if (left != null) {
+                               left.write (writer);
+                       }
+                       if (right != null) {
+                               right.write (writer);
+                       }
+               }
+       }
+}
index 32a0fd4..ae79a7d 100644 (file)
@@ -23,8 +23,8 @@
 using GLib;
 
 namespace Vala {
-       public class CCodeBlock : CCodeNode {
-               List<string#># statements;
+       public class CCodeBlock : CCodeStatement {
+               ref List<ref CCodeStatement> statements;
                
                public void add_statement (string statement) {
                        statements.append (statement);
@@ -32,10 +32,10 @@ namespace Vala {
                
                public override void write (CCodeWriter writer) {
                        writer.write_begin_block ();
-                       foreach (string statement in statements) {
-                               writer.write_indent ();
-                               writer.write_string (statement);
-                               writer.write_string (";\n");
+                       foreach (CCodeStatement statement in statements) {
+                               if (statement != null) {
+                                       statement.write (writer);
+                               }
                        }
                        writer.write_end_block ();
                }
diff --git a/vala/ccode/valaccodeconstant.vala b/vala/ccode/valaccodeconstant.vala
new file mode 100644 (file)
index 0000000..1f0f41b
--- /dev/null
@@ -0,0 +1,33 @@
+/* valaccodeconstant.vala
+ *
+ * Copyright (C) 2006  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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+namespace Vala {
+       public class CCodeConstant : CCodeExpression {
+               public readonly ref string name;
+               
+               public override void write (CCodeWriter writer) {
+                       writer.write_string (name);
+               }
+       }
+}
diff --git a/vala/ccode/valaccodedeclarationstatement.vala b/vala/ccode/valaccodedeclarationstatement.vala
new file mode 100644 (file)
index 0000000..8843c39
--- /dev/null
@@ -0,0 +1,55 @@
+/* valaccodedeclarationstatement.vala
+ *
+ * Copyright (C) 2006  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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+namespace Vala {
+       public class CCodeDeclarationStatement : CCodeStatement {
+               public readonly ref string type_name;
+               ref List<ref CCodeVariableDeclarator> variable_declarators;
+               
+               public void add_declarator (CCodeVariableDeclarator decl) {
+                       variable_declarators.append (decl);
+               }
+               
+               public override void write (CCodeWriter writer) {
+                       writer.write_indent ();
+                       if (type_name != null) {
+                               writer.write_string (type_name);
+                       }
+                       writer.write_string (" ");
+               
+                       bool first = true;
+                       foreach (CCodeVariableDeclarator decl in variable_declarators) {
+                               if (!first) {
+                                       writer.write_string (", ");
+                               } else {
+                                       first = false;
+                               }
+                               decl.write (writer);
+                       }
+
+                       writer.write_string (";");
+                       writer.write_newline ();
+               }
+       }
+}
diff --git a/vala/ccode/valaccodeemptystatement.vala b/vala/ccode/valaccodeemptystatement.vala
new file mode 100644 (file)
index 0000000..4b8df11
--- /dev/null
@@ -0,0 +1,33 @@
+/* valaccodeemptystatement.vala
+ *
+ * Copyright (C) 2006  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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+namespace Vala {
+       public class CCodeEmptyStatement : CCodeStatement {
+               public override void write (CCodeWriter writer) {
+                       writer.write_indent ();
+                       writer.write_string (";");
+                       writer.write_newline ();
+               }
+       }
+}
diff --git a/vala/ccode/valaccodeexpression.vala b/vala/ccode/valaccodeexpression.vala
new file mode 100644 (file)
index 0000000..2298b7e
--- /dev/null
@@ -0,0 +1,28 @@
+/* valaccodeexpression.vala
+ *
+ * Copyright (C) 2006  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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+namespace Vala {
+       public abstract class CCodeExpression : CCodeNode {
+       }
+}
diff --git a/vala/ccode/valaccodeexpressionstatement.vala b/vala/ccode/valaccodeexpressionstatement.vala
new file mode 100644 (file)
index 0000000..9764eb3
--- /dev/null
@@ -0,0 +1,38 @@
+/* valaccodeexpressionstatement.vala
+ *
+ * Copyright (C) 2006  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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+namespace Vala {
+       public class CCodeExpressionStatement : CCodeStatement {
+               public readonly ref CCodeExpression expression;
+       
+               public override void write (CCodeWriter writer) {
+                       writer.write_indent ();
+                       if (expression != null) {
+                               expression.write (writer);
+                       }
+                       writer.write_string (";");
+                       writer.write_newline ();
+               }
+       }
+}
diff --git a/vala/ccode/valaccodeforstatement.vala b/vala/ccode/valaccodeforstatement.vala
new file mode 100644 (file)
index 0000000..e7b6831
--- /dev/null
@@ -0,0 +1,81 @@
+/* valaccodeforstatement.vala
+ *
+ * Copyright (C) 2006  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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+namespace Vala {
+       public class CCodeForStatement : CCodeStatement {
+               public readonly ref CCodeExpression condition;
+               public readonly ref CCodeStatement body;
+               
+               ref List<ref CCodeExpression> initializer;
+               ref List<ref CCodeExpression> iterator;
+
+               public void add_initializer (CCodeExpression expr) {
+                       initializer.append (expr);
+               }
+
+               public void add_iterator (CCodeExpression expr) {
+                       iterator.append (expr);
+               }
+               
+               public override void write (CCodeWriter writer) {
+                       bool first;
+                       
+                       writer.write_indent ();
+                       writer.write_string ("for (");
+                       
+                       first = true;
+                       foreach (CCodeExpression init_expr in initializer) {
+                               if (!first) {
+                                       writer.write_string (", ");
+                               } else {
+                                       first = false;
+                               }
+                               if (init_expr != null) {
+                                       init_expr.write (writer);
+                               }
+                       }
+
+                       writer.write_string ("; ");
+                       if (condition != null) {
+                               condition.write (writer);
+                       }
+                       writer.write_string ("; ");
+                       
+                       first = true;
+                       foreach (CCodeExpression it_expr in iterator) {
+                               if (!first) {
+                                       writer.write_string (", ");
+                               } else {
+                                       first = false;
+                               }
+                               if (it_expr != null) {
+                                       it_expr.write (writer);
+                               }
+                       }
+
+                       writer.write_string (")");
+                       body.write (writer);
+               }
+       }
+}
index 42753db..eda8a19 100644 (file)
@@ -35,6 +35,7 @@ namespace Vala {
                }
                
                public override void write (CCodeWriter writer) {
+                       writer.write_newline ();
                        if ((modifiers & CCodeModifiers.STATIC) == CCodeModifiers.STATIC) {
                                writer.write_string ("static ");
                        }
@@ -47,10 +48,12 @@ namespace Vala {
                        }
                        writer.write_string (")");
                        if (block == null) {
-                               writer.write_string (";\n");
+                               writer.write_string (";");
                        } else {
+                               writer.write_newline ();
                                block.write (writer);
                        }
+                       writer.write_newline ();
                }
        }
 }
diff --git a/vala/ccode/valaccodefunctioncall.vala b/vala/ccode/valaccodefunctioncall.vala
new file mode 100644 (file)
index 0000000..b6ce0ac
--- /dev/null
@@ -0,0 +1,54 @@
+/* valaccodefunctioncall.vala
+ *
+ * Copyright (C) 2006  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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+namespace Vala {
+       public class CCodeFunctionCall : CCodeExpression {
+               public readonly ref CCodeExpression call;
+               ref List<ref CCodeExpression> arguments;
+               
+               public void add_argument (CCodeExpression expr) {
+                       arguments.append (expr);
+               }
+               
+               public override void write (CCodeWriter writer) {
+                       call.write (writer);
+                       writer.write_string (" (");
+
+                       bool first = true;
+                       foreach (CCodeExpression expr in arguments) {
+                               if (!first) {
+                                       writer.write_string (", ");
+                               } else {
+                                       first = false;
+                               }
+                               
+                               if (expr != null) {
+                                       expr.write (writer);
+                               }
+                       }
+
+                       writer.write_string (")");
+               }
+       }
+}
diff --git a/vala/ccode/valaccodeidentifier.vala b/vala/ccode/valaccodeidentifier.vala
new file mode 100644 (file)
index 0000000..d9a98aa
--- /dev/null
@@ -0,0 +1,33 @@
+/* valaccodeidentifier.vala
+ *
+ * Copyright (C) 2006  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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+namespace Vala {
+       public class CCodeIdentifier : CCodeExpression {
+               public readonly ref string name;
+               
+               public override void write (CCodeWriter writer) {
+                       writer.write_string (name);
+               }
+       }
+}
diff --git a/vala/ccode/valaccodeifstatement.vala b/vala/ccode/valaccodeifstatement.vala
new file mode 100644 (file)
index 0000000..a3c584e
--- /dev/null
@@ -0,0 +1,50 @@
+/* valaccodeifstatement.vala
+ *
+ * Copyright (C) 2006  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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+namespace Vala {
+       public class CCodeIfStatement : CCodeStatement {
+               public readonly ref CCodeExpression condition;
+               public readonly ref CCodeStatement true_statement;
+               public readonly ref CCodeStatement false_statement;
+               
+               public override void write (CCodeWriter writer) {
+                       writer.write_indent ();
+                       writer.write_string ("if (");
+                       if (condition != null) {
+                               condition.write (writer);
+                       }
+                       writer.write_string (")");
+                       true_statement.write (writer);
+                       if (false_statement != null) {
+                               if (writer.bol) {
+                                       writer.write_indent ();
+                                       writer.write_string ("else ");
+                               } else {
+                                       writer.write_string (" else ");
+                               }
+                               false_statement.write (writer);
+                       }
+               }
+       }
+}
diff --git a/vala/ccode/valaccodereturnstatement.vala b/vala/ccode/valaccodereturnstatement.vala
new file mode 100644 (file)
index 0000000..7af7fad
--- /dev/null
@@ -0,0 +1,41 @@
+/* valaccodereturnstatement.vala
+ *
+ * Copyright (C) 2006  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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+namespace Vala {
+       public class CCodeReturnStatement : CCodeStatement {
+               public readonly ref CCodeExpression return_expression;
+               
+               public override void write (CCodeWriter writer) {
+                       writer.write_indent ();
+                       writer.write_string ("return ");
+               
+                       if (return_expression != null) {
+                               return_expression.write (writer);
+                       }
+
+                       writer.write_string (";");
+                       writer.write_newline ();
+               }
+       }
+}
diff --git a/vala/ccode/valaccodestatement.vala b/vala/ccode/valaccodestatement.vala
new file mode 100644 (file)
index 0000000..f78184e
--- /dev/null
@@ -0,0 +1,28 @@
+/* valaccodestatement.vala
+ *
+ * Copyright (C) 2006  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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+namespace Vala {
+       public abstract class CCodeStatement : CCodeNode {
+       }
+}
index 0295cc3..7e0f2c6 100644 (file)
@@ -24,8 +24,8 @@ using GLib;
 
 namespace Vala {
        public class CCodeStruct : CCodeNode {
-               public readonly string# name;
-               List<string#># fields;
+               public readonly ref string name;
+               ref List<ref string> fields;
                
                public void add_field (string type, string name) {
                        fields.append ("%s %s".printf (type, name));
@@ -38,10 +38,12 @@ namespace Vala {
                        foreach (string field in fields) {
                                writer.write_indent ();
                                writer.write_string (field);
-                               writer.write_string (";\n");
+                               writer.write_string (";");
+                               writer.write_newline ();
                        }
                        writer.write_end_block ();
-                       writer.write_string (";\n");
+                       writer.write_string (";");
+                       writer.write_newline ();
                }
        }
 }
diff --git a/vala/ccode/valaccodevariabledeclarator.vala b/vala/ccode/valaccodevariabledeclarator.vala
new file mode 100644 (file)
index 0000000..06819d5
--- /dev/null
@@ -0,0 +1,39 @@
+/* valaccodevariabledeclarator.vala
+ *
+ * Copyright (C) 2006  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
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Jürg Billeter <j@bitron.ch>
+ */
+
+using GLib;
+
+namespace Vala {
+       public class CCodeVariableDeclarator : CCodeNode {
+               public readonly ref string name;
+               public readonly ref CCodeExpression initializer;
+               
+               public override void write (CCodeWriter writer) {
+                       writer.write_string (name);
+                       
+                       if (initializer != null) {
+                               writer.write_string (" = ");
+                               initializer.write (writer);
+                       }
+               }
+       }
+}
index f542c9e..c728c45 100644 (file)
@@ -27,6 +27,8 @@ namespace Vala {
                public readonly File# stream;
                
                int indent;
+               /* at begin of line */
+               public bool bol = true;
                
                public void close () {
                        stream.close ();
@@ -34,17 +36,34 @@ namespace Vala {
                
                public void write_indent () {
                        int i;
+                       
+                       if (!bol) {
+                               stream.putc ('\n');
+                       }
+                       
                        for (i = 0; i < indent; i++) {
                                stream.putc ('\t');
                        }
+                       
+                       bol = false;
                }
                
                public void write_string (string s) {
                        stream.printf ("%s", s);
+                       bol = false;
+               }
+               
+               public void write_newline () {
+                       stream.putc ('\n');
+                       bol = true;
                }
                
                public void write_begin_block () {
-                       stream.printf (" {\n");
+                       if (!bol) {
+                               stream.putc (' ');
+                       }
+                       stream.putc ('{');
+                       write_newline ();
                        indent++;
                }
                
index 2cd2400..9db687a 100644 (file)
@@ -49,7 +49,7 @@ literal                       ({literal_integer}|{literal_character}|{literal_string})
 
 "/*"                           { uploc; BEGIN (IN_COMMENT); }
 <IN_COMMENT>[^*\n]*            { uploc; yymore (); }
-<IN_COMMENT>"*"+[^/\n]*                { uploc; yymore (); }
+<IN_COMMENT>"*"+[^*/\n]*               { uploc; yymore (); }
 <IN_COMMENT>\n                 { yylloc->first_line = yylloc->last_line = yylineno; yylloc->first_column = 1; yylloc->last_column = 0; yymore (); }
 <IN_COMMENT>"*/"               { uploc; BEGIN (INITIAL); yytext[strlen (yytext) - 2] = '\0'; vala_parser_push_comment (parser, g_strdup (yytext)); }
 
index 5da2fbf..607e93e 100644 (file)
@@ -24,11 +24,9 @@ using GLib;
 
 namespace Vala {
        public class Class : Struct {
-               public readonly string# name;
                public readonly SourceReference# source_reference;
-               public Namespace @namespace;
                
-               public static Class# @new (string name, SourceReference source) {
+               public static ref Class new (string name, SourceReference source) {
                        return (new Class (name = name, source_reference = source));
                }
                
@@ -39,10 +37,6 @@ namespace Vala {
 
                        visitor.visit_end_class (this);
                }
-               
-               public override string get_cname () {
-                       return name;
-               }
 
                public override bool is_reference_type () {
                        return true;
index d428618..fee4496 100644 (file)
@@ -117,7 +117,7 @@ namespace Vala {
                        instance_struct.add_field (f.type_reference.get_cname (), f.name);
                }
                
-               public override void visit_method (Method m) {
+               public override void visit_end_method (Method m) {
                        var cmethod_decl = new CCodeFunction (name = m.name, return_type = "void");
                        function = new CCodeFunction (name = m.name, return_type = "void");
                        
@@ -128,6 +128,11 @@ namespace Vala {
                                function.modifiers |= CCodeModifiers.STATIC;
                                source_type_member_declaration.append (cmethod_decl);
                        }
+
+                       if (m.body != null) {
+                               function.block = m.body.ccodenode;
+                       }
+
                        if (m.source_reference.comment != null) {
                                source_type_member_definition.append (new CCodeComment (text = m.source_reference.comment));
                        }
@@ -137,9 +142,150 @@ namespace Vala {
 
                public override void visit_block (Block b) {
                        var cblock = new CCodeBlock ();
-                       if (function.block == null) {
-                               function.block = cblock;
+                       
+                       foreach (Statement stmt in b.statement_list) {
+                               cblock.add_statement ((CCodeStatement) stmt.ccodenode);
+                       }
+                       
+                       b.ccodenode = cblock;
+               }
+
+               public override void visit_empty_statement (EmptyStatement stmt) {
+                       stmt.ccodenode = new CCodeEmptyStatement ();
+               }
+
+               public override void visit_declaration_statement (DeclarationStatement stmt) {
+                       /* not yet handled var declarations */
+                       if (stmt.declaration.type_reference == null) {
+                               return;
+                       }
+                       
+                       var cdecl = new CCodeDeclarationStatement (type_name = stmt.declaration.type_reference.get_cname ());
+                       
+                       foreach (VariableDeclarator decl in stmt.declaration.variable_declarators) {
+                               cdecl.add_declarator ((CCodeVariableDeclarator) decl.ccodenode);
+                       }
+                       
+                       stmt.ccodenode = cdecl;
+               }
+
+               public override void visit_variable_declarator (VariableDeclarator decl) {
+                       if (decl.initializer != null) {
+                               decl.ccodenode = new CCodeVariableDeclarator (name = decl.name, initializer = decl.initializer.ccodenode);
+                       } else {
+                               decl.ccodenode = new CCodeVariableDeclarator (name = decl.name);
+                       }
+               }
+
+               public override void visit_expression_statement (ExpressionStatement stmt) {
+                       stmt.ccodenode = new CCodeExpressionStatement (expression = (CCodeExpression) stmt.expression.ccodenode);
+               }
+
+               public override void visit_if_statement (IfStatement stmt) {
+                       if (stmt.false_statement != null) {
+                               stmt.ccodenode = new CCodeIfStatement (condition = (CCodeExpression) stmt.condition.ccodenode, true_statement = (CCodeStatement) stmt.true_statement.ccodenode, false_statement = (CCodeStatement) stmt.false_statement.ccodenode);
+                       } else {
+                               stmt.ccodenode = new CCodeIfStatement (condition = (CCodeExpression) stmt.condition.ccodenode, true_statement = (CCodeStatement) stmt.true_statement.ccodenode);
+                       }
+               }
+
+               public override void visit_for_statement (ForStatement stmt) {
+                       var cfor = new CCodeForStatement (condition = (CCodeExpression) stmt.condition.ccodenode, body = (CCodeStatement) stmt.body.ccodenode);
+                       
+                       foreach (Expression init_expr in stmt.initializer) {
+                               cfor.add_initializer ((CCodeExpression) init_expr.ccodenode);
+                       }
+                       
+                       foreach (Expression it_expr in stmt.iterator) {
+                               cfor.add_iterator ((CCodeExpression) it_expr.ccodenode);
+                       }
+                       
+                       stmt.ccodenode = cfor;
+               }
+
+               public override void visit_return_statement (ReturnStatement stmt) {
+                       if (stmt.return_expression == null) {
+                               stmt.ccodenode = new CCodeReturnStatement ();
+                       } else {
+                               stmt.ccodenode = new CCodeReturnStatement (return_expression = (CCodeExpression) stmt.return_expression.ccodenode);
+                       }
+               }
+
+               public override void visit_boolean_literal (BooleanLiteral expr) {
+                       if (expr.value) {
+                               expr.ccodenode = new CCodeConstant (name = "TRUE");
+                       } else {
+                               expr.ccodenode = new CCodeConstant (name = "FALSE");
+                       }
+               }
+
+               public override void visit_character_literal (CharacterLiteral expr) {
+                       expr.ccodenode = new CCodeConstant (name = expr.value);
+               }
+
+               public override void visit_integer_literal (IntegerLiteral expr) {
+                       expr.ccodenode = new CCodeConstant (name = expr.value);
+               }
+
+               public override void visit_string_literal (StringLiteral expr) {
+                       expr.ccodenode = new CCodeConstant (name = expr.value);
+               }
+
+               public override void visit_null_literal (NullLiteral expr) {
+                       expr.ccodenode = new CCodeConstant (name = "NULL");
+               }
+
+               public override void visit_literal_expression (LiteralExpression expr) {
+                       expr.ccodenode = expr.literal.ccodenode;
+               }
+
+               public override void visit_simple_name (SimpleName expr) {
+                       /* local variable */
+                       expr.ccodenode = new CCodeIdentifier (name = expr.name);
+               }
+
+               public override void visit_member_access (MemberAccess expr) {
+                       expr.ccodenode = new CCodeIdentifier (name = expr.member_name);
+               }
+
+               public override void visit_invocation_expression (InvocationExpression expr) {
+                       var ccall = new CCodeFunctionCall (call = (CCodeExpression) expr.call.ccodenode);
+                       
+                       foreach (Expression arg in expr.argument_list) {
+                               ccall.add_argument ((CCodeExpression) arg.ccodenode);
+                       }
+                       
+                       expr.ccodenode = ccall;
+               }
+
+               public override void visit_object_creation_expression (ObjectCreationExpression expr) {
+                       var ccall = new CCodeFunctionCall (call = new CCodeIdentifier (name = "g_object_new"));
+                       
+                       ccall.add_argument (new CCodeConstant (name = expr.type_reference.get_upper_case_cname ("TYPE_")));
+
+                       foreach (NamedArgument arg in expr.named_argument_list) {
+                               ccall.add_argument (new CCodeConstant (name = "\"%s\"".printf (arg.name)));
+                               ccall.add_argument ((CCodeExpression) arg.argument.ccodenode);
                        }
+                       ccall.add_argument (new CCodeConstant (name = "NULL"));
+                       
+                       expr.ccodenode = ccall;
+               }
+
+               public override void visit_unary_expression (UnaryExpression expr) {
+                       expr.ccodenode = expr.inner.ccodenode;
+               }
+
+               public override void visit_cast_expression (CastExpression expr) {
+                       expr.ccodenode = expr.inner.ccodenode;
+               }
+
+               public override void visit_binary_expression (BinaryExpression expr) {
+                       expr.ccodenode = new CCodeBinaryExpression (left = expr.left.ccodenode, right = expr.right.ccodenode);
+               }
+
+               public override void visit_assignment (Assignment a) {
+                       a.ccodenode = new CCodeAssignment (left = (CCodeExpression) a.left.ccodenode, right = (CCodeExpression) a.right.ccodenode);
                }
        }
 }
index 616867e..7706154 100644 (file)
@@ -26,6 +26,7 @@ namespace Vala {
        public abstract class CodeNode {
                public Symbol# symbol;
                public ref List<ref Attribute> attributes;
+               public ref CCodeNode ccodenode;
        
                public abstract void accept (CodeVisitor visitor);
        }
index b31d183..98694c8 100644 (file)
@@ -57,7 +57,10 @@ namespace Vala {
                public virtual void visit_field (Field f) {
                }
 
-               public virtual void visit_method (Method m) {
+               public virtual void visit_begin_method (Method m) {
+               }
+
+               public virtual void visit_end_method (Method m) {
                }
 
                public virtual void visit_property (Property prop) {
@@ -81,6 +84,12 @@ namespace Vala {
                public virtual void visit_declaration_statement (DeclarationStatement stmt) {
                }
 
+               public virtual void visit_local_variable_declaration (LocalVariableDeclaration decl) {
+               }
+
+               public virtual void visit_variable_declarator (VariableDeclarator decl) {
+               }
+
                public virtual void visit_expression_statement (ExpressionStatement stmt) {
                }
 
@@ -123,7 +132,7 @@ namespace Vala {
                public virtual void visit_member_access (MemberAccess expr) {
                }
 
-               public virtual void visit_invocation_expression (ObjectCreationExpression expr) {
+               public virtual void visit_invocation_expression (InvocationExpression expr) {
                }
 
                public virtual void visit_postfix_expression (PostfixExpression expr) {
index e59530f..c6134fd 100644 (file)
@@ -32,6 +32,8 @@ namespace Vala {
                }
                
                public override void accept (CodeVisitor visitor) {
+                       declaration.accept (visitor);
+               
                        visitor.visit_declaration_statement (this);
                }
        }
index 0b5eda3..57a9d52 100644 (file)
@@ -32,9 +32,9 @@ namespace Vala {
                }
                
                public override void accept (CodeVisitor visitor) {
-                       visitor.visit_expression_statement (this);
-                       
                        expression.accept (visitor);
+
+                       visitor.visit_expression_statement (this);
                }
        }
 }
index aae5680..1356c22 100644 (file)
@@ -24,16 +24,28 @@ using GLib;
 
 namespace Vala {
        public class LocalVariableDeclaration : CodeNode {
-               public readonly TypeReference# type_reference;
-               public readonly List<VariableDeclarator#># variable_declarators;
-               public readonly SourceReference# source_reference;
+               public readonly ref TypeReference type_reference;
+               public readonly ref List<ref VariableDeclarator> variable_declarators;
+               public readonly ref SourceReference source_reference;
                
-               public static LocalVariableDeclaration# @new (TypeReference type, List<VariableDeclarator> declarators, SourceReference source) {
+               public static ref LocalVariableDeclaration new (TypeReference type, List<VariableDeclarator> declarators, SourceReference source) {
                        return (new LocalVariableDeclaration (type_reference = type, variable_declarators = declarators, source_reference = source));
                }
                
-               public static LocalVariableDeclaration# new_var (List<VariableDeclarator> declarators, SourceReference source) {
+               public static ref LocalVariableDeclaration new_var (List<VariableDeclarator> declarators, SourceReference source) {
                        return (new LocalVariableDeclaration (variable_declarators = declarators, source_reference = source));
                }
+               
+               public override void accept (CodeVisitor visitor) {
+                       if (type_reference != null) {
+                               type_reference.accept (visitor);
+                       }
+                       
+                       foreach (VariableDeclarator decl in variable_declarators) {
+                               decl.accept (visitor);
+                       }
+               
+                       visitor.visit_local_variable_declaration (this);
+               }
        }
 }
index 62d15b8..94f0849 100644 (file)
@@ -49,11 +49,13 @@ namespace Vala {
                }
                
                public override void accept (CodeVisitor visitor) {
-                       visitor.visit_method (this);
+                       visitor.visit_begin_method (this);
                        
                        if (body != null) {
                                body.accept (visitor);
                        }
+
+                       visitor.visit_end_method (this);
                }
 
                public string get_cname () {
index 1aa4228..2766b1b 100644 (file)
@@ -24,15 +24,17 @@ using GLib;
 
 namespace Vala {
        public class Namespace : CodeNode {
-               public readonly string# name;
-               public readonly SourceReference# source_reference;
+               public readonly ref string name;
+               public readonly ref SourceReference source_reference;
 
-               List<Class#># classes;
-               List<Struct#># structs;
-               List<Enum#># enums;
-               List<Field#># fields;
+               ref List<ref Class> classes;
+               ref List<ref Struct> structs;
+               ref List<ref Enum> enums;
+               ref List<ref Field> fields;
                
-               public static Namespace# @new (string name, SourceReference source) {
+               public ref string lower_case_cprefix;
+               
+               public static ref Namespace new (string name, SourceReference source) {
                        return (new Namespace (name = name, source_reference = source));
                }
                
@@ -86,5 +88,24 @@ namespace Vala {
 
                        visitor.visit_end_namespace (this);
                }
+
+               public static ref string camel_case_to_lower_case (string camel_case) {
+                       return camel_case.down (-1);
+               }
+               
+               public string get_lower_case_cprefix () {
+                       if (lower_case_cprefix == null) {
+                               if (name == null) {
+                                       lower_case_cprefix = "";
+                               } else {
+                                       lower_case_cprefix = "%s_".printf (camel_case_to_lower_case (name));
+                               }
+                       }
+                       return lower_case_cprefix;
+               }
+               
+               public void set_lower_case_cprefix (string cprefix) {
+                       this.lower_case_cprefix = cprefix;
+               }
        }
 }
index 6fa2de2..d08b05b 100644 (file)
@@ -33,6 +33,8 @@ namespace Vala {
                List<Method#># methods;
                
                public ref string cname;
+               public ref string lower_case_csuffix;
+               bool reference_type;
                
                public static Struct# new (string name, SourceReference source) {
                        return (new Struct (name = name, source_reference = source));
@@ -85,9 +87,31 @@ namespace Vala {
                public void set_cname (string cname) {
                        this.cname = cname;
                }
+               
+               public string get_lower_case_csuffix () {
+                       if (lower_case_csuffix == null) {
+                               lower_case_csuffix = Namespace.camel_case_to_lower_case (name);
+                       }
+                       return lower_case_csuffix;
+               }
+               
+               public void set_lower_case_csuffix (string csuffix) {
+                       this.lower_case_csuffix = csuffix;
+               }
+               
+               public ref string get_lower_case_cname (string infix) {
+                       if (infix == null) {
+                               infix = "";
+                       }
+                       return "%s%s%s".printf (@namespace.get_lower_case_cprefix (), infix, get_lower_case_csuffix ());
+               }
+               
+               public override ref string get_upper_case_cname (string infix) {
+                       return get_lower_case_cname (infix).up (-1);
+               }
 
                public override bool is_reference_type () {
-                       return false;
+                       return reference_type;
                }
                
                void process_ccode_attribute (Attribute a) {
@@ -108,6 +132,8 @@ namespace Vala {
                        foreach (Attribute a in attributes) {
                                if (a.name.cmp ("CCode") == 0) {
                                        process_ccode_attribute (a);
+                               } else if (a.name.cmp ("ReferenceType") == 0) {
+                                       reference_type = true;
                                }
                        }
                }
index 23d5845..77d2eec 100644 (file)
@@ -85,7 +85,7 @@ namespace Vala {
                        f.parent_type.symbol.add (f.name, f.symbol);
                }
                
-               public override void visit_method (Method m) {
+               public override void visit_begin_method (Method m) {
                        if (m.parent_type.symbol.lookup (m.name) != null) {
                                // TODO: raise error
                                stderr.printf ("symbol conflict\n");
index f484242..0c987ea 100644 (file)
@@ -26,5 +26,6 @@ namespace Vala {
        public abstract class Type_ : CodeNode {
                public abstract string get_cname ();
                public abstract bool is_reference_type ();
+               public abstract string get_upper_case_cname (string infix);
        }
 }
index a1d67d9..6d8f315 100644 (file)
@@ -90,7 +90,7 @@ namespace Vala {
                        visitor.visit_type_reference (this);
                }
 
-               public string# get_cname () {
+               public ref string get_cname () {
                        string ptr;
                        string arr;
                        if (type_parameter == null && !type.is_reference_type () && !is_ref) {
@@ -111,8 +111,13 @@ namespace Vala {
                                return "gpointer".concat (ptr, arr, null);
                        } else {
                                /* raise error */
+                               stderr.printf ("error: unresolved type reference\n");
                                return null;
                        }
                }
+               
+               public ref string get_upper_case_cname (string infix) {
+                       return type.get_upper_case_cname (infix);
+               }
        }
 }
index 41d0818..55cfca6 100644 (file)
@@ -24,12 +24,20 @@ using GLib;
 
 namespace Vala {
        public class VariableDeclarator : CodeNode {
-               public readonly string# name;
-               public readonly Expression# initializer;
-               public readonly SourceReference# source_reference;
+               public readonly ref string name;
+               public readonly ref Expression initializer;
+               public readonly ref SourceReference source_reference;
        
-               public static VariableDeclarator# @new (string name, Expression init, SourceReference source) {
+               public static ref VariableDeclarator new (string name, Expression init, SourceReference source) {
                        return (new VariableDeclarator (name = name, initializer = init, source_reference = source));
                }
+               
+               public override void accept (CodeVisitor visitor) {
+                       if (initializer != null) {
+                               initializer.accept (visitor);
+                       }
+               
+                       visitor.visit_variable_declarator (this);
+               }
        }
 }
index 2990926..3af613b 100644 (file)
@@ -447,6 +447,10 @@ vala_context_resolve_types_in_expression (ValaContext *context, ValaNamespace *n
                break;
        case VALA_EXPRESSION_TYPE_OBJECT_CREATION:
                vala_context_resolve_type_reference (context, namespace, NULL, expr->object_creation.type);
+               for (l = expr->object_creation.named_argument_list; l != NULL; l = l->next) {
+                       ValaNamedArgument *na = l->data;
+                       vala_context_resolve_types_in_expression (context, namespace, na->expression);
+               }
                break;
        case VALA_EXPRESSION_TYPE_PARENTHESIZED:
                vala_context_resolve_types_in_expression (context, namespace, expr->inner);