]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Improve performance of SemanticAnalyzer.is_type_accessible
authorJürg Billeter <j@bitron.ch>
Sat, 21 Aug 2010 10:07:28 +0000 (12:07 +0200)
committerJürg Billeter <j@bitron.ch>
Fri, 17 Sep 2010 23:00:13 +0000 (01:00 +0200)
vala/valaarraytype.vala
vala/valadatatype.vala
vala/valadelegatetype.vala
vala/valapointertype.vala
vala/valasemanticanalyzer.vala
vala/valasignaltype.vala
vala/valasymbol.vala

index ee57df57d034afa48d5f58f24f25e0077d150d7a..9c651e739762c3d1cd69247dbfc2680c87b90c4f 100644 (file)
@@ -232,8 +232,8 @@ public class Vala.ArrayType : ReferenceType {
                }
        }
 
-       public override List<Symbol> get_symbols () {
-               return element_type.get_symbols ();
+       public override bool is_accessible (Symbol sym) {
+               return element_type.is_accessible (sym);
        }
 
        public override bool check (SemanticAnalyzer analyzer) {
index 67bba3245a969a6101860052adc8c83e8a6d4a19..aa838d1e346f401ca4bc8ae7aa322e2372023d1c 100644 (file)
@@ -435,17 +435,12 @@ public abstract class Vala.DataType : CodeNode {
                return false;
        }
 
-       /**
-        * Returns a list of symbols that define this type.
-        *
-        * @return symbol list
-        */
-       public virtual List<Symbol> get_symbols () {
-               var symbols = new ArrayList<Symbol> ();
+       // check whether this type is at least as accessible as the specified symbol
+       public virtual bool is_accessible (Symbol sym) {
                if (data_type != null) {
-                       symbols.add (data_type);
+                       return data_type.is_accessible (sym);
                }
-               return symbols;
+               return true;
        }
 
        public virtual Symbol? get_member (string member_name) {
index 5e4938503b4019778f343b4f60fdab0676209334..c904caf294a2e097e2bc2815382aa96d64653d6a 100644 (file)
@@ -93,10 +93,8 @@ public class Vala.DelegateType : DataType {
                }
        }
 
-       public override List<Symbol> get_symbols () {
-               var symbols = new ArrayList<Symbol> ();
-               symbols.add (delegate_symbol);
-               return symbols;
+       public override bool is_accessible (Symbol sym) {
+               return delegate_symbol.is_accessible (sym);
        }
 
        public override string? get_type_id () {
index f1b318d9a535e89d7143c7530182a1b46c436d03..9d11d8d34556c7dee223595d44326b691faddad7 100644 (file)
@@ -118,8 +118,8 @@ public class Vala.PointerType : DataType {
                return SemanticAnalyzer.symbol_lookup_inherited (base_symbol, member_name);
        }
 
-       public override List<Symbol> get_symbols () {
-               return base_type.get_symbols ();
+       public override bool is_accessible (Symbol sym) {
+               return base_type.is_accessible (sym);
        }
 
        public override string? get_type_id () {
index 0d9057ffad9648a87ac4517290c37e3e449a2e23..576412c37e6c2407ec752631ba2b7fdd653c02f7 100644 (file)
@@ -241,16 +241,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
 
        // check whether type is at least as accessible as the specified symbol
        public bool is_type_accessible (Symbol sym, DataType type) {
-               foreach (Symbol type_symbol in type.get_symbols ()) {
-                       Scope method_scope = sym.get_top_accessible_scope ();
-                       Scope type_scope = type_symbol.get_top_accessible_scope ();
-                       if ((method_scope == null && type_scope != null)
-                           || (method_scope != null && !method_scope.is_subscope_of (type_scope))) {
-                               return false;
-                       }
-               }
-
-               return true;
+               return type.is_accessible (sym);
        }
 
        public DataType? get_value_type_for_symbol (Symbol sym, bool lvalue) {
index 11a110933bd282081dab23ab9419473130561f7e..6ab5568cc6cd97c1f4b65a70fbd71c1259abe3be 100644 (file)
@@ -113,9 +113,7 @@ public class Vala.SignalType : DataType {
                return null;
        }
 
-       public override List<Symbol> get_symbols () {
-               var symbols = new ArrayList<Symbol> ();
-               symbols.add (signal_symbol);
-               return symbols;
+       public override bool is_accessible (Symbol sym) {
+               return signal_symbol.is_accessible (sym);
        }
 }
index fd74c6ce7d856eee16419a7f32afb1f7ce353560..cfe25402c3d011a690c3af859d1ba29d540db656 100644 (file)
@@ -534,6 +534,18 @@ public abstract class Vala.Symbol : CodeNode {
 
                return null;
        }
+
+       // check whether this symbol is at least as accessible as the specified symbol
+       public  bool is_accessible (Symbol sym) {
+               Scope sym_scope = sym.get_top_accessible_scope ();
+               Scope this_scope = this.get_top_accessible_scope ();
+               if ((sym_scope == null && this_scope != null)
+                   || (sym_scope != null && !sym_scope.is_subscope_of (this_scope))) {
+                       return false;
+               }
+
+               return true;
+       }
 }
 
 public enum Vala.SymbolAccessibility {