Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
kekyo committed May 1, 2024
1 parent f3de083 commit 54405a2
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 542 deletions.
5 changes: 4 additions & 1 deletion README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -886,10 +886,13 @@ public struct foo
public int32[*] c
```

配列の要素数を`*`と指定すると、この値型配列は要素数を特定しない型となります
配列の要素数を`*`と指定すると、この値型配列は要素数を特定しない型(フレックス配列)となります
この型は特殊な値型配列で、配列のインデクサアクセスは、要素数の範囲外チェックが行われません。
当然、存在しない要素にアクセスした場合の結果は未定義となるため、注意が必要です。

フレックス配列は、構造体型の最後のメンバーに使用することを想定していますが、
chibildはこのチェックを行いません。

注意: 構造体型を使用するには、`System.ValueType` 型への参照が解決される必要があります。
`mscorlib.dll` 又は `System.Private.CoreLib.dll` への参照を追加して下さい。

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -906,10 +906,13 @@ The last member of the structure type can be a value array type with unspecified
```

If you specify the number of array elements as `*`,
that does not specify the number of elements.
that does not specify the number of elements (called flex array.)
It is a special type for indexer accesses are not checked for element counts out of range.
Naturally, the result of accessing an out of element will be undefined, so care must be taken.

Although the flex array type is intended to be used for the last member of the structure type,
chibild does not perform this check.

Note: To use an structure type, a reference to the `System.ValueType` type must be resolved.
Add a reference to `mscorlib.dll` or `System.Private.CoreLib.dll`.

Expand Down
40 changes: 20 additions & 20 deletions chibild/chibild.core.Tests/LinkerTests.Constant2.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@

// =============== CLASS MEMBERS DECLARATION ===================

.class public abstract auto ansi sealed C.text
extends [mscorlib]System.Object
{
.method public static valuetype System.Byte_len6
foo() cil managed
{
// Code size 6 (0x6)
.maxstack 8
IL_0000: ldsfld valuetype System.Byte_len6 modopt([mscorlib]System.Runtime.CompilerServices.IsConst) C.rdata::bar
IL_0005: ret
} // end of method text::foo

} // end of class C.text

.class public abstract auto ansi sealed beforefieldinit C.rdata
extends [mscorlib]System.Object
{
.field public static initonly valuetype System.Byte_len6 modopt([mscorlib]System.Runtime.CompilerServices.IsConst) bar at I_00002090
} // end of class C.rdata

.class public sequential ansi sealed System.Byte_len6
extends [mscorlib]System.ValueType
{
Expand Down Expand Up @@ -100,26 +120,6 @@
} // end of property Byte_len6::Item
} // end of class System.Byte_len6

.class public abstract auto ansi sealed C.text
extends [mscorlib]System.Object
{
.method public static valuetype System.Byte_len6
foo() cil managed
{
// Code size 6 (0x6)
.maxstack 8
IL_0000: ldsfld valuetype System.Byte_len6 modopt([mscorlib]System.Runtime.CompilerServices.IsConst) C.rdata::bar
IL_0005: ret
} // end of method text::foo

} // end of class C.text

.class public abstract auto ansi sealed beforefieldinit C.rdata
extends [mscorlib]System.Object
{
.field public static initonly valuetype System.Byte_len6 modopt([mscorlib]System.Runtime.CompilerServices.IsConst) bar at I_00002090
} // end of class C.rdata


// =============================================================

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


// .NET IL Disassembler. Version 8.0.0


Expand All @@ -25,15 +25,6 @@

// =============== CLASS MEMBERS DECLARATION ===================

.class private auto ansi sealed C.type.foo
extends [mscorlib]System.Enum
{
.field public specialname rtspecialname uint64 value__
.field public static literal uint64 beef
.field public static literal uint64 poke
.field public static literal uint64 chicken
} // end of class C.type.foo

.class private abstract auto ansi sealed beforefieldinit '<source>$'
extends [mscorlib]System.Object
{
Expand All @@ -48,6 +39,15 @@

} // end of class '<source>$'

.class private auto ansi sealed C.type.foo
extends [mscorlib]System.Enum
{
.field public specialname rtspecialname uint64 value__
.field public static literal uint64 beef
.field public static literal uint64 poke
.field public static literal uint64 chicken
} // end of class C.type.foo


// =============================================================

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


// .NET IL Disassembler. Version 8.0.0


Expand All @@ -25,14 +25,6 @@

// =============== CLASS MEMBERS DECLARATION ===================

.class private sequential ansi sealed C.type.foo
extends [mscorlib]System.ValueType
{
.field public int32 a
.field public int8 b
.field public int32 c
} // end of class C.type.foo

.class private abstract auto ansi sealed beforefieldinit '<source>$'
extends [mscorlib]System.Object
{
Expand All @@ -48,6 +40,14 @@

} // end of class '<source>$'

.class private sequential ansi sealed C.type.foo
extends [mscorlib]System.ValueType
{
.field public int32 a
.field public int8 b
.field public int32 c
} // end of class C.type.foo


// =============================================================

Expand Down
40 changes: 20 additions & 20 deletions chibild/chibild.core.Tests/LinkerTests.FlexValueArray.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@

// =============== CLASS MEMBERS DECLARATION ===================

.class public abstract auto ansi sealed C.text
extends [mscorlib]System.Object
{
.method public static valuetype System.Char_flex
foo() cil managed
{
// Code size 6 (0x6)
.maxstack 8
IL_0000: ldsfld valuetype System.Char_flex C.data::bar
IL_0005: ret
} // end of method text::foo

} // end of class C.text

.class public abstract auto ansi sealed beforefieldinit C.data
extends [mscorlib]System.Object
{
.field public static valuetype System.Char_flex bar
} // end of class C.data

.class public sequential ansi sealed System.Char_flex
extends [mscorlib]System.ValueType
{
Expand Down Expand Up @@ -72,26 +92,6 @@
} // end of property Char_flex::Item
} // end of class System.Char_flex

.class public abstract auto ansi sealed C.text
extends [mscorlib]System.Object
{
.method public static valuetype System.Char_flex
foo() cil managed
{
// Code size 6 (0x6)
.maxstack 8
IL_0000: ldsfld valuetype System.Char_flex C.data::bar
IL_0005: ret
} // end of method text::foo

} // end of class C.text

.class public abstract auto ansi sealed beforefieldinit C.data
extends [mscorlib]System.Object
{
.field public static valuetype System.Char_flex bar
} // end of class C.data


// =============================================================

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@

// =============== CLASS MEMBERS DECLARATION ===================

.class public abstract auto ansi sealed C.text
extends [mscorlib]System.Object
{
.method public static valuetype System.Byte_len6
foo() cil managed
{
// Code size 6 (0x6)
.maxstack 8
IL_0000: ldsfld valuetype System.Byte_len6 C.data::bar
IL_0005: ret
} // end of method text::foo

} // end of class C.text

.class public abstract auto ansi sealed beforefieldinit C.data
extends [mscorlib]System.Object
{
.field public static initonly valuetype System.Byte_len6 bar at I_00002090
} // end of class C.data

.class public sequential ansi sealed System.Byte_len6
extends [mscorlib]System.ValueType
{
Expand Down Expand Up @@ -100,26 +120,6 @@
} // end of property Byte_len6::Item
} // end of class System.Byte_len6

.class public abstract auto ansi sealed C.text
extends [mscorlib]System.Object
{
.method public static valuetype System.Byte_len6
foo() cil managed
{
// Code size 6 (0x6)
.maxstack 8
IL_0000: ldsfld valuetype System.Byte_len6 C.data::bar
IL_0005: ret
} // end of method text::foo

} // end of class C.text

.class public abstract auto ansi sealed beforefieldinit C.data
extends [mscorlib]System.Object
{
.field public static initonly valuetype System.Byte_len6 bar at I_00002090
} // end of class C.data


// =============================================================

Expand Down
Loading

0 comments on commit 54405a2

Please sign in to comment.