Internal Implementations
From Pigmeo Development Wiki
Some Methods are not implemented in managed code, instead, they are implemented usually by the CLR. When compiling apps for microcontrollers, Pigmeo Compiler implements those methods.
Contents |
Types of intenally-implemented methods
P/Invokes
Calls to native libraries. Not supported by Pigmeo.
Attribute MethodImplAttribute - InternalCall
Methods found inside the .NET Framework intended to be implemented directly by the CLR.
Pigmeo.Internal.InternalImplementation Custom Attribute
Methods tagged with this attribute have got a body which is executed on managed environments, but Pigmeo Compiler will reimplement this depending on the target architecture.
How Pigmeo Compiler implements them
Pigmeo.Compiler.PIR.Program.ImplementInternally() [Program.cs]
Implements some methods by injecting manually-generated PIR.
ImplementInternally() calls Pigmeo.Compiler.PIR.Method.Implement() and then tries to implement hardcoded internally implemented calls in PIR. This means some times the entire call to a method is replaced by hardcoded PIR instead of implementing a method and then calling it from anywhere.
Examples:
- Pigmeo.Extensions.uint8Extensions.SetBit(). This method is not always internally implemented, even on microcontrollers, so it is also implemented in managed code.
Pigmeo.Compiler.PIR.Method.Implement() [Method.cs]
This is the main place for implementing methods internally. Calls to them may get replaced by calls to another method written in managed code, or they may get implemented manually in PIR.
The Implement() method does nothing when the current PIR Method has no internal implementation in PIR, so it will be implemented later in the compilation process.
Pigmeo.Compiler.BackendPIC.PirOperationToAsm
Methods marked as internal implementations not implemented yet try to be implemented directly in assembly language by calling Pigmeo.Compiler.BackendPIC.PirOperationToAsm.InternalImplementations.GetInlinedInternalImplementation().
Examples:
- Processor.Nop()

