diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2019-08-25 15:18:04 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2019-08-28 20:25:37 +0200 |
commit | ba8122d3a64e44eac44c5254c93fb181df601b0a (patch) | |
tree | 3f904ab2eb0f4ced7fe8d98f16a9e73cacc702e2 /codegen/valaccodemethodmodule.vala | |
parent | 0514e4637ff4f4ac7209f9b2c2be565e33390a35 (diff) | |
download | vala-ba8122d3a64e44eac44c5254c93fb181df601b0a.tar.gz |
vala: Move find_parent_type_symbol/get_this_type() to SemanticAnalyzer
Diffstat (limited to 'codegen/valaccodemethodmodule.vala')
-rw-r--r-- | codegen/valaccodemethodmodule.vala | 29 |
1 files changed, 2 insertions, 27 deletions
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala index 7b8702e11..864d6a93e 100644 --- a/codegen/valaccodemethodmodule.vala +++ b/codegen/valaccodemethodmodule.vala @@ -946,20 +946,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule { } } else if ((m.binding == MemberBinding.INSTANCE || (m.parent_symbol is Struct && m is CreationMethod)) && (direction != 2 || get_ccode_finish_instance (m))) { - TypeSymbol parent_type = find_parent_type (m); - DataType this_type; - if (parent_type is Class) { - this_type = new ObjectType ((Class) parent_type); - } else if (parent_type is Interface) { - this_type = new ObjectType ((Interface) parent_type); - } else if (parent_type is Struct) { - this_type = new StructValueType ((Struct) parent_type); - } else if (parent_type is Enum) { - this_type = new EnumValueType ((Enum) parent_type); - } else { - Report.error (parent_type.source_reference, "internal: Unsupported symbol type"); - this_type = new InvalidType (); - } + var this_type = SemanticAnalyzer.get_this_type (m); generate_type_declaration (this_type, decl_space); @@ -979,9 +966,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule { } cparam_map.set (get_param_pos (get_ccode_instance_pos (m)), instance_param); } else if (m.binding == MemberBinding.CLASS) { - TypeSymbol parent_type = find_parent_type (m); - DataType this_type; - this_type = new ClassType ((Class) parent_type); + var this_type = SemanticAnalyzer.get_this_type (m); var class_param = new CCodeParameter ("klass", get_ccode_name (this_type)); cparam_map.set (get_param_pos (get_ccode_instance_pos (m)), class_param); } @@ -1216,16 +1201,6 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule { ccode.add_expression (ccheck); } - private TypeSymbol? find_parent_type (Symbol sym) { - while (sym != null) { - if (sym is TypeSymbol) { - return (TypeSymbol) sym; - } - sym = sym.parent_symbol; - } - return null; - } - public override void visit_creation_method (CreationMethod m) { push_line (m.source_reference); |