The reason this is complicated is because Inc (x), Dec (x) and others like Pred (x) and Succ (x) are actually generated by the compiler and, if you like, just a Function style of syntactic sugar over the built-in compiler operation.
You can, as some people believe, make some of them overload, some of them with smart generics and some of them with options. But nothing will be convenient for emulating these functions or just as functionally.
The compiler implements Inc (), for example, for all ordered types, including Enums, Integer, and subranges on these types (now the rather obscure feature of the classic Pascal virtual is that all types can have subranges defined on these types).
If you really told us more about what you are doing, you may be closer. But the general answer: No, there is no source code for Inc and Dec, because these are compiler primitives. If the source code is RTL for the Inc function, you can look at it and adapt it.
inc (x) can be defined as x: = Succ (x), but then how do you define Succ (x)? How is x: = Inc (x)? You see. At some point, the magic compiler takes over.
source share