Exemple #1
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     WriteILRange(output, options);
     if (ConstrainedTo != null)
     {
         output.Write("constrained[");
         ConstrainedTo.WriteTo(output, ILNameSyntax.ShortTypeName);
         output.Write("].");
     }
     if (IsTail)
     {
         output.Write("tail.");
     }
     output.Write(OpCode);
     output.Write(' ');
     Method.WriteTo(output);
     output.Write('(');
     for (int i = 0; i < Arguments.Count; i++)
     {
         if (i > 0)
         {
             output.Write(", ");
         }
         Arguments[i].WriteTo(output, options);
     }
     output.Write(')');
 }
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     WriteILRange(output, options);
     if (options.UseLogicOperationSugar)
     {
         if (MatchLogicAnd(out var lhs, out var rhs))
         {
             output.Write("logic.and(");
             lhs.WriteTo(output, options);
             output.Write(", ");
             rhs.WriteTo(output, options);
             output.Write(')');
             return;
         }
         if (MatchLogicOr(out lhs, out rhs))
         {
             output.Write("logic.or(");
             lhs.WriteTo(output, options);
             output.Write(", ");
             rhs.WriteTo(output, options);
             output.Write(')');
             return;
         }
     }
     output.Write(OpCode);
     output.Write(" (");
     condition.WriteTo(output, options);
     output.Write(") ");
     trueInst.WriteTo(output, options);
     if (falseInst.OpCode != OpCode.Nop)
     {
         output.Write(" else ");
         falseInst.WriteTo(output, options);
     }
 }
Exemple #3
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     WriteILRange(output, options);
     output.Write(OpCode);
     output.Write("." + BinaryNumericInstruction.GetOperatorName(Operator));
     if (CompoundAssignmentType == CompoundAssignmentType.EvaluatesToNewValue)
     {
         output.Write(".new");
     }
     else
     {
         output.Write(".old");
     }
     if (CheckForOverflow)
     {
         output.Write(".ovf");
     }
     if (Sign == Sign.Unsigned)
     {
         output.Write(".unsigned");
     }
     else if (Sign == Sign.Signed)
     {
         output.Write(".signed");
     }
     output.Write('(');
     Target.WriteTo(output, options);
     output.Write(", ");
     Value.WriteTo(output, options);
     output.Write(')');
 }
Exemple #4
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     WriteILRange(output, options);
     output.Write(OpCode);
     output.Write(' ');
     output.WriteLocalReference(TargetLabel, (object)targetBlock ?? TargetILOffset);
 }
Exemple #5
0
        public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
        {
            WriteILRange(output, options);
            output.Write("call.indirect ");
            ReturnType.WriteTo(output);
            output.Write('(');
            bool first = true;

            foreach (var(inst, type) in Arguments.Zip(ParameterTypes, (a, b) => (a, b)))
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    output.Write(", ");
                }
                inst.WriteTo(output, options);
                output.Write(" : ");
                type.WriteTo(output);
            }
            if (Arguments.Count > 0)
            {
                output.Write(", ");
            }
            functionPointer.WriteTo(output, options);
            output.Write(')');
        }
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     WriteILRange(output, options);
     output.Write(".try ");
     TryBlock.WriteTo(output, options);
     output.Write(" fault ");
     faultBlock.WriteTo(output, options);
 }
Exemple #7
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     WriteILRange(output, options);
     output.Write(OpCode);
     output.Write('.');
     output.Write(resultType);
     output.Write('(');
     this.array.WriteTo(output, options);
     output.Write(')');
 }
Exemple #8
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     WriteILRange(output, options);
     output.Write(OpCode);
     output.Write("(");
     valueInst.WriteTo(output, options);
     output.Write(", ");
     fallbackInst.WriteTo(output, options);
     output.Write(")");
 }
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     WriteILRange(output, options);
     output.Write(".try ");
     TryBlock.WriteTo(output, options);
     foreach (var handler in Handlers)
     {
         output.Write(' ');
         handler.WriteTo(output, options);
     }
 }
Exemple #10
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     WriteILRange(output, options);
     output.Write(OpCode);
     if (IsLifted)
     {
         output.Write(".lifted");
     }
     output.Write('(');
     this.Argument.WriteTo(output, options);
     output.Write(')');
 }
Exemple #11
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     WriteILRange(output, options);
     output.Write("lock (");
     OnExpression.WriteTo(output, options);
     output.WriteLine(") {");
     output.Indent();
     Body.WriteTo(output, options);
     output.Unindent();
     output.WriteLine();
     output.Write("}");
 }
Exemple #12
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     WriteILRange(output, options);
     output.Write(OpCode);
     if (targetContainer != null)
     {
         output.Write(' ');
         output.WriteLocalReference(TargetLabel, targetContainer);
         output.Write(" (");
         value.WriteTo(output, options);
         output.Write(')');
     }
 }
Exemple #13
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     WriteILRange(output, options);
     output.Write(OpCode);
     if (IsChecked)
     {
         output.Write(".checked");
     }
     output.Write(' ');
     type.WriteTo(output);
     output.Write('(');
     Argument.WriteTo(output, options);
     output.Write(')');
 }
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     WriteILRange(output, options);
     output.Write("catch ");
     if (variable != null)
     {
         output.WriteLocalReference(variable.Name, variable, isDefinition: true);
         output.Write(" : ");
         Disassembler.DisassemblerHelpers.WriteOperand(output, variable.Type);
     }
     output.Write(" when (");
     filter.WriteTo(output, options);
     output.Write(')');
     output.Write(' ');
     body.WriteTo(output, options);
 }
Exemple #15
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     WriteILRange(output, options);
     output.Write(OpCode);
     output.Write("." + Operation.ToString().ToLower());
     DynamicInstruction.WriteBinderFlags(BinderFlags, output, options);
     if (CompoundAssignmentType == CompoundAssignmentType.EvaluatesToNewValue)
     {
         output.Write(".new");
     }
     else
     {
         output.Write(".old");
     }
     output.Write(' ');
     DynamicInstruction.WriteArgumentList(output, options, (Target, TargetArgumentInfo), (Value, ValueArgumentInfo));
 }
Exemple #16
0
        public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
        {
            WriteILRange(output, options);
            if (options.UseLogicOperationSugar && MatchLogicNot(out var arg))
            {
                output.Write("logic.not(");
                arg.WriteTo(output, options);
                output.Write(')');
                return;
            }
            output.Write(OpCode);
            output.Write('.');
            output.Write(InputType.ToString().ToLower());
            switch (Sign)
            {
            case Sign.Signed:
                output.Write(".signed");
                break;

            case Sign.Unsigned:
                output.Write(".unsigned");
                break;
            }
            switch (LiftingKind)
            {
            case ComparisonLiftingKind.CSharp:
                output.Write(".lifted[C#]");
                break;

            case ComparisonLiftingKind.ThreeValuedLogic:
                output.Write(".lifted[3VL]");
                break;
            }
            output.Write('(');
            Left.WriteTo(output, options);
            output.Write(' ');
            output.Write(Kind.GetToken());
            output.Write(' ');
            Right.WriteTo(output, options);
            output.Write(')');
        }
Exemple #17
0
        public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
        {
            WriteILRange(output, options);
            output.Write(OpCode);

            if (CompoundAssignmentType == CompoundAssignmentType.EvaluatesToNewValue)
            {
                output.Write(".new");
            }
            else
            {
                output.Write(".old");
            }
            output.Write(' ');
            Method.WriteTo(output);
            output.Write('(');
            this.Target.WriteTo(output, options);
            output.Write(", ");
            this.Value.WriteTo(output, options);
            output.Write(')');
        }
Exemple #18
0
        public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
        {
            WriteILRange(output, options);
            output.WriteLocalReference("case", this, isDefinition: true);
            output.Write(' ');
            if (HasNullLabel)
            {
                output.Write("null");
                if (!Labels.IsEmpty)
                {
                    output.Write(", ");
                    output.Write(Labels.ToString());
                }
            }
            else
            {
                output.Write(Labels.ToString());
            }
            output.Write(": ");

            body.WriteTo(output, options);
        }
Exemple #19
0
        public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
        {
            WriteILRange(output, options);
            output.Write("Block ");
            output.WriteLocalReference(Label, this, isDefinition: true);
            if (Kind != BlockKind.ControlFlow)
            {
                output.Write($" ({Kind})");
            }
            if (Parent is BlockContainer)
            {
                output.Write(" (incoming: {0})", IncomingEdgeCount);
            }
            output.Write(' ');
            output.MarkFoldStart("{...}");
            output.WriteLine("{");
            output.Indent();
            int index = 0;

            foreach (var inst in Instructions)
            {
                if (options.ShowChildIndexInBlock)
                {
                    output.Write("[" + index + "] ");
                    index++;
                }
                inst.WriteTo(output, options);
                output.WriteLine();
            }
            if (finalInstruction.OpCode != OpCode.Nop)
            {
                output.Write("final: ");
                finalInstruction.WriteTo(output, options);
                output.WriteLine();
            }
            output.Unindent();
            output.Write("}");
            output.MarkFoldEnd();
        }
Exemple #20
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     WriteILRange(output, options);
     output.Write("switch");
     if (IsLifted)
     {
         output.Write(".lifted");
     }
     output.Write(" (");
     value.WriteTo(output, options);
     output.Write(") ");
     output.MarkFoldStart("{...}");
     output.WriteLine("{");
     output.Indent();
     foreach (var section in this.Sections)
     {
         section.WriteTo(output, options);
         output.WriteLine();
     }
     output.Unindent();
     output.Write('}');
     output.MarkFoldEnd();
 }
 /// <summary>
 /// Writes the ILAst to the text output.
 /// </summary>
 public abstract void WriteTo(ITextOutput output, ILAstWritingOptions options);
 public void WriteILRange(ITextOutput output, ILAstWritingOptions options)
 {
     ILRange.WriteTo(output, options);
 }
 internal static void WriteArgumentList(ITextOutput output, ILAstWritingOptions options, params (ILInstruction, CSharpArgumentInfo)[] arguments)
 protected void WriteBinderFlags(ITextOutput output, ILAstWritingOptions options)
 {
     WriteBinderFlags(BinderFlags, output, options);
 }
Exemple #25
0
        public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
        {
            WriteILRange(output, options);
            output.Write(OpCode);
            if (Method != null)
            {
                output.Write(' ');
                Method.WriteTo(output);
            }
            if (IsExpressionTree)
            {
                output.Write(".ET");
            }
            if (DelegateType != null)
            {
                output.Write("[");
                DelegateType.WriteTo(output);
                output.Write("]");
            }
            output.WriteLine(" {");
            output.Indent();

            if (IsAsync)
            {
                output.WriteLine(".async");
            }
            if (IsIterator)
            {
                output.WriteLine(".iterator");
            }

            output.MarkFoldStart(Variables.Count + " variable(s)", true);
            foreach (var variable in Variables)
            {
                variable.WriteDefinitionTo(output);
                output.WriteLine();
            }
            output.MarkFoldEnd();
            output.WriteLine();

            foreach (string warning in Warnings)
            {
                output.WriteLine("//" + warning);
            }

            body.WriteTo(output, options);
            output.WriteLine();

            if (options.ShowILRanges)
            {
                var unusedILRanges = FindUnusedILRanges();
                if (!unusedILRanges.IsEmpty)
                {
                    output.Write("// Unused IL Ranges: ");
                    output.Write(string.Join(", ", unusedILRanges.Intervals.Select(
                                                 range => $"[{range.Start:x4}..{range.InclusiveEnd:x4}]")));
                    output.WriteLine();
                }
            }

            output.Unindent();
            output.WriteLine("}");
        }
 internal static void WriteBinderFlags(CSharpBinderFlags flags, ITextOutput output, ILAstWritingOptions options)
 {
     if ((flags & CSharpBinderFlags.BinaryOperationLogical) != 0)
     {
         output.Write(".logic");
     }
     if ((flags & CSharpBinderFlags.CheckedContext) != 0)
     {
         output.Write(".checked");
     }
     if ((flags & CSharpBinderFlags.ConvertArrayIndex) != 0)
     {
         output.Write(".arrayindex");
     }
     if ((flags & CSharpBinderFlags.ConvertExplicit) != 0)
     {
         output.Write(".explicit");
     }
     if ((flags & CSharpBinderFlags.InvokeSimpleName) != 0)
     {
         output.Write(".invokesimple");
     }
     if ((flags & CSharpBinderFlags.InvokeSpecialName) != 0)
     {
         output.Write(".invokespecial");
     }
     if ((flags & CSharpBinderFlags.ResultDiscarded) != 0)
     {
         output.Write(".discard");
     }
     if ((flags & CSharpBinderFlags.ResultIndexed) != 0)
     {
         output.Write(".resultindexed");
     }
     if ((flags & CSharpBinderFlags.ValueFromCompoundAssignment) != 0)
     {
         output.Write(".compound");
     }
 }