}
}
+ public override void visit_unary_expression (UnaryExpression expr) {
+ var parent_statement = expr.parent_statement;
+ if (parent_statement == null) {
+ base.visit_unary_expression (expr);
+ return;
+ }
+
+ if (expr.operator == UnaryOperator.INCREMENT || expr.operator == UnaryOperator.DECREMENT) {
+ var target_type = copy_type (expr.target_type);
+ begin_replace_expression (expr);
+
+ Expression replacement;
+ if (expr.operator == UnaryOperator.INCREMENT) {
+ replacement = expression (@"$(expr.inner) = $(expr.inner) + 1");
+ } else {
+ replacement = expression (@"$(expr.inner) = $(expr.inner) - 1");
+ }
+ replacement.target_type = target_type;
+
+ end_replace_expression (replacement);
+ return;
+ }
+
+ base.visit_unary_expression (expr);
+ }
+
public override void visit_object_creation_expression (ObjectCreationExpression expr) {
if (expr.tree_can_fail) {
if (expr.parent_node is LocalVariable || expr.parent_node is ExpressionStatement) {
return false;
}
- var old_value = new MemberAccess (ma.inner, ma.member_name, inner.source_reference);
- var bin = new BinaryExpression (operator == UnaryOperator.INCREMENT ? BinaryOperator.PLUS : BinaryOperator.MINUS, old_value, new IntegerLiteral ("1"), source_reference);
-
- var assignment = new Assignment (ma, bin, AssignmentOperator.SIMPLE, source_reference);
- assignment.target_type = target_type;
- context.analyzer.replaced_nodes.add (this);
- parent_node.replace_expression (this, assignment);
- assignment.check (context);
+ value_type = inner.value_type.copy ();
return true;
} else if (operator == UnaryOperator.REF || operator == UnaryOperator.OUT) {
var ea = inner as ElementAccess;