summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2010-07-25 11:39:18 +0200
committerJürg Billeter <j@bitron.ch>2010-07-27 15:38:05 +0200
commit1f1ecb7a7776f3fd0c5efb7d1635b29f61329b73 (patch)
tree952379708defcd178e7e21629c47c9258efaf2ec
parent11170a0962836e3d7ee79b4b92e58849a63c6e95 (diff)
downloadvala-1f1ecb7a7776f3fd0c5efb7d1635b29f61329b73.tar.gz
Rename Constant.initializer to Constant.value
-rw-r--r--codegen/valaccodebasemodule.vala6
-rw-r--r--codegen/valadovabasemodule.vala6
-rw-r--r--codegen/valagirwriter.vala2
-rw-r--r--vala/valaconstant.vala44
4 files changed, 29 insertions, 29 deletions
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 4edeb1a88..677f4ffc8 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -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);
}
}
diff --git a/codegen/valadovabasemodule.vala b/codegen/valadovabasemodule.vala
index 9f9025589..915448fe9 100644
--- a/codegen/valadovabasemodule.vala
+++ b/codegen/valadovabasemodule.vala
@@ -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);
}
}
diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala
index b01eb4780..601583c86 100644
--- a/codegen/valagirwriter.vala
+++ b/codegen/valagirwriter.vala
@@ -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 ();
diff --git a/vala/valaconstant.vala b/vala/valaconstant.vala
index 416ab22c8..223ea45dc 100644
--- a/vala/valaconstant.vala
+++ b/vala/valaconstant.vala
@@ -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");
}
}