2007-12-04 Jürg Billeter <j@bitron.ch>
+ * 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 <j@bitron.ch>
+
* vala/valasymbolresolver.vala: don't call replace_type when type
resolving failed
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;
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;
} 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);
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);
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);
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)");
}
}
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;
}
}
valaarraylengthfield.vala \
valaarraymovemethod.vala \
valaarrayresizemethod.vala \
+ valaarraytype.vala \
valaassignment.vala \
valaattribute.vala \
valaattributeprocessor.vala \
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 \
valatypesymbol.vala \
valaunaryexpression.vala \
valaunresolvedtype.vala \
+ valavaluetype.vala \
valavariabledeclarator.vala \
valawhilestatement.vala \
$(NULL)
--- /dev/null
+/* 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 <j@bitron.ch>
+ */
+
+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) {
+ }
+}
--- /dev/null
+/* 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 <j@bitron.ch>
+ */
+
+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) {
+ }
+}
--- /dev/null
+/* 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 <j@bitron.ch>
+ */
+
+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;
+ }
+}
--- /dev/null
+/* 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 <j@bitron.ch>
+ */
+
+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;
+ }
+}