Class SwitchDescriptor


  • public final class SwitchDescriptor
    extends Object
    A decoded, structuring-ready view of a native int/enum switch.
    • Constructor Detail

      • SwitchDescriptor

        public SwitchDescriptor​(IRBlock header,
                                Expression selector,
                                IRBlock merge,
                                List<SwitchDescriptor.CaseSpec> cases,
                                Set<IRBlock> caseHeaders)
        Creates a descriptor whose header successors are the case bodies.
        Parameters:
        header - the switch block
        selector - the recovered selector expression
        merge - where control resumes after the switch, or null if every case exits
        cases - the cases in source order, default last
        caseHeaders - every distinct case-body entry block
      • SwitchDescriptor

        public SwitchDescriptor​(IRBlock header,
                                Expression selector,
                                IRBlock merge,
                                List<SwitchDescriptor.CaseSpec> cases,
                                Set<IRBlock> caseHeaders,
                                boolean desugaredSelector)
        Creates a descriptor, stating whether the header's successors are dispatch scaffolding rather than case bodies.
        Parameters:
        header - the switch block
        selector - the recovered selector expression
        merge - where control resumes after the switch, or null if every case exits
        cases - the cases in source order, default last
        caseHeaders - every distinct case-body entry block
        desugaredSelector - true when the raw successors are a desugared dispatch chain
    • Method Detail

      • desugaredSelector

        public boolean desugaredSelector()
        Returns:
        true when the raw CFG edges out of the header are a desugared dispatch scaffold - a string switch's hashCode/equals chains - rather than the case bodies, so the model must follow this descriptor's case headers and merge instead of the raw successors
      • header

        public IRBlock header()
        Returns:
        the switch block itself
      • selector

        public Expression selector()
        Returns:
        the recovered selector expression - an enum variable, e.ordinal(), or the raw key
      • merge

        public IRBlock merge()
        Returns:
        the block where control resumes after the switch, or null when every case exits
      • caseHeaders

        public Set<IRBlock> caseHeaders()
        Returns:
        every distinct case-body entry block, the sibling stop-set, excluding the merge