Exemplo n.º 1
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     WriteILRange(output, options);
     output.Write(OpCode);
     output.Write(' ');
     output.WriteLocalReference(TargetLabel, (object)targetBlock ?? TargetILOffset);
 }
Exemplo n.º 2
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     WriteILRange(output, options);
     output.Write("deconstruct ");
     output.MarkFoldStart("{...}");
     output.WriteLine("{");
     output.Indent();
     output.WriteLine("init:");
     output.Indent();
     foreach (var inst in this.Init)
     {
         inst.WriteTo(output, options);
         output.WriteLine();
     }
     output.Unindent();
     output.WriteLine("pattern:");
     output.Indent();
     pattern.WriteTo(output, options);
     output.Unindent();
     output.WriteLine();
     output.Write("conversions: ");
     conversions.WriteTo(output, options);
     output.WriteLine();
     output.Write("assignments: ");
     assignments.WriteTo(output, options);
     output.Unindent();
     output.WriteLine();
     output.Write('}');
     output.MarkFoldEnd();
 }
Exemplo n.º 3
0
        public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
        {
            ILRange.WriteTo(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('(');
            int firstIndex = (OpCode != OpCode.NewObj && !Method.IsStatic) ? -1 : 0;

            for (int i = 0; i < Arguments.Count; i++)
            {
                if (i > 0)
                {
                    output.Write(", ");
                }
                if (ArgumentToParameterMap[i] != firstIndex + i)
                {
                    output.Write($"{ArgumentToParameterMap[i]}: ");
                }
                Arguments[i].WriteTo(output, options);
            }
            output.Write(')');
        }
Exemplo n.º 4
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     output.Write(".try ");
     TryBlock.WriteTo(output, options);
     output.Write(" fault ");
     faultBlock.WriteTo(output, options);
 }
Exemplo n.º 5
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     output.WriteDefinition("BlockContainer", this);
     output.Write(' ');
     output.MarkFoldStart("{...}");
     output.WriteLine("{");
     output.Indent();
     foreach (var inst in Blocks)
     {
         if (inst.Parent == this)
         {
             inst.WriteTo(output, options);
         }
         else
         {
             output.Write("stale reference to ");
             output.WriteReference(inst.Label, inst, isLocal: true);
         }
         output.WriteLine();
         output.WriteLine();
     }
     output.Unindent();
     output.Write("}");
     output.MarkFoldEnd();
 }
Exemplo n.º 6
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     WriteILRange(output, options);
     if (ConstrainedTo != null)
     {
         output.Write("constrained[");
         ConstrainedTo.WriteTo(output);
         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(')');
 }
Exemplo n.º 7
0
 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);
     }
 }
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     WriteILRange(output, options);
     output.Write(OpCode);
     output.Write("." + BinaryNumericInstruction.GetOperatorName(Operator));
     if (CheckForOverflow)
     {
         output.Write(".ovf");
     }
     if (Sign == Sign.Unsigned)
     {
         output.Write(".unsigned");
     }
     else if (Sign == Sign.Signed)
     {
         output.Write(".signed");
     }
     output.Write('.');
     output.Write(UnderlyingResultType.ToString().ToLowerInvariant());
     if (IsLifted)
     {
         output.Write(".lifted");
     }
     base.WriteSuffix(output);
     output.Write('(');
     Target.WriteTo(output, options);
     output.Write(", ");
     Value.WriteTo(output, options);
     output.Write(')');
 }
Exemplo n.º 9
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     ILRange.WriteTo(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(')');
 }
Exemplo n.º 10
0
        public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
        {
            WriteILRange(output, options);
            output.Write("call.indirect ");
            ReturnType.WriteTo(output);
            output.Write('(');
            bool first         = true;
            int  firstArgument = IsInstance ? 1 : 0;

            if (firstArgument == 1)
            {
                Arguments[0].WriteTo(output, options);
                first = false;
            }
            foreach (var(inst, type) in Arguments.Skip(firstArgument).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(')');
        }
Exemplo n.º 11
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     ILRange.WriteTo(output, options);
     output.Write("Block ");
     output.WriteDefinition(Label, this);
     if (Parent is BlockContainer)
     {
         output.Write(" (incoming: {0})", IncomingEdgeCount);
     }
     output.Write(' ');
     output.MarkFoldStart("{...}");
     output.WriteLine("{");
     output.Indent();
     foreach (var inst in Instructions)
     {
         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();
 }
Exemplo n.º 12
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     WriteILRange(output, options);
     output.Write(".try ");
     TryBlock.WriteTo(output, options);
     output.Write(" finally ");
     finallyBlock.WriteTo(output, options);
 }
Exemplo n.º 13
0
        public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
        {
            output.Write("case ");
            output.Write(Labels.ToString());
            output.Write(": ");

            body.WriteTo(output, options);
        }
Exemplo n.º 14
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     output.Write("nullable.unwrap ");
     output.Write(ResultType);
     output.Write('(');
     Argument.WriteTo(output, options);
     output.Write(')');
 }
Exemplo n.º 15
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     output.Write(OpCode);
     output.Write("(");
     valueInst.WriteTo(output, options);
     output.Write(", ");
     fallbackInst.WriteTo(output, options);
     output.Write(")");
 }
Exemplo n.º 16
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     output.Write(OpCode);
     output.Write('.');
     output.Write(resultType);
     output.Write('(');
     this.array.WriteTo(output, options);
     output.Write(')');
 }
Exemplo n.º 17
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     WriteILRange(output, options);
     output.Write(OpCode);
     output.Write(' ');
     output.Write(Index.ToString());
     output.Write('(');
     this.Argument.WriteTo(output, options);
     output.Write(')');
 }
Exemplo n.º 18
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     output.Write(".try ");
     TryBlock.WriteTo(output, options);
     foreach (var handler in Handlers)
     {
         output.Write(' ');
         handler.WriteTo(output, options);
     }
 }
Exemplo n.º 19
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);
     base.WriteSuffix(output);
     output.Write(' ');
     DynamicInstruction.WriteArgumentList(output, options, (Target, TargetArgumentInfo), (Value, ValueArgumentInfo));
 }
Exemplo n.º 20
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     output.Write("lock (");
     OnExpression.WriteTo(output, options);
     output.WriteLine(") {");
     output.Indent();
     Body.WriteTo(output, options);
     output.Unindent();
     output.WriteLine();
     output.Write("}");
 }
Exemplo n.º 21
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     output.Write(OpCode);
     if (IsLifted)
     {
         output.Write(".lifted");
     }
     output.Write('(');
     this.Argument.WriteTo(output, options);
     output.Write(')');
 }
Exemplo n.º 22
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     output.Write(OpCode);
     if (targetContainer != null)
     {
         output.Write(' ');
         output.WriteReference(TargetLabel, targetContainer, isLocal: true);
         output.Write(" (");
         value.WriteTo(output, options);
         output.Write(')');
     }
 }
Exemplo n.º 23
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     output.Write("using (");
     Variable.WriteTo(output);
     output.Write(" = ");
     ResourceExpression.WriteTo(output, options);
     output.WriteLine(") {");
     output.Indent();
     Body.WriteTo(output, options);
     output.Unindent();
     output.WriteLine();
     output.Write("}");
 }
Exemplo n.º 24
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     WriteILRange(output, options);
     output.Write(OpCode);
     base.WriteSuffix(output);
     output.Write(' ');
     Method.WriteTo(output);
     output.Write('(');
     this.Target.WriteTo(output, options);
     output.Write(", ");
     this.Value.WriteTo(output, options);
     output.Write(')');
 }
Exemplo n.º 25
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     ILRange.WriteTo(output, options);
     output.Write(OpCode);
     if (IsChecked)
     {
         output.Write(".checked");
     }
     output.Write(' ');
     type.WriteTo(output);
     output.Write('(');
     Argument.WriteTo(output, options);
     output.Write(')');
 }
Exemplo n.º 26
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     output.Write("catch ");
     if (variable != null)
     {
         output.WriteDefinition(variable.Name, variable);
         output.Write(" : ");
         Disassembler.DisassemblerHelpers.WriteOperand(output, variable.Type);
     }
     output.Write(" when (");
     filter.WriteTo(output, options);
     output.Write(')');
     output.Write(' ');
     body.WriteTo(output, options);
 }
Exemplo n.º 27
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     ILRange.WriteTo(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));
 }
Exemplo n.º 28
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     ILRange.WriteTo(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(')');
 }
Exemplo n.º 29
0
 public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
 {
     output.Write("switch (");
     value.WriteTo(output, options);
     output.Write(") ");
     output.MarkFoldStart("{...}");
     output.WriteLine("{");
     output.Indent();
     output.Write("default: ");
     defaultBody.WriteTo(output, options);
     output.WriteLine();
     foreach (var section in this.Sections)
     {
         section.WriteTo(output, options);
         output.WriteLine();
     }
     output.Unindent();
     output.Write('}');
     output.MarkFoldEnd();
 }
Exemplo n.º 30
0
        public override void WriteTo(ITextOutput output, ILAstWritingOptions options)
        {
            ILRange.WriteTo(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(')');
        }