report error when declaring static properties
authorJuerg Billeter <j@bitron.ch>
Fri, 1 Feb 2008 18:51:12 +0000 (18:51 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Fri, 1 Feb 2008 18:51:12 +0000 (18:51 +0000)
2008-02-01  Juerg Billeter  <j@bitron.ch>

* vala/parser.y, vala/valaproperty.vala, vala/valasemanticanalyzer.vala:
  report error when declaring static properties

svn path=/trunk/; revision=947

ChangeLog
vala/parser.y
vala/valaproperty.vala
vala/valasemanticanalyzer.vala

index 1b85816..7468d3d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2008-02-01  Jürg Billeter  <j@bitron.ch>
 
+       * vala/parser.y, vala/valaproperty.vala, vala/valasemanticanalyzer.vala:
+         report error when declaring static properties
+
+2008-02-01  Jürg Billeter  <j@bitron.ch>
+
        * vala/valasemanticanalyzer.vala: report error for binary
          expressions with invalid operands, fixes bug 513708
 
index 0384f0f..469419e 100644 (file)
@@ -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);
+               }
          }
        ;
 
index fea3a46..f3e22c8 100644 (file)
@@ -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.
index 8a9e185..81d1c6c 100644 (file)
@@ -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