Class LocalVariableTableBuilder


  • public final class LocalVariableTableBuilder
    extends Object
    A builder for a LocalVariableTable over the source-local model recorded during AST lowering (IRMethod.SourceLocal), taking slots from RegisterAllocator and scoping each entry to the blocks holding that local's defs and uses.
    • Constructor Detail

      • LocalVariableTableBuilder

        public LocalVariableTableBuilder​(IRMethod irMethod,
                                         RegisterAllocator regAlloc,
                                         BytecodeEmitter emitter,
                                         int codeLength,
                                         ConstPool constPool,
                                         MethodEntry targetMethod)
        Creates a builder over one lowered method.
        Parameters:
        irMethod - the method whose source-local records supply names and declared types
        regAlloc - the final register allocation, which owns the two-slot long/double accounting
        emitter - the emitter holding the written slots and store end offsets of the final layout
        codeLength - length in bytes of the emitted code, used as the scope end for parameters
        constPool - pool the name and descriptor Utf8 entries are added to
        targetMethod - the method the attribute will be attached to
    • Method Detail

      • build

        public LocalVariableTableAttribute build()
        Builds the attribute, emitting one entry per slot a local occupies so that a variable whose versions landed on different slots does not over-reach into its neighbours' scopes.
        Returns:
        the built attribute, or null when the method carries no source-local model
      • getSignaturesByLvKey

        public Map<Long,​String> getSignaturesByLvKey()
        Returns:
        generic signatures for the emitted entries, taken from the source-local declarations and keyed slot << 32 | nameIndex - the key the type-table rebuild matches on