Browse Source

ldsfld

stsfld
pull/1/head^2
David Srbecký 18 years ago
parent
commit
3f268ec44f
  1. 38
      bin/Debug/output.cs
  2. 12
      src/AstMetodBodyBuilder.cs
  3. 3
      src/Transforms/Ast/RemoveParenthesis.cs
  4. 11
      src/Transforms/Ast/SimplifyTypeReferences.cs

38
bin/Debug/output.cs

@ -33,14 +33,14 @@ namespace Reversi @@ -33,14 +33,14 @@ namespace Reversi
{
for (int i = 0; i < 8; i = i + 1) {
for (int j = 0; j < 8; j = j + 1) {
squares.Set(i, j, IL__ldsfld(Empty));
squares.Set(i, j, Empty);
safeDiscs.Set(i, j, 0);
}
}
squares.Set(3, 3, IL__ldsfld(White));
squares.Set(3, 4, IL__ldsfld(Black));
squares.Set(4, 3, IL__ldsfld(Black));
squares.Set(4, 4, IL__ldsfld(White));
squares.Set(3, 3, White);
squares.Set(3, 4, Black);
squares.Set(4, 3, Black);
squares.Set(4, 4, White);
UpdateCounts();
}
public int GetSquareContents(int row, int col)
@ -76,7 +76,7 @@ namespace Reversi @@ -76,7 +76,7 @@ namespace Reversi
}
public bool IsValidMove(int color, int row, int col)
{
if (!(squares.Get(row, col) == IL__ldsfld(Empty))) {
if (squares.Get(row, col) != Empty) {
return 0;
}
for (int i = -1; i <= 1; i = i + 1) {
@ -124,7 +124,7 @@ namespace Reversi @@ -124,7 +124,7 @@ namespace Reversi
V_2 = 0;
for (int i = 0; i < 8; i = i + 1) {
for (int j = 0; j < 8; j = j + 1) {
if (!(squares.Get(i, j) == IL__ldsfld(Empty)) && !safeDiscs.Get(i, j) && !IsOutflankable(i, j)) {
if (squares.Get(i, j) != Empty && !safeDiscs.Get(i, j) && !IsOutflankable(i, j)) {
safeDiscs.Set(i, j, 1);
V_2 = 1;
}
@ -136,16 +136,16 @@ namespace Reversi @@ -136,16 +136,16 @@ namespace Reversi
j = 0;
for (; j < 8; j = j + 1) {
bool V_5 = 0;
if (!(squares.Get(i, j) == IL__ldsfld(Empty))) {
if (squares.Get(i, j) != Empty) {
for (int k = -1; k <= 1; k = k + 1) {
for (int l = -1; l <= 1; l = l + 1) {
if ((k || l) && i + k >= 0 && i + k < 8 && j + l >= 0 && j + l < 8 && !(squares.Get((i + k), (j + l)) != IL__ldsfld(Empty))) {
if ((k || l) && i + k >= 0 && i + k < 8 && j + l >= 0 && j + l < 8 && squares.Get(i + k, j + l) == Empty) {
V_5 = 1;
}
}
}
}
if (!(squares.Get(i, j) != IL__ldsfld(Black))) {
if (squares.Get(i, j) == Black) {
IL__dup(this);
object expr123 = expr122.blackCount;
int expr129 = expr123 + 1;
@ -164,7 +164,7 @@ namespace Reversi @@ -164,7 +164,7 @@ namespace Reversi
}
}
else {
if (!(squares.Get(i, j) != IL__ldsfld(White))) {
if (squares.Get(i, j) == White) {
IL__dup(this);
object expr176 = expr175.whiteCount;
int expr17C = expr176 + 1;
@ -203,7 +203,7 @@ namespace Reversi @@ -203,7 +203,7 @@ namespace Reversi
bool V_4 = 0;
bool V_6 = 0;
for (int k = 0; k < col && !V_3; k = k + 1) {
if (!(squares.Get(row, k) != IL__ldsfld(Empty))) {
if (squares.Get(row, k) == Empty) {
V_3 = 1;
}
else {
@ -214,7 +214,7 @@ namespace Reversi @@ -214,7 +214,7 @@ namespace Reversi
}
k = col + 1;
for (; k < 8 && !V_4; k = k + 1) {
if (!(squares.Get(row, k) != IL__ldsfld(Empty))) {
if (squares.Get(row, k) == Empty) {
V_4 = 1;
}
else {
@ -231,7 +231,7 @@ namespace Reversi @@ -231,7 +231,7 @@ namespace Reversi
V_5 = 0;
V_6 = 0;
for (int j = 0; j < row && !V_3; j = j + 1) {
if (!(squares.Get(j, col) != IL__ldsfld(Empty))) {
if (squares.Get(j, col) == Empty) {
V_3 = 1;
}
else {
@ -242,7 +242,7 @@ namespace Reversi @@ -242,7 +242,7 @@ namespace Reversi
}
j = row + 1;
for (; j < 8 && !V_4; j = j + 1) {
if (!(squares.Get(j, col) != IL__ldsfld(Empty))) {
if (squares.Get(j, col) == Empty) {
V_4 = 1;
}
else {
@ -261,7 +261,7 @@ namespace Reversi @@ -261,7 +261,7 @@ namespace Reversi
j = row - 1;
k = col - 1;
for (; j >= 0 && k >= 0 && !V_3; k = k - 1) {
if (!(squares.Get(j, k) != IL__ldsfld(Empty))) {
if (squares.Get(j, k) == Empty) {
V_3 = 1;
}
else {
@ -274,7 +274,7 @@ namespace Reversi @@ -274,7 +274,7 @@ namespace Reversi
j = row + 1;
k = col + 1;
for (; j < 8 && k < 8 && !V_4; k = k + 1) {
if (!(squares.Get(j, k) != IL__ldsfld(Empty))) {
if (squares.Get(j, k) == Empty) {
V_4 = 1;
}
else {
@ -294,7 +294,7 @@ namespace Reversi @@ -294,7 +294,7 @@ namespace Reversi
j = row - 1;
k = col + 1;
for (; j >= 0 && k < 8 && !V_3; k = k + 1) {
if (!(squares.Get(j, k) != IL__ldsfld(Empty))) {
if (squares.Get(j, k) == Empty) {
V_3 = 1;
}
else {
@ -307,7 +307,7 @@ namespace Reversi @@ -307,7 +307,7 @@ namespace Reversi
j = row + 1;
k = col - 1;
for (; j < 8 && k >= 0 && !V_4; k = k - 1) {
if (!(squares.Get(j, k) != IL__ldsfld(Empty))) {
if (squares.Get(j, k) == Empty) {
V_4 = 1;
}
else {

12
src/AstMetodBodyBuilder.cs

@ -498,7 +498,8 @@ namespace Decompiler @@ -498,7 +498,8 @@ namespace Decompiler
case Code.Ldc_I8:
case Code.Ldc_R4:
case Code.Ldc_R8: return new Ast.PrimitiveExpression(operand, null);
case Code.Ldfld: {
case Code.Ldfld:
case Code.Ldsfld: {
FieldDefinition field = (FieldDefinition) operand;
if (field.IsStatic) {
return new Ast.MemberReferenceExpression(
@ -509,7 +510,8 @@ namespace Decompiler @@ -509,7 +510,8 @@ namespace Decompiler
return new Ast.MemberReferenceExpression(arg1, field.Name);
}
}
case Code.Stfld: {
case Code.Stfld:
case Code.Stsfld: {
FieldDefinition field = (FieldDefinition) operand;
if (field.IsStatic) {
return new AssignmentExpression(
@ -528,14 +530,13 @@ namespace Decompiler @@ -528,14 +530,13 @@ namespace Decompiler
);
}
}
case Code.Ldflda: throw new NotImplementedException();
case Code.Ldflda:
case Code.Ldsflda: throw new NotImplementedException();
case Code.Ldftn: throw new NotImplementedException();
case Code.Ldloc: return new Ast.IdentifierExpression(((VariableDefinition)operand).Name);
case Code.Ldloca: throw new NotImplementedException();
case Code.Ldnull: return new Ast.PrimitiveExpression(null, null);
case Code.Ldobj: throw new NotImplementedException();
case Code.Ldsfld: throw new NotImplementedException();
case Code.Ldsflda: throw new NotImplementedException();
case Code.Ldstr: return new Ast.PrimitiveExpression(operand, null);
case Code.Ldtoken:
if (operand is Cecil.TypeReference) {
@ -578,7 +579,6 @@ namespace Decompiler @@ -578,7 +579,6 @@ namespace Decompiler
return astLocalVar;
}
case Code.Stobj: throw new NotImplementedException();
case Code.Stsfld: throw new NotImplementedException();
case Code.Switch: throw new NotImplementedException();
case Code.Tail: throw new NotImplementedException();
case Code.Throw: throw new NotImplementedException();

3
src/Transforms/Ast/RemoveParenthesis.cs

@ -61,6 +61,9 @@ namespace Decompiler.Transforms.Ast @@ -61,6 +61,9 @@ namespace Decompiler.Transforms.Ast
if (GetPrecedence(invocation.TargetObject) >= GetPrecedence(invocation)) {
invocation.TargetObject = Deparenthesize(invocation.TargetObject);
}
for(int i = 0; i < invocation.Arguments.Count; i++) {
invocation.Arguments[i] = Deparenthesize(invocation.Arguments[i]);
}
return base.VisitInvocationExpression(invocation, data);
}

11
src/Transforms/Ast/SimplifyTypeReferences.cs

@ -8,11 +8,20 @@ namespace Decompiler.Transforms.Ast @@ -8,11 +8,20 @@ namespace Decompiler.Transforms.Ast
{
public class SimplifyTypeReferences: AbstractAstTransformer
{
string currentNamepace = string.Empty;
string currentClass = null;
public override object VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data)
{
currentNamepace = namespaceDeclaration.Name;
base.VisitNamespaceDeclaration(namespaceDeclaration, data);
currentNamepace = string.Empty;
return null;
}
public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
currentClass = typeDeclaration.Name;
currentClass = currentNamepace + "." + typeDeclaration.Name;
base.VisitTypeDeclaration(typeDeclaration, data);
currentClass = null;
return null;

Loading…
Cancel
Save