Change bargull-20110413-mTp by bargull@Bargull02 on 2011-04-13 17:22:51
in /home/anba/src/svn/openlaszlo/trunk
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Use new visitor classes to replace bulk if-instanceof tests
when traversing the AST
New Features: LPP-9876 (Generate utility visitor classes automatically)
(partial)
Technical Reviewer: ptw
QA Reviewer: (pending)
Overview:
instanceof tests are a sign of poor oo-design, double-dispatch should be
preferred.
Details:
SimpleNode:
#childrenAccept(ParserVisitor, Object)
- actually this method is auto-generated by JavaCC, but since we're
using our own modified version of SimpleNode it wasn't present until now
#jjtAccept(AdapterGenericParserVisitor),
childrenAccept(AdapterGenericParserVisitor)
- accept() methods for the new visitor classes, internally calling the
ParserVisitor based accept() methods
Compiler:
- use auto-generated visitor instead of hand-written visitor
NewInstanceVisitor:
- no longer needed, see above
ReferenceCollector:
#immutableProperties
- no longer used, can be removed
#pureFunctions
- changed to static, final, unmodifiable set, so the set is constructed
only once and can be shared across instances
#visitInternal()
- removed visitInternal() method and replaced with visitor based approach
#wrap()
- helper method to debug the collector, enabling better separation of
concerns
Pair class:
- JavaCC's visitor() methods only expect one data-argument, but the old
visitInternal() method used two arguments: a set for references and
another set for functions
- to make this work for the new visitor based apprach, I've added a
simple tuple class
Tests:
compile lps.jar, compile lfc
Files:
M WEB-INF/lps/server/src/org/openlaszlo/sc/ReferenceCollector.java
D WEB-INF/lps/server/src/org/openlaszlo/sc/NewInstanceVisitor.java
M WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
M WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/SimpleNode.java
Changeset:
http://svn.openlaszlo.org/openlaszlo/patches/bargull-20110413-mTp.tar