2007-11-29 Jürg Billeter <j@bitron.ch>
+ * vala/valaaddressofexpression.vala,
+ vala/valaarraycreationexpression.vala, vala/valaassignment.vala,
+ vala/valabaseaccess.vala, vala/valabinaryexpression.vala,
+ vala/valacastexpression.vala, vala/valaconditionalexpression.vala,
+ vala/valaelementaccess.vala, vala/valaexpression.vala,
+ vala/valainitializerlist.vala, vala/valainvocationexpression.vala,
+ vala/valalambdaexpression.vala, vala/valaliteralexpression.vala,
+ vala/valamemberaccess.vala, vala/valaobjectcreationexpression.vala,
+ vala/valaparenthesizedexpression.vala,
+ vala/valapointerindirection.vala, vala/valapostfixexpression.vala,
+ vala/valareferencetransferexpression.vala,
+ vala/valasizeofexpression.vala, vala/valatypecheck.vala,
+ vala/valatypeofexpression.vala, vala/valaunaryexpression.vala: add
+ is_pure method to Expression class
+
+2007-11-29 Jürg Billeter <j@bitron.ch>
+
* tests/: refactor tests to have more descriptive names
2007-11-29 Jürg Billeter <j@bitron.ch>
inner = (Expression) new_node;
}
}
+
+ public override bool is_pure () {
+ return inner.is_pure ();
+ }
}
public override void accept (CodeVisitor! visitor) {
visitor.visit_array_creation_expression (this);
}
+
+ public override bool is_pure () {
+ return false;
+ }
}
right = (Expression) new_node;
}
}
+
+ public override bool is_pure () {
+ return false;
+ }
}
public enum Vala.AssignmentOperator {
public override string! to_string () {
return "base";
}
+
+ public override bool is_pure () {
+ return true;
+ }
}
right = (Expression) new_node;
}
}
+
+ public override bool is_pure () {
+ return left.is_pure () && right.is_pure ();
+ }
}
public enum Vala.BinaryOperator {
/* valacastexpression.vala
*
- * Copyright (C) 2006 Jürg Billeter
+ * Copyright (C) 2006-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
inner = (Expression) new_node;
}
}
+
+ public override bool is_pure () {
+ return inner.is_pure ();
+ }
}
visitor.visit_conditional_expression (this);
}
+
+ public override bool is_pure () {
+ return condition.is_pure () && true_expression.is_pure () && false_expression.is_pure ();
+ }
}
visitor.visit_element_access (this);
}
+
+ public override bool is_pure () {
+ foreach (Expression index in indices) {
+ if (!index.is_pure ()) {
+ return false;
+ }
+ }
+ return container.is_pure ();
+ }
}
* The code generator sets and uses them for memory management.
*/
public ArrayList<VariableDeclarator> temp_vars = new ArrayList<VariableDeclarator> ();
+
+ /**
+ * Returns whether this expression is pure, i.e. whether this expression
+ * is free of side-effects.
+ */
+ public abstract bool is_pure ();
}
public override void accept (CodeVisitor! visitor) {
visitor.visit_initializer_list (this);
}
+
+ public override bool is_pure () {
+ foreach (Expression initializer in initializers) {
+ if (!initializer.is_pure ()) {
+ return false;
+ }
+ }
+ return true;
+ }
}
new_node.parent_node = this;
}
}
+
+ public override bool is_pure () {
+ return false;
+ }
}
method.accept (visitor);
}
}
+
+ public override bool is_pure () {
+ return false;
+ }
}
public override string! to_string () {
return literal.to_string ();
}
+
+ public override bool is_pure () {
+ return true;
+ }
}
inner = (Expression) new_node;
}
}
+
+ public override bool is_pure () {
+ // accessing property could have side-effects
+ return false;
+ }
}
new_node.parent_node = this;
}
}
+
+ public override bool is_pure () {
+ return false;
+ }
}
/* valaparenthesizedexpression.vala
*
- * Copyright (C) 2006 Jürg Billeter
+ * Copyright (C) 2006-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
inner = (Expression) new_node;
}
}
+
+ public override bool is_pure () {
+ return inner.is_pure ();
+ }
}
inner = (Expression) new_node;
}
}
+
+ public override bool is_pure () {
+ return inner.is_pure ();
+ }
}
/* valapostfixexpression.vala
*
- * Copyright (C) 2006 Jürg Billeter
+ * Copyright (C) 2006-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
visitor.visit_postfix_expression (this);
}
+
+ public override bool is_pure () {
+ return false;
+ }
}
inner = (Expression) new_node;
}
}
+
+ public override bool is_pure () {
+ return false;
+ }
}
visitor.visit_sizeof_expression (this);
}
+
+ public override bool is_pure () {
+ return true;
+ }
}
/* valatypecheck.vala
*
- * Copyright (C) 2006 Jürg Billeter
+ * Copyright (C) 2006-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
visitor.visit_type_check (this);
}
+
+ public override bool is_pure () {
+ return expression.is_pure ();
+ }
}
/* valatypeofexpression.vala
*
- * Copyright (C) 2006 Jürg Billeter
+ * Copyright (C) 2006-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
visitor.visit_typeof_expression (this);
}
+
+ public override bool is_pure () {
+ return true;
+ }
}
/* valaunaryexpression.vala
*
- * Copyright (C) 2006 Jürg Billeter
+ * Copyright (C) 2006-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
public override string! to_string () {
return operator_string + _inner.to_string ();
}
+
+ public override bool is_pure () {
+ if (operator == UnaryOperator.INCREMENT || operator == UnaryOperator.DECREMENT) {
+ return false;
+ }
+
+ return inner.is_pure ();
+ }
}
public enum Vala.UnaryOperator {