how to run the Dataflow analysis in closure-compile?

45 views
Skip to first unread message

wolf not

unread,
Dec 26, 2024, 12:59:11 PM12/26/24
to Closure Compiler Discuss
recently ,i am learning using closure-compiler.i looked up the docs of https://github.com/google/closure-compiler/wiki/Writing-Compiler-Pass.I get that write a simple pass ,and compile it using this command:
bazelisk build //:compiler_uberjar_deploy.jar .
then i using the command:
java -jar bazel-bin/compiler_unshaded_deploy.jar --js="./filename".
after this,it will parse my js file and run the pass i write.But another question strike me after i see the  DataFlowAnalysis.java. I review this code, i guess that it is a dataflow analysis framework, then i also found the MustBeReachingVariableDef.java which using the data framework.after i understand the code ,i hava no way to run it ,like the case that  i write the simpile pass.so i post my question here.

how to run the MustBeReachingVariableDef.java to perform the dataflow analysis? is it same as i write simple pass and need me to modify the compile option to run this code ? because i  did not find the entry:main function .

Bradford Smith

unread,
Dec 27, 2024, 1:09:59 PM12/27/24
to Closure Compiler Discuss
The `MustBeReachingVariableDef` class is not intended to be executed as a standalone program.

It is intended to be used for analyzing part of an AST (Abstract Syntax Tree) during a compiler pass in order to gather information needed to perform optimizations.
You can learn more by examining how `FlowSensitiveInlineVariables` uses it.

I hope that helps.

Bradford

wolf not

unread,
Jan 2, 2025, 11:51:32 AMJan 2
to Closure Compiler Discuss
thx,what you reply really does me a big favor!
Reply all
Reply to author
Forward
0 new messages