]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Rename Constant.initializer to Constant.value
authorJürg Billeter <j@bitron.ch>
Sun, 25 Jul 2010 09:39:18 +0000 (11:39 +0200)
committerJürg Billeter <j@bitron.ch>
Tue, 27 Jul 2010 13:38:05 +0000 (15:38 +0200)
codegen/valaccodebasemodule.vala
codegen/valadovabasemodule.vala
codegen/valagirwriter.vala
vala/valaconstant.vala

index 4edeb1a88403037e2a18b98042cd445c702ff8c3..677f4ffc80ea6b6464d947f13384bd87612bdbe0 100644 (file)
@@ -776,7 +776,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
                if (!c.external) {
                        generate_type_declaration (c.type_reference, decl_space);
 
-                       var initializer_list = c.initializer as InitializerList;
+                       var initializer_list = c.value as InitializerList;
                        if (initializer_list != null) {
                                var cdecl = new CCodeDeclaration (c.type_reference.get_const_cname ());
                                var arr = "";
@@ -784,7 +784,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
                                        arr = "[%d]".printf (initializer_list.size);
                                }
 
-                               var cinitializer = (CCodeExpression) c.initializer.ccodenode;
+                               var cinitializer = (CCodeExpression) c.value.ccodenode;
                                if (!definition) {
                                        // never output value in header
                                        // special case needed as this method combines declaration and definition
@@ -800,7 +800,7 @@ public class Vala.CCodeBaseModule : CCodeModule {
 
                                decl_space.add_constant_declaration (cdecl);
                        } else {
-                               var cdefine = new CCodeMacroReplacement.with_expression (c.get_cname (), (CCodeExpression) c.initializer.ccodenode);
+                               var cdefine = new CCodeMacroReplacement.with_expression (c.get_cname (), (CCodeExpression) c.value.ccodenode);
                                decl_space.add_type_member_declaration (cdefine);
                        }
                }
index 9f902558961b950f7a9ff3243bdc6715137387ab..915448fe9b7fe64befaa086ceb2d86fc409e889d 100644 (file)
@@ -401,18 +401,18 @@ internal class Vala.DovaBaseModule : CCodeModule {
                c.accept_children (codegen);
 
                if (!c.external) {
-                       if (c.initializer is InitializerList) {
+                       if (c.value is InitializerList) {
                                var cdecl = new CCodeDeclaration (c.type_reference.get_const_cname ());
                                var arr = "";
                                if (c.type_reference is ArrayType) {
                                        arr = "[]";
                                }
-                               cdecl.add_declarator (new CCodeVariableDeclarator ("%s%s".printf (c.get_cname (), arr), (CCodeExpression) c.initializer.ccodenode));
+                               cdecl.add_declarator (new CCodeVariableDeclarator ("%s%s".printf (c.get_cname (), arr), (CCodeExpression) c.value.ccodenode));
                                cdecl.modifiers = CCodeModifiers.STATIC;
 
                                decl_space.add_constant_declaration (cdecl);
                        } else {
-                               var cdefine = new CCodeMacroReplacement.with_expression (c.get_cname (), (CCodeExpression) c.initializer.ccodenode);
+                               var cdefine = new CCodeMacroReplacement.with_expression (c.get_cname (), (CCodeExpression) c.value.ccodenode);
                                decl_space.add_type_member_declaration (cdefine);
                        }
                }
index b01eb478010bd5eb5fc2b47e0854bb56b9c4c887..601583c86d7a02247ffc5f93594185dc5c4178d4 100644 (file)
@@ -487,7 +487,7 @@ public class Vala.GIRWriter : CodeVisitor {
                }
 
                //TODO Add better constant evaluation
-               var initializer = c.initializer;
+               var initializer = c.value;
                string value = literal_expression_to_value_string (initializer);
 
                write_indent ();
index 416ab22c846c14d4d4a904b00701965a4fd287de..223ea45dc21c7779c3ac1a6d7b1dcf1d0f37ac42 100644 (file)
@@ -1,6 +1,6 @@
 /* valaconstant.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
@@ -40,12 +40,12 @@ public class Vala.Constant : Symbol, Lockable {
        /**
         * The value of this constant.
         */
-       public Expression? initializer { 
-               get { return _initializer; }
+       public Expression? value {
+               get { return _value; }
                set {
-                       _initializer = value;
-                       if (_initializer != null) {
-                               _initializer.parent_node = this;
+                       _value = value;
+                       if (_value != null) {
+                               _value.parent_node = this;
                        }
                }
        }
@@ -56,21 +56,21 @@ public class Vala.Constant : Symbol, Lockable {
 
        private DataType _data_type;
 
-       private Expression _initializer;
+       private Expression _value;
 
        /**
         * Creates a new constant.
         *
         * @param name             constant name
         * @param type_reference   constant type
-        * @param initializer      constant value
+        * @param value            constant value
         * @param source_reference reference to source code
         * @return                 newly created constant
         */
-       public Constant (string name, DataType type_reference, Expression? initializer, SourceReference? source_reference, Comment? comment = null) {
+       public Constant (string name, DataType type_reference, Expression? value, SourceReference? source_reference, Comment? comment = null) {
                base (name, source_reference, comment);
                this.type_reference = type_reference;
-               this.initializer = initializer;
+               this.value = value;
        }
 
        public override void accept (CodeVisitor visitor) {
@@ -80,8 +80,8 @@ public class Vala.Constant : Symbol, Lockable {
        public override void accept_children (CodeVisitor visitor) {
                type_reference.accept (visitor);
 
-               if (initializer != null) {              
-                       initializer.accept (visitor);
+               if (value != null) {
+                       value.accept (visitor);
                }
        }
 
@@ -121,8 +121,8 @@ public class Vala.Constant : Symbol, Lockable {
        }
 
        public override void replace_expression (Expression old_node, Expression new_node) {
-               if (initializer == old_node) {
-                       initializer = new_node;
+               if (value == old_node) {
+                       value = new_node;
                }
        }
 
@@ -183,24 +183,24 @@ public class Vala.Constant : Symbol, Lockable {
                }
 
                if (!external) {
-                       if (initializer == null) {
+                       if (value == null) {
                                error = true;
-                               Report.error (source_reference, "A const field requires a initializer to be provided");
+                               Report.error (source_reference, "A const field requires a value to be provided");
                        } else {
-                               initializer.target_type = type_reference;
+                               value.target_type = type_reference;
 
-                               initializer.check (analyzer);
+                               value.check (analyzer);
 
-                               if (!initializer.value_type.compatible (type_reference)) {
+                               if (!value.value_type.compatible (type_reference)) {
                                        error = true;
-                                       Report.error (source_reference, "Cannot convert from `%s' to `%s'".printf (initializer.value_type.to_string (), type_reference.to_string ()));
+                                       Report.error (source_reference, "Cannot convert from `%s' to `%s'".printf (value.value_type.to_string (), type_reference.to_string ()));
                                        return false;
                                }
                        }
                } else {
-                       if (initializer != null) {
+                       if (value != null) {
                                error = true;
-                               Report.error (source_reference, "External constants cannot use initializers");
+                               Report.error (source_reference, "External constants cannot use values");
                        }
                }