RVM
  1. RVM
  2. RVM-356

Use generic type to eliminate frequent casting of Operands

    Details

    • Type: Improvement Improvement
    • Status: Open Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 1000
    • Component/s: Compiler: Optimizing
    • Labels:
      None
    • Number of attachments :
      0

      Description

      We currently define Operand.copy to return an Operand, if we instead changed the declaration of Operand to:

      class Operand<T extends Operand<T>>

      or:

      class Operand<T extends Operand<?>>

      then we can define copy to return T. This would mean, for example, in RegisterOperand we could define copy as:

      class RegisterOperand extends Operand<RegisterOperand> { ...
      RegisterOperand copy()

      { ... }

      We often copy and have to cast so that instructions have unique operands and that the operand is of the correct type. To try to make the matter more elegant we currently have methods like copyRO and asRegister, but generic types appear to make this unnecessary and a little bit more graceful.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Ian Rogers
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: