Example #1
0
 public void Visit(Int32ConstantEntry entry)
 {
     _sb.AppendLine($"t{entry.TreeID,-3} = intconst {entry.Value}");
 }
 public void Visit(Int32ConstantEntry entry)
 {
     _genericStackEntryVisitor.Visit <Int32ConstantEntry>(entry);
 }
Example #3
0
        public void Import(Instruction instruction, ImportContext context, IILImporterProxy importer)
        {
            var code = instruction.OpCode.Code;

            switch (code)
            {
            case Code.Br_S:
            case Code.Blt_S:
            case Code.Bgt_S:
            case Code.Ble_S:
            case Code.Bge_S:
            case Code.Beq_S:
            case Code.Bne_Un_S:
            case Code.Brfalse_S:
            case Code.Brtrue_S:
                code += (Code.Br - Code.Br_S);
                break;
            }
            var target = instruction.OperandAs <Instruction>();

            var targetBlock      = importer.BasicBlocks[(int)target.Offset];
            var fallthroughBlock = (code != Code.Br) ? context.FallThroughBlock : null;

            if (code != Code.Br)
            {
                var op2 = importer.PopExpression();
                if (op2.Kind != StackValueKind.Int32 && op2.Kind != StackValueKind.NativeInt)
                {
                    throw new NotSupportedException("Boolean comparisons only supported using int and nativeint as underlying type");
                }

                StackEntry op1;
                Operation  op;
                if (code != Code.Brfalse && code != Code.Brtrue)
                {
                    op1 = importer.PopExpression();
                    op  = Operation.Eq + (code - Code.Beq);

                    // If one of the values is a native int then cast the other to be native int too
                    if (op1.Kind == StackValueKind.NativeInt && op2.Kind == StackValueKind.Int32)
                    {
                        op2 = new CastEntry(Common.TypeSystem.WellKnownType.Object, op2, op1.Kind);
                    }
                    else if (op1.Kind == StackValueKind.Int32 && op2.Kind == StackValueKind.NativeInt)
                    {
                        op1 = new CastEntry(Common.TypeSystem.WellKnownType.Object, op1, op2.Kind);
                    }
                }
                else
                {
                    op1 = new Int32ConstantEntry(0);
                    op  = (code == Code.Brfalse) ? Operation.Eq : Operation.Ne;
                }
                op1 = new BinaryOperator(op, isComparison: true, op1, op2, op1.Kind);
                importer.ImportAppendTree(new JumpTrueEntry(targetBlock.Label, op1));
            }
            else
            {
                importer.ImportAppendTree(new JumpEntry(targetBlock.Label));
            }

            // Fall through handling
            importer.ImportFallThrough(targetBlock);

            if (fallthroughBlock != null)
            {
                importer.ImportFallThrough(fallthroughBlock);
            }

            context.StopImporting = true;
        }
Example #4
0
 public void Visit(Int32ConstantEntry entry)
 {
     SetNext(entry);
 }
Example #5
0
 public void Visit(Int32ConstantEntry entry)
 {
     Print($"CNS_INT {entry.Value}");
 }