Class BloatedAssignmentScope.ScopeBlock

  • Enclosing class:
    BloatedAssignmentScope

    private class BloatedAssignmentScope.ScopeBlock
    extends java.lang.Object
    holds the description of a scope { } block, be it a for, if, while block
    • Field Detail

      • startLocation

        private int startLocation
      • finishLocation

        private int finishLocation
      • isLoop

        private boolean isLoop
      • isGoto

        private boolean isGoto
      • isSync

        private boolean isSync
      • isTry

        private boolean isTry
      • isCase

        private boolean isCase
      • loads

        private java.util.Map<java.lang.Integer,​java.lang.Integer> loads
      • stores

        private java.util.Map<java.lang.Integer,​java.lang.Integer> stores
    • Constructor Detail

      • ScopeBlock

        public ScopeBlock​(int start,
                          int finish)
        constructs a new scope block
        Parameters:
        start - the beginning of the block
        finish - the end of the block
    • Method Detail

      • toString

        public java.lang.String toString()
        returns a string representation of the scope block
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation
      • getStart

        public int getStart()
        returns the start of the block
        Returns:
        the start of the block
      • getFinish

        public int getFinish()
        returns the end of the block
        Returns:
        the end of the block
      • setStart

        public void setStart​(int start)
        sets the start pc of the block
        Parameters:
        start - the start pc
      • setFinish

        public void setFinish​(int finish)
        sets the finish pc of the block
        Parameters:
        finish - the finish pc
      • hasChildren

        public boolean hasChildren()
      • setLoop

        public void setLoop()
        sets that this block is a loop
      • isLoop

        public boolean isLoop()
        returns whether this scope block is a loop
        Returns:
        whether this block is a loop
      • setGoto

        public void setGoto()
        sets that this block was caused from a goto, (an if block exit)
      • isGoto

        public boolean isGoto()
        returns whether this block was caused from a goto
        Returns:
        whether this block was caused by a goto
      • setSync

        public void setSync()
        sets that this block was caused from a synchronized block
      • isSync

        public boolean isSync()
        returns whether this block was caused from a synchronized block
        Returns:
        whether this block was caused by a synchronized block
      • setTry

        public void setTry()
        sets that this block was caused from a try block
      • isTry

        public boolean isTry()
        returns whether this block was caused from a try block
        Returns:
        whether this block was caused by a try block
      • setCase

        public void setCase()
        sets that this block was caused from a case block
      • isCase

        public boolean isCase()
        returns whether this block was caused from a case block
        Returns:
        whether this block was caused by a case block
      • addStore

        public void addStore​(int reg,
                             int pc,
                             BloatedAssignmentScope.UserObject assocObject)
        adds the register as a store in this scope block
        Parameters:
        reg - the register that was stored
        pc - the instruction that did the store
        assocObject - the the object that is associated with this store, usually the field from which this came
      • removeByAssoc

        public void removeByAssoc​(java.lang.Object assocObject)
        removes stores to registers that where retrieved from method calls on assocObject
        Parameters:
        assocObject - the object that a method call was just performed on
      • addLoad

        public void addLoad​(int reg,
                            int pc)
        adds the register as a load in this scope block
        Parameters:
        reg - the register that was loaded
        pc - the instruction that did the load
      • addChild

        public void addChild​(BloatedAssignmentScope.ScopeBlock newChild)
        adds a scope block to this subtree by finding the correct place in the hierarchy to store it
        Parameters:
        newChild - the scope block to add to the tree
      • markFieldAssociatedWrites

        public void markFieldAssociatedWrites​(int sourceReg)
      • findBugs

        public void findBugs​(java.util.Set<java.lang.Integer> parentUsedRegs)
        report stores that occur at scopes higher than associated loads that are not involved with loops
        Parameters:
        parentUsedRegs - the set of registers that where used by the parent scope block
      • appearsToBeUserRegister

        private boolean appearsToBeUserRegister​(int reg)
        in some cases the java compiler synthesizes variable for its own purposes. Hopefully when it does this these, can not be found in the localvariable table. If we find this to be the case, don't report them
        Parameters:
        reg - the register to check
        Returns:
        if reg variable appears in the local variable table
      • usesReg

        public boolean usesReg​(java.lang.Integer reg)
        returns whether this block either loads or stores into the register in question
        Parameters:
        reg - the register to look for loads or stores
        Returns:
        whether the block uses the register
      • pushUpLoadStores

        public void pushUpLoadStores()
        push all loads and stores to this block up to the parent