]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Use pre-resolved symbol/type of SemanticAnalyzer if possible
authorRico Tzschichholz <ricotz@ubuntu.com>
Fri, 5 Mar 2021 18:32:38 +0000 (19:32 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Fri, 5 Mar 2021 18:32:38 +0000 (19:32 +0100)
codegen/valaccodeattribute.vala
vala/valaarraytype.vala
vala/valacharacterliteral.vala
vala/valaenumvaluetype.vala
vala/valaerrortype.vala
vala/valamethod.vala
vala/valasignaltype.vala

index a521bbccf17f54b21187c9688a18835af43a69ff..f945540abed6e2a65a08627dc8126c86847b424c 100644 (file)
@@ -1035,7 +1035,7 @@ public class Vala.CCodeAttribute : AttributeCache {
                        } else {
                                return "G_TYPE_POINTER";
                        }
-               } else if (node is ArrayType && ((ArrayType) node).element_type.type_symbol.get_full_name () == "string") {
+               } else if (node is ArrayType && ((ArrayType) node).element_type.type_symbol == CodeContext.get ().analyzer.string_type.type_symbol) {
                        return "G_TYPE_STRV";
                } else if (node is PointerType || node is DelegateType) {
                        return "G_TYPE_POINTER";
@@ -1123,7 +1123,7 @@ public class Vala.CCodeAttribute : AttributeCache {
                        return "POINTER";
                } else if (node is ArrayType) {
                        unowned ArrayType array_type = (ArrayType) node;
-                       if (array_type.element_type.type_symbol.get_full_name () == "string") {
+                       if (array_type.element_type.type_symbol == CodeContext.get ().analyzer.string_type.type_symbol) {
                                return "BOXED,%s".printf (get_ccode_marshaller_type_name (array_type.length_type.type_symbol));
                        } else {
                                var ret = "POINTER";
@@ -1391,7 +1391,7 @@ public class Vala.CCodeAttribute : AttributeCache {
                                        return "g_param_spec_boxed";
                                }
                        }
-               } else if (node is ArrayType && ((ArrayType)node).element_type.type_symbol == CodeContext.get().analyzer.string_type.type_symbol) {
+               } else if (node is ArrayType && ((ArrayType) node).element_type.type_symbol == CodeContext.get ().analyzer.string_type.type_symbol) {
                        return "g_param_spec_boxed";
                } else if (node is DataType && ((DataType) node).type_symbol != null) {
                        return get_ccode_param_spec_function (((DataType) node).type_symbol);
index c1ddb882984bce726597de303cc02a5241ce9a69..44b01b0f2a156d63b2664a8959b8f97f578777cf 100644 (file)
@@ -210,7 +210,7 @@ public class Vala.ArrayType : ReferenceType {
                var context = CodeContext.get ();
 
                if (context.profile == Profile.GOBJECT && target_type.type_symbol != null) {
-                       if (target_type.type_symbol.is_subtype_of (context.analyzer.gvalue_type.type_symbol) && element_type.type_symbol == context.root.scope.lookup ("string")) {
+                       if (target_type.type_symbol.is_subtype_of (context.analyzer.gvalue_type.type_symbol) && element_type.type_symbol == context.analyzer.string_type.type_symbol) {
                                // allow implicit conversion from string[] to GValue
                                return true;
                        }
index 334359add55b63a38a5d0dce7398dc760b227a21..c979595c4b86435e351d2cc0ca93a33686bca779 100644 (file)
@@ -91,9 +91,9 @@ public class Vala.CharacterLiteral : Literal {
                checked = true;
 
                if (get_char () < 128) {
-                       value_type = new IntegerType ((Struct) context.root.scope.lookup ("char"));
+                       value_type = context.analyzer.char_type.copy ();
                } else {
-                       value_type = new IntegerType ((Struct) context.root.scope.lookup ("unichar"));
+                       value_type = context.analyzer.unichar_type.copy ();
                }
 
                return !error;
index 1038286087afaeab445683b1e5a41ec46d7904fc..aa3ff0bb467f1f685d55803bc92d666acdd3b72f 100644 (file)
@@ -43,7 +43,7 @@ public class Vala.EnumValueType : ValueType {
 
        public unowned Method get_to_string_method () {
                if (to_string_method == null) {
-                       var string_type = new ObjectType ((Class) CodeContext.get ().root.scope.lookup ("string"));
+                       var string_type = CodeContext.get ().analyzer.string_type.copy ();
                        string_type.value_owned = false;
                        to_string_method = new Method ("to_string", string_type);
                        to_string_method.access = SymbolAccessibility.PUBLIC;
index e0b59c5d73ab54939a0b1c3285381880213bd24c..95ce7cf5e2278b4707042a910dbe60a177f7c5df 100644 (file)
@@ -115,8 +115,7 @@ public class Vala.ErrorType : ReferenceType {
        }
 
        public override Symbol? get_member (string member_name) {
-               var gerror_symbol = CodeContext.get ().root.scope.lookup ("GLib").scope.lookup ("Error");
-               return gerror_symbol.scope.lookup (member_name);
+               return CodeContext.get ().analyzer.gerror_type.scope.lookup (member_name);
        }
 
        public override bool is_reference_type_or_type_parameter () {
index 99bacda44e90dabcf9b5cc66746f1a6cc747c3fe..427a379804ee8e0208609eb30eabbf391df8ad51 100644 (file)
@@ -1201,7 +1201,7 @@ public class Vala.Method : Subroutine, Callable {
                assert (this.coroutine);
 
                if (callback_method == null) {
-                       var bool_type = new BooleanType ((Struct) CodeContext.get ().root.scope.lookup ("bool"));
+                       var bool_type = CodeContext.get ().analyzer.bool_type.copy ();
                        bool_type.value_owned = true;
                        callback_method = new Method ("callback", bool_type, source_reference);
                        callback_method.access = SymbolAccessibility.PUBLIC;
index db7934f99167110727bf01b78875d470c331e26e..c64cce4a2c5f89ce49cb2fd98fb2c3b3e791095f 100644 (file)
@@ -71,7 +71,7 @@ public class Vala.SignalType : CallableType {
 
        unowned Method get_connect_method () {
                if (connect_method == null) {
-                       var ulong_type = new IntegerType ((Struct) CodeContext.get ().root.scope.lookup ("ulong"));
+                       var ulong_type = CodeContext.get ().analyzer.ulong_type.copy ();
                        connect_method = new Method ("connect", ulong_type);
                        connect_method.access = SymbolAccessibility.PUBLIC;
                        connect_method.external = true;
@@ -83,7 +83,7 @@ public class Vala.SignalType : CallableType {
 
        unowned Method get_connect_after_method () {
                if (connect_after_method == null) {
-                       var ulong_type = new IntegerType ((Struct) CodeContext.get ().root.scope.lookup ("ulong"));
+                       var ulong_type = CodeContext.get ().analyzer.ulong_type.copy ();
                        connect_after_method = new Method ("connect_after", ulong_type);
                        connect_after_method.access = SymbolAccessibility.PUBLIC;
                        connect_after_method.external = true;