From: Juerg Billeter Date: Tue, 4 Dec 2007 19:03:22 +0000 (+0000) Subject: use subclasses of DataType X-Git-Tag: VALA_0_1_6~111 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5324ba3fbcf26cc9cbc442dfa199541a40246e3a;p=platform%2Fupstream%2Fvala.git use subclasses of DataType 2007-12-04 Juerg Billeter * vala/valaarray.vala, vala/valaclass.vala, vala/valaenum.vala, vala/valainterface.vala, vala/valareferencetype.vala, vala/valasemanticanalyzer.vala, vala/valasignal.vala, vala/valastruct.vala, gobject/valaccodegeneratormethod.vala, gobject/valadbusbindingprovider.vala: use subclasses of DataType svn path=/trunk/; revision=756 --- diff --git a/ChangeLog b/ChangeLog index 5a07549..4c92c49 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2007-12-04 Jürg Billeter + * vala/valaarray.vala, vala/valaclass.vala, vala/valaenum.vala, + vala/valainterface.vala, vala/valareferencetype.vala, + vala/valasemanticanalyzer.vala, vala/valasignal.vala, + vala/valastruct.vala, gobject/valaccodegeneratormethod.vala, + gobject/valadbusbindingprovider.vala: use subclasses of DataType + +2007-12-04 Jürg Billeter + Update svn:ignore property. 2007-12-04 Jürg Billeter diff --git a/gobject/valaccodegeneratormethod.vala b/gobject/valaccodegeneratormethod.vala index 307d3c8..54155c6 100644 --- a/gobject/valaccodegeneratormethod.vala +++ b/gobject/valaccodegeneratormethod.vala @@ -248,8 +248,7 @@ public class Vala.CCodeGenerator { } var base_expression_type = new DataType (); base_expression_type.data_type = base_method.parent_symbol; - var self_target_type = new DataType (); - self_target_type.data_type = cl; + var self_target_type = new ReferenceType (cl); CCodeExpression cself = get_implicit_cast_expression (new CCodeIdentifier ("base"), base_expression_type, self_target_type); var cdecl = new CCodeDeclaration ("%s *".printf (cl.get_cname ())); diff --git a/gobject/valadbusbindingprovider.vala b/gobject/valadbusbindingprovider.vala index 9ca61c3..80aa980 100644 --- a/gobject/valadbusbindingprovider.vala +++ b/gobject/valadbusbindingprovider.vala @@ -31,7 +31,7 @@ public class Vala.DBusBindingProvider : Object, BindingProvider { set { _context = value; - string_type = (Typesymbol) _context.root.scope.lookup ("string"); + string_type = (Class) _context.root.scope.lookup ("string"); var dbus_ns = _context.root.scope.lookup ("DBus"); if (dbus_ns != null) { @@ -42,7 +42,7 @@ public class Vala.DBusBindingProvider : Object, BindingProvider { } private CodeContext _context; - private Typesymbol string_type; + private Class string_type; private Typesymbol connection_type; private Typesymbol dbus_error_type; @@ -59,8 +59,7 @@ public class Vala.DBusBindingProvider : Object, BindingProvider { } Iterator type_args_it = type_args.iterator (); type_args_it.next (); - var ret_type = new DataType (); - ret_type.data_type = type_args_it.get ().data_type; + var ret_type = type_args_it.get ().copy (); if (!is_dbus_interface (ret_type.data_type)) { return null; } @@ -68,8 +67,7 @@ public class Vala.DBusBindingProvider : Object, BindingProvider { m.set_cname ("dbus_g_proxy_new_for_name"); m.add_cheader_filename ("dbus/dbus-glib.h"); m.access = SymbolAccessibility.PUBLIC; - var string_type_ref = new DataType (); - string_type_ref.data_type = string_type; + var string_type_ref = new ReferenceType (string_type); m.add_parameter (_context.create_formal_parameter ("name", string_type_ref)); m.add_parameter (_context.create_formal_parameter ("path", string_type_ref)); symbols.add (m); diff --git a/vala/valaarray.vala b/vala/valaarray.vala index c941f75..1c866ea 100644 --- a/vala/valaarray.vala +++ b/vala/valaarray.vala @@ -158,8 +158,7 @@ public class Vala.Array : Typesymbol { length_field.access = SymbolAccessibility.PUBLIC; var root_symbol = source_reference.file.context.root; - length_field.type_reference = new DataType (); - length_field.type_reference.data_type = (Typesymbol) root_symbol.scope.lookup ("int"); + length_field.type_reference = new ValueType ((Typesymbol) root_symbol.scope.lookup ("int")); } return length_field; @@ -169,14 +168,13 @@ public class Vala.Array : Typesymbol { if (resize_method == null) { resize_method = new ArrayResizeMethod (source_reference); - resize_method.return_type = new DataType (); + resize_method.return_type = new VoidType (); resize_method.access = SymbolAccessibility.PUBLIC; resize_method.set_cname ("g_renew"); var root_symbol = source_reference.file.context.root; - var int_type = new DataType (); - int_type.data_type = (Typesymbol) root_symbol.scope.lookup ("int"); + var int_type = new ValueType ((Typesymbol) root_symbol.scope.lookup ("int")); resize_method.add_parameter (new FormalParameter ("length", int_type)); @@ -189,14 +187,13 @@ public class Vala.Array : Typesymbol { if (move_method == null) { move_method = new ArrayMoveMethod (source_reference); - move_method.return_type = new DataType (); + move_method.return_type = new VoidType (); move_method.access = SymbolAccessibility.PUBLIC; move_method.set_cname ("_vala_array_move"); var root_symbol = source_reference.file.context.root; - var int_type = new DataType (); - int_type.data_type = (Typesymbol) root_symbol.scope.lookup ("int"); + var int_type = new ValueType ((Typesymbol) root_symbol.scope.lookup ("int")); move_method.add_parameter (new FormalParameter ("src", int_type)); move_method.add_parameter (new FormalParameter ("dest", int_type)); diff --git a/vala/valaclass.vala b/vala/valaclass.vala index 0b089c6..ef9c066 100644 --- a/vala/valaclass.vala +++ b/vala/valaclass.vala @@ -189,8 +189,7 @@ public class Vala.Class : Typesymbol { */ public void add_method (Method! m) { if (m.instance || m is CreationMethod) { - m.this_parameter = new FormalParameter ("this", new DataType ()); - m.this_parameter.type_reference.data_type = this; + m.this_parameter = new FormalParameter ("this", new ReferenceType (this)); m.scope.add (m.this_parameter.name, m.this_parameter); } if (m is CreationMethod) { @@ -224,8 +223,7 @@ public class Vala.Class : Typesymbol { properties.add (prop); scope.add (prop.name, prop); - prop.this_parameter = new FormalParameter ("this", new DataType ()); - prop.this_parameter.type_reference.data_type = this; + prop.this_parameter = new FormalParameter ("this", new ReferenceType (this)); prop.scope.add (prop.this_parameter.name, prop.this_parameter); if (!no_field && prop.set_accessor != null && prop.set_accessor.body == null && diff --git a/vala/valaenum.vala b/vala/valaenum.vala index 71bb89c..4190d26 100644 --- a/vala/valaenum.vala +++ b/vala/valaenum.vala @@ -77,8 +77,7 @@ public class Vala.Enum : Typesymbol { return; } if (m.instance) { - m.this_parameter = new FormalParameter ("this", new DataType ()); - m.this_parameter.type_reference.data_type = this; + m.this_parameter = new FormalParameter ("this", new ValueType (this)); m.scope.add (m.this_parameter.name, m.this_parameter); } diff --git a/vala/valainterface.vala b/vala/valainterface.vala index 82df7d2..4b717bf 100644 --- a/vala/valainterface.vala +++ b/vala/valainterface.vala @@ -122,8 +122,7 @@ public class Vala.Interface : Typesymbol { return; } if (m.instance) { - m.this_parameter = new FormalParameter ("this", new DataType ()); - m.this_parameter.type_reference.data_type = this; + m.this_parameter = new FormalParameter ("this", new ReferenceType (this)); m.scope.add (m.this_parameter.name, m.this_parameter); } diff --git a/vala/valareferencetype.vala b/vala/valareferencetype.vala index 21b48e9..08b6097 100644 --- a/vala/valareferencetype.vala +++ b/vala/valareferencetype.vala @@ -23,15 +23,15 @@ using GLib; /** - * A reference type, i.e. a class type. + * A reference type, i.e. a class or interface type. */ public class Vala.ReferenceType : DataType { /** - * The referred class. + * The referred class or interface. */ - public weak Class type_symbol { get; set; } + public weak Typesymbol type_symbol { get; set; } - public ReferenceType (construct Class! type_symbol) { + public ReferenceType (construct Typesymbol! type_symbol) { data_type = type_symbol; } } diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala index d3ec32c..7f85659 100644 --- a/vala/valasemanticanalyzer.vala +++ b/vala/valasemanticanalyzer.vala @@ -84,25 +84,18 @@ public class Vala.SemanticAnalyzer : CodeVisitor { root_symbol = context.root; - bool_type = new DataType (); - bool_type.data_type = (Typesymbol) root_symbol.scope.lookup ("bool"); - - string_type = new DataType (); - string_type.data_type = (Typesymbol) root_symbol.scope.lookup ("string"); + bool_type = new ValueType ((Typesymbol) root_symbol.scope.lookup ("bool")); + string_type = new ReferenceType ((Typesymbol) root_symbol.scope.lookup ("string")); pointer_type = (Typesymbol) root_symbol.scope.lookup ("pointer"); - int_type = new DataType (); - int_type.data_type = (Typesymbol) root_symbol.scope.lookup ("int"); + int_type = new ValueType ((Typesymbol) root_symbol.scope.lookup ("int")); - uint_type = new DataType (); - uint_type.data_type = (Typesymbol) root_symbol.scope.lookup ("uint"); + uint_type = new ValueType ((Typesymbol) root_symbol.scope.lookup ("uint")); - ulong_type = new DataType (); - ulong_type.data_type = (Typesymbol) root_symbol.scope.lookup ("ulong"); + ulong_type = new ValueType ((Typesymbol) root_symbol.scope.lookup ("ulong")); - unichar_type = new DataType (); - unichar_type.data_type = (Typesymbol) root_symbol.scope.lookup ("unichar"); + unichar_type = new ValueType ((Typesymbol) root_symbol.scope.lookup ("unichar")); // TODO: don't require GLib namespace in semantic analyzer var glib_ns = root_symbol.scope.lookup ("GLib"); @@ -110,8 +103,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { object_type = (Typesymbol) glib_ns.scope.lookup ("Object"); initially_unowned_type = (Typesymbol) glib_ns.scope.lookup ("InitiallyUnowned"); - type_type = new DataType (); - type_type.data_type = (Typesymbol) glib_ns.scope.lookup ("Type"); + type_type = new ValueType ((Typesymbol) glib_ns.scope.lookup ("Type")); glist_type = (Typesymbol) glib_ns.scope.lookup ("List"); gslist_type = (Typesymbol) glib_ns.scope.lookup ("SList"); @@ -605,7 +597,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { current_return_type = acc.prop.type_reference; } else { // void - current_return_type = new DataType (); + current_return_type = new VoidType (); } if (!acc.source_reference.file.pkg) { @@ -1175,8 +1167,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } public override void visit_character_literal (CharacterLiteral! expr) { - expr.static_type = new DataType (); - expr.static_type.data_type = (Typesymbol) root_symbol.scope.lookup ("char"); + expr.static_type = new ValueType ((Typesymbol) root_symbol.scope.lookup ("char")); } public override void visit_integer_literal (IntegerLiteral! expr) { @@ -1195,9 +1186,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } public override void visit_null_literal (NullLiteral! expr) { - /* empty DataType represents null */ - - expr.static_type = new DataType (); + expr.static_type = new NullType (); } public override void visit_literal_expression (LiteralExpression! expr) { @@ -1225,9 +1214,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { var decl = (VariableDeclarator) sym; return decl.type_reference; } else if (sym is EnumValue) { - var type = new DataType (); - type.data_type = (Typesymbol) sym.parent_symbol; - return type; + return new ValueType ((Typesymbol) sym.parent_symbol); } return null; } @@ -1883,8 +1870,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { base_type_it.next (); expr.static_type = base_type_it.get (); } else { - expr.static_type = new DataType (); - expr.static_type.data_type = current_class.base_class; + expr.static_type = new ReferenceType (current_class.base_class); } expr.symbol_reference = expr.static_type.data_type; diff --git a/vala/valasignal.vala b/vala/valasignal.vala index bf8e20f..f8088e5 100644 --- a/vala/valasignal.vala +++ b/vala/valasignal.vala @@ -95,8 +95,7 @@ public class Vala.Signal : Member, Invokable, Lockable { generated_callback = new Callback (null, return_type); generated_callback.instance = true; - var sender_type = new DataType (); - sender_type.data_type = (Typesymbol) parent_symbol; + var sender_type = new ReferenceType ((Typesymbol) parent_symbol); var sender_param = new FormalParameter ("sender", sender_type); generated_callback.add_parameter (sender_param); diff --git a/vala/valastruct.vala b/vala/valastruct.vala index 2e806e4..c5c3217 100644 --- a/vala/valastruct.vala +++ b/vala/valastruct.vala @@ -114,8 +114,7 @@ public class Vala.Struct : Typesymbol { return_if_fail (m != null); if (m.instance) { - m.this_parameter = new FormalParameter ("this", new DataType ()); - m.this_parameter.type_reference.data_type = this; + m.this_parameter = new FormalParameter ("this", new ValueType (this)); m.scope.add (m.this_parameter.name, m.this_parameter); } if (m is CreationMethod) {