From: Rico Tzschichholz Date: Mon, 17 Apr 2023 15:46:09 +0000 (+0200) Subject: WIP writer where clause X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=377f41037f4a742836e8c98391c6df8cfeda36f1;p=thirdparty%2Fvala.git WIP writer where clause --- diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala index c016497b5..7a497b7b4 100644 --- a/vala/valacodewriter.vala +++ b/vala/valacodewriter.vala @@ -268,6 +268,9 @@ public class Vala.CodeWriter : CodeVisitor { write_type (base_type); } } + + write_type_parameter_constraints (cl.get_type_parameters ()); + write_begin_block (); current_scope = cl.scope; @@ -357,6 +360,8 @@ public class Vala.CodeWriter : CodeVisitor { write_type (st.base_type); } + write_type_parameter_constraints (st.get_type_parameters ()); + write_begin_block (); current_scope = st.scope; @@ -410,6 +415,9 @@ public class Vala.CodeWriter : CodeVisitor { write_type (prerequisite); } } + + write_type_parameter_constraints (iface.get_type_parameters ()); + write_begin_block (); current_scope = iface.scope; @@ -735,6 +743,8 @@ public class Vala.CodeWriter : CodeVisitor { cb.get_error_types (error_types); write_error_domains (error_types); + write_type_parameter_constraints (cb.get_type_parameters ()); + write_string (";"); write_newline (); @@ -853,6 +863,8 @@ public class Vala.CodeWriter : CodeVisitor { m.get_error_types (error_types); write_error_domains (error_types); + write_type_parameter_constraints (m.get_type_parameters ()); + write_code_block (m.body); write_newline (); @@ -1777,6 +1789,30 @@ public class Vala.CodeWriter : CodeVisitor { write_string (">"); } } + + void write_type_parameter_constraints (List type_params) { + if (type_params.size > 0) { + foreach (TypeParameter type_param in type_params) { + unowned DataType? type_constraint = type_param.type_constraint; + if (type_constraint == null) { + continue; + } + write_string (" where "); + write_identifier (type_param.name); + write_string (" : "); + bool first = true; + //FIXME + foreach (DataType type in new DataType[] { type_constraint }) { + if (first) { + first = false; + } else { + write_string (","); + } + write_type (type); + } + } + } + } } public enum Vala.CodeWriterType {