Esempio n. 1
0
        public static HLTypeOfLocation Create(HLType pTypeOfType)
        {
            HLTypeOfLocation location = new HLTypeOfLocation(HLDomain.SystemType);

            location.mTypeOfType = pTypeOfType;
            return(location);
        }
 public static HLNewObjectInstruction Create(HLMethod pMethod, HLType pNewObjectType, HLLocation pDestinationSource)
 {
     HLNewObjectInstruction instruction = new HLNewObjectInstruction(pMethod);
     instruction.mNewObjectType = pNewObjectType;
     instruction.mDestinationSource = pDestinationSource;
     return instruction;
 }
Esempio n. 3
0
        public static HLEnumLiteralLocation Create(HLType pType, string pLiteral)
        {
            HLEnumLiteralLocation location = new HLEnumLiteralLocation(pType);

            location.mLiteral = pLiteral;
            return(location);
        }
Esempio n. 4
0
        public static HLSizeOfLocation Create(HLType pSizeOfType)
        {
            HLSizeOfLocation location = new HLSizeOfLocation(HLDomain.SystemInt32);

            location.mSizeOfType = pSizeOfType;
            return(location);
        }
        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);
        }
        internal static void CheckStaticConstructorCalled(LLFunction pFunction, HLType pType)
        {
            if (pType.StaticConstructor == null) return;
            if (pType.StaticConstructor.LLFunction == pFunction) return;
            LLLocation locationConstructorCalled = LLGlobalLocation.Create(LLModule.GetGlobal(pType.ToString()));
            LLLocation locationConstructorCalledOriginal = LLTemporaryLocation.Create(pFunction.CreateTemporary(locationConstructorCalled.Type.PointerDepthMinusOne));
            pFunction.CurrentBlock.EmitCompareExchange(locationConstructorCalledOriginal, locationConstructorCalled, LLLiteralLocation.Create(LLLiteral.Create(locationConstructorCalledOriginal.Type, "0")), LLLiteralLocation.Create(LLLiteral.Create(locationConstructorCalledOriginal.Type, "1")), LLCompareExchangeOrdering.acq_rel);

            LLLocation locationConstructorCall = LLTemporaryLocation.Create(pFunction.CreateTemporary(LLModule.BooleanType));
            pFunction.CurrentBlock.EmitCompareIntegers(locationConstructorCall, locationConstructorCalledOriginal, LLLiteralLocation.Create(LLLiteral.Create(locationConstructorCalledOriginal.Type, "0")), LLCompareIntegersCondition.eq);

            LLLabel labelTrue = pFunction.CreateLabel(pFunction.Labels.Count);
            LLLabel labelFalse = pFunction.CreateLabel(pFunction.Labels.Count);
            LLLabel labelNext = pFunction.CreateLabel(pFunction.Labels.Count);
            pFunction.CurrentBlock.EmitBranch(locationConstructorCall, labelTrue, labelFalse);

            LLInstructionBlock blockTrue = pFunction.CreateBlock(labelTrue);
            List<LLLocation> parameters = new List<LLLocation>();
            parameters.Add(LLLiteralLocation.Create(LLLiteral.Create(pType.StaticConstructor.LLFunction.Parameters[0].Type, "zeroinitializer")));
            blockTrue.EmitCall(null, LLFunctionLocation.Create(pType.StaticConstructor.LLFunction), parameters);
            blockTrue.EmitGoto(labelNext);

            LLInstructionBlock blockFalse = pFunction.CreateBlock(labelFalse);
            blockFalse.EmitGoto(labelNext);

            pFunction.CurrentBlock = pFunction.CreateBlock(labelNext);
        }
        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);
        }
Esempio n. 8
0
        public static HLNewObjectInstruction Create(HLMethod pMethod, HLType pNewObjectType, HLLocation pDestinationSource)
        {
            HLNewObjectInstruction instruction = new HLNewObjectInstruction(pMethod);

            instruction.mNewObjectType     = pNewObjectType;
            instruction.mDestinationSource = pDestinationSource;
            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 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 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;
 }
Esempio n. 13
0
        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 void CheckStaticConstructorCalled(LLFunction pFunction, HLType pType)
        {
            if (pType.StaticConstructor == null)
            {
                return;
            }
            if (pType.StaticConstructor.LLFunction == pFunction)
            {
                return;
            }
            LLLocation locationConstructorCalled         = LLGlobalLocation.Create(LLModule.GetGlobal(pType.ToString()));
            LLLocation locationConstructorCalledOriginal = LLTemporaryLocation.Create(pFunction.CreateTemporary(locationConstructorCalled.Type.PointerDepthMinusOne));

            pFunction.CurrentBlock.EmitCompareExchange(locationConstructorCalledOriginal, locationConstructorCalled, LLLiteralLocation.Create(LLLiteral.Create(locationConstructorCalledOriginal.Type, "0")), LLLiteralLocation.Create(LLLiteral.Create(locationConstructorCalledOriginal.Type, "1")), LLCompareExchangeOrdering.acq_rel);

            LLLocation locationConstructorCall = LLTemporaryLocation.Create(pFunction.CreateTemporary(LLModule.BooleanType));

            pFunction.CurrentBlock.EmitCompareIntegers(locationConstructorCall, locationConstructorCalledOriginal, LLLiteralLocation.Create(LLLiteral.Create(locationConstructorCalledOriginal.Type, "0")), LLCompareIntegersCondition.eq);

            LLLabel labelTrue  = pFunction.CreateLabel(pFunction.Labels.Count);
            LLLabel labelFalse = pFunction.CreateLabel(pFunction.Labels.Count);
            LLLabel labelNext  = pFunction.CreateLabel(pFunction.Labels.Count);

            pFunction.CurrentBlock.EmitBranch(locationConstructorCall, labelTrue, labelFalse);

            LLInstructionBlock blockTrue  = pFunction.CreateBlock(labelTrue);
            List <LLLocation>  parameters = new List <LLLocation>();

            parameters.Add(LLLiteralLocation.Create(LLLiteral.Create(pType.StaticConstructor.LLFunction.Parameters[0].Type, "zeroinitializer")));
            blockTrue.EmitCall(null, LLFunctionLocation.Create(pType.StaticConstructor.LLFunction), parameters);
            blockTrue.EmitGoto(labelNext);

            LLInstructionBlock blockFalse = pFunction.CreateBlock(labelFalse);

            blockFalse.EmitGoto(labelNext);

            pFunction.CurrentBlock = pFunction.CreateBlock(labelNext);
        }
Esempio n. 15
0
 private HLTemporaryLocation(HLType pType) : base(pType)
 {
 }
 public static HLEnumLiteralLocation Create(HLType pType, string pLiteral)
 {
     HLEnumLiteralLocation location = new HLEnumLiteralLocation(pType);
     location.mLiteral = pLiteral;
     return location;
 }
Esempio n. 17
0
 public static HLDefaultLocation Create(HLType pType)
 {
     return new HLDefaultLocation(pType);
 }
 private HLTemporaryLocation(HLType pType)
     : base(pType)
 {
 }
 private HLParameterLocation(HLType pType)
     : base(pType)
 {
 }
Esempio n. 20
0
 public static HLNullLocation Create(HLType pType)
 {
     return new HLNullLocation(pType);
 }
Esempio n. 21
0
 private HLNullLocation(HLType pType)
     : base(pType)
 {
 }
 private HLFieldAddressLocation(HLType pType)
     : base(pType)
 {
 }
Esempio n. 23
0
 private HLTemporaryAddressLocation(HLType pType) : base(pType)
 {
 }
Esempio n. 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);
        }
Esempio n. 25
0
 private HLCharLiteralLocation(HLType pType) : base(pType)
 {
 }
 private HLArrayElementAddressLocation(HLType pType)
     : base(pType)
 {
 }
Esempio n. 27
0
 private HLLocalAddressLocation(HLType pType) : base(pType)
 {
 }
Esempio n. 28
0
 private HLLocalLocation(HLType pType) : base(pType)
 {
 }
Esempio n. 29
0
 private HLStringLiteralLocation(HLType pType) : base(pType)
 {
 }
Esempio n. 30
0
 private HLEnumLiteralLocation(HLType pType) : base(pType)
 {
 }
 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;
 }
 private HLParameterAddressLocation(HLType pType)
     : base(pType)
 {
 }
 private HLLocalAddressLocation(HLType pType)
     : base(pType)
 {
 }
        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);
        }
Esempio n. 35
0
 private HLDefaultLocation(HLType pType)
     : base(pType)
 {
 }
        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));
        }
Esempio n. 37
0
 private HLParameterAddressLocation(HLType pType) : base(pType)
 {
 }
Esempio n. 38
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);
        }
 private HLTemporaryAddressLocation(HLType pType)
     : base(pType)
 {
 }
Esempio n. 40
0
 private HLLocalLocation(HLType pType)
     : base(pType)
 {
 }
Esempio n. 41
0
 private HLArrayLengthLocation(HLType pType) : base(pType)
 {
 }
Esempio n. 42
0
 private HLStaticFieldLocation(HLType pType) : base(pType)
 {
 }
 private HLEnumLiteralLocation(HLType pType)
     : base(pType)
 {
 }
Esempio n. 44
0
 private HLUInt32LiteralLocation(HLType pType) : base(pType)
 {
 }
Esempio n. 45
0
 private HLInt64LiteralLocation(HLType pType) : base(pType)
 {
 }
 private HLInt64LiteralLocation(HLType pType)
     : base(pType)
 {
 }
Esempio n. 47
0
 private HLParameterLocation(HLType pType) : base(pType)
 {
 }
Esempio n. 48
0
 private HLTypeOfLocation(HLType pType) : base(pType)
 {
 }
Esempio n. 49
0
 private HLArrayElementLocation(HLType pType) : base(pType)
 {
 }
 private HLIndirectAddressLocation(HLType pType) : base(pType)
 {
 }
 private HLStaticFieldLocation(HLType pType)
     : base(pType)
 {
 }
Esempio n. 52
0
 private HLBooleanLiteralLocation(HLType pType) : base(pType)
 {
 }
 private HLArrayLengthLocation(HLType pType)
     : base(pType)
 {
 }
 private HLBooleanLiteralLocation(HLType pType)
     : base(pType)
 {
 }
Esempio n. 55
0
 private HLFieldAddressLocation(HLType pType) : base(pType)
 {
 }
 private HLUInt16LiteralLocation(HLType pType)
     : base(pType)
 {
 }
 private HLCharLiteralLocation(HLType pType)
     : base(pType)
 {
 }
 private HLIndirectAddressLocation(HLType pType)
     : base(pType)
 {
 }
 private HLFloat32LiteralLocation(HLType pType)
     : base(pType)
 {
 }
Esempio n. 60
0
 private HLNullLocation(HLType pType) : base(pType)
 {
 }