예제 #1
0
        public void Switch_Unconditional_ParseCheck()
        {
            LValueRef  valueRef     = new LValueRef(LType.Int32Type(), "%1");
            LLabelType defaultLabel = new LLabelType("%default");
            LSwitch    @switch      = new LSwitch(valueRef, defaultLabel);

            Assert.AreEqual("switch i32 %1, label %default [ ]",
                            LHelper.Trim(@switch.ParseInstruction()));
        }
예제 #2
0
        public LConditionalBr(LValueRef condition, LLabelType ifTrueLabel, LLabelType ifFalseLabel)
        {
            if (!condition.Type.IsPrimitiveType() || condition.Type.CheckedCast <LPrimitiveType>().Type != LPrimitiveTypes.@bool)
            {
                throw new Exception("Condition must be from type i1. Actual type: " + condition.ParseType());
            }

            Condition    = condition;
            IfTrueLabel  = ifTrueLabel;
            IfFalseLabel = ifFalseLabel;
        }
예제 #3
0
        public void AdvancedLabel_RegisterInstructionByLabelTest_LabelNotFound_Exception()
        {
            var func   = LFunction.Create("foo_function", new LValueRef(LType.Int32Type(), ""));
            var label1 = func.Register(new LLabelType("entry"));
            var label2 = new LLabelType("label2");

            Assert.Throws <Exception>(() => {
                var alloca     = func.Register(new LAlloca(func, LType.F32Type()));
                var pointerRef = alloca.PointerRef;
                var load       = func.Register(label2, new LLoad(func, pointerRef));
            });
        }
예제 #4
0
        public void Switch_ParseCheck()
        {
            LValueRef  valueRef     = new LValueRef(LType.Int32Type(), "%1");
            LLabelType defaultLabel = new LLabelType("%default");
            LSwitch    @switch      = new LSwitch(valueRef, defaultLabel);

            @switch.JumpTableDestinations.Add((0, new LLabelType("%one")));
            @switch.JumpTableDestinations.Add((1, new LLabelType("%two")));
            @switch.JumpTableDestinations.Add((2, new LLabelType("%three")));
            @switch.JumpTableDestinations.Add((3, new LLabelType("%four")));

            Assert.AreEqual($"switch i32 %1, label %default [ i32 0, label %one{Environment.NewLine}i32 1, label %two{Environment.NewLine}i32 2, label %three{Environment.NewLine}i32 3, label %four ]",
                            LHelper.Trim(@switch.ParseInstruction()));
        }
예제 #5
0
 public LUnconditionalBr(LLabelType destinationLabel)
 {
     DestinationLabel = destinationLabel;
 }
예제 #6
0
 internal LLabelEntry(LLabelType label)
 {
     Label = label;
 }