Class SortVisitor


  • public class SortVisitor
    extends Visitor
    A visitor sorting the variants by the lengths of their masks - from the shortest to the longest one.

    This ensures that the generated decoder will not read bytes beyond the current instruction.

    Expected tree at input:

       Rule
         Variant
           ...
           Mask (length=3)
           Pattern
         Variant
           ...
           Mask (length=4)
           Pattern
     

    Expected tree at output:

       Rule
         Variant
           ...
           Mask (length=4)
           Pattern
         Variant
           ...
           Mask (length=3)
           Pattern
     
    • Constructor Summary

      Constructors 
      Constructor Description
      SortVisitor()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void visit​(Mask mask)
      Adds the mask to the sorting list and detaches the parent variant.
      void visit​(Rule rule)
      Collects the variants, sorts them by mask length and re-attaches them in the correct order.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SortVisitor

        public SortVisitor()