From: Juerg Billeter Date: Tue, 4 Dec 2007 21:33:09 +0000 (+0000) Subject: use subclasses of DataType X-Git-Tag: VALA_0_1_6~109 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7ed426f1b3f87fd9fb3ef2a2acbfed1a33e75d93;p=platform%2Fupstream%2Fvala.git use subclasses of DataType 2007-12-04 Juerg Billeter * vala/valasemanticanalyzer.vala, gobject/valaccodegenerator.vala, gobject/valaccodegeneratormethod.vala, gobject/valadbusbindingprovider.vala: use subclasses of DataType svn path=/trunk/; revision=758 --- diff --git a/ChangeLog b/ChangeLog index 8ff20be..99effae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2007-12-04 Jürg Billeter + * vala/valasemanticanalyzer.vala, gobject/valaccodegenerator.vala, + gobject/valaccodegeneratormethod.vala, + gobject/valadbusbindingprovider.vala: use subclasses of DataType + +2007-12-04 Jürg Billeter + * vala/valacreationmethod.vala, vala/valasemanticanalyzer.vala, gobject/valaccodegeneratormethod.vala: fix return type for creation methods diff --git a/gobject/valaccodegenerator.vala b/gobject/valaccodegenerator.vala index ddbcd0f..18ea2e8 100644 --- a/gobject/valaccodegenerator.vala +++ b/gobject/valaccodegenerator.vala @@ -540,8 +540,7 @@ public class Vala.CCodeGenerator : CodeGenerator { var t = (Typesymbol) prop.parent_symbol; - var this_type = new DataType (); - this_type.data_type = t; + var this_type = new ReferenceType (t); var cselfparam = new CCodeFormalParameter ("self", this_type.get_cname ()); var cvalueparam = new CCodeFormalParameter ("value", prop.type_reference.get_cname (false, true)); diff --git a/gobject/valaccodegeneratormethod.vala b/gobject/valaccodegeneratormethod.vala index a4f7284..6251d1c 100644 --- a/gobject/valaccodegeneratormethod.vala +++ b/gobject/valaccodegeneratormethod.vala @@ -127,12 +127,10 @@ public class Vala.CCodeGenerator { var this_type = new DataType (); this_type.data_type = find_parent_type (m); if (m.base_interface_method != null && !m.is_abstract && !m.is_virtual) { - var base_type = new DataType (); - base_type.data_type = (Typesymbol) m.base_interface_method.parent_symbol; + var base_type = new ReferenceType ((Typesymbol) m.base_interface_method.parent_symbol); instance_param = new CCodeFormalParameter ("base", base_type.get_cname ()); } else if (m.overrides) { - var base_type = new DataType (); - base_type.data_type = (Typesymbol) m.base_method.parent_symbol; + var base_type = new ReferenceType ((Typesymbol) m.base_method.parent_symbol); instance_param = new CCodeFormalParameter ("base", base_type.get_cname ()); } else { if (m.parent_symbol is Struct && !((Struct) m.parent_symbol).is_simple_type ()) { @@ -252,8 +250,7 @@ public class Vala.CCodeGenerator { } else { base_method = m.base_interface_method; } - var base_expression_type = new DataType (); - base_expression_type.data_type = base_method.parent_symbol; + var base_expression_type = new ReferenceType ((Typesymbol) base_method.parent_symbol); var self_target_type = new ReferenceType (cl); CCodeExpression cself = get_implicit_cast_expression (new CCodeIdentifier ("base"), base_expression_type, self_target_type); @@ -385,8 +382,7 @@ public class Vala.CCodeGenerator { var vfunc = new CCodeFunction (m.get_cname (), creturn_type.get_cname ()); vfunc.line = function.line; - var this_type = new DataType (); - this_type.data_type = (Typesymbol) m.parent_symbol; + var this_type = new ReferenceType ((Typesymbol) m.parent_symbol); var cparam = new CCodeFormalParameter ("self", this_type.get_cname ()); vfunc.add_parameter (cparam); diff --git a/gobject/valadbusbindingprovider.vala b/gobject/valadbusbindingprovider.vala index 80aa980..6abdfde 100644 --- a/gobject/valadbusbindingprovider.vala +++ b/gobject/valadbusbindingprovider.vala @@ -95,7 +95,7 @@ public class Vala.DBusBindingProvider : Object, BindingProvider { if (a.left != ma) { return null; } - var s = new DBusSignal (ma.member_name, new DataType (), ma.source_reference); + var s = new DBusSignal (ma.member_name, new VoidType (), ma.source_reference); s.access = SymbolAccessibility.PUBLIC; symbols.add (s); return s; diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala index b6aad08..ee65ecd 100644 --- a/vala/valasemanticanalyzer.vala +++ b/vala/valasemanticanalyzer.vala @@ -610,8 +610,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } public override void visit_constructor (Constructor! c) { - c.this_parameter = new FormalParameter ("this", new DataType ()); - c.this_parameter.type_reference.data_type = (Typesymbol) current_symbol; + c.this_parameter = new FormalParameter ("this", new ReferenceType (current_class)); c.scope.add (c.this_parameter.name, c.this_parameter); c.owner = current_symbol.scope; @@ -912,8 +911,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { var collection_type = stmt.collection.static_type.data_type; if (iterable_type != null && collection_type.is_subtype_of (iterable_type)) { stmt.iterator_variable_declarator = new VariableDeclarator ("%s_it".printf (stmt.variable_name)); - stmt.iterator_variable_declarator.type_reference = new DataType (); - stmt.iterator_variable_declarator.type_reference.data_type = iterator_type; + stmt.iterator_variable_declarator.type_reference = new ReferenceType (iterator_type); stmt.iterator_variable_declarator.type_reference.takes_ownership = true; stmt.iterator_variable_declarator.type_reference.add_type_argument (stmt.type_reference); @@ -992,8 +990,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } clause.variable_declarator = new VariableDeclarator (clause.variable_name); - clause.variable_declarator.type_reference = new DataType (); - clause.variable_declarator.type_reference.data_type = gerror_type; + clause.variable_declarator.type_reference = new ReferenceType (gerror_type); clause.body.scope.add (clause.variable_name, clause.variable_declarator); @@ -1153,13 +1150,11 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } public override void visit_integer_literal (IntegerLiteral! expr) { - expr.static_type = new DataType (); - expr.static_type.data_type = (Typesymbol) root_symbol.scope.lookup (expr.get_type_name ()); + expr.static_type = new ValueType ((Typesymbol) root_symbol.scope.lookup (expr.get_type_name ())); } public override void visit_real_literal (RealLiteral! expr) { - expr.static_type = new DataType (); - expr.static_type.data_type = (Typesymbol) root_symbol.scope.lookup (expr.get_type_name ()); + expr.static_type = new ValueType ((Typesymbol) root_symbol.scope.lookup (expr.get_type_name ())); } public override void visit_string_literal (StringLiteral! expr) { @@ -1701,8 +1696,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { foreach (DataType base_type in base_types) { if (SemanticAnalyzer.symbol_lookup_inherited (base_type.data_type, generic_member.name) != null) { // construct a new type reference for the base type with correctly linked type arguments - var instance_base_type = new DataType (); - instance_base_type.data_type = base_type.data_type; + var instance_base_type = new ReferenceType (base_type.data_type); foreach (DataType type_arg in base_type.get_type_arguments ()) { if (type_arg.type_parameter != null) { // link to type argument of derived type @@ -1903,18 +1897,21 @@ public class Vala.SemanticAnalyzer : CodeVisitor { expr.symbol_reference = constructor_sym; } - if (type_sym is Class || type_sym is Struct) { + if (type_sym is Class) { + type = (Typesymbol) type_sym; + expr.type_reference = new ReferenceType (type); + } else if (type_sym is Struct) { type = (Typesymbol) type_sym; + expr.type_reference = new ValueType (type); } else if (type_sym is Enum && ((Enum) type_sym).error_domain) { type = (Typesymbol) type_sym; + expr.type_reference = new ValueType (type); } else { expr.error = true; Report.error (expr.source_reference, "`%s' is not a class, struct, or error domain".printf (type_sym.get_full_name ())); return; } - expr.type_reference = new DataType (); - expr.type_reference.data_type = type; foreach (DataType type_arg in type_args) { expr.type_reference.add_type_argument (type_arg); @@ -1988,7 +1985,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { Report.error (expr.source_reference, "Invalid type for argument 1"); } } - expr.static_type = new DataType (); + expr.static_type = new VoidType (); } foreach (MemberInitializer init in expr.get_object_initializer ()) {