From: Rico Tzschichholz Date: Fri, 5 Mar 2021 18:32:38 +0000 (+0100) Subject: Use pre-resolved symbol/type of SemanticAnalyzer if possible X-Git-Tag: 0.51.90~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=497b0a65535e7ac266dfcd4e2cbfa25d1f9651f9;p=thirdparty%2Fvala.git Use pre-resolved symbol/type of SemanticAnalyzer if possible --- diff --git a/codegen/valaccodeattribute.vala b/codegen/valaccodeattribute.vala index a521bbccf..f945540ab 100644 --- a/codegen/valaccodeattribute.vala +++ b/codegen/valaccodeattribute.vala @@ -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); diff --git a/vala/valaarraytype.vala b/vala/valaarraytype.vala index c1ddb8829..44b01b0f2 100644 --- a/vala/valaarraytype.vala +++ b/vala/valaarraytype.vala @@ -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; } diff --git a/vala/valacharacterliteral.vala b/vala/valacharacterliteral.vala index 334359add..c979595c4 100644 --- a/vala/valacharacterliteral.vala +++ b/vala/valacharacterliteral.vala @@ -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; diff --git a/vala/valaenumvaluetype.vala b/vala/valaenumvaluetype.vala index 103828608..aa3ff0bb4 100644 --- a/vala/valaenumvaluetype.vala +++ b/vala/valaenumvaluetype.vala @@ -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; diff --git a/vala/valaerrortype.vala b/vala/valaerrortype.vala index e0b59c5d7..95ce7cf5e 100644 --- a/vala/valaerrortype.vala +++ b/vala/valaerrortype.vala @@ -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 () { diff --git a/vala/valamethod.vala b/vala/valamethod.vala index 99bacda44..427a37980 100644 --- a/vala/valamethod.vala +++ b/vala/valamethod.vala @@ -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; diff --git a/vala/valasignaltype.vala b/vala/valasignaltype.vala index db7934f99..c64cce4a2 100644 --- a/vala/valasignaltype.vala +++ b/vala/valasignaltype.vala @@ -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;