Class TypeSafeInstructionFactory


  • public class TypeSafeInstructionFactory
    extends Object
    Intended for SyntheticMethods, uses JavaInstructionFactory. As the name states this SSAInstructionFactory does type checks. If they pass the actual instructions are generated using the JavaInstructionFactory. Obviously this factory is not complete yet. It's extended on demand.
    Since:
    2013-10-20
    See Also:
    JavaLanguage.JavaInstructionFactory
    • Constructor Detail

      • TypeSafeInstructionFactory

        public TypeSafeInstructionFactory​(IClassHierarchy cha)
    • Method Detail

      • InvokeInstruction

        public SSAInvokeInstruction InvokeInstruction​(int iindex,
                                                      SSAValue result,
                                                      List<? extends SSAValue> params,
                                                      SSAValue exception,
                                                      CallSiteReference site)
        result = site(params). Instruction that calls a method which has a return-value. All parameters (but exception) are typechecked first. If the check passes they get unpacked and handed over to the corresponding JavaInstructionFactory.InvokeInstruction. Calls result.setAssigned()
        Parameters:
        iindex - Zero or a positive number unique to any instruction of the same method
        result - Where to place the return-value of the called method. Is SSAValue.setAssigned() automatically.
        params - Parameters to the call starting with the implicit this-pointer if necessary
        exception - An SSAValue receiving the exception-object when something in the method throws unhandled
        site - The CallSiteReference to this call.
      • InvokeInstruction

        public SSAInvokeInstruction InvokeInstruction​(int iindex,
                                                      List<? extends SSAValue> params,
                                                      SSAValue exception,
                                                      CallSiteReference site)
        Instruction that calls a void-method. All parameters (but exception) are typechecked first. If the check passes they get unpacked and handed over to the corresponding JavaInstructionFactory.InvokeInstruction.
        Parameters:
        iindex - Zero or a positive number unique to any instruction of the same method
        params - Parameters to the call starting with the implicit this-pointer if necessary
        exception - An SSAValue receiving the exception-object when something in the method throws unhandled
        site - The CallSiteReference to this call.
      • ReturnInstruction

        public SSAReturnInstruction ReturnInstruction​(int iindex,
                                                      SSAValue result)
        Check if the type of the SSAValue is assignable to the return-value of the method it's valid in. If type check passes the corresponding ReturnInstruction of the JavaInstructionFactory is called.
        Parameters:
        iindex - Zero or a positive number unique to any instruction of the same method
        result - SSAValue to return _with_ validIn _set_!
        Throws:
        IllegalArgumentException - if result has no validIn set
      • GetInstruction

        public SSAGetInstruction GetInstruction​(int iindex,
                                                SSAValue targetValue,
                                                SSAValue containingInstance,
                                                FieldReference field)
        targetValue = containingInstance.field. Reads field from containingInstance into targetValue. If type check passes the corresponding GetInstruction of the JavaInstructionFactory is called. Calls targetValue.setAssigned()
        Parameters:
        iindex - Zero or a positive number unique to any instruction of the same method
        targetValue - the result of the GetInstruction is placed there
        containingInstance - The Object instance to read the field from
        field - The description of the field
      • GetInstruction

        public SSAGetInstruction GetInstruction​(int iindex,
                                                SSAValue targetValue,
                                                FieldReference field)
        Reads static field into targetValue. If type check passes the corresponding GetInstruction of the JavaInstructionFactory is called. Calls targetValue.setAssigned()
        Parameters:
        iindex - Zero or a positive number unique to any instruction of the same method
        targetValue - the result of the GetInstruction is placed there
        containingInstance - The Object instance to read the field from
        field - The description of the field
      • PutInstruction

        public SSAPutInstruction PutInstruction​(int iindex,
                                                SSAValue targetInstance,
                                                SSAValue newValue,
                                                FieldReference field)
        Writes newValue to field of targetInstance. If type check passes the corresponding PutInstruction of the JavaInstructionFactory is called.
        Parameters:
        iindex - Zero or a psitive number unique to any instruction of the same method
        targetInstance - the instance of the object to write a field of
        newValue - The value to write to the field
        field - The description of the target
      • PutInstruction

        public SSAPutInstruction PutInstruction​(int iindex,
                                                SSAValue newValue,
                                                FieldReference field)
        Writes newValue to static field. If type check passes the corresponding PutInstruction of the JavaInstructionFactory is called.
        Parameters:
        iindex - Zero or a psitive number unique to any instruction of the same method
        targetInstance - the instance of the object to write a field of
        newValue - The value to write to the field
        field - The description of the target
      • PhiInstruction

        public SSAPhiInstruction PhiInstruction​(int iindex,
                                                SSAValue result,
                                                Collection<? extends SSAValue> params)
        Combine SSA-Values into a newone. If type check passes the corresponding PhiInstruction of the JavaInstructionFactory is called. Calls result.setAssigned().
        Parameters:
        iindex - Zero or a positive number unique to any instruction of the same method
        result - Where to write result to
        params - at least one SSAValue to read from
      • ReturnInstruction

        public SSAReturnInstruction ReturnInstruction​(int iindex)
        Return from a void-function. Handed through to JavaInstructionFactory directly (unless the iindex is negative).
        Parameters:
        iindex - Zero or a positive number unique to any instruction of the same method
      • GotoInstruction

        public SSAGotoInstruction GotoInstruction​(int iindex,
                                                  int target)
        Unconditionally jump to a (non-Phi) Instruction.
        Parameters:
        target - the iindex of the instruction to jump to
      • ArrayLoadInstruction

        public SSAArrayLoadInstruction ArrayLoadInstruction​(int iindex,
                                                            SSAValue result,
                                                            SSAValue array,
                                                            int index)
        result = array[index]. Load a a reference from an array.
        Parameters:
        result - The SSAValue to store the loaded stuff in
        array - The array to load from
        index - Te position in array to load from
      • ArrayStoreInstruction

        public SSAArrayStoreInstruction ArrayStoreInstruction​(int iindex,
                                                              SSAValue array,
                                                              int index,
                                                              SSAValue value)
        array[index] = value. Save a value to a specific position in an Array.
        Parameters:
        array - the array to store to
        index - the position in the array to place value at
        value - The SSAValue to store in the array