flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lance Johnson <friedfrogs...@yahoo.com.INVALID>
Subject Using ForStatementNode for AST analysis of for each statements
Date Thu, 09 May 2019 05:15:18 GMT

This email will probably contain some dumb questions buried in a jumble 
of context, but I'm potentially looking at patching Flex to fix this 
problem and would like to exhaust all /other/ possibilities before I do 
so.  The project I am working on has already snowballed into an 
avalanche, so additional complexity is something I would like to avoid.

I'm involved in a rather complicated modding project, where, due to 
licensing restrictions, we are patching commercially-licensed but 
undistributable code[1] by using the usual diff method, and then using 
Flex's generated AST to find particular sequences of statements in 
parsed code. We then patch them appropriately, and then emit the patched 
ActionScript using a custom Evaluator. The evaluator in question is 
based on PrettyPrinter, but is ending up being quite more exhaustive in 
order to present compilable code. We use this tool to collect 
information and patch repetitive statements that can be parsed with 
tools like regular expressions, but need thousands of lines of 
supporting code to properly keep track of context and syntax.

The problem I'm running into is that I'm having to run the Parser with 
`Context.scriptAssistParsing` turned on, as I need the AST with as few 
mutations as possible, and without loading includes or imports. 
Unfortunately, this has resulted into running into a problem with 
ForStatementNodes in this mode.

It appears that, while `for each` statements are parsed, there is no 
indication applied in NodeFactory to the ForStatementNode to indicate 
that the Node is a `for each` loop /in scriptAssistParsing mode/. In 
addition, if I were to turn scriptAssistParsing off, there would be 
significant mutations applied.  In NodeFactory.java, it appears like 
there were plans made to introduce a boolean (is_each?) to mark this, 
but it never materialized.

Is there another way to determine this information, or will I need to 
patch Flex itself to expose it?  If this is something that should be 
added to the upstream project, what would be the most agreeable means to 
implement it?  Right now, I simply plan on adding a public boolean 
is_each to ForStatementNode, and updating NodeFactory accordingly.

Thanks in advance,

Lance Johnson

1: The owners of the code in question have released it on GitHub, but 
the license terms forbid distribution of modified code or binaries, so 
we distribute our mod as patches, instead.  There's also talk of more 
permissive licensing in the future. Maybe.

View raw message