Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Methods for getting indices and making loads and stores #500

Merged
merged 3 commits into from
Oct 4, 2022
Merged

Methods for getting indices and making loads and stores #500

merged 3 commits into from
Oct 4, 2022

Conversation

LoganDark
Copy link
Contributor

Adds these extension methods on CodeInstruction:

  • LocalIndex, which returns the operand of any ldloc/ldloca/stloc, even the short forms or the fixed forms (i.e. ldloc.s or ldloc.1)

  • ArgIndex, which does the same but for ldarg/ldarga/starg

Adds these static helper methods to CodeInstruction:

  • LoadLocal, which allows you to produce an optimal load from an index, optionally loading the address

  • StoreLocal, which allows you to produce an optional store to an index

  • LoadArg, which allows you to produce an optimal load from an argument, optionally loading the address

  • StoreArg, which allows you to produce an optimal store to an argument

All of the methods are annotated with doc comments and include links to their counterparts via <seealso> references.

Please let me know if I got the names, documentation, or code style (I'm used to OTB) incorrect.

Adds these extension methods on CodeInstruction:

- LocalIndex, which returns the operand of any ldloc/ldloca/stloc, even
  the short forms or the fixed forms (i.e. ldloc.s or ldloc.1)

- ArgIndex, which does the same but for ldarg/ldarga/starg

Adds these static helper methods to CodeInstruction:

- LoadLocal, which allows you to produce an optimal load from an index,
  optionally loading the address

- StoreLocal, which allows you to produce an optional store to an index

- LoadArg, which allows you to produce an optimal load from an argument,
  optionally loading the address

- StoreArg, which allows you to produce an optimal store to an argument

All of the methods are annotated with doc comments and include links to
their counterparts via `<seealso>` references.
@LoganDark
Copy link
Contributor Author

LoganDark commented Oct 3, 2022

Marking as draft since I forgot to look into CodeMatch stuff

@LoganDark LoganDark marked this pull request as draft October 3, 2022 17:58
@LoganDark LoganDark marked this pull request as ready for review October 3, 2022 18:28
Harmony/Tools/CodeMatch.cs Outdated Show resolved Hide resolved
Harmony/Tools/CodeMatch.cs Outdated Show resolved Hide resolved
Harmony/Tools/CodeMatch.cs Outdated Show resolved Hide resolved
Harmony/Tools/CodeMatch.cs Outdated Show resolved Hide resolved
This adds four new static methods to CodeMatch:

- LoadsLocal which matches any local load (ldloc family)
- StoresLocal which matches any local store (stloc family)
- LoadsArgument which matches any argument load (ldarg family)
- StoresArgument which matches any argument store (starg family)

Matching specific indices can be done with the predicate and checking
the instruction LocalIndex or ArgIndex
@LoganDark LoganDark requested a review from pardeike October 3, 2022 18:49
@pardeike
Copy link
Owner

pardeike commented Oct 3, 2022

Almost done. Just the last rename. Code quality is great.

@LoganDark
Copy link
Contributor Author

Almost done. Just the last rename. Code quality is great.

What do you mean the last rename? I don't see any comments that I didn't address with my force-push. :)

@pardeike
Copy link
Owner

pardeike commented Oct 4, 2022

Extensions.cs:505

@LoganDark
Copy link
Contributor Author

Extensions.cs:505

There's no comment there. What did you want it changed to? ArgumentIndex?

I'm having trouble getting feedback on this one but I think this is
what we want?
@pardeike
Copy link
Owner

pardeike commented Oct 4, 2022 via email

@LoganDark
Copy link
Contributor Author

Yeah, as you see in my screenshot it shows Pending for me.

I can't actually see your screenshot (uh, did you post it somewhere?) but it says pending review because I re-requested after addressing your comments.

(If you sent a screenshot over email as an attachment, GitHub didn't put it in your comment.)

Does this look good to merge now?

@pardeike pardeike merged commit 5f76f1c into pardeike:master Oct 4, 2022
@LoganDark LoganDark deleted the local-index branch October 4, 2022 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants