public override AccessorOrMutator VisitPostfixUnaryExpression(PostfixUnaryExpressionSyntax node) { var operand = Visit(node.Operand); switch (node.Kind()) { case SyntaxKind.PostIncrementExpression: case SyntaxKind.PostDecrementExpression: { var accessor = operand as Accessor; if (accessor != null) { var methodSymbol = Model.GetSymbolInfo(node).Symbol as IMethodSymbol; if (methodSymbol != null) { var value = operand.GetMutator(this); var result = Lifter.LiftInstanceNonVoidNullaryMethod(methodSymbol)(accessor.GetMutator(this)); accessor.AcceptAssignment(this, result.Item1); return(value); // Return the value before the assignment } } break; } } throw new SyntaxErrorException("Unsupported syntax: " + node); }
public override AccessorOrMutator VisitPrefixUnaryExpression(PrefixUnaryExpressionSyntax node) { var operand = Visit(node.Operand); switch (node.Kind()) { case SyntaxKind.PreIncrementExpression: case SyntaxKind.PreDecrementExpression: { var accessor = operand as Accessor; if (accessor != null) { var methodSymbol = Model.GetSymbolInfo(node).Symbol as IMethodSymbol; if (methodSymbol != null) { var result = Lifter.LiftInstanceNonVoidNullaryMethod(methodSymbol)(accessor.GetMutator(this)); accessor.AcceptAssignment(this, result.Item1); return(result.Item2); } } break; } case SyntaxKind.UnaryPlusExpression: case SyntaxKind.UnaryMinusExpression: case SyntaxKind.BitwiseNotExpression: case SyntaxKind.LogicalNotExpression: { var methodSymbol = Model.GetSymbolInfo(node).Symbol as IMethodSymbol; if (methodSymbol != null) { return(Lifter.LiftStaticNonVoidUnaryMethod(methodSymbol)(operand.GetMutator(this))); } else if (node.Operand is LiteralExpressionSyntax) { var literalExpr = operand.GetMutator(this).CreateUpdate(); if (literalExpr is BitVecExpr) { return(operand.GetMutator(this).WithValue(Ctx.MkBVNeg((BitVecExpr)literalExpr))); } throw new SyntaxErrorException("Unsupported literal syntax: " + node); } break; } } throw new SyntaxErrorException("Unsupported syntax: " + node); }