vala r2256 - in trunk: . gobject vala vapi
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r2256 - in trunk: . gobject vala vapi
- Date: Sat, 3 Jan 2009 14:02:49 +0000 (UTC)
Author: juergbi
Date: Sat Jan 3 14:02:48 2009
New Revision: 2256
URL: http://svn.gnome.org/viewvc/vala?rev=2256&view=rev
Log:
2009-01-03 JÃrg Billeter <j bitron ch>
* vala/Makefile.am:
* vala/valaarraytype.vala:
* vala/valabinaryexpression.vala:
* vala/valabooleantype.vala:
* vala/valacharacterliteral.vala:
* vala/valadostatement.vala:
* vala/valaenum.vala:
* vala/valaenumvaluetype.vala:
* vala/valaerrordomain.vala:
* vala/valafloatingtype.vala:
* vala/valaintegerliteral.vala:
* vala/valaintegertype.vala:
* vala/valaobjectcreationexpression.vala:
* vala/valarealliteral.vala:
* vala/valasemanticanalyzer.vala:
* vala/valastruct.vala:
* vala/valastructvaluetype.vala:
* vala/valasymbolresolver.vala:
* vala/valavaluetype.vala:
* gobject/valaccodebasemodule.vala:
* gobject/valaccodemethodmodule.vala:
* vapi/glib-2.0.vapi:
Add BooleanType, EnumValueType, FloatingType, and StructValueType
as ValueType subclasses
Added:
trunk/vala/valabooleantype.vala
trunk/vala/valaenumvaluetype.vala
trunk/vala/valafloatingtype.vala
trunk/vala/valastructvaluetype.vala
Modified:
trunk/ChangeLog
trunk/gobject/valaccodebasemodule.vala
trunk/gobject/valaccodemethodmodule.vala
trunk/vala/Makefile.am
trunk/vala/valaarraytype.vala
trunk/vala/valabinaryexpression.vala
trunk/vala/valacharacterliteral.vala
trunk/vala/valadostatement.vala
trunk/vala/valaenum.vala
trunk/vala/valaerrordomain.vala
trunk/vala/valaintegerliteral.vala
trunk/vala/valaintegertype.vala
trunk/vala/valaobjectcreationexpression.vala
trunk/vala/valarealliteral.vala
trunk/vala/valasemanticanalyzer.vala
trunk/vala/valastruct.vala
trunk/vala/valasymbolresolver.vala
trunk/vala/valavaluetype.vala
trunk/vapi/glib-2.0.vapi
Modified: trunk/gobject/valaccodebasemodule.vala
==============================================================================
--- trunk/gobject/valaccodebasemodule.vala (original)
+++ trunk/gobject/valaccodebasemodule.vala Sat Jan 3 14:02:48 2009
@@ -1,6 +1,6 @@
/* valaccodebasemodule.vala
*
- * Copyright (C) 2006-2008 JÃrg Billeter, Raffaele Sandrini
+ * Copyright (C) 2006-2009 JÃrg Billeter, Raffaele Sandrini
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -553,26 +553,26 @@
root_symbol = context.root;
- bool_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("bool"));
- char_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("char"));
- uchar_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("uchar"));
- unichar_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("unichar"));
- short_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("short"));
- ushort_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("ushort"));
- int_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("int"));
- uint_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("uint"));
- long_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("long"));
- ulong_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("ulong"));
- int8_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("int8"));
- uint8_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("uint8"));
- int16_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("int16"));
- uint16_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("uint16"));
- int32_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("int32"));
- uint32_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("uint32"));
- int64_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("int64"));
- uint64_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("uint64"));
- float_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("float"));
- double_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("double"));
+ bool_type = new BooleanType ((Struct) root_symbol.scope.lookup ("bool"));
+ char_type = new IntegerType ((Struct) root_symbol.scope.lookup ("char"));
+ uchar_type = new IntegerType ((Struct) root_symbol.scope.lookup ("uchar"));
+ unichar_type = new IntegerType ((Struct) root_symbol.scope.lookup ("unichar"));
+ short_type = new IntegerType ((Struct) root_symbol.scope.lookup ("short"));
+ ushort_type = new IntegerType ((Struct) root_symbol.scope.lookup ("ushort"));
+ int_type = new IntegerType ((Struct) root_symbol.scope.lookup ("int"));
+ uint_type = new IntegerType ((Struct) root_symbol.scope.lookup ("uint"));
+ long_type = new IntegerType ((Struct) root_symbol.scope.lookup ("long"));
+ ulong_type = new IntegerType ((Struct) root_symbol.scope.lookup ("ulong"));
+ int8_type = new IntegerType ((Struct) root_symbol.scope.lookup ("int8"));
+ uint8_type = new IntegerType ((Struct) root_symbol.scope.lookup ("uint8"));
+ int16_type = new IntegerType ((Struct) root_symbol.scope.lookup ("int16"));
+ uint16_type = new IntegerType ((Struct) root_symbol.scope.lookup ("uint16"));
+ int32_type = new IntegerType ((Struct) root_symbol.scope.lookup ("int32"));
+ uint32_type = new IntegerType ((Struct) root_symbol.scope.lookup ("uint32"));
+ int64_type = new IntegerType ((Struct) root_symbol.scope.lookup ("int64"));
+ uint64_type = new IntegerType ((Struct) root_symbol.scope.lookup ("uint64"));
+ float_type = new FloatingType ((Struct) root_symbol.scope.lookup ("float"));
+ double_type = new FloatingType ((Struct) root_symbol.scope.lookup ("double"));
string_type = new ObjectType ((Class) root_symbol.scope.lookup ("string"));
var glib_ns = root_symbol.scope.lookup ("GLib");
@@ -586,7 +586,7 @@
garray_type = (TypeSymbol) glib_ns.scope.lookup ("Array");
gbytearray_type = (TypeSymbol) glib_ns.scope.lookup ("ByteArray");
- gquark_type = new ValueType ((TypeSymbol) glib_ns.scope.lookup ("Quark"));
+ gquark_type = new IntegerType ((Struct) glib_ns.scope.lookup ("Quark"));
gvalue_type = (Struct) glib_ns.scope.lookup ("Value");
mutex_type = (Struct) glib_ns.scope.lookup ("StaticRecMutex");
@@ -3496,9 +3496,18 @@
} else if (sym is Interface) {
type = new ObjectType ((Interface) sym);
} else if (sym is Struct) {
- type = new ValueType ((Struct) sym);
+ var st = (Struct) sym;
+ if (st.is_boolean_type ()) {
+ type = new BooleanType (st);
+ } else if (st.is_integer_type ()) {
+ type = new IntegerType (st);
+ } else if (st.is_floating_type ()) {
+ type = new FloatingType (st);
+ } else {
+ type = new StructValueType (st);
+ }
} else if (sym is Enum) {
- type = new ValueType ((Enum) sym);
+ type = new EnumValueType ((Enum) sym);
} else if (sym is ErrorDomain) {
type = new ErrorType ((ErrorDomain) sym, null);
} else if (sym is ErrorCode) {
Modified: trunk/gobject/valaccodemethodmodule.vala
==============================================================================
--- trunk/gobject/valaccodemethodmodule.vala (original)
+++ trunk/gobject/valaccodemethodmodule.vala Sat Jan 3 14:02:48 2009
@@ -1,6 +1,6 @@
/* valaccodemethodmodule.vala
*
- * Copyright (C) 2007-2008 JÃrg Billeter
+ * Copyright (C) 2007-2009 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
@@ -346,7 +346,7 @@
prop_name = new CCodeConstant ("\"%s-type\"".printf (type_param.name.down ()));
param_name = new CCodeIdentifier ("%s_type".printf (type_param.name.down ()));
- cinit.append (new CCodeExpressionStatement (get_construct_property_assignment (prop_name, new ValueType (gtype_type), param_name)));
+ cinit.append (new CCodeExpressionStatement (get_construct_property_assignment (prop_name, new IntegerType ((Struct) gtype_type), param_name)));
prop_name = new CCodeConstant ("\"%s-dup-func\"".printf (type_param.name.down ()));
param_name = new CCodeIdentifier ("%s_dup_func".printf (type_param.name.down ()));
@@ -522,8 +522,12 @@
this_type = new ObjectType ((Class) parent_type);
} else if (parent_type is Interface) {
this_type = new ObjectType ((Interface) parent_type);
+ } else if (parent_type is Struct) {
+ this_type = new StructValueType ((Struct) parent_type);
+ } else if (parent_type is Enum) {
+ this_type = new EnumValueType ((Enum) parent_type);
} else {
- this_type = new ValueType (parent_type);
+ assert_not_reached ();
}
CCodeFormalParameter instance_param = null;
Modified: trunk/vala/Makefile.am
==============================================================================
--- trunk/vala/Makefile.am (original)
+++ trunk/vala/Makefile.am Sat Jan 3 14:02:48 2009
@@ -27,6 +27,7 @@
valabinaryexpression.vala \
valablock.vala \
valabooleanliteral.vala \
+ valabooleantype.vala \
valabreakstatement.vala \
valacastexpression.vala \
valacatchclause.vala \
@@ -57,6 +58,7 @@
valaemptystatement.vala \
valaenum.vala \
valaenumvalue.vala \
+ valaenumvaluetype.vala \
valaerrorcode.vala \
valaerrordomain.vala \
valaerrortype.vala \
@@ -64,6 +66,7 @@
valaexpressionstatement.vala \
valafield.vala \
valafieldprototype.vala \
+ valafloatingtype.vala \
valaflowanalyzer.vala \
valaforeachstatement.vala \
valaformalparameter.vala \
@@ -125,6 +128,7 @@
valastatementlist.vala \
valastringliteral.vala \
valastruct.vala \
+ valastructvaluetype.vala \
valaswitchlabel.vala \
valaswitchsection.vala \
valaswitchstatement.vala \
Modified: trunk/vala/valaarraytype.vala
==============================================================================
--- trunk/vala/valaarraytype.vala (original)
+++ trunk/vala/valaarraytype.vala Sat Jan 3 14:02:48 2009
@@ -1,6 +1,6 @@
/* valaarraytype.vala
*
- * Copyright (C) 2007-2008 JÃrg Billeter
+ * Copyright (C) 2007-2009 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
@@ -74,10 +74,10 @@
var root_symbol = source_reference.file.context.root;
if (rank > 1) {
// length is an int[] containing the dimensions of the array, starting at 0
- ValueType integer = new ValueType((TypeSymbol) root_symbol.scope.lookup("int"));
+ ValueType integer = new IntegerType ((Struct) root_symbol.scope.lookup ("int"));
length_field.field_type = new ArrayType (integer, 1, source_reference);
} else {
- length_field.field_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("int"));
+ length_field.field_type = new IntegerType ((Struct) root_symbol.scope.lookup ("int"));
}
}
@@ -94,7 +94,7 @@
resize_method.set_cname ("g_renew");
var root_symbol = source_reference.file.context.root;
- var int_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("int"));
+ var int_type = new IntegerType ((Struct) root_symbol.scope.lookup ("int"));
resize_method.add_parameter (new FormalParameter ("length", int_type));
@@ -113,7 +113,7 @@
move_method.set_cname ("_vala_array_move");
var root_symbol = source_reference.file.context.root;
- var int_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("int"));
+ var int_type = new IntegerType ((Struct) root_symbol.scope.lookup ("int"));
move_method.add_parameter (new FormalParameter ("src", int_type));
move_method.add_parameter (new FormalParameter ("dest", int_type));
Modified: trunk/vala/valabinaryexpression.vala
==============================================================================
--- trunk/vala/valabinaryexpression.vala (original)
+++ trunk/vala/valabinaryexpression.vala Sat Jan 3 14:02:48 2009
@@ -1,6 +1,6 @@
/* valabinaryexpression.vala
*
- * Copyright (C) 2006-2008 JÃrg Billeter
+ * Copyright (C) 2006-2009 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
@@ -157,7 +157,7 @@
// convert conditional expression into if statement
// required for flow analysis and exception handling
- var local = new LocalVariable (new ValueType (analyzer.bool_type.data_type), get_temp_name (), null, source_reference);
+ var local = new LocalVariable (analyzer.bool_type.copy (), get_temp_name (), null, source_reference);
var decl = new DeclarationStatement (local, source_reference);
decl.check (analyzer);
Added: trunk/vala/valabooleantype.vala
==============================================================================
--- (empty file)
+++ trunk/vala/valabooleantype.vala Sat Jan 3 14:02:48 2009
@@ -0,0 +1,40 @@
+/* valabooleantype.vala
+ *
+ * Copyright (C) 2009 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 boolean type.
+ */
+public class Vala.BooleanType : ValueType {
+ public BooleanType (Struct type_symbol) {
+ base (type_symbol);
+ }
+
+ public override DataType copy () {
+ var result = new BooleanType ((Struct) type_symbol);
+ result.source_reference = source_reference;
+ result.value_owned = value_owned;
+ result.nullable = nullable;
+ return result;
+ }
+}
Modified: trunk/vala/valacharacterliteral.vala
==============================================================================
--- trunk/vala/valacharacterliteral.vala (original)
+++ trunk/vala/valacharacterliteral.vala Sat Jan 3 14:02:48 2009
@@ -1,6 +1,6 @@
/* valacharacterliteral.vala
*
- * Copyright (C) 2006-2008 JÃrg Billeter, Raffaele Sandrini
+ * Copyright (C) 2006-2009 JÃrg Billeter, Raffaele Sandrini
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -85,7 +85,7 @@
checked = true;
- value_type = new ValueType ((TypeSymbol) analyzer.root_symbol.scope.lookup ("char"));
+ value_type = new IntegerType ((Struct) analyzer.root_symbol.scope.lookup ("char"));
return !error;
}
Modified: trunk/vala/valadostatement.vala
==============================================================================
--- trunk/vala/valadostatement.vala (original)
+++ trunk/vala/valadostatement.vala Sat Jan 3 14:02:48 2009
@@ -1,6 +1,6 @@
/* valadostatement.vala
*
- * Copyright (C) 2006-2008 JÃrg Billeter
+ * Copyright (C) 2006-2009 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
@@ -130,7 +130,7 @@
* } while (true);
*/
- var first_local = new LocalVariable (new ValueType (analyzer.bool_type.data_type), get_temp_name (), new BooleanLiteral (false, source_reference), source_reference);
+ var first_local = new LocalVariable (analyzer.bool_type.copy (), get_temp_name (), new BooleanLiteral (false, source_reference), source_reference);
var first_decl = new DeclarationStatement (first_local, source_reference);
first_decl.check (analyzer);
var block = (Block) analyzer.current_symbol;
Modified: trunk/vala/valaenum.vala
==============================================================================
--- trunk/vala/valaenum.vala (original)
+++ trunk/vala/valaenum.vala Sat Jan 3 14:02:48 2009
@@ -1,6 +1,6 @@
/* valaenum.vala
*
- * Copyright (C) 2006-2008 JÃrg Billeter
+ * Copyright (C) 2006-2009 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
@@ -79,7 +79,7 @@
return;
}
if (m.binding == MemberBinding.INSTANCE) {
- m.this_parameter = new FormalParameter ("this", new ValueType (this));
+ m.this_parameter = new FormalParameter ("this", new EnumValueType (this));
m.scope.add (m.this_parameter.name, m.this_parameter);
}
Added: trunk/vala/valaenumvaluetype.vala
==============================================================================
--- (empty file)
+++ trunk/vala/valaenumvaluetype.vala Sat Jan 3 14:02:48 2009
@@ -0,0 +1,41 @@
+/* valaenumvaluetype.vala
+ *
+ * Copyright (C) 2009 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 enum value type.
+ */
+public class Vala.EnumValueType : ValueType {
+ public EnumValueType (Enum type_symbol) {
+ base (type_symbol);
+ }
+
+ public override DataType copy () {
+ var result = new EnumValueType ((Enum) type_symbol);
+ result.source_reference = source_reference;
+ result.value_owned = value_owned;
+ result.nullable = nullable;
+
+ return result;
+ }
+}
Modified: trunk/vala/valaerrordomain.vala
==============================================================================
--- trunk/vala/valaerrordomain.vala (original)
+++ trunk/vala/valaerrordomain.vala Sat Jan 3 14:02:48 2009
@@ -1,6 +1,6 @@
/* valaerrordomain.vala
*
- * Copyright (C) 2008 JÃrg Billeter
+ * Copyright (C) 2008-2009 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
@@ -68,7 +68,7 @@
return;
}
if (m.binding == MemberBinding.INSTANCE) {
- m.this_parameter = new FormalParameter ("this", new ValueType (this));
+ m.this_parameter = new FormalParameter ("this", new ErrorType (this, null));
m.scope.add (m.this_parameter.name, m.this_parameter);
}
Added: trunk/vala/valafloatingtype.vala
==============================================================================
--- (empty file)
+++ trunk/vala/valafloatingtype.vala Sat Jan 3 14:02:48 2009
@@ -0,0 +1,40 @@
+/* valafloatingtype.vala
+ *
+ * Copyright (C) 2009 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 floating-point type.
+ */
+public class Vala.FloatingType : ValueType {
+ public FloatingType (Struct type_symbol) {
+ base (type_symbol);
+ }
+
+ public override DataType copy () {
+ var result = new FloatingType ((Struct) type_symbol);
+ result.source_reference = source_reference;
+ result.value_owned = value_owned;
+ result.nullable = nullable;
+ return result;
+ }
+}
Modified: trunk/vala/valaintegerliteral.vala
==============================================================================
--- trunk/vala/valaintegerliteral.vala (original)
+++ trunk/vala/valaintegerliteral.vala Sat Jan 3 14:02:48 2009
@@ -114,7 +114,7 @@
checked = true;
- value_type = new IntegerType ((TypeSymbol) analyzer.root_symbol.scope.lookup (get_type_name ()), value, get_type_name ());
+ value_type = new IntegerType ((Struct) analyzer.root_symbol.scope.lookup (get_type_name ()), value, get_type_name ());
return !error;
}
Modified: trunk/vala/valaintegertype.vala
==============================================================================
--- trunk/vala/valaintegertype.vala (original)
+++ trunk/vala/valaintegertype.vala Sat Jan 3 14:02:48 2009
@@ -1,6 +1,6 @@
/* valaintegertype.vala
*
- * Copyright (C) 2008 JÃrg Billeter
+ * Copyright (C) 2008-2009 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
@@ -26,18 +26,21 @@
* An integer type.
*/
public class Vala.IntegerType : ValueType {
- string literal_value;
- string literal_type_name;
+ string? literal_value;
+ string? literal_type_name;
- public IntegerType (TypeSymbol type_symbol, string literal_value, string literal_type_name) {
- this.type_symbol = type_symbol;
- data_type = type_symbol;
+ public IntegerType (Struct type_symbol, string? literal_value = null, string? literal_type_name = null) {
+ base (type_symbol);
this.literal_value = literal_value;
this.literal_type_name = literal_type_name;
}
public override DataType copy () {
- return new IntegerType (type_symbol, literal_value, literal_type_name);
+ var result = new IntegerType ((Struct) type_symbol, literal_value, literal_type_name);
+ result.source_reference = source_reference;
+ result.value_owned = value_owned;
+ result.nullable = nullable;
+ return result;
}
public override bool compatible (DataType target_type) {
Modified: trunk/vala/valaobjectcreationexpression.vala
==============================================================================
--- trunk/vala/valaobjectcreationexpression.vala (original)
+++ trunk/vala/valaobjectcreationexpression.vala Sat Jan 3 14:02:48 2009
@@ -1,6 +1,6 @@
/* valaobjectcreationexpression.vala
*
- * Copyright (C) 2006-2008 JÃrg Billeter
+ * Copyright (C) 2006-2009 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
@@ -204,7 +204,7 @@
type_reference = new ObjectType ((Class) type);
} else if (type_sym is Struct) {
type = (TypeSymbol) type_sym;
- type_reference = new ValueType (type);
+ type_reference = new StructValueType ((Struct) type);
} else if (type_sym is ErrorCode) {
type_reference = new ErrorType ((ErrorDomain) type_sym.parent_symbol, (ErrorCode) type_sym, source_reference);
symbol_reference = type_sym;
Modified: trunk/vala/valarealliteral.vala
==============================================================================
--- trunk/vala/valarealliteral.vala (original)
+++ trunk/vala/valarealliteral.vala Sat Jan 3 14:02:48 2009
@@ -1,6 +1,6 @@
/* valarealliteral.vala
*
- * Copyright (C) 2006-2008 JÃrg Billeter
+ * Copyright (C) 2006-2009 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
@@ -77,7 +77,7 @@
checked = true;
- value_type = new ValueType ((TypeSymbol) analyzer.root_symbol.scope.lookup (get_type_name ()));
+ value_type = new FloatingType ((Struct) analyzer.root_symbol.scope.lookup (get_type_name ()));
return !error;
}
Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala (original)
+++ trunk/vala/valasemanticanalyzer.vala Sat Jan 3 14:02:48 2009
@@ -1,6 +1,6 @@
/* valasemanticanalyzer.vala
*
- * Copyright (C) 2006-2008 JÃrg Billeter, Raffaele Sandrini
+ * Copyright (C) 2006-2009 JÃrg Billeter, Raffaele Sandrini
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -83,22 +83,22 @@
root_symbol = context.root;
- bool_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("bool"));
+ bool_type = new BooleanType ((Struct) root_symbol.scope.lookup ("bool"));
string_type = new ObjectType ((Class) root_symbol.scope.lookup ("string"));
- uchar_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("uchar"));
- short_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("short"));
- ushort_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("ushort"));
- int_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("int"));
- uint_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("uint"));
- long_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("long"));
- ulong_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("ulong"));
- size_t_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("size_t"));
- ssize_t_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("ssize_t"));
- uint64_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("uint64"));
- int8_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("int8"));
- unichar_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("unichar"));
- double_type = new ValueType ((TypeSymbol) root_symbol.scope.lookup ("double"));
+ uchar_type = new IntegerType ((Struct) root_symbol.scope.lookup ("uchar"));
+ short_type = new IntegerType ((Struct) root_symbol.scope.lookup ("short"));
+ ushort_type = new IntegerType ((Struct) root_symbol.scope.lookup ("ushort"));
+ int_type = new IntegerType ((Struct) root_symbol.scope.lookup ("int"));
+ uint_type = new IntegerType ((Struct) root_symbol.scope.lookup ("uint"));
+ long_type = new IntegerType ((Struct) root_symbol.scope.lookup ("long"));
+ ulong_type = new IntegerType ((Struct) root_symbol.scope.lookup ("ulong"));
+ size_t_type = new IntegerType ((Struct) root_symbol.scope.lookup ("size_t"));
+ ssize_t_type = new IntegerType ((Struct) root_symbol.scope.lookup ("ssize_t"));
+ uint64_type = new IntegerType ((Struct) root_symbol.scope.lookup ("uint64"));
+ int8_type = new IntegerType ((Struct) root_symbol.scope.lookup ("int8"));
+ unichar_type = new IntegerType ((Struct) root_symbol.scope.lookup ("unichar"));
+ double_type = new FloatingType ((Struct) root_symbol.scope.lookup ("double"));
// TODO: don't require GLib namespace in semantic analyzer
var glib_ns = root_symbol.scope.lookup ("GLib");
@@ -106,7 +106,7 @@
object_type = (Class) glib_ns.scope.lookup ("Object");
initially_unowned_type = (TypeSymbol) glib_ns.scope.lookup ("InitiallyUnowned");
- type_type = new ValueType ((TypeSymbol) glib_ns.scope.lookup ("Type"));
+ type_type = new IntegerType ((Struct) glib_ns.scope.lookup ("Type"));
glist_type = new ObjectType ((Class) glib_ns.scope.lookup ("List"));
gslist_type = new ObjectType ((Class) glib_ns.scope.lookup ("SList"));
@@ -181,7 +181,7 @@
}
return type;
} else if (sym is EnumValue) {
- return new ValueType ((TypeSymbol) sym.parent_symbol);
+ return new EnumValueType ((Enum) sym.parent_symbol);
} else if (sym is Method) {
return new MethodType ((Method) sym);
} else if (sym is Signal) {
@@ -251,9 +251,18 @@
if (sym is ObjectTypeSymbol) {
type = new ObjectType ((ObjectTypeSymbol) sym);
} else if (sym is Struct) {
- type = new ValueType ((Struct) sym);
+ var st = (Struct) sym;
+ if (st.is_boolean_type ()) {
+ type = new BooleanType (st);
+ } else if (st.is_integer_type ()) {
+ type = new IntegerType (st);
+ } else if (st.is_floating_type ()) {
+ type = new FloatingType (st);
+ } else {
+ type = new StructValueType (st);
+ }
} else if (sym is Enum) {
- type = new ValueType ((Enum) sym);
+ type = new EnumValueType ((Enum) sym);
} else if (sym is ErrorDomain) {
type = new ErrorType ((ErrorDomain) sym, null);
} else if (sym is ErrorCode) {
Modified: trunk/vala/valastruct.vala
==============================================================================
--- trunk/vala/valastruct.vala (original)
+++ trunk/vala/valastruct.vala Sat Jan 3 14:02:48 2009
@@ -1,6 +1,6 @@
/* valastruct.vala
*
- * Copyright (C) 2006-2008 JÃrg Billeter
+ * Copyright (C) 2006-2009 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
@@ -39,6 +39,7 @@
private string type_id;
private string lower_case_cprefix;
private string lower_case_csuffix;
+ private bool boolean_type;
private bool integer_type;
private bool floating_type;
private int rank;
@@ -138,7 +139,7 @@
return_if_fail (m != null);
if (m.binding == MemberBinding.INSTANCE || m is CreationMethod) {
- m.this_parameter = new FormalParameter ("this", new ValueType (this));
+ m.this_parameter = new FormalParameter ("this", new StructValueType (this));
m.scope.add (m.this_parameter.name, m.this_parameter);
}
if (!(m.return_type is VoidType) && m.get_postconditions ().size > 0) {
@@ -270,6 +271,21 @@
}
/**
+ * Returns whether this is a boolean type.
+ *
+ * @return true if this is a boolean type, false otherwise
+ */
+ public bool is_boolean_type () {
+ foreach (DataType type in base_types) {
+ var st = type.data_type as Struct;
+ if (st != null && st.is_boolean_type ()) {
+ return true;
+ }
+ }
+ return boolean_type;
+ }
+
+ /**
* Returns whether this is an integer type.
*
* @return true if this is an integer type, false otherwise
@@ -350,13 +366,17 @@
}
}
+ private void process_boolean_type_attribute (Attribute a) {
+ boolean_type = true;
+ }
+
private void process_integer_type_attribute (Attribute a) {
integer_type = true;
if (a.has_argument ("rank")) {
rank = a.get_integer ("rank");
}
}
-
+
private void process_floating_type_attribute (Attribute a) {
floating_type = true;
if (a.has_argument ("rank")) {
@@ -371,6 +391,8 @@
foreach (Attribute a in attributes) {
if (a.name == "CCode") {
process_ccode_attribute (a);
+ } else if (a.name == "BooleanType") {
+ process_boolean_type_attribute (a);
} else if (a.name == "IntegerType") {
process_integer_type_attribute (a);
} else if (a.name == "FloatingType") {
Added: trunk/vala/valastructvaluetype.vala
==============================================================================
--- (empty file)
+++ trunk/vala/valastructvaluetype.vala Sat Jan 3 14:02:48 2009
@@ -0,0 +1,45 @@
+/* valastructvaluetype.vala
+ *
+ * Copyright (C) 2009 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 struct value type.
+ */
+public class Vala.StructValueType : ValueType {
+ public StructValueType (Struct type_symbol) {
+ base (type_symbol);
+ }
+
+ public override DataType copy () {
+ var result = new StructValueType ((Struct) type_symbol);
+ result.source_reference = source_reference;
+ result.value_owned = value_owned;
+ result.nullable = nullable;
+
+ foreach (DataType arg in get_type_arguments ()) {
+ result.add_type_argument (arg.copy ());
+ }
+
+ return result;
+ }
+}
Modified: trunk/vala/valasymbolresolver.vala
==============================================================================
--- trunk/vala/valasymbolresolver.vala (original)
+++ trunk/vala/valasymbolresolver.vala Sat Jan 3 14:02:48 2009
@@ -1,6 +1,6 @@
/* valasymbolresolver.vala
*
- * Copyright (C) 2006-2008 JÃrg Billeter, Raffaele Sandrini
+ * Copyright (C) 2006-2009 JÃrg Billeter, Raffaele Sandrini
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -276,9 +276,18 @@
} else if (sym is Interface) {
type = new ObjectType ((Interface) sym);
} else if (sym is Struct) {
- type = new ValueType ((Struct) sym);
+ var st = (Struct) sym;
+ if (st.is_boolean_type ()) {
+ type = new BooleanType (st);
+ } else if (st.is_integer_type ()) {
+ type = new IntegerType (st);
+ } else if (st.is_floating_type ()) {
+ type = new FloatingType (st);
+ } else {
+ type = new StructValueType (st);
+ }
} else if (sym is Enum) {
- type = new ValueType ((Enum) sym);
+ type = new EnumValueType ((Enum) sym);
} else if (sym is ErrorDomain) {
type = new ErrorType ((ErrorDomain) sym, null, unresolved_type.source_reference);
} else if (sym is ErrorCode) {
Modified: trunk/vala/valavaluetype.vala
==============================================================================
--- trunk/vala/valavaluetype.vala (original)
+++ trunk/vala/valavaluetype.vala Sat Jan 3 14:02:48 2009
@@ -1,6 +1,6 @@
/* valavaluetype.vala
*
- * Copyright (C) 2007-2008 JÃrg Billeter
+ * Copyright (C) 2007-2009 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
@@ -25,7 +25,7 @@
/**
* A value type, i.e. a struct or an enum type.
*/
-public class Vala.ValueType : DataType {
+public abstract class Vala.ValueType : DataType {
/**
* The referred struct or enum.
*/
@@ -36,21 +36,6 @@
data_type = type_symbol;
}
- public override DataType copy () {
- var result = new ValueType (type_symbol);
- result.source_reference = source_reference;
- result.value_owned = value_owned;
- result.nullable = nullable;
- result.is_dynamic = is_dynamic;
- result.floating_reference = floating_reference;
-
- foreach (DataType arg in get_type_arguments ()) {
- result.add_type_argument (arg.copy ());
- }
-
- return result;
- }
-
public override string? get_cname () {
string ptr = "";
if (nullable) {
Modified: trunk/vapi/glib-2.0.vapi
==============================================================================
--- trunk/vapi/glib-2.0.vapi (original)
+++ trunk/vapi/glib-2.0.vapi Sat Jan 3 14:02:48 2009
@@ -30,6 +30,7 @@
[SimpleType]
[CCode (cname = "gboolean", cheader_filename = "glib.h", type_id = "G_TYPE_BOOLEAN", marshaller_type_name = "BOOLEAN", get_value_function = "g_value_get_boolean", set_value_function = "g_value_set_boolean", default_value = "FALSE", type_signature = "b")]
+[BooleanType]
public struct bool {
public string to_string () {
if (this) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]