From: Juerg Billeter Date: Fri, 1 Feb 2008 18:51:12 +0000 (+0000) Subject: report error when declaring static properties X-Git-Tag: VALA_0_1_7~144 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a705e367872aadbfc9eda7bd1cdeefd7ac8d5184;p=platform%2Fupstream%2Fvala.git report error when declaring static properties 2008-02-01 Juerg Billeter * vala/parser.y, vala/valaproperty.vala, vala/valasemanticanalyzer.vala: report error when declaring static properties svn path=/trunk/; revision=947 --- diff --git a/ChangeLog b/ChangeLog index 1b85816..7468d3d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2008-02-01 Jürg Billeter + * vala/parser.y, vala/valaproperty.vala, vala/valasemanticanalyzer.vala: + report error when declaring static properties + +2008-02-01 Jürg Billeter + * vala/valasemanticanalyzer.vala: report error for binary expressions with invalid operands, fixes bug 513708 diff --git a/vala/parser.y b/vala/parser.y index 0384f0f..469419e 100644 --- a/vala/parser.y +++ b/vala/parser.y @@ -3363,6 +3363,9 @@ property_declaration if (($4 & VALA_MODIFIER_OVERRIDE) == VALA_MODIFIER_OVERRIDE) { vala_property_set_overrides ($$, TRUE); } + if (($4 & VALA_MODIFIER_STATIC) == VALA_MODIFIER_STATIC) { + vala_property_set_instance ($$, FALSE); + } } | comment opt_attributes opt_access_modifier opt_modifiers type identifier OPEN_BRACE set_accessor_declaration opt_get_accessor_declaration CLOSE_BRACE { @@ -3396,6 +3399,9 @@ property_declaration if (($4 & VALA_MODIFIER_OVERRIDE) == VALA_MODIFIER_OVERRIDE) { vala_property_set_overrides ($$, TRUE); } + if (($4 & VALA_MODIFIER_STATIC) == VALA_MODIFIER_STATIC) { + vala_property_set_instance ($$, FALSE); + } } ; diff --git a/vala/valaproperty.vala b/vala/valaproperty.vala index fea3a46..f3e22c8 100644 --- a/vala/valaproperty.vala +++ b/vala/valaproperty.vala @@ -1,6 +1,6 @@ /* valaproperty.vala * - * Copyright (C) 2006-2007 Jürg Billeter + * Copyright (C) 2006-2008 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 @@ -88,7 +88,16 @@ public class Vala.Property : Member, Lockable { * property of a base type. */ public bool overrides { get; set; } - + + /** + * Specifies whether this field may only be accessed with an instance of + * the contained type. + */ + public bool instance { + get { return _instance; } + set { _instance = value; } + } + /** * Specifies the virtual or abstract property this property overrides. * Reference must be weak as virtual properties set base_property to @@ -104,6 +113,7 @@ public class Vala.Property : Member, Lockable { private bool lock_used = false; private DataType _data_type; + private bool _instance = true; /** * Creates a new property. diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala index 8a9e185..81d1c6c 100644 --- a/vala/valasemanticanalyzer.vala +++ b/vala/valasemanticanalyzer.vala @@ -583,6 +583,12 @@ public class Vala.SemanticAnalyzer : CodeVisitor { public override void visit_property (Property! prop) { current_symbol = prop; + if (!prop.instance) { + Report.error (prop.source_reference, "static properties are not yet supported"); + prop.error = true; + return; + } + prop.accept_children (this); /* abstract/virtual properties using reference types without