Generate FillDispatchTable with a Source Generator and method attribute like [InterruptHandler(AL = 0x38, BH = 0x23, SetCarryFlagOnError = true] #374
Labels
enhancement
New feature or request
feature request
This would be good to have
low priority
Fixing this is not urgent, or would take too much manpower for too little gain
refactoring
Involves refactoring existing code
Is your feature request related to a problem? Please describe.
Filling out the FillDispatchTable method is a long and repetitive task, prone to errors. Especially for the DOS kernel, which is very large.
An error can be for example: the same key is used in the dictionary for several interrupt handlers, leading to an exception when the emulator initializes.
Describe the solution you'd like
A Source Generator could take care of that instead. Driven by a method attribute. For a code that is supposed to run when AL and/or AL and AH (which means AX), and/or BL are certain values, and that is supposed to set the carry flag on error:
Could be instead:
The FillDispatchTable method would be generated, with entries such as:
We would only have to declare the class as partial and to call FillDispatchTable in the ctor.
And the compiler could be used to raise a compiler error when several handlers share the same values in the callback handlers dictionnary (that would require writing an analyzer).
Describe alternatives you've considered
None.
Additional context
Interrupt handlers that use the value of AL and other registers to determine what code to run also exist in the EMS handler, for example.
The text was updated successfully, but these errors were encountered: