internal static LLLocation LoadArrayElementPointer(LLFunction pFunction, HLLocation pInstance, HLLocation pIndex, HLType pElementType)
        {
            LLLocation locationIndex = pIndex.Load(pFunction);
            LLLocation locationElementOffset = locationIndex;
            long? literalElementOffset = null;
            if (locationIndex is LLLiteralLocation)
            {
                literalElementOffset = Convert.ToInt64(((LLLiteralLocation)locationIndex).Literal.Value) * pElementType.VariableSize;
            }
            else if (pElementType.VariableSize > 1)
            {
                locationElementOffset = LLTemporaryLocation.Create(pFunction.CreateTemporary(locationIndex.Type));
                pFunction.CurrentBlock.EmitMultiply(locationElementOffset, locationIndex, LLLiteralLocation.Create(LLLiteral.Create(locationElementOffset.Type, pElementType.VariableSize.ToString())));
            }

            LLLocation locationArrayPointer = pInstance.Load(pFunction);
            locationArrayPointer = pFunction.CurrentBlock.EmitConversion(locationArrayPointer, LLModule.GetOrCreatePointerType(LLModule.GetOrCreateUnsignedType(8), 1));

            LLLocation locationElementPointer = null;
            if (literalElementOffset.HasValue)
            {
                locationElementOffset = LLLiteralLocation.Create(LLLiteral.Create(LLModule.GetOrCreateSignedType(64), (literalElementOffset.Value + HLDomain.SystemArray.CalculatedSize).ToString()));
                locationElementPointer = LLTemporaryLocation.Create(pFunction.CreateTemporary(locationArrayPointer.Type));
                pFunction.CurrentBlock.EmitGetElementPointer(locationElementPointer, locationArrayPointer, locationElementOffset);
            }
            else
            {
                LLLocation locationTemporary = LLTemporaryLocation.Create(pFunction.CreateTemporary(locationArrayPointer.Type));
                pFunction.CurrentBlock.EmitGetElementPointer(locationTemporary, locationArrayPointer, LLLiteralLocation.Create(LLLiteral.Create(LLModule.GetOrCreateSignedType(32), (HLDomain.SystemArray.CalculatedSize).ToString())));
                locationElementPointer = LLTemporaryLocation.Create(pFunction.CreateTemporary(locationArrayPointer.Type));
                pFunction.CurrentBlock.EmitGetElementPointer(locationElementPointer, locationTemporary, locationElementOffset);
            }
            return pFunction.CurrentBlock.EmitConversion(locationElementPointer, pElementType.LLType.PointerDepthPlusOne);
        }
 public static HLNewObjectInstruction Create(HLMethod pMethod, HLType pNewObjectType, HLLocation pDestinationSource)
 {
     HLNewObjectInstruction instruction = new HLNewObjectInstruction(pMethod);
     instruction.mNewObjectType = pNewObjectType;
     instruction.mDestinationSource = pDestinationSource;
     return instruction;
 }
Example #3
0
        public static HLReturnInstruction Create(HLMethod pMethod, HLLocation pSource)
        {
            HLReturnInstruction instruction = new HLReturnInstruction(pMethod);

            instruction.mSource = pSource;
            return(instruction);
        }
 public static HLFieldAddressLocation Create(HLLocation pInstance, HLField pField)
 {
     HLFieldAddressLocation location = new HLFieldAddressLocation(HLDomain.GetOrCreateType(MutableModelHelper.GetManagedPointerTypeReference(pField.Type.Definition, HLDomain.Host.InternFactory, pField.Type.Definition)));
     location.mInstance = pInstance;
     location.mField = pField;
     return location;
 }
        public static HLIndirectAddressLocation Create(HLLocation pAddress, HLType pType)
        {
            HLIndirectAddressLocation location = new HLIndirectAddressLocation(HLDomain.GetOrCreateType(MutableModelHelper.GetManagedPointerTypeReference(pType.Definition, HLDomain.Host.InternFactory, pType.Definition)));

            location.mAddress = pAddress;
            return(location);
        }
 public static HLBitwiseNotInstruction Create(HLMethod pMethod, HLLocation pDestination, HLLocation pSource)
 {
     HLBitwiseNotInstruction instruction = new HLBitwiseNotInstruction(pMethod);
     instruction.mDestination = pDestination;
     instruction.mSource = pSource;
     return instruction;
 }
 public static HLFieldLocation Create(HLLocation pInstance, HLField pField)
 {
     HLFieldLocation location = new HLFieldLocation(pField.Type);
     location.mInstance = pInstance;
     location.mField = pField;
     return location;
 }
Example #8
0
        public static HLArrayLengthLocation Create(HLLocation pInstance)
        {
            HLArrayLengthLocation location = new HLArrayLengthLocation(HLDomain.SystemInt32);

            location.mInstance = pInstance;
            return(location);
        }
Example #9
0
        public static HLFieldLocation Create(HLLocation pInstance, HLField pField)
        {
            HLFieldLocation location = new HLFieldLocation(pField.Type);

            location.mInstance = pInstance;
            location.mField    = pField;
            return(location);
        }
        public static HLBitwiseNegateInstruction Create(HLMethod pMethod, HLLocation pDestination, HLLocation pSource)
        {
            HLBitwiseNegateInstruction instruction = new HLBitwiseNegateInstruction(pMethod);

            instruction.mDestination = pDestination;
            instruction.mSource      = pSource;
            return(instruction);
        }
 public static HLMultiplyInstruction Create(HLMethod pMethod, HLLocation pDestination, HLLocation pLeftOperandSource, HLLocation pRightOperandSource)
 {
     HLMultiplyInstruction instruction = new HLMultiplyInstruction(pMethod);
     instruction.mDestination = pDestination;
     instruction.mLeftOperandSource = pLeftOperandSource;
     instruction.mRightOperandSource = pRightOperandSource;
     return instruction;
 }
 public static HLBranchInstruction Create(HLMethod pMethod, HLLocation pConditionSource, HLLabel pTrueLabel, HLLabel pFalseLabel)
 {
     HLBranchInstruction instruction = new HLBranchInstruction(pMethod);
     instruction.mConditionSource = pConditionSource;
     instruction.mTrueLabel = pTrueLabel;
     instruction.mFalseLabel = pFalseLabel;
     return instruction;
 }
 public static HLArrayElementAddressLocation Create(HLLocation pInstance, HLLocation pIndex, HLType pElementType)
 {
     HLArrayElementAddressLocation location = new HLArrayElementAddressLocation(HLDomain.GetOrCreateType(MutableModelHelper.GetManagedPointerTypeReference(pElementType.Definition, HLDomain.Host.InternFactory, pElementType.Definition)));
     location.mInstance = pInstance;
     location.mIndex = pIndex;
     location.mElementType = pElementType;
     return location;
 }
 public static HLSwitchInstruction Create(HLMethod pMethod, HLLocation pConditionSource, HLLabel pDefaultLabel, List<Tuple<HLLiteralLocation, HLLabel>> pCases)
 {
     HLSwitchInstruction instruction = new HLSwitchInstruction(pMethod);
     instruction.mConditionSource = pConditionSource;
     instruction.mDefaultLabel = pDefaultLabel;
     instruction.mCases = new List<Tuple<HLLiteralLocation, HLLabel>>(pCases);
     return instruction;
 }
 public static HLArrayElementLocation Create(HLLocation pInstance, HLLocation pIndex, HLType pElementType)
 {
     HLArrayElementLocation location = new HLArrayElementLocation(pElementType);
     location.mInstance = pInstance;
     location.mIndex = pIndex;
     location.mElementType = pElementType;
     return location;
 }
        public static HLFieldAddressLocation Create(HLLocation pInstance, HLField pField)
        {
            HLFieldAddressLocation location = new HLFieldAddressLocation(HLDomain.GetOrCreateType(MutableModelHelper.GetManagedPointerTypeReference(pField.Type.Definition, HLDomain.Host.InternFactory, pField.Type.Definition)));

            location.mInstance = pInstance;
            location.mField    = pField;
            return(location);
        }
 public static HLNewArrayInstruction Create(HLMethod pMethod, HLLocation pDestinationSource, HLLocation pSizeSource, HLType pArrayType, HLType pElementType)
 {
     HLNewArrayInstruction instruction = new HLNewArrayInstruction(pMethod);
     instruction.mDestinationSource = pDestinationSource;
     instruction.mSizeSource = pSizeSource;
     instruction.mArrayType = pArrayType;
     instruction.mElementType = pElementType;
     return instruction;
 }
 public static HLCallInstruction Create(HLMethod pMethod, HLMethod pCalledMethod, bool pVirtual, HLLocation pReturnDestination, List<HLLocation> pParameterSources)
 {
     HLCallInstruction instruction = new HLCallInstruction(pMethod);
     instruction.mCalledMethod = pCalledMethod;
     instruction.mVirtual = pVirtual;
     instruction.mReturnDestination = pReturnDestination;
     instruction.mParameterSources = new List<HLLocation>(pParameterSources);
     return instruction;
 }
Example #19
0
        public static HLBranchInstruction Create(HLMethod pMethod, HLLocation pConditionSource, HLLabel pTrueLabel, HLLabel pFalseLabel)
        {
            HLBranchInstruction instruction = new HLBranchInstruction(pMethod);

            instruction.mConditionSource = pConditionSource;
            instruction.mTrueLabel       = pTrueLabel;
            instruction.mFalseLabel      = pFalseLabel;
            return(instruction);
        }
Example #20
0
        public static HLMultiplyInstruction Create(HLMethod pMethod, HLLocation pDestination, HLLocation pLeftOperandSource, HLLocation pRightOperandSource)
        {
            HLMultiplyInstruction instruction = new HLMultiplyInstruction(pMethod);

            instruction.mDestination        = pDestination;
            instruction.mLeftOperandSource  = pLeftOperandSource;
            instruction.mRightOperandSource = pRightOperandSource;
            return(instruction);
        }
Example #21
0
        public static HLSwitchInstruction Create(HLMethod pMethod, HLLocation pConditionSource, HLLabel pDefaultLabel, List <Tuple <HLLiteralLocation, HLLabel> > pCases)
        {
            HLSwitchInstruction instruction = new HLSwitchInstruction(pMethod);

            instruction.mConditionSource = pConditionSource;
            instruction.mDefaultLabel    = pDefaultLabel;
            instruction.mCases           = new List <Tuple <HLLiteralLocation, HLLabel> >(pCases);
            return(instruction);
        }
Example #22
0
        public static HLArrayElementLocation Create(HLLocation pInstance, HLLocation pIndex, HLType pElementType)
        {
            HLArrayElementLocation location = new HLArrayElementLocation(pElementType);

            location.mInstance    = pInstance;
            location.mIndex       = pIndex;
            location.mElementType = pElementType;
            return(location);
        }
        public static HLArrayElementAddressLocation Create(HLLocation pInstance, HLLocation pIndex, HLType pElementType)
        {
            HLArrayElementAddressLocation location = new HLArrayElementAddressLocation(HLDomain.GetOrCreateType(MutableModelHelper.GetManagedPointerTypeReference(pElementType.Definition, HLDomain.Host.InternFactory, pElementType.Definition)));

            location.mInstance    = pInstance;
            location.mIndex       = pIndex;
            location.mElementType = pElementType;
            return(location);
        }
Example #24
0
        public static HLNewArrayInstruction Create(HLMethod pMethod, HLLocation pDestinationSource, HLLocation pSizeSource, HLType pArrayType, HLType pElementType)
        {
            HLNewArrayInstruction instruction = new HLNewArrayInstruction(pMethod);

            instruction.mDestinationSource = pDestinationSource;
            instruction.mSizeSource        = pSizeSource;
            instruction.mArrayType         = pArrayType;
            instruction.mElementType       = pElementType;
            return(instruction);
        }
 public static HLNewDelegateInstruction Create(HLMethod pMethod, HLType pNewDelegateType, HLLocation pDestinationSource, HLLocation pInstanceSource, HLMethod pMethodCalled, bool pVirtual)
 {
     HLNewDelegateInstruction instruction = new HLNewDelegateInstruction(pMethod);
     instruction.mNewDelegateType = pNewDelegateType;
     instruction.mDestinationSource = pDestinationSource;
     instruction.mInstanceSource = pInstanceSource;
     instruction.mMethodCalled = pMethodCalled;
     instruction.mVirtual = pVirtual;
     return instruction;
 }
 internal static LLLocation LoadInstanceFieldPointer(LLFunction pFunction, HLLocation pInstance, HLField pField)
 {
     LLLocation locationInstance = pInstance.Load(pFunction);
     locationInstance = pFunction.CurrentBlock.EmitConversion(locationInstance, LLModule.GetOrCreatePointerType(LLModule.GetOrCreateUnsignedType(8), 1));
     LLLocation locationFieldPointer = locationInstance;
     if (pField.Offset > 0)
     {
         locationFieldPointer = LLTemporaryLocation.Create(pFunction.CreateTemporary(locationFieldPointer.Type));
         pFunction.CurrentBlock.EmitGetElementPointer(locationFieldPointer, locationInstance, LLLiteralLocation.Create(LLLiteral.Create(LLModule.GetOrCreateUnsignedType(32), pField.Offset.ToString())));
     }
     return pFunction.CurrentBlock.EmitConversion(locationFieldPointer, pField.Type.LLType.PointerDepthPlusOne);
 }
        internal static LLLocation LoadInstanceFieldPointer(LLFunction pFunction, HLLocation pInstance, HLField pField)
        {
            LLLocation locationInstance = pInstance.Load(pFunction);

            locationInstance = pFunction.CurrentBlock.EmitConversion(locationInstance, LLModule.GetOrCreatePointerType(LLModule.GetOrCreateUnsignedType(8), 1));
            LLLocation locationFieldPointer = locationInstance;

            if (pField.Offset > 0)
            {
                locationFieldPointer = LLTemporaryLocation.Create(pFunction.CreateTemporary(locationFieldPointer.Type));
                pFunction.CurrentBlock.EmitGetElementPointer(locationFieldPointer, locationInstance, LLLiteralLocation.Create(LLLiteral.Create(LLModule.GetOrCreateUnsignedType(32), pField.Offset.ToString())));
            }
            return(pFunction.CurrentBlock.EmitConversion(locationFieldPointer, pField.Type.LLType.PointerDepthPlusOne));
        }
        internal static LLLocation LoadArrayElementPointer(LLFunction pFunction, HLLocation pInstance, HLLocation pIndex, HLType pElementType)
        {
            LLLocation locationIndex         = pIndex.Load(pFunction);
            LLLocation locationElementOffset = locationIndex;
            long?      literalElementOffset  = null;

            if (locationIndex is LLLiteralLocation)
            {
                literalElementOffset = Convert.ToInt64(((LLLiteralLocation)locationIndex).Literal.Value) * pElementType.VariableSize;
            }
            else if (pElementType.VariableSize > 1)
            {
                locationElementOffset = LLTemporaryLocation.Create(pFunction.CreateTemporary(locationIndex.Type));
                pFunction.CurrentBlock.EmitMultiply(locationElementOffset, locationIndex, LLLiteralLocation.Create(LLLiteral.Create(locationElementOffset.Type, pElementType.VariableSize.ToString())));
            }

            LLLocation locationArrayPointer = pInstance.Load(pFunction);

            locationArrayPointer = pFunction.CurrentBlock.EmitConversion(locationArrayPointer, LLModule.GetOrCreatePointerType(LLModule.GetOrCreateUnsignedType(8), 1));

            LLLocation locationElementPointer = null;

            if (literalElementOffset.HasValue)
            {
                locationElementOffset  = LLLiteralLocation.Create(LLLiteral.Create(LLModule.GetOrCreateSignedType(64), (literalElementOffset.Value + HLDomain.SystemArray.CalculatedSize).ToString()));
                locationElementPointer = LLTemporaryLocation.Create(pFunction.CreateTemporary(locationArrayPointer.Type));
                pFunction.CurrentBlock.EmitGetElementPointer(locationElementPointer, locationArrayPointer, locationElementOffset);
            }
            else
            {
                LLLocation locationTemporary = LLTemporaryLocation.Create(pFunction.CreateTemporary(locationArrayPointer.Type));
                pFunction.CurrentBlock.EmitGetElementPointer(locationTemporary, locationArrayPointer, LLLiteralLocation.Create(LLLiteral.Create(LLModule.GetOrCreateSignedType(32), (HLDomain.SystemArray.CalculatedSize).ToString())));
                locationElementPointer = LLTemporaryLocation.Create(pFunction.CreateTemporary(locationArrayPointer.Type));
                pFunction.CurrentBlock.EmitGetElementPointer(locationElementPointer, locationTemporary, locationElementOffset);
            }
            return(pFunction.CurrentBlock.EmitConversion(locationElementPointer, pElementType.LLType.PointerDepthPlusOne));
        }
 public static HLIndirectAddressLocation Create(HLLocation pAddress, HLType pType)
 {
     HLIndirectAddressLocation location = new HLIndirectAddressLocation(HLDomain.GetOrCreateType(MutableModelHelper.GetManagedPointerTypeReference(pType.Definition, HLDomain.Host.InternFactory, pType.Definition)));
     location.mAddress = pAddress;
     return location;
 }
 public static HLArrayLengthLocation Create(HLLocation pInstance)
 {
     HLArrayLengthLocation location = new HLArrayLengthLocation(HLDomain.SystemInt32);
     location.mInstance = pInstance;
     return location;
 }
Example #31
0
        public static HLNewObjectInstruction Create(HLMethod pMethod, HLType pNewObjectType, HLLocation pDestinationSource)
        {
            HLNewObjectInstruction instruction = new HLNewObjectInstruction(pMethod);

            instruction.mNewObjectType     = pNewObjectType;
            instruction.mDestinationSource = pDestinationSource;
            return(instruction);
        }
Example #32
0
        public static HLCallInstruction Create(HLMethod pMethod, HLMethod pCalledMethod, bool pVirtual, HLLocation pReturnDestination, List <HLLocation> pParameterSources)
        {
            HLCallInstruction instruction = new HLCallInstruction(pMethod);

            instruction.mCalledMethod      = pCalledMethod;
            instruction.mVirtual           = pVirtual;
            instruction.mReturnDestination = pReturnDestination;
            instruction.mParameterSources  = new List <HLLocation>(pParameterSources);
            return(instruction);
        }
        public static HLNewDelegateInstruction Create(HLMethod pMethod, HLType pNewDelegateType, HLLocation pDestinationSource, HLLocation pInstanceSource, HLMethod pMethodCalled, bool pVirtual)
        {
            HLNewDelegateInstruction instruction = new HLNewDelegateInstruction(pMethod);

            instruction.mNewDelegateType   = pNewDelegateType;
            instruction.mDestinationSource = pDestinationSource;
            instruction.mInstanceSource    = pInstanceSource;
            instruction.mMethodCalled      = pMethodCalled;
            instruction.mVirtual           = pVirtual;
            return(instruction);
        }
 public static HLReturnInstruction Create(HLMethod pMethod, HLLocation pSource)
 {
     HLReturnInstruction instruction = new HLReturnInstruction(pMethod);
     instruction.mSource = pSource;
     return instruction;
 }