summaryrefslogtreecommitdiff
path: root/ccode
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2009-09-22 23:09:03 +0200
committerJürg Billeter <j@bitron.ch>2009-09-22 23:09:03 +0200
commit363f6c8a3475c2221cb08700cb1c785685281892 (patch)
tree1e68af5ae0d230b81e8ff431de43d55f3a20fd97 /ccode
parent0920805aa49de47216f1d1f5d4b2ff9c92df5d61 (diff)
downloadvala-363f6c8a3475c2221cb08700cb1c785685281892.tar.gz
Simplify &(*foo) and *(&foo) to foo
Diffstat (limited to 'ccode')
-rw-r--r--ccode/valaccodeunaryexpression.vala14
1 files changed, 13 insertions, 1 deletions
diff --git a/ccode/valaccodeunaryexpression.vala b/ccode/valaccodeunaryexpression.vala
index 0f33478af..7f2b89b23 100644
--- a/ccode/valaccodeunaryexpression.vala
+++ b/ccode/valaccodeunaryexpression.vala
@@ -1,6 +1,6 @@
/* valaccodeunaryexpression.vala
*
- * Copyright (C) 2006 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
@@ -51,8 +51,20 @@ public class Vala.CCodeUnaryExpression : CCodeExpression {
} else if (operator == CCodeUnaryOperator.BITWISE_COMPLEMENT) {
writer.write_string ("~");
} else if (operator == CCodeUnaryOperator.POINTER_INDIRECTION) {
+ var inner_unary = inner as CCodeUnaryExpression;
+ if (inner_unary != null && inner_unary.operator == CCodeUnaryOperator.ADDRESS_OF) {
+ // simplify expression
+ inner_unary.inner.write (writer);
+ return;
+ }
writer.write_string ("*");
} else if (operator == CCodeUnaryOperator.ADDRESS_OF) {
+ var inner_unary = inner as CCodeUnaryExpression;
+ if (inner_unary != null && inner_unary.operator == CCodeUnaryOperator.POINTER_INDIRECTION) {
+ // simplify expression
+ inner_unary.inner.write (writer);
+ return;
+ }
writer.write_string ("&");
} else if (operator == CCodeUnaryOperator.PREFIX_INCREMENT) {
writer.write_string ("++");