[vala] Add support for static properties
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Subject: [vala] Add support for static properties
- Date: Thu, 16 Jul 2009 18:00:43 +0000 (UTC)
commit ce152e4261b46cceb135478685f0885cbdb4d20e
Author: JiÅ?à Zárevúcky <zarevucky jiri gmail com>
Date: Thu Jul 16 19:58:35 2009 +0200
Add support for static properties
Fixes bug 586166.
codegen/valaccodebasemodule.vala | 16 ++++++++++------
vala/valamemberaccess.vala | 2 +-
vala/valaparser.vala | 1 +
vala/valasemanticanalyzer.vala | 3 ++-
4 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 240485e..bea64e0 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -1155,11 +1155,6 @@ internal class Vala.CCodeBaseModule : CCodeModule {
bool returns_real_struct = prop.property_type.is_real_struct_type ();
- var t = (ObjectTypeSymbol) prop.parent_symbol;
-
- var this_type = new ObjectType (t);
- generate_type_declaration (this_type, decl_space);
- var cselfparam = new CCodeFormalParameter ("self", this_type.get_cname ());
CCodeFormalParameter cvalueparam;
if (returns_real_struct) {
@@ -1174,7 +1169,16 @@ internal class Vala.CCodeBaseModule : CCodeModule {
} else {
function = new CCodeFunction (acc.get_cname (), "void");
}
- function.add_parameter (cselfparam);
+
+ if (prop.binding == MemberBinding.INSTANCE) {
+ var t = (ObjectTypeSymbol) prop.parent_symbol;
+ var this_type = new ObjectType (t);
+ generate_type_declaration (this_type, decl_space);
+ var cselfparam = new CCodeFormalParameter ("self", this_type.get_cname ());
+
+ function.add_parameter (cselfparam);
+ }
+
if (acc.writable || acc.construction || returns_real_struct) {
function.add_parameter (cvalueparam);
}
diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala
index 2ef15a4..aa44c1e 100644
--- a/vala/valamemberaccess.vala
+++ b/vala/valamemberaccess.vala
@@ -246,7 +246,7 @@ public class Vala.MemberAccess : Expression {
} else if (sym is Property) {
var prop = (Property) sym;
this_parameter = prop.this_parameter;
- may_access_instance_members = true;
+ may_access_instance_members = (prop.binding == MemberBinding.INSTANCE);
} else if (sym is Constructor) {
var c = (Constructor) sym;
this_parameter = c.this_parameter;
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 5afcd4e..88dacd5 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -2359,6 +2359,7 @@ public class Vala.Parser : CodeVisitor {
var field_type = prop.property_type.copy ();
prop.field = new Field ("_%s".printf (prop.name), field_type, prop.default_expression, prop.source_reference);
prop.field.access = SymbolAccessibility.PRIVATE;
+ prop.field.binding = prop.binding;
}
}
diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala
index 755b0ae..38380f8 100644
--- a/vala/valasemanticanalyzer.vala
+++ b/vala/valasemanticanalyzer.vala
@@ -636,7 +636,8 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
} else if (sym is Destructor) {
return true;
} else if (sym is Property) {
- return true;
+ var p = (Property) sym;
+ return p.binding == MemberBinding.INSTANCE;
}
sym = sym.parent_symbol;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]