EEC-Developers / eec

Enhanced E Compiler - AmigaE programming
Other
12 stars 3 forks source link

Refactoring globals #9

Open SamuraiCrow opened 4 years ago

SamuraiCrow commented 4 years ago

After having looked through the eecmain.e file, there is a great possibility of modularizing the code using OOP. For example there are many places where g_optosid is checked against all the constants: OSID_NONE, OSID_MORPHOS, OSID_AMIGAOS and OSID_AMIGAOS4. These could all be combined using inheritance by making g_optosid into a context class and making all the IF, ELSIF, ELSEIF, ELSE, ENDIF statements into a method in that class. The context class may also keep track of library modes, ELF vs. HUNK executable types, and so on with all of the non-applicable methods of library mode, for example, being returned as no-ops in executable mode.

Using this may allow the contexts to be reimplemented as shared libraries for all the different sets of startup-codes and code generators. Some contexts will require more than one codegen such as MorphOS being able to use mixed binaries containing both 68k and PPC code.

SamuraiCrow commented 4 years ago

This is a prerequisite of adding more platforms, IMO, because then all the conditionals are replaced all at once using inheritance of the context abstract class rather than a dozen different places.

SamuraiCrow commented 5 months ago

This is now identified as a prerequisite of #6 because globals cannot be safely shared across modular networks of shared libraries.