From: Juerg Billeter Date: Tue, 4 Dec 2007 12:48:31 +0000 (+0000) Subject: add ArrayType, PointerType, ReferenceType, and ValueType classes X-Git-Tag: VALA_0_1_6~114 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e5b456f7ba36c1009a386bcec54641862d097fc9;p=platform%2Fupstream%2Fvala.git add ArrayType, PointerType, ReferenceType, and ValueType classes 2007-12-04 Juerg Billeter * vala/Makefile.am, vala/valaarraytype.vala, vala/valapointertype.vala, vala/valareferencetype.vala, vala/valavaluetype.vala, gobject/valaccodegenerator.vala, gobject/valaccodegeneratormemberaccess.vala: add ArrayType, PointerType, ReferenceType, and ValueType classes svn path=/trunk/; revision=753 --- diff --git a/ChangeLog b/ChangeLog index d1d353c..80dd1dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2007-12-04 Jürg Billeter + * vala/Makefile.am, vala/valaarraytype.vala, vala/valapointertype.vala, + vala/valareferencetype.vala, vala/valavaluetype.vala, + gobject/valaccodegenerator.vala, + gobject/valaccodegeneratormemberaccess.vala: add ArrayType, + PointerType, ReferenceType, and ValueType classes + +2007-12-04 Jürg Billeter + * vala/valasymbolresolver.vala: don't call replace_type when type resolving failed diff --git a/gobject/valaccodegenerator.vala b/gobject/valaccodegenerator.vala index 11fcd63..7b42093 100644 --- a/gobject/valaccodegenerator.vala +++ b/gobject/valaccodegenerator.vala @@ -37,7 +37,7 @@ public class Vala.CCodeGenerator : CodeGenerator { Symbol root_symbol; Symbol current_symbol; - public Symbol current_type_symbol; + public Typesymbol current_type_symbol; Class current_class; Method current_method; DataType current_return_type; diff --git a/gobject/valaccodegeneratormemberaccess.vala b/gobject/valaccodegeneratormemberaccess.vala index 8ed304f..d93d557 100644 --- a/gobject/valaccodegeneratormemberaccess.vala +++ b/gobject/valaccodegeneratormemberaccess.vala @@ -24,7 +24,7 @@ using GLib; public class Vala.CCodeGenerator { - private void process_cmember (MemberAccess! expr, CCodeExpression pub_inst, Typesymbol base_type) { + private void process_cmember (MemberAccess! expr, CCodeExpression pub_inst, DataType base_type) { if (expr.symbol_reference is Method) { var m = (Method) expr.symbol_reference; @@ -75,8 +75,7 @@ public class Vala.CCodeGenerator { } else if (expr.symbol_reference is Field) { var f = (Field) expr.symbol_reference; if (f.instance) { - var instance_expression_type = new DataType (); - instance_expression_type.data_type = base_type; + var instance_expression_type = base_type; var instance_target_type = new DataType (); instance_target_type.data_type = (Typesymbol) f.parent_symbol; CCodeExpression typed_inst = get_implicit_cast_expression (pub_inst, instance_expression_type, instance_target_type); @@ -113,8 +112,7 @@ public class Vala.CCodeGenerator { var base_property_type = (Typesymbol) base_property.parent_symbol; var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_get_%s".printf (base_property_type.get_lower_case_cname (null), base_property.name))); - var instance_expression_type = new DataType (); - instance_expression_type.data_type = base_type; + var instance_expression_type = base_type; var instance_target_type = new DataType (); instance_target_type.data_type = base_property_type; CCodeExpression typed_pub_inst = get_implicit_cast_expression (pub_inst, instance_expression_type, instance_target_type); @@ -170,8 +168,7 @@ public class Vala.CCodeGenerator { if (sig.has_emitter) { var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_%s".printf (cl.get_lower_case_cname (null), sig.name))); - var instance_expression_type = new DataType (); - instance_expression_type.data_type = base_type; + var instance_expression_type = base_type; var instance_target_type = new DataType (); instance_target_type.data_type = cl; CCodeExpression typed_pub_inst = get_implicit_cast_expression (pub_inst, instance_expression_type, instance_target_type); @@ -195,16 +192,17 @@ public class Vala.CCodeGenerator { public override void visit_member_access (MemberAccess! expr) { CCodeExpression pub_inst = null; - Typesymbol base_type = null; + DataType base_type = null; if (expr.inner == null) { pub_inst = new CCodeIdentifier ("self"); if (current_type_symbol != null) { /* base type is available if this is a type method */ - base_type = (Typesymbol) current_type_symbol; - - if (!base_type.is_reference_type ()) { + if (current_type_symbol is Class) { + base_type = new ReferenceType ((Class) current_type_symbol); + } else { + base_type = new ValueType (current_type_symbol); pub_inst = new CCodeIdentifier ("(*self)"); } } @@ -212,7 +210,7 @@ public class Vala.CCodeGenerator { pub_inst = (CCodeExpression) expr.inner.ccodenode; if (expr.inner.static_type != null) { - base_type = expr.inner.static_type.data_type; + base_type = expr.inner.static_type; } } diff --git a/vala/Makefile.am b/vala/Makefile.am index 1d78a87..6f5a073 100644 --- a/vala/Makefile.am +++ b/vala/Makefile.am @@ -19,6 +19,7 @@ libvalacore_la_VALASOURCES = \ valaarraylengthfield.vala \ valaarraymovemethod.vala \ valaarrayresizemethod.vala \ + valaarraytype.vala \ valaassignment.vala \ valaattribute.vala \ valaattributeprocessor.vala \ @@ -85,11 +86,13 @@ libvalacore_la_VALASOURCES = \ valaparser.vala \ valapointer.vala \ valapointerindirection.vala \ + valapointertype.vala \ valapostfixexpression.vala \ valapropertyaccessor.vala \ valaproperty.vala \ valarealliteral.vala \ valareferencetransferexpression.vala \ + valareferencetype.vala \ valareport.vala \ valareturnstatement.vala \ valascope.vala \ @@ -115,6 +118,7 @@ libvalacore_la_VALASOURCES = \ valatypesymbol.vala \ valaunaryexpression.vala \ valaunresolvedtype.vala \ + valavaluetype.vala \ valavariabledeclarator.vala \ valawhilestatement.vala \ $(NULL) diff --git a/vala/valaarraytype.vala b/vala/valaarraytype.vala new file mode 100644 index 0000000..ef85b29 --- /dev/null +++ b/vala/valaarraytype.vala @@ -0,0 +1,36 @@ +/* valaarraytype.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 array type. + */ +public class Vala.ArrayType : DataType { + /** + * The element type. + */ + public weak DataType element_type { get; set; } + + public ArrayType (construct DataType! element_type) { + } +} diff --git a/vala/valapointertype.vala b/vala/valapointertype.vala new file mode 100644 index 0000000..f8cf00a --- /dev/null +++ b/vala/valapointertype.vala @@ -0,0 +1,36 @@ +/* valapointertype.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; + +/** + * A pointer type. + */ +public class Vala.PointerType : DataType { + /** + * The base type the pointer is referring to. + */ + public weak DataType base_type { get; set; } + + public PointerType (construct DataType! base_type) { + } +} diff --git a/vala/valareferencetype.vala b/vala/valareferencetype.vala new file mode 100644 index 0000000..21b48e9 --- /dev/null +++ b/vala/valareferencetype.vala @@ -0,0 +1,37 @@ +/* valareferencetype.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; + +/** + * A reference type, i.e. a class type. + */ +public class Vala.ReferenceType : DataType { + /** + * The referred class. + */ + public weak Class type_symbol { get; set; } + + public ReferenceType (construct Class! type_symbol) { + data_type = type_symbol; + } +} diff --git a/vala/valavaluetype.vala b/vala/valavaluetype.vala new file mode 100644 index 0000000..053d5b7 --- /dev/null +++ b/vala/valavaluetype.vala @@ -0,0 +1,37 @@ +/* valavaluetype.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; + +/** + * A value type, i.e. a struct or an enum type. + */ +public class Vala.ValueType : DataType { + /** + * The referred struct or enum. + */ + public weak Typesymbol type_symbol { get; set; } + + public ValueType (construct Typesymbol! type_symbol) { + data_type = type_symbol; + } +}