From 25ae8db899ef5e3dfa430c2486a1c137c3db5a94 Mon Sep 17 00:00:00 2001 From: Juerg Billeter Date: Mon, 24 Dec 2007 20:37:32 +0000 Subject: [PATCH] add InvalidType class 2007-12-24 Juerg Billeter * vala/Makefile.am, vala/valainvalidtype.vala, vala/valasemanticanalyzer.vala, gobject/valaccodegeneratormethod.vala: add InvalidType class svn path=/trunk/; revision=790 --- ChangeLog | 6 ++++++ gobject/valaccodegeneratormethod.vala | 12 ++++++++++-- vala/Makefile.am | 1 + vala/valainvalidtype.vala | 32 ++++++++++++++++++++++++++++++++ vala/valasemanticanalyzer.vala | 8 ++------ 5 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 vala/valainvalidtype.vala diff --git a/ChangeLog b/ChangeLog index f8a5f64..d2dae6f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2007-12-24 Jürg Billeter + * vala/Makefile.am, vala/valainvalidtype.vala, + vala/valasemanticanalyzer.vala, gobject/valaccodegeneratormethod.vala: + add InvalidType class + +2007-12-24 Jürg Billeter + * vapi/gtk+-2.0.vapi, vapi/packages/gtk+-2.0/: hide deprecated GtkProgress class diff --git a/gobject/valaccodegeneratormethod.vala b/gobject/valaccodegeneratormethod.vala index 7245890..cb21180 100644 --- a/gobject/valaccodegeneratormethod.vala +++ b/gobject/valaccodegeneratormethod.vala @@ -124,8 +124,16 @@ public class Vala.CCodeGenerator { CCodeFormalParameter instance_param = null; if (m.instance || (m.parent_symbol is Struct && m is CreationMethod)) { - var this_type = new DataType (); - this_type.data_type = find_parent_type (m); + Typesymbol parent_type = find_parent_type (m); + DataType this_type; + if (parent_type is Class) { + this_type = new ClassType ((Class) parent_type); + } else if (parent_type is Interface) { + this_type = new InterfaceType ((Interface) parent_type); + } else { + this_type = new ValueType (parent_type); + } + if (m.base_interface_method != null && !m.is_abstract && !m.is_virtual) { var base_type = new InterfaceType ((Interface) m.base_interface_method.parent_symbol); instance_param = new CCodeFormalParameter ("base", base_type.get_cname ()); diff --git a/vala/Makefile.am b/vala/Makefile.am index d88804b..4d6c49f 100644 --- a/vala/Makefile.am +++ b/vala/Makefile.am @@ -67,6 +67,7 @@ libvalacore_la_VALASOURCES = \ valainterface.vala \ valainterfacetype.vala \ valainterfacewriter.vala \ + valainvalidtype.vala \ valainvocationexpression.vala \ valalambdaexpression.vala \ valaliteral.vala \ diff --git a/vala/valainvalidtype.vala b/vala/valainvalidtype.vala new file mode 100644 index 0000000..0791677 --- /dev/null +++ b/vala/valainvalidtype.vala @@ -0,0 +1,32 @@ +/* valainvalidtype.vala + * + * Copyright (C) 2007 Jürg Billeter + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Author: + * Jürg Billeter + */ + +using GLib; + +/** + * An invalid reference to a data type. + */ +public class Vala.InvalidType : DataType { + public InvalidType () { + error = true; + } +} diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala index 43ce031..cae86f0 100644 --- a/vala/valasemanticanalyzer.vala +++ b/vala/valasemanticanalyzer.vala @@ -2301,9 +2301,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { foreach (DataType type in types) { last_type = type; if (type.error) { - base_type = new DataType (); - base_type.error = true; - return base_type; + return new InvalidType (); } if (type.data_type == null && type.type_parameter == null) { if (!null_found) { @@ -2365,10 +2363,8 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } } } else { - base_type = new DataType (); - base_type.error = true; Report.error (type.source_reference, "internal error: unsupported type `%s'".printf (type.to_string ())); - return base_type; + return new InvalidType (); } if (base_type == null) { base_type = new DataType (); -- 2.7.4