Skip to content

Commit

Permalink
(#332) CodeGen: roll back certain behavior, mark local structs as broken
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Mar 3, 2024
1 parent e43cdfc commit 2616361
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 50 deletions.
2 changes: 1 addition & 1 deletion Cesium.CodeGen.Tests/CodeGenTypeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ int main() {
}
");

[Fact]
[Fact(Skip = "TODO[#xxx]: Support local struct types")]
public Task LocalStructTest() => DoTest("""
int main(void) {
struct foo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
IL_0027: ldflda _Union_Long__5u_Int__6u <typedef>foo::uni
IL_002c: ldc.i4.s 10
IL_002e: conv.i8
IL_002f: stfld System.Int64 <typedef>_Union_Long__5u_Int__6u::_5u
IL_002f: stfld System.Int64 _Union_Long__5u_Int__6u::_5u
IL_0034: ldloca.s V_0
IL_0036: ldflda _Anon_Int__7 <typedef>foo::s
IL_003b: ldc.i4.s 10
IL_003d: stfld System.Int32 <typedef>_Anon_Int__7::_7
IL_003d: stfld System.Int32 _Anon_Int__7::_7
IL_0042: ldloca.s V_0
IL_0044: ldfld System.Int32 <typedef>foo::_1
IL_0049: ldloca.s V_0
Expand All @@ -37,11 +37,11 @@
IL_0062: add
IL_0063: ldloca.s V_0
IL_0065: ldflda _Union_Long__5u_Int__6u <typedef>foo::uni
IL_006a: ldfld System.Int32 <typedef>_Union_Long__5u_Int__6u::_6u
IL_006a: ldfld System.Int32 _Union_Long__5u_Int__6u::_6u
IL_006f: add
IL_0070: ldloca.s V_0
IL_0072: ldflda _Anon_Int__7 <typedef>foo::s
IL_0077: ldfld System.Int32 <typedef>_Anon_Int__7::_7
IL_0077: ldfld System.Int32 _Anon_Int__7::_7
IL_007c: add
IL_007d: ret

Expand Down Expand Up @@ -80,12 +80,3 @@
Type: _Anon_Int__7
Fields:
System.Int32 _Anon_Int__7::_7

Type: <typedef>_Union_Long__5u_Int__6u
Fields:
System.Int64 <typedef>_Union_Long__5u_Int__6u::_5u
System.Int32 <typedef>_Union_Long__5u_Int__6u::_6u

Type: <typedef>_Anon_Int__7
Fields:
System.Int32 <typedef>_Anon_Int__7::_7
Original file line number Diff line number Diff line change
Expand Up @@ -64,29 +64,29 @@
IL_00cb: conv.i8
IL_00cc: ldloca.s V_0
IL_00ce: ldflda _Anon_Long__1_Long__2 Foo::inner
IL_00d3: ldfld System.Int64 <typedef>_Anon_Long__1_Long__2::_1
IL_00d3: ldfld System.Int64 _Anon_Long__1_Long__2::_1
IL_00d8: add
IL_00d9: ldloca.s V_0
IL_00db: ldflda _Anon_Long__1_Long__2 Foo::inner
IL_00e0: ldfld System.Int64 <typedef>_Anon_Long__1_Long__2::_2
IL_00e0: ldfld System.Int64 _Anon_Long__1_Long__2::_2
IL_00e5: add
IL_00e6: ldloca.s V_0
IL_00e8: ldflda _Anon_Long_he_Long_ha Foo::other_inner
IL_00ed: ldfld System.Int64 <typedef>_Anon_Long_he_Long_ha::ha
IL_00ed: ldfld System.Int64 _Anon_Long_he_Long_ha::ha
IL_00f2: add
IL_00f3: ldloca.s V_0
IL_00f5: ldflda _Anon_Long_he_Long_ha Foo::other_inner
IL_00fa: ldfld System.Int64 <typedef>_Anon_Long_he_Long_ha::he
IL_00fa: ldfld System.Int64 _Anon_Long_he_Long_ha::he
IL_00ff: add
IL_0100: ldloca.s V_0
IL_0102: ldflda _Anon__level_2 Foo::level_1
IL_0107: ldflda <typedef>_Anon_Int_level_3 <typedef>_Anon__level_2::level_2
IL_010c: ldfld System.Int32 <typedef>_Anon_Int_level_3::level_3
IL_0107: ldflda _Anon_Int_level_3 _Anon__level_2::level_2
IL_010c: ldfld System.Int32 _Anon_Int_level_3::level_3
IL_0111: conv.i8
IL_0112: add
IL_0113: ldloca.s V_0
IL_0115: ldflda _Union_Int_not_anon_Float_its Foo::named_union
IL_011a: ldfld System.Int32 <typedef>_Union_Int_not_anon_Float_its::not_anon
IL_011a: ldfld System.Int32 _Union_Int_not_anon_Float_its::not_anon
IL_011f: conv.i8
IL_0120: add
IL_0121: ldloca.s V_0
Expand Down Expand Up @@ -153,26 +153,3 @@
Type: _Anon__level_2
Fields:
_Anon_Int_level_3 _Anon__level_2::level_2

Type: <typedef>_Anon_Long__1_Long__2
Fields:
System.Int64 <typedef>_Anon_Long__1_Long__2::_1
System.Int64 <typedef>_Anon_Long__1_Long__2::_2

Type: <typedef>_Anon_Long_he_Long_ha
Fields:
System.Int64 <typedef>_Anon_Long_he_Long_ha::he
System.Int64 <typedef>_Anon_Long_he_Long_ha::ha

Type: <typedef>_Anon_Int_level_3
Fields:
System.Int32 <typedef>_Anon_Int_level_3::level_3

Type: <typedef>_Anon__level_2
Fields:
<typedef>_Anon_Int_level_3 <typedef>_Anon__level_2::level_2

Type: <typedef>_Union_Int_not_anon_Float_its
Fields:
System.Int32 <typedef>_Union_Int_not_anon_Float_its::not_anon
System.Single <typedef>_Union_Int_not_anon_Float_its::its
6 changes: 0 additions & 6 deletions Cesium.CodeGen/Ir/Expressions/Values/LValueInstanceField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ protected override FieldReference GetField(IEmitScope scope)

List<FieldDefinition>? path = null;

if (!_structType.IsAlreadyEmitted(scope.Context))
{
// The last-chance try to emit the type:
_structType.EmitType(scope.Context);
}

var valueTypeReference = _structType.Resolve(scope.Context);
var valueTypeDef = valueTypeReference.Resolve();

Expand Down

0 comments on commit 2616361

Please sign in to comment.