MichalStrehovsky / zerosharp

Demo of the potential of C# for systems programming with the .NET native ahead-of-time compilation technology.
2.02k stars 105 forks source link

Confused on how this works. #25

Closed Shadowblitz16 closed 2 years ago

Shadowblitz16 commented 2 years ago

How exactly does this work? Are these just magic definitions the C# compiler looks for?...

    // The layout of primitive types is special cased because it would be recursive.
    // These really don't need any fields to work.
    public struct Boolean { }
    public struct Char { }
    public struct SByte { }
    public struct Byte { }
    public struct Int16 { }
    public struct UInt16 { }
    public struct Int32 { }
    public struct UInt32 { }
    public struct Int64 { }
    public struct UInt64 { }
    public struct IntPtr { }
    public struct UIntPtr { }
    public struct Single { }
    public struct Double { }

If so you should probably document them, If not is there a way to rename the basic types?

MichalStrehovsky commented 2 years ago

This is how these types need to be named per the ECMA-335 (runtime) and ECMA-334 (C#) standard. The name is a protocol that gives these types a special meaning (e.g. in runtime, System.Int32 in the core library gets size 4 and a 4 byte alignment, similarly in the C# compiler, System.Int32 is the type that e.g. literal 1234 will be typed as).

Shadowblitz16 commented 2 years ago

Ok so there is no way to rename them then. thankyou