← 输入框|github.com|刷新
Skip to content

ILCursor.Emit(OpCode, Instruction) and ILCursor.Emit(OpCode, Instruction[]) should emit ILLabels #239

Open

Description

@Hamunii

Description

ILCursor.Emit(OpCode, Instruction) and ILCursor.Emit(OpCode, Instruction[]) methods don't turn instructions into ILLabels or ILLabel[]s, but the match branch extension methods expect ILLabels or ILLabel[]s, such as x.MatchBr.

Example

This fails the match:

ILCursor c = new(il);
c.Emit(OpCodes.Br, c.Next!);
c.Goto(0);
c.GotoNext(x => x.MatchBr(out _));

This match succeeds:

ILCursor c = new(il);
c.Emit(OpCodes.Br, il.DefineLabel(c.Next!));
c.Goto(0);
c.GotoNext(x => x.MatchBr(out _));

The ILLabel conversion is already done for the source generated emit methods so this works (for other than this issue: #237):

ILCursor c = new(il);
c.EmitBr(c.Next!);
c.Goto(0);
c.GotoNext(x => x.MatchBr(out _));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions