Example #1
0
        public void SimpleAllocaParse_Expected_True()
        {
            LAlloca alloca = new LAlloca(_function, LType.Int32Type());

            Assert.AreEqual($"{alloca.PointerRef.Identifier} = {LKeywords.Alloca} {LType.Int32Type().Parse()}",
                            LHelper.Trim(alloca.ParseInstruction()));
        }
Example #2
0
        public void AllocaLiteralStruct_Expected_Ok()
        {
            var     @struct = new LLiteralStruct(new LValueRef(LType.Int128Type(), ""), new LValueRef(LType.Int16Type(), ""));
            LAlloca alloca  = new LAlloca(_function, @struct);

            Assert.AreEqual($"{alloca.PointerRef.Identifier} = {LKeywords.Alloca} {{ i128, i16 }}", LHelper.Trim(alloca.ParseInstruction()));
            Assert.AreEqual("{ i128, i16 }*", LHelper.Trim(alloca.PointerRef.ParseType()));
        }
Example #3
0
        public void AllocaTriplePointerType_Expected_Equal()
        {
            LPointerRef singlePointer = new LPointerRef(new LValueRef(LType.Int32Type(), ""), _function.GetPointerRefIdentifier());
            LPointerRef doublePointer = new LPointerRef(singlePointer, _function.GetPointerRefIdentifier());
            LAlloca     alloca        = new LAlloca(_function, doublePointer);

            Assert.AreEqual($"{alloca.PointerRef.Identifier} = {LKeywords.Alloca} {LType.Int32Type().Parse()}**", LHelper.Trim(alloca.ParseInstruction()));
            Assert.AreEqual($"{LType.Int32Type().Parse()}***", LHelper.Trim(alloca.PointerRef.ParseType()));
        }
Example #4
0
        public void AllocaIdentifiedStruct_Expected_Ok()
        {
            string  structIdentifier = "abcTestStruct";
            var     @struct          = new LIdentifiedStruct(structIdentifier, new LValueRef(LType.Int128Type(), ""), new LValueRef(LType.Int16Type(), ""));
            LAlloca alloca           = new LAlloca(_function, @struct);

            Assert.AreEqual($"{alloca.PointerRef.Identifier} = {LKeywords.Alloca} {structIdentifier}", LHelper.Trim(alloca.ParseInstruction()));
            Assert.AreEqual($"{structIdentifier}*", LHelper.Trim(alloca.PointerRef.ParseType()));
        }
Example #5
0
        public void SimpleAllocaAlignmentExceeded_Expected_Exception()
        {
            LAlloca alloca;

            Assert.Throws <Exception>(() =>
                                      alloca = new LAlloca(_function, LType.Int32Type())
            {
                Alignment = 1 << 30
            });
        }
Example #6
0
        public void AllocaParseAddrspace_Expected_True()
        {
            LAlloca alloca = new LAlloca(_function, LType.Int32Type())
            {
                Addrspace = 4
            };

            Assert.AreEqual(
                $"{alloca.PointerRef.Identifier} = {LKeywords.Alloca} {LType.Int32Type().Parse()}, {LKeywords.Addrspace}(4)",
                LHelper.Trim(alloca.ParseInstruction()));
        }
Example #7
0
        public void AllocaParseNumOfElements_Expected_True()
        {
            LAlloca alloca = new LAlloca(_function, LType.Int32Type())
            {
                NumOfElements = 5
            };

            Assert.AreEqual(
                $"{alloca.PointerRef.Identifier} = {LKeywords.Alloca} {LType.Int32Type().Parse()}, {LType.Int32Type().Parse()} 5",
                LHelper.Trim(alloca.ParseInstruction()));
        }
Example #8
0
 public void SetUp()
 {
     _alloca = new LAlloca(_function, LType.Int32Type());
 }