-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Auto Charter.linq | ||
Spritesheet Cutter.linq | ||
Loan Balance Calculator.linq | ||
Loan Balance Calculator.linq | ||
OpCode Browser.linq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<Query Kind="Program"> | ||
<Reference Relative="..\..\..\..\Source\Repos\linqpad-dump-editable\src\DumpEditable\bin\Debug\net47\LINQPad.DumpEditable.dll">C:\Users\rdavis\Source\Repos\linqpad-dump-editable\src\DumpEditable\bin\Debug\net47\LINQPad.DumpEditable.dll</Reference> | ||
<Namespace>LINQPad.DumpEditable</Namespace> | ||
<Namespace>System.Reflection.Emit</Namespace> | ||
</Query> | ||
|
||
void Main() | ||
{ | ||
EditableDumpContainer.DefaultOptions.StringBasedEditor = | ||
Editors.TextBoxBasedStringEditor(liveUpdates: true); | ||
|
||
var filter = new OpCodeFilter().DumpEditable(out var editor); | ||
var opcodes = new DumpContainer().Dump(); | ||
var selectedOpcode = new DumpContainer() { DumpDepth = 2 }.Dump(); | ||
|
||
var filteredOpcodes = | ||
AllOpCodes | ||
.Where(filter.Matches) | ||
.Select(o => new Hyperlinq(() => selectedOpcode.Content = o, o.Name)); | ||
|
||
editor.OnChanged += () => opcodes.Content = Util.HorizontalRun(true, filteredOpcodes); | ||
editor.OnChanged(); | ||
} | ||
|
||
public IEnumerable<OpCode> AllOpCodes | ||
=> typeof(OpCodes) | ||
.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.Default) | ||
.Select(f => (OpCode) f.GetValue(null)); | ||
|
||
public class OpCodeFilter | ||
{ | ||
public string Name { get; set; } | ||
public OpCodeType? OpCodeType { get; set; } | ||
public FlowControl? FlowControl { get; set; } | ||
public OperandType? OperandType{ get; set; } | ||
|
||
public bool Matches(OpCode o) | ||
=> (String.IsNullOrWhiteSpace(Name) || o.Name.ToLower().Contains(Name.ToLower())) | ||
&& (OpCodeType is null || o.OpCodeType == OpCodeType) | ||
&& (FlowControl is null || o.FlowControl == FlowControl) | ||
&& (OperandType is null || o.OperandType == OperandType); | ||
} |