Skip to content

Commit

Permalink
Unifier: add missing brackets around (Domain.Selector | Domain.Pointer)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptomin committed Dec 21, 2023
1 parent 669c148 commit 94f028e
Show file tree
Hide file tree
Showing 221 changed files with 292,979 additions and 214,488 deletions.
4 changes: 2 additions & 2 deletions src/Core/Types/Unifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ private bool IsCompatibleWithPointer(Pointer ptrA, DataType b, int depth)
}
if (b is PrimitiveType pb)
{
if ((pb.Domain & Domain.Selector | Domain.Pointer) != 0 && pb.Size == ptrA.Size)
if ((pb.Domain & (Domain.Selector | Domain.Pointer)) != 0 && pb.Size == ptrA.Size)
return true;
}
return false;
Expand Down Expand Up @@ -781,7 +781,7 @@ public void Unify()
if (b is PrimitiveType pb)
{
if ((ptrA.Size == 0 || pb.Size == 0 || ptrA.Size == pb.Size) &&
(pb.Domain & Domain.Pointer | Domain.Selector) != 0)
(pb.Domain & (Domain.Pointer | Domain.Selector)) != 0)
{
return ptrA.Clone();
}
Expand Down
9 changes: 5 additions & 4 deletions src/UnitTests/Decompiler/Evaluation/IdConstantTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ public void Idc_ConstantReferencePointerToInt()
var ctx = new Mock<EvaluationContext>();
ctx.Setup(c => c.GetValue(edx)).Returns(Constant.Int32(0x567));

IdConstant ic = new IdConstant();
var e = ic.Match(edx, ctx.Object, new Unifier(null, null), listener);
IdConstant ic = new IdConstant();
var factory = new TypeFactory();
var e = ic.Match(edx, ctx.Object, new Unifier(factory, null), listener);
Assert.That(e, Is.Not.Null);
Assert.AreEqual("00000567", e.ToString());
Assert.AreEqual("(ptr32 int32)", e.DataType.ToString());
Assert.AreEqual("0x567<32>", e.ToString());
Assert.AreEqual("(union (int32 u0) (INTPTR u1))", e.DataType.ToString());
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,8 @@ define proc1
proc1_entry:
// succ: l1
l1:
eax2 = *eax1
eax3 = *eax2
eax2 = (real32 **) *eax1
eax3 = (real32 *) *eax2
g_r1004 = *eax3
proc1_exit:
Expand Down Expand Up @@ -1513,7 +1513,7 @@ define main
main_entry:
// succ: l1
l1:
(0xC00<16>->*((char *) bx + 4<i32>))()
(0xC00<16>->*(bx + 4<16>))()
main_exit:
";
Expand Down
2 changes: 1 addition & 1 deletion src/tests/Analysis/CrwIpLiveness.exp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fn0C00_0026_exit:
Register word16 fn0C00_0033(Sequence segptr32 ds_si)
// MayUse: Sequence ds:si:[0..31]
// DataTypes:
// Sequence ds:si: (ptr32 (struct 0002))
// Sequence ds:si: (union (segptr32 u0) ((ptr32 (struct 0002)) u1))
// LiveOut: ax
// Trashed: SCZO ax Top
// Preserved: sp
Expand Down
6 changes: 3 additions & 3 deletions src/tests/Analysis/CrwParameters.exp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn0C00_0000_exit:
Register word16 fn0C00_0025(Sequence segptr32 ds_si, Register out ptr16 siOut)
// MayUse: Sequence ds:si:[0..31]
// DataTypes:
// Sequence ds:si: (ptr32 (struct 0002))
// Sequence ds:si: (union (segptr32 u0) ((ptr32 (struct 0002)) u1))
// LiveOut: ax si
// Trashed: ax si Top
// Preserved: sp
Expand Down Expand Up @@ -80,7 +80,7 @@ fn0C00_0025_exit:
Register word16 fn0C00_0027(Sequence segptr32 ds_si, Register out ptr16 siOut)
// MayUse: Sequence ds:si:[0..31]
// DataTypes:
// Sequence ds:si: (ptr32 (struct 0002))
// Sequence ds:si: (union (segptr32 u0) ((ptr32 (struct 0002)) u1))
// LiveOut: ax si
// Trashed: SCZO ax si Top
// Preserved: sp
Expand Down Expand Up @@ -127,7 +127,7 @@ fn0C00_0027_exit:
Register word16 fn0C00_002F(Sequence segptr32 ds_si, Register out ptr16 siOut)
// MayUse: Sequence ds:si:[0..31]
// DataTypes:
// Sequence ds:si: (ptr32 (struct 0006))
// Sequence ds:si: (union (segptr32 u0) ((ptr32 (struct 0006)) u1))
// LiveOut: ax si
// Trashed: ax si Top
// Preserved: sp
Expand Down
2 changes: 1 addition & 1 deletion src/tests/Analysis/CrwProcIsolation.exp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn0C00_0000_exit:
void fn0C00_000F(Sequence segptr32 ds_di)
// MayUse: Sequence ds:di:[0..31]
// DataTypes:
// Sequence ds:di: (ptr32 (struct 0002))
// Sequence ds:di: (union (segptr32 u0) ((ptr32 (struct 0002)) u1))
// LiveOut:
// Trashed: Top
// Preserved: sp
Expand Down
2 changes: 1 addition & 1 deletion src/tests/Analysis/CrwSliceReturn.exp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn0C00_0000_exit:
Register word16 fn0C00_0015(Sequence segptr32 ds_si)
// MayUse: Sequence ds:si:[0..31]
// DataTypes:
// Sequence ds:si: (ptr32 (struct 0002))
// Sequence ds:si: (union (segptr32 u0) ((ptr32 (struct 0002)) u1))
// LiveOut: ax
// Trashed: ax Top
// Preserved: sp
Expand Down
4 changes: 2 additions & 2 deletions src/tests/Analysis/CrwStackVariables.exp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn0C00_0000_exit:
Register word16 fn0C00_0020(Stack segptr32 ptrArg02)
// MayUse: Stack +0002:[0..31]
// DataTypes:
// Stack +0002: (ptr32 (struct 0006))
// Stack +0002: (union (segptr32 u0) ((ptr32 (struct 0006)) u1))
// LiveOut: ax
// Trashed: ax bx es Top
// Preserved: bp sp
Expand Down Expand Up @@ -80,7 +80,7 @@ fn0C00_0020_exit:
Register word16 fn0C00_002E(Stack segptr32 ptrArg02, Stack word16 wArg06)
// MayUse: Stack +0002:[0..31] Stack +0006:[0..15]
// DataTypes:
// Stack +0002: (ptr32 (struct 0008))
// Stack +0002: (union (segptr32 u0) ((ptr32 (struct 0008 (6 T_6 t0006))) u1))
// Stack +0006: word16
// LiveOut: ax
// Trashed: SCZO ax bx es Top
Expand Down
4 changes: 2 additions & 2 deletions src/tests/Analysis/CrwVoidFunctions.exp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void fn0C00_0029(Sequence segptr32 ds_di, Register word16 ax)
// MayUse: ax:[0..15] Sequence ds:di:[0..31]
// DataTypes:
// ax: word16
// Sequence ds:di: (ptr32 (struct 0002))
// Sequence ds:di: (union (segptr32 u0) ((ptr32 (struct 0002 (0 T_2 t0000))) u1))
// LiveOut:
// Trashed: Top
// Preserved: sp
Expand Down Expand Up @@ -147,7 +147,7 @@ fn0C00_0029_exit:
void fn0C00_002C(Sequence segptr32 ds_di, Stack word16 wArg02)
// MayUse: Sequence ds:di:[0..31] Stack +0002:[0..15]
// DataTypes:
// Sequence ds:di: (ptr32 (struct 0002))
// Sequence ds:di: (union (segptr32 u0) ((ptr32 (struct 0002 (0 T_2 t0000))) u1))
// Stack +0002: word16
// LiveOut:
// Trashed: ax Top
Expand Down
16 changes: 8 additions & 8 deletions src/tests/Typing/DtbReals.exp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Eq_3: (ptr16 (segment (400 T_52 t0400) (408 T_57 t0408)))
T_3 (in ds : selector)
T_6 (in ds : selector)
T_14 (in ds : selector)
Eq_4: (ptr32 (fn T_11 (T_3, T_9, T_10)))
Eq_4: (union (segptr32 u0) ((ptr32 (fn T_11 (T_3, T_9, T_10))) u1))
T_4 (in fn0C00_0010 : segptr32)
T_5 (in signature of fn0C00_0010 : void)
Eq_7: (memptr T_6 (struct (0 T_19 t0000) (8 T_24 t0008) (10 T_29 t0010)))
Expand All @@ -57,7 +57,7 @@ Eq_8: (memptr T_6 (struct (0 T_39 t0000) (20 T_43 t0020) (28 T_48 t0028)))
T_10 (in 0x320<16> : word16)
Eq_11: void
T_11 (in fn0C00_0010(ds, 0x300<16>, 0x320<16>) : void)
Eq_12: (ptr32 (fn T_15 (T_3)))
Eq_12: (union (segptr32 u0) ((ptr32 (fn T_15 (T_3))) u1))
T_12 (in fn0C00_0037 : segptr32)
T_13 (in signature of fn0C00_0037 : void)
Eq_15: void
Expand Down Expand Up @@ -154,11 +154,11 @@ T_3: (in ds : selector)
OrigDataType: (ptr16 (segment))
T_4: (in fn0C00_0010 : segptr32)
Class: Eq_4
DataType: (ptr32 (fn T_11 (T_3, T_9, T_10)))
OrigDataType: (ptr32 (fn T_11 (T_3, T_9, T_10)))
DataType: (union (segptr32 u0) ((ptr32 (fn T_11 (T_3, T_9, T_10))) u1))
OrigDataType: (union (segptr32 u0) ((ptr32 (fn T_11 (T_3, T_9, T_10))) u1))
T_5: (in signature of fn0C00_0010 : void)
Class: Eq_4
DataType: (ptr32 (fn T_11 (T_3, T_9, T_10)))
DataType: (union (segptr32 u0) ((ptr32 (fn T_11 (T_3, T_9, T_10))) u1))
OrigDataType:
T_6: (in ds : selector)
Class: Eq_3
Expand Down Expand Up @@ -186,11 +186,11 @@ T_11: (in fn0C00_0010(ds, 0x300<16>, 0x320<16>) : void)
OrigDataType: void
T_12: (in fn0C00_0037 : segptr32)
Class: Eq_12
DataType: (ptr32 (fn T_15 (T_3)))
OrigDataType: (ptr32 (fn T_15 (T_3)))
DataType: (union (segptr32 u0) ((ptr32 (fn T_15 (T_3))) u1))
OrigDataType: (union (segptr32 u0) ((ptr32 (fn T_15 (T_3))) u1))
T_13: (in signature of fn0C00_0037 : void)
Class: Eq_12
DataType: (ptr32 (fn T_15 (T_3)))
DataType: (union (segptr32 u0) ((ptr32 (fn T_15 (T_3))) u1))
OrigDataType:
T_14: (in ds : selector)
Class: Eq_3
Expand Down
8 changes: 4 additions & 4 deletions src/tests/Typing/DtbReg00011.exp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Eq_1: (ptr32 (struct "Globals"))
globals_t (in globals : (ptr32 (struct "Globals")))
Eq_2: (ptr16 (segment "seg0C00_t" 002A))
T_2 (in seg0C00 : selector)
Eq_3: (ptr32 (fn T_5 ()))
Eq_3: (union (segptr32 u0) ((ptr32 (fn T_5 ())) u1))
T_3 (in fn0C00_0004 : segptr32)
T_4 (in signature of fn0C00_0004 : void)
Eq_5: void
Expand Down Expand Up @@ -106,11 +106,11 @@ T_2: (in seg0C00 : selector)
OrigDataType: (ptr16 (segment "seg0C00_t" 002A))
T_3: (in fn0C00_0004 : segptr32)
Class: Eq_3
DataType: (ptr32 (fn T_5 ()))
OrigDataType: (ptr32 (fn T_5 ()))
DataType: (union (segptr32 u0) ((ptr32 (fn T_5 ())) u1))
OrigDataType: (union (segptr32 u0) ((ptr32 (fn T_5 ())) u1))
T_4: (in signature of fn0C00_0004 : void)
Class: Eq_3
DataType: (ptr32 (fn T_5 ()))
DataType: (union (segptr32 u0) ((ptr32 (fn T_5 ())) u1))
OrigDataType:
T_5: (in fn0C00_0004() : void)
Class: Eq_5
Expand Down
26 changes: 16 additions & 10 deletions src/tests/Typing/TerComparison.exp
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ define proc1
proc1_entry:
// succ: l1
l1:
f = p->ptr0004 < &g_t1028
f = p->t0004.u1 < 0x1028<32>
proc1_exit:

// Equivalence classes ////////////
Eq_1: (struct "Globals" (1028 Eq_5 t1028))
Eq_1: (struct "Globals")
globals_t (in globals : (ptr32 (struct "Globals")))
Eq_2: (struct "Eq_2" (4 (ptr32 Eq_5) ptr0004))
Eq_2: (struct "Eq_2" (4 Eq_5 t0004))
T_2 (in p : (ptr32 Eq_2))
Eq_5: (struct "foo" 0008)
T_5 (in Mem0[p + 4<32>:(ptr32 (struct "foo" 0008))] : (ptr32 (struct "foo" 0008)))
Eq_5: (union "Eq_5" (int32 u0) ((ptr32 Eq_9) u1))
T_5 (in Mem0[p + 4<32>:(ptr32 Eq_9)] : (ptr32 Eq_9))
T_6 (in 0x1028<32> : word32)
Eq_9: (struct "foo" 0008)
T_9
// Type Variables ////////////
globals_t: (in globals : (ptr32 (struct "Globals")))
Class: Eq_1
Expand All @@ -43,19 +45,23 @@ T_4: (in p + 4<32> : word32)
Class: Eq_4
DataType: word32
OrigDataType: word32
T_5: (in Mem0[p + 4<32>:(ptr32 (struct "foo" 0008))] : (ptr32 (struct "foo" 0008)))
T_5: (in Mem0[p + 4<32>:(ptr32 Eq_9)] : (ptr32 Eq_9))
Class: Eq_5
DataType: (ptr32 Eq_5)
OrigDataType: (ptr32 (struct "foo" 0008))
DataType: Eq_5
OrigDataType: (union (int32 u0) ((ptr32 Eq_9) u1))
T_6: (in 0x1028<32> : word32)
Class: Eq_5
DataType: (ptr32 Eq_5)
DataType: int32
OrigDataType: int32
T_7: (in p->ptr0004 < &g_t1028 : bool)
T_7: (in p->t0004.u1 < 0x1028<32> : bool)
Class: Eq_7
DataType: bool
OrigDataType: bool
T_8: (in f : bool)
Class: Eq_7
DataType: bool
OrigDataType: bool
T_9:
Class: Eq_9
DataType: Eq_9
OrigDataType:
8 changes: 4 additions & 4 deletions src/tests/Typing/TerReg00011.exp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Eq_1: (struct "Globals" (4DE10 (ptr16 Eq_25) ptr4DE10))
globals_t (in globals : (ptr32 (struct "Globals")))
Eq_2: (segment "seg0C00_t" 002A)
T_2 (in seg0C00 : selector)
Eq_3: (fn void ())
Eq_3: (union "Eq_3" (segptr32 u0) ((ptr32 (fn void ())) u1))
T_3 (in fn0C00_0004 : segptr32)
T_4 (in signature of fn0C00_0004 : void)
Eq_6: (union "Eq_6" (int16 u0) ((memptr (ptr16 Eq_25) byte) u1))
Expand All @@ -89,11 +89,11 @@ T_2: (in seg0C00 : selector)
OrigDataType: (ptr16 (segment "seg0C00_t" 002A))
T_3: (in fn0C00_0004 : segptr32)
Class: Eq_3
DataType: (ptr32 Eq_3)
OrigDataType: (ptr32 (fn T_5 ()))
DataType: Eq_3
OrigDataType: (union (segptr32 u0) ((ptr32 (fn void ())) u1))
T_4: (in signature of fn0C00_0004 : void)
Class: Eq_3
DataType: (ptr32 Eq_3)
DataType: Eq_3
OrigDataType:
T_5: (in fn0C00_0004() : void)
Class: Eq_5
Expand Down
12 changes: 6 additions & 6 deletions src/tests/Typing/TtranFactorial.exp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Eq_2: (segment "seg0C00_t" 002B)
T_2 (in seg0C00 : selector)
Eq_3: (segment (64 int16 w0064))
T_3 (in ds : selector)
Eq_4: (fn int16 (int16))
Eq_4: (union (segptr32 u0) ((ptr32 (fn int16 (int16))) u1))
T_4 (in fn0C00_000F : segptr32)
T_5 (in signature of fn0C00_000F : void)
T_17 (in fn0C00_000F : segptr32)
Expand All @@ -55,11 +55,11 @@ T_3: (in ds : selector)
OrigDataType: (ptr16 (segment (64 T_11 t0064)))
T_4: (in fn0C00_000F : segptr32)
Class: Eq_4
DataType: (ptr32 Eq_4)
OrigDataType: (ptr32 (fn T_8 (T_7)))
DataType: Eq_4
OrigDataType: (union (segptr32 u0) ((ptr32 (fn T_8 (T_7))) u1))
T_5: (in signature of fn0C00_000F : void)
Class: Eq_4
DataType: (ptr32 Eq_4)
DataType: Eq_4
OrigDataType:
T_6: (in wArg02 : word16)
Class: Eq_6
Expand Down Expand Up @@ -107,8 +107,8 @@ T_16: (in ax_13 : word16)
OrigDataType: int16
T_17: (in fn0C00_000F : segptr32)
Class: Eq_4
DataType: (ptr32 Eq_4)
OrigDataType: (ptr32 (fn T_19 (T_18)))
DataType: Eq_4
OrigDataType: (union (segptr32 u0) ((ptr32 (fn T_19 (T_18))) u1))
T_18: (in wArg02 - 1<16> : word16)
Class: Eq_6
DataType: int16
Expand Down
12 changes: 6 additions & 6 deletions src/tests/Typing/TtranFactorialReg.exp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Eq_2: (segment "seg0C00_t" 0021)
T_2 (in seg0C00 : selector)
Eq_3: (segment (64 int16 w0064))
T_3 (in ds : selector)
Eq_4: (fn int16 (int16))
Eq_4: (union (segptr32 u0) ((ptr32 (fn int16 (int16))) u1))
T_4 (in fn0C00_000B : segptr32)
T_5 (in signature of fn0C00_000B : void)
T_17 (in fn0C00_000B : segptr32)
Expand All @@ -55,11 +55,11 @@ T_3: (in ds : selector)
OrigDataType: (ptr16 (segment (64 T_11 t0064)))
T_4: (in fn0C00_000B : segptr32)
Class: Eq_4
DataType: (ptr32 Eq_4)
OrigDataType: (ptr32 (fn T_8 (T_7)))
DataType: Eq_4
OrigDataType: (union (segptr32 u0) ((ptr32 (fn T_8 (T_7))) u1))
T_5: (in signature of fn0C00_000B : void)
Class: Eq_4
DataType: (ptr32 Eq_4)
DataType: Eq_4
OrigDataType:
T_6: (in cx : word16)
Class: Eq_6
Expand Down Expand Up @@ -107,8 +107,8 @@ T_16: (in ax_11 : word16)
OrigDataType: int16
T_17: (in fn0C00_000B : segptr32)
Class: Eq_4
DataType: (ptr32 Eq_4)
OrigDataType: (ptr32 (fn T_20 (T_19)))
DataType: Eq_4
OrigDataType: (union (segptr32 u0) ((ptr32 (fn T_20 (T_19))) u1))
T_18: (in 1<16> : word16)
Class: Eq_18
DataType: int16
Expand Down
Loading

0 comments on commit 94f028e

Please sign in to comment.