[vala] tag sizeof as constant
- From: Florian Brosch <flobrosch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] tag sizeof as constant
- Date: Sat, 21 Jan 2012 13:08:48 +0000 (UTC)
commit 714bfd1429db327940541f03022ee8374c22db62
Author: Florian Brosch <flo brosch gmail com>
Date: Sat Jan 21 12:55:11 2012 +0100
tag sizeof as constant
tests/Makefile.am | 1 +
tests/basic-types/sizeof.vala | 12 ++++++++++++
vala/valasizeofexpression.vala | 4 ++++
3 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 39e49ce..41760d8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -20,6 +20,7 @@ TESTS = \
basic-types/strings.vala \
basic-types/arrays.vala \
basic-types/pointers.vala \
+ basic-types/sizeof.vala \
basic-types/bug591552.vala \
basic-types/bug595751.vala \
basic-types/bug596637.vala \
diff --git a/tests/basic-types/sizeof.vala b/tests/basic-types/sizeof.vala
new file mode 100644
index 0000000..931891f
--- /dev/null
+++ b/tests/basic-types/sizeof.vala
@@ -0,0 +1,12 @@
+
+
+public const size_t simple_size = sizeof (int);
+public const size_t composed_size = sizeof (int) + sizeof (size_t);
+
+static void main () {
+ assert (composed_size == (sizeof (int) + sizeof (size_t)));
+ assert (simple_size == sizeof (int));
+}
+
+
+
diff --git a/vala/valasizeofexpression.vala b/vala/valasizeofexpression.vala
index 01fda86..42c1ee5 100644
--- a/vala/valasizeofexpression.vala
+++ b/vala/valasizeofexpression.vala
@@ -65,6 +65,10 @@ public class Vala.SizeofExpression : Expression {
return true;
}
+ public override bool is_constant () {
+ return true;
+ }
+
public override void replace_type (DataType old_type, DataType new_type) {
if (type_reference == old_type) {
type_reference = new_type;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]