Browse Source

Parenthesize all expression to ensure correctness.

pull/1/head^2
David Srbecký 18 years ago
parent
commit
6faf690899
  1. 393
      bin/Debug/output.cs
  2. 48
      src/AstMetodBodyBuilder.cs
  3. 38
      src/StackExpression.cs

393
bin/Debug/output.cs

@ -31,295 +31,322 @@ namespace Reversi
} }
public void SetForNewGame() public void SetForNewGame()
{ {
for (int i = 0; (i < 8); i = (i + 1)) { for (int i = (0); (((i) < (8)));) {
for (int j = 0; (j < 8); j = (j + 1)) { for (int j = (0); (((j) < (8)));) {
(@this.squares).Set(i, j, (IL__ldsfld(Empty))); (((@this).squares).Set((i), (j), IL__ldsfld(Empty)));
(@this.safeDiscs).Set(i, j, 0); (((@this).safeDiscs).Set((i), (j), (0)));
(j = ((j) + (1)));
} }
(i = ((i) + (1)));
} }
(@this.squares).Set(3, 3, (IL__ldsfld(White))); (((@this).squares).Set((3), (3), IL__ldsfld(White)));
(@this.squares).Set(3, 4, (IL__ldsfld(Black))); (((@this).squares).Set((3), (4), IL__ldsfld(Black)));
(@this.squares).Set(4, 3, (IL__ldsfld(Black))); (((@this).squares).Set((4), (3), IL__ldsfld(Black)));
(@this.squares).Set(4, 4, (IL__ldsfld(White))); (((@this).squares).Set((4), (4), IL__ldsfld(White)));
@this.UpdateCounts(); ((@this).UpdateCounts());
} }
public int GetSquareContents(int row, int col) public int GetSquareContents(int row, int col)
{ {
return (@this.squares).Get(row, col); return (((@this).squares).Get((row), (col)));
} }
public void MakeMove(int color, int row, int col) public void MakeMove(int color, int row, int col)
{ {
(@this.squares).Set(row, col, color); (((@this).squares).Set((row), (col), (color)));
for (int i = -1; (i <= 1); i = (i + 1)) { for (int i = (-1); (((i) <= (1)));) {
for (int j = -1; (j <= 1); j = (j + 1)) { for (int j = (-1); (((j) <= (1)));) {
if (!(((!i && !j) || !@this.IsOutflanking(color, row, col, i, j)))) { if (!(((!((i)) && (!(j))) || (!((@this).IsOutflanking((color), (row), (col), (i), (j))))))) {
int k = (row + i); int k = ((row) + (i));
for (int l = (col + j); ((@this.squares).Get(k, l) == -color); l = (l + j)) { for (int l = ((col) + (j)); (((((@this).squares).Get((k), (l))) == (-(color))));) {
(@this.squares).Set(k, l, color); (((@this).squares).Set((k), (l), (color)));
k = (k + i); (k = ((k) + (i)));
(l = ((l) + (j)));
} }
} }
(j = ((j) + (1)));
} }
(i = ((i) + (1)));
} }
@this.UpdateCounts(); ((@this).UpdateCounts());
} }
public bool HasAnyValidMove(int color) public bool HasAnyValidMove(int color)
{ {
for (int i = 0; (i < 8); i = (i + 1)) { for (int i = (0); (((i) < (8)));) {
for (int j = 0; (j < 8); j = (j + 1)) { for (int j = (0); (((j) < (8)));) {
if (!(!@this.IsValidMove(color, i, j))) { if (!((!((@this).IsValidMove((color), (i), (j)))))) {
return 1; return (1);
} }
(j = ((j) + (1)));
} }
(i = ((i) + (1)));
} }
return 0; return (0);
} }
public bool IsValidMove(int color, int row, int col) public bool IsValidMove(int color, int row, int col)
{ {
if (!((@this.squares).Get(row, col) == (IL__ldsfld(Empty)))) { if (!(((((@this).squares).Get((row), (col))) == IL__ldsfld(Empty)))) {
return 0; return (0);
} }
for (int i = -1; (i <= 1); i = (i + 1)) { for (int i = (-1); (((i) <= (1)));) {
for (int j = -1; (j <= 1); j = (j + 1)) { for (int j = (-1); (((j) <= (1)));) {
if (!(((!i && !j) || !@this.IsOutflanking(color, row, col, i, j)))) { if (!(((!((i)) && (!(j))) || (!((@this).IsOutflanking((color), (row), (col), (i), (j))))))) {
return 1; return (1);
} }
(j = ((j) + (1)));
} }
(i = ((i) + (1)));
} }
return 0; return (0);
} }
public int GetValidMoveCount(int color) public int GetValidMoveCount(int color)
{ {
int i = 0; int i = (0);
for (int j = 0; (j < 8); j = (j + 1)) { for (int j = (0); (((j) < (8)));) {
for (int k = 0; (k < 8); k = (k + 1)) { for (int k = (0); (((k) < (8)));) {
if (!(!@this.IsValidMove(color, j, k))) { if (!((!((@this).IsValidMove((color), (j), (k)))))) {
i = (i + 1); (i = ((i) + (1)));
} }
(k = ((k) + (1)));
} }
(j = ((j) + (1)));
} }
return i; return (i);
} }
private bool IsOutflanking(int color, int row, int col, int dr, int dc) private bool IsOutflanking(int color, int row, int col, int dr, int dc)
{ {
int i = (row + dr); int i = ((row) + (dr));
for (int j = (col + dc); ((!(((i < 0 || i >= 8) || j < 0) || j >= 8) && (@this.squares).Get(i, j) == -color)); j = (j + dc)) { for (int j = ((col) + (dc)); ((!(((((i) < (0)) || ((i) >= (8))) || ((j) < (0))) || ((j) >= (8))) && ((((@this).squares).Get((i), (j))) == (-(color)))));) {
i = (i + dr); (i = ((i) + (dr)));
(j = ((j) + (dc)));
} }
if (!((!((((i < 0 || i > 7) || j < 0) || j > 7) || (!(i - dr) != row && (j - dc) == col)) && (@this.squares).Get(i, j) == color))) { if (!((!((((((i) < (0)) || ((i) > (7))) || ((j) < (0))) || ((j) > (7))) || (!(((i) - (dr)) != (row)) && (((j) - (dc)) == (col)))) && ((((@this).squares).Get((i), (j))) == (color))))) {
return 0; return (0);
} }
return 1; return (1);
} }
private void UpdateCounts() private void UpdateCounts()
{ {
@this.blackCount = 0; ((@this).blackCount = (0));
@this.whiteCount = 0; ((@this).whiteCount = (0));
@this.emptyCount = 0; ((@this).emptyCount = (0));
@this.blackFrontierCount = 0; ((@this).blackFrontierCount = (0));
@this.whiteFrontierCount = 0; ((@this).whiteFrontierCount = (0));
@this.whiteSafeCount = 0; ((@this).whiteSafeCount = (0));
@this.blackSafeCount = 0; ((@this).blackSafeCount = (0));
for (bool V_2 = 1; (V_2);) { for (bool V_2 = (1); (((V_2)));) {
V_2 = 0; (V_2 = (0));
for (int i = 0; (i < 8); i = (i + 1)) { for (int i = (0); (((i) < (8)));) {
for (int j = 0; (j < 8); j = (j + 1)) { for (int j = (0); (((j) < (8)));) {
if (!((((@this.squares).Get(i, j) == (IL__ldsfld(Empty)) || (@this.safeDiscs).Get(i, j)) || @this.IsOutflankable(i, j)))) { if (!(((((((@this).squares).Get((i), (j))) == IL__ldsfld(Empty)) || ((((@this).safeDiscs).Get((i), (j))))) || (((@this).IsOutflankable((i), (j))))))) {
(@this.safeDiscs).Set(i, j, 1); (((@this).safeDiscs).Set((i), (j), (1)));
V_2 = 1; (V_2 = (1));
} }
(j = ((j) + (1)));
} }
(i = ((i) + (1)));
} }
} }
i = 0; (i = (0));
for (; (i < 8); i = (i + 1)) { for (; (((i) < (8)));) {
j = 0; (j = (0));
for (; (j < 8); j = (j + 1)) { for (; (((j) < (8)));) {
bool V_5 = 0; bool V_5 = (0);
if (!((@this.squares).Get(i, j) == (IL__ldsfld(Empty)))) { if (!(((((@this).squares).Get((i), (j))) == IL__ldsfld(Empty)))) {
for (int k = -1; (k <= 1); k = (k + 1)) { for (int k = (-1); (((k) <= (1)));) {
for (int l = -1; (l <= 1); l = (l + 1)) { for (int l = (-1); (((l) <= (1)));) {
if (!(((((((!k && !l) || (i + k) < 0) || (i + k) >= 8) || (j + l) < 0) || (j + l) >= 8) || (@this.squares).Get((i + k), (j + l)) != (IL__ldsfld(Empty))))) { if (!(((((((!((k)) && (!(l))) || (((i) + (k)) < (0))) || (((i) + (k)) >= (8))) || (((j) + (l)) < (0))) || (((j) + (l)) >= (8))) || ((((@this).squares).Get(((i) + (k)), ((j) + (l)))) != IL__ldsfld(Empty))))) {
V_5 = 1; (V_5 = (1));
} }
(l = ((l) + (1)));
} }
(k = ((k) + (1)));
} }
} }
if (!((@this.squares).Get(i, j) != (IL__ldsfld(Black)))) { if (!(((((@this).squares).Get((i), (j))) != IL__ldsfld(Black)))) {
IL__dup(@this); IL__dup((@this));
object expr123 = expr122.blackCount; object expr123 = (expr122.blackCount);
int expr129 = expr123 + 1; int expr129 = (expr123 + (1));
expr122.blackCount = expr129; (expr122.blackCount = expr129);
if (!(!V_5)) { if (!((!(V_5)))) {
IL__dup(@this); IL__dup((@this));
object expr135 = expr134.blackFrontierCount; object expr135 = (expr134.blackFrontierCount);
int expr13B = expr135 + 1; int expr13B = (expr135 + (1));
expr134.blackFrontierCount = expr13B; (expr134.blackFrontierCount = expr13B);
} }
if (!(!(@this.safeDiscs).Get(i, j))) { if (!((!(((@this).safeDiscs).Get((i), (j)))))) {
IL__dup(@this); IL__dup((@this));
object expr152 = expr151.blackSafeCount; object expr152 = (expr151.blackSafeCount);
int expr158 = expr152 + 1; int expr158 = (expr152 + (1));
expr151.blackSafeCount = expr158; (expr151.blackSafeCount = expr158);
} }
} }
else { else {
if (!((@this.squares).Get(i, j) != (IL__ldsfld(White)))) { if (!(((((@this).squares).Get((i), (j))) != IL__ldsfld(White)))) {
IL__dup(@this); IL__dup((@this));
object expr176 = expr175.whiteCount; object expr176 = (expr175.whiteCount);
int expr17C = expr176 + 1; int expr17C = (expr176 + (1));
expr175.whiteCount = expr17C; (expr175.whiteCount = expr17C);
if (!(!V_5)) { if (!((!(V_5)))) {
IL__dup(@this); IL__dup((@this));
object expr188 = expr187.whiteFrontierCount; object expr188 = (expr187.whiteFrontierCount);
int expr18E = expr188 + 1; int expr18E = (expr188 + (1));
expr187.whiteFrontierCount = expr18E; (expr187.whiteFrontierCount = expr18E);
} }
if (!(!(@this.safeDiscs).Get(i, j))) { if (!((!(((@this).safeDiscs).Get((i), (j)))))) {
IL__dup(@this); IL__dup((@this));
object expr1A5 = expr1A4.whiteSafeCount; object expr1A5 = (expr1A4.whiteSafeCount);
int expr1AB = expr1A5 + 1; int expr1AB = (expr1A5 + (1));
expr1A4.whiteSafeCount = expr1AB; (expr1A4.whiteSafeCount = expr1AB);
continue; goto BasicBlock_313;
} }
else { else {
continue; goto BasicBlock_313;
} }
} }
IL__dup(@this); IL__dup((@this));
object expr1B5 = expr1B4.emptyCount; object expr1B5 = (expr1B4.emptyCount);
int expr1BB = expr1B5 + 1; int expr1BB = (expr1B5 + (1));
expr1B4.emptyCount = expr1BB; (expr1B4.emptyCount = expr1BB);
} }
BasicBlock_313:
(j = ((j) + (1)));
} }
(i = ((i) + (1)));
} }
} }
private bool IsOutflankable(int row, int col) private bool IsOutflankable(int row, int col)
{ {
int i = (@this.squares).Get(row, col); int i = (((@this).squares).Get((row), (col)));
bool V_3 = 0; bool V_3 = (0);
bool V_5 = 0; bool V_5 = (0);
bool V_4 = 0; bool V_4 = (0);
bool V_6 = 0; bool V_6 = (0);
for (int k = 0; ((!k >= col && !V_3)); k = (k + 1)) { for (int k = (0); ((!((k) >= (col)) && (!(V_3))));) {
if (!((@this.squares).Get(row, k) != (IL__ldsfld(Empty)))) { if (!(((((@this).squares).Get((row), (k))) != IL__ldsfld(Empty)))) {
V_3 = 1; (V_3 = (1));
} }
else { else {
if (!((!(@this.squares).Get(row, k) != i && (@this.safeDiscs).Get(row, k)))) { if (!((!((((@this).squares).Get((row), (k))) != (i)) && ((((@this).safeDiscs).Get((row), (k))))))) {
V_5 = 1; (V_5 = (1));
} }
} }
(k = ((k) + (1)));
} }
k = (col + 1); (k = ((col) + (1)));
for (; ((!k >= 8 && !V_4)); k = (k + 1)) { for (; ((!((k) >= (8)) && (!(V_4))));) {
if (!((@this.squares).Get(row, k) != (IL__ldsfld(Empty)))) { if (!(((((@this).squares).Get((row), (k))) != IL__ldsfld(Empty)))) {
V_4 = 1; (V_4 = (1));
} }
else { else {
if (!((!(@this.squares).Get(row, k) != i && (@this.safeDiscs).Get(row, k)))) { if (!((!((((@this).squares).Get((row), (k))) != (i)) && ((((@this).safeDiscs).Get((row), (k))))))) {
V_6 = 1; (V_6 = (1));
} }
} }
(k = ((k) + (1)));
} }
if (!((!((!!V_3 && V_4) || (!!V_3 && V_6)) && (!V_5 || !V_4)))) { if (!((!((!(!(V_3)) && ((V_4))) || (!(!(V_3)) && ((V_6)))) && ((!(V_5)) || (!(V_4)))))) {
return 1; return (1);
} }
V_3 = 0; (V_3 = (0));
V_4 = 0; (V_4 = (0));
V_5 = 0; (V_5 = (0));
V_6 = 0; (V_6 = (0));
for (int j = 0; ((!j >= row && !V_3)); j = (j + 1)) { for (int j = (0); ((!((j) >= (row)) && (!(V_3))));) {
if (!((@this.squares).Get(j, col) != (IL__ldsfld(Empty)))) { if (!(((((@this).squares).Get((j), (col))) != IL__ldsfld(Empty)))) {
V_3 = 1; (V_3 = (1));
} }
else { else {
if (!((!(@this.squares).Get(j, col) != i && (@this.safeDiscs).Get(j, col)))) { if (!((!((((@this).squares).Get((j), (col))) != (i)) && ((((@this).safeDiscs).Get((j), (col))))))) {
V_5 = 1; (V_5 = (1));
} }
} }
(j = ((j) + (1)));
} }
j = (row + 1); (j = ((row) + (1)));
for (; ((!j >= 8 && !V_4)); j = (j + 1)) { for (; ((!((j) >= (8)) && (!(V_4))));) {
if (!((@this.squares).Get(j, col) != (IL__ldsfld(Empty)))) { if (!(((((@this).squares).Get((j), (col))) != IL__ldsfld(Empty)))) {
V_4 = 1; (V_4 = (1));
} }
else { else {
if (!((!(@this.squares).Get(j, col) != i && (@this.safeDiscs).Get(j, col)))) { if (!((!((((@this).squares).Get((j), (col))) != (i)) && ((((@this).safeDiscs).Get((j), (col))))))) {
V_6 = 1; (V_6 = (1));
} }
} }
(j = ((j) + (1)));
} }
if (!((!((!!V_3 && V_4) || (!!V_3 && V_6)) && (!V_5 || !V_4)))) { if (!((!((!(!(V_3)) && ((V_4))) || (!(!(V_3)) && ((V_6)))) && ((!(V_5)) || (!(V_4)))))) {
return 1; return (1);
} }
V_3 = 0; (V_3 = (0));
V_4 = 0; (V_4 = (0));
V_5 = 0; (V_5 = (0));
V_6 = 0; (V_6 = (0));
j = (row - 1); (j = ((row) - (1)));
k = (col - 1); (k = ((col) - (1)));
for (; ((!(j < 0 || k < 0) && !V_3)); k = (k - 1)) { for (; ((!(((j) < (0)) || ((k) < (0))) && (!(V_3))));) {
if (!((@this.squares).Get(j, k) != (IL__ldsfld(Empty)))) { if (!(((((@this).squares).Get((j), (k))) != IL__ldsfld(Empty)))) {
V_3 = 1; (V_3 = (1));
} }
else { else {
if (!((!(@this.squares).Get(j, k) != i && (@this.safeDiscs).Get(j, k)))) { if (!((!((((@this).squares).Get((j), (k))) != (i)) && ((((@this).safeDiscs).Get((j), (k))))))) {
V_5 = 1; (V_5 = (1));
} }
} }
j = (j - 1); (j = ((j) - (1)));
(k = ((k) - (1)));
} }
j = (row + 1); (j = ((row) + (1)));
k = (col + 1); (k = ((col) + (1)));
for (; ((!(j >= 8 || k >= 8) && !V_4)); k = (k + 1)) { for (; ((!(((j) >= (8)) || ((k) >= (8))) && (!(V_4))));) {
if (!((@this.squares).Get(j, k) != (IL__ldsfld(Empty)))) { if (!(((((@this).squares).Get((j), (k))) != IL__ldsfld(Empty)))) {
V_4 = 1; (V_4 = (1));
} }
else { else {
if (!((!(@this.squares).Get(j, k) != i && (@this.safeDiscs).Get(j, k)))) { if (!((!((((@this).squares).Get((j), (k))) != (i)) && ((((@this).safeDiscs).Get((j), (k))))))) {
V_6 = 1; (V_6 = (1));
} }
} }
j = (j + 1); (j = ((j) + (1)));
(k = ((k) + (1)));
} }
if (!((!((!!V_3 && V_4) || (!!V_3 && V_6)) && (!V_5 || !V_4)))) { if (!((!((!(!(V_3)) && ((V_4))) || (!(!(V_3)) && ((V_6)))) && ((!(V_5)) || (!(V_4)))))) {
return 1; return (1);
} }
V_3 = 0; (V_3 = (0));
V_4 = 0; (V_4 = (0));
V_5 = 0; (V_5 = (0));
V_6 = 0; (V_6 = (0));
j = (row - 1); (j = ((row) - (1)));
k = (col + 1); (k = ((col) + (1)));
for (; ((!(j < 0 || k >= 8) && !V_3)); k = (k + 1)) { for (; ((!(((j) < (0)) || ((k) >= (8))) && (!(V_3))));) {
if (!((@this.squares).Get(j, k) != (IL__ldsfld(Empty)))) { if (!(((((@this).squares).Get((j), (k))) != IL__ldsfld(Empty)))) {
V_3 = 1; (V_3 = (1));
} }
else { else {
if (!((!(@this.squares).Get(j, k) != i && (@this.safeDiscs).Get(j, k)))) { if (!((!((((@this).squares).Get((j), (k))) != (i)) && ((((@this).safeDiscs).Get((j), (k))))))) {
V_5 = 1; (V_5 = (1));
} }
} }
j = (j - 1); (j = ((j) - (1)));
(k = ((k) + (1)));
} }
j = (row + 1); (j = ((row) + (1)));
k = (col - 1); (k = ((col) - (1)));
for (; ((!(j >= 8 || k < 0) && !V_4)); k = (k - 1)) { for (; ((!(((j) >= (8)) || ((k) < (0))) && (!(V_4))));) {
if (!((@this.squares).Get(j, k) != (IL__ldsfld(Empty)))) { if (!(((((@this).squares).Get((j), (k))) != IL__ldsfld(Empty)))) {
V_4 = 1; (V_4 = (1));
} }
else { else {
if (!((!(@this.squares).Get(j, k) != i && (@this.safeDiscs).Get(j, k)))) { if (!((!((((@this).squares).Get((j), (k))) != (i)) && ((((@this).safeDiscs).Get((j), (k))))))) {
V_6 = 1; (V_6 = (1));
} }
} }
j = (j + 1); (j = ((j) + (1)));
(k = ((k) - (1)));
} }
if (!((!((!!V_3 && V_4) || (!!V_3 && V_6)) && (!V_5 || !V_4)))) { if (!((!((!(!(V_3)) && ((V_4))) || (!(!(V_3)) && ((V_6)))) && ((!(V_5)) || (!(V_4)))))) {
return 1; return (1);
} }
return 0; return (0);
} }
} }
} }

48
src/AstMetodBodyBuilder.cs

@ -178,12 +178,7 @@ namespace Decompiler
} }
// Args generated by nested expressions (which must be closed) // Args generated by nested expressions (which must be closed)
foreach(StackExpression nestedExpr in expr.LastArguments) { foreach(StackExpression nestedExpr in expr.LastArguments) {
Ast.Expression astExpr = (Ast.Expression)TransformExpression(nestedExpr); args.Add((Ast.Expression)TransformExpression(nestedExpr));
if (nestedExpr.MustBeParenthesized) {
args.Add(new Ast.ParenthesizedExpression(astExpr));
} else {
args.Add(astExpr);
}
} }
return args; return args;
} }
@ -191,15 +186,7 @@ namespace Decompiler
object TransformExpression(StackExpression expr) object TransformExpression(StackExpression expr)
{ {
List<Ast.Expression> args = TransformExpressionArguments(expr); List<Ast.Expression> args = TransformExpressionArguments(expr);
try { return TransformByteCode(methodDef, expr.LastByteCode, args);
return TransformByteCode(methodDef, expr.LastByteCode, args.ToArray());
} catch (NotImplementedException) {
// Output the operand of the unknown IL code as well
if (expr.LastByteCode.Operand != null) {
args.Insert(0, new IdentifierExpression(expr.LastByteCode.FormatedOperand));
}
return new Ast.InvocationExpression(new IdentifierExpression("IL__" + expr.LastByteCode.OpCode.Name), args);
}
} }
Ast.Statement TransformExpressionToStatement(StackExpression expr) Ast.Statement TransformExpressionToStatement(StackExpression expr)
@ -230,11 +217,7 @@ namespace Decompiler
Ast.Expression MakeBranchCondition(Branch branch) Ast.Expression MakeBranchCondition(Branch branch)
{ {
if (branch is SimpleBranch) { // TODO: Delete return new ParenthesizedExpression(MakeBranchCondition_Internal(branch));
return MakeBranchCondition_Internal(branch);
} else {
return new ParenthesizedExpression(MakeBranchCondition_Internal(branch));
}
} }
Ast.Expression MakeBranchCondition_Internal(Branch branch) Ast.Expression MakeBranchCondition_Internal(Branch branch)
@ -293,15 +276,32 @@ namespace Decompiler
} }
} }
static object TransformByteCode(MethodDefinition methodDef, ByteCode byteCode, params Ast.Expression[] args) static object TransformByteCode(MethodDefinition methodDef, ByteCode byteCode, List<Ast.Expression> args)
{
try {
object ret = TransformByteCode_Internal(methodDef, byteCode, args);
if (ret is Ast.Expression) {
ret = new ParenthesizedExpression((Ast.Expression)ret);
}
return ret;
} catch (NotImplementedException) {
// Output the operand of the unknown IL code as well
if (byteCode.Operand != null) {
args.Insert(0, new IdentifierExpression(byteCode.FormatedOperand));
}
return new Ast.InvocationExpression(new IdentifierExpression("IL__" + byteCode.OpCode.Name), args);
}
}
static object TransformByteCode_Internal(MethodDefinition methodDef, ByteCode byteCode, List<Ast.Expression> args)
{ {
OpCode opCode = byteCode.OpCode; OpCode opCode = byteCode.OpCode;
object operand = byteCode.Operand; object operand = byteCode.Operand;
Ast.TypeReference operandAsTypeRef = operand is Cecil.TypeReference ? new Ast.TypeReference(((Cecil.TypeReference)operand).FullName) : null; Ast.TypeReference operandAsTypeRef = operand is Cecil.TypeReference ? new Ast.TypeReference(((Cecil.TypeReference)operand).FullName) : null;
ByteCode operandAsByteCode = operand as ByteCode; ByteCode operandAsByteCode = operand as ByteCode;
Ast.Expression arg1 = args.Length >= 1 ? args[0] : null; Ast.Expression arg1 = args.Count >= 1 ? args[0] : null;
Ast.Expression arg2 = args.Length >= 2 ? args[1] : null; Ast.Expression arg2 = args.Count >= 2 ? args[1] : null;
Ast.Expression arg3 = args.Length >= 3 ? args[2] : null; Ast.Expression arg3 = args.Count >= 3 ? args[2] : null;
Ast.Statement branchCommand = null; Ast.Statement branchCommand = null;
if (operand is ByteCode) { if (operand is ByteCode) {

38
src/StackExpression.cs

@ -142,43 +142,5 @@ namespace Decompiler
{ {
return this.LastByteCode.ToString(); return this.LastByteCode.ToString();
} }
public bool MustBeParenthesized {
get {
switch(this.LastByteCode.OpCode.Code) {
#region Arithmetic
case Code.Neg:
case Code.Not:
#endregion
#region Arrays
case Code.Newarr:
case Code.Ldlen:
case Code.Ldelem_I:
case Code.Ldelem_I1:
case Code.Ldelem_I2:
case Code.Ldelem_I4:
case Code.Ldelem_I8:
case Code.Ldelem_U1:
case Code.Ldelem_U2:
case Code.Ldelem_U4:
case Code.Ldelem_R4:
case Code.Ldelem_R8:
case Code.Ldelem_Ref:
#endregion
case Code.Call:
case Code.Ldarg:
case Code.Ldc_I4:
case Code.Ldc_I8:
case Code.Ldc_R4:
case Code.Ldc_R8:
case Code.Ldloc:
case Code.Ldnull:
case Code.Ldstr:
return false;
default:
return true;
}
}
}
} }
} }

Loading…
Cancel
Save