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

feat(plugin): expose ControlFlow to JS #563

Merged
merged 2 commits into from Dec 10, 2020

Conversation

magurotuna
Copy link
Member

@magurotuna magurotuna commented Dec 8, 2020

PoC

Let's say we have foo.js with the following content:

function f() {
  return 1;
  return "f";
}

function g() {
  throw new Error();
  return "g";
}

running cargo run --example dlint -- run foo.ts --plugin ./examples/dlint/plugins/test_plugin3.js, then we can see:

image

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@magurotuna this is great!

@@ -0,0 +1,18 @@
class ControlFlow {
static isReachable(stmt) {
const { isReachable } = Deno.core.jsonOpSync("query_control_flow_by_span", {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: can you add op_ prefix to names of ops? I find it a lot easier to search for op call sites

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I forgot that. I'll do it tomorrow (because it's late at night here :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done b6a85be

@magurotuna magurotuna marked this pull request as ready for review December 10, 2020 11:15
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, no comments

@bartlomieju bartlomieju merged commit 3cf6e77 into denoland:master Dec 10, 2020
@magurotuna magurotuna deleted the plugin-control-flow branch December 26, 2020 08: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.

None yet

2 participants