Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8365677

Template-Framework Library: add an "abstract" type that is the supertype of all PrimitiveTypes

XMLWordPrintable

      Currently, we model all PrimitiveTypes seperately, with no way to get all of them in a call to "dataNames().subtypeOf(...)". It may be convenient to have some way of getting all of them.

      For modeling purposes, there are at least 2 different dimensions of importance:
      - When generating code, we may have some "generic" approach: me may access memory of this type, and ask for its size in bytes etc. But the Template can be used with any primitive type, so there has to be some way of abstracting over that. The supertype of all primitive types would just be a witness to this "abstract" class, but not actually be able to provide a size in bytes, because that of course depends on the subtype, the "concrete" primitive types that all have their own witness, which know the size in bytes.
      - We may want to retrieve all dataNames that are primitive types (of all possible sizes in bytes), hence we want to call something like "dataName().subtypeOf(allPrimitiveTypes)". What we get back will be a concrete primitive type, that knows its size in bytes.

      There are multiple approaches here.
      - Use PrimitiveType as the supertype, and move the current implementation to some "concrete" class. The concrete class could be "ConcretePrimitiveType" (a bit verbose).
      - Have a AllPrimitiveTypes class that models, leave the PrimitiveType name for the "concrete" ones.
      - In the enum, add an option "ALL" to the Kind. This would be the "leader". It would then have to throw an exception when queried for the size in bytes and other similar queries. Could push programming mistakes to runtime, where you get the exception. Might be nicer to explicitly model the "abstract" vs "concrete" in separate classes.

      The Java classes for the two should probably not be subclasses, but the witnesses should answer that the "concrete" isSubytpeOf "abstract".

            epeter Emanuel Peter
            epeter Emanuel Peter
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: