Review still very incomplete, but publishing now so we can overlap
answers with more questions.

Sorry, but I hadn't seen till now that there's a more recent patchset.
All further comments will be on that one.


http://codereview.appspot.com/8703/diff/1/15
File src/com/google/caja/opensocial/applet/example-aes.js (right):

http://codereview.appspot.com/8703/diff/1/15#newcode37
Line 37: * AES Cipher function: encrypt 'input' with Rijndael algorithm
Why is this in src/../opensocial/applet instead of third_party or
tests/../demos/benchmarks ?

http://codereview.appspot.com/8703/diff/1/11
File src/com/google/caja/opensocial/applet/example-life.js (right):

http://codereview.appspot.com/8703/diff/1/11#newcode1
Line 1: <!-- Cellular automaton gadget. This code is in the public
domain. -->
Why is this in src/../opensocial/applet instead of third_party or
tests/../demos/benchmarks ?

http://codereview.appspot.com/8703/diff/1/14
File src/com/google/caja/opensocial/applet/xmlhttp.js (right):

http://codereview.appspot.com/8703/diff/1/14#newcode17
Line 17: * An XMLHttpRequest wrapper.
Seems strange to do all this work to create a safe wrapper only for use
by the testbed. Is there any overlap with Ihab's work to create a tamed
XMLHttpRequest wrapper? Should there be?

http://codereview.appspot.com/8703/diff/1/14#newcode51
Line 51: // http://isaacschlueter.com/2006/10/msie-memory-leaks/
TODO(erights): Follow these links and learn enough about XMLHttpRequest
problems in current browsers to be able to comment. The current review
comments on this CL lack this, and so are incomplete.

http://codereview.appspot.com/8703/diff/1/14#newcode63
Line 63: // Make sure that xml http response processing does not
interleave
Omigod! Asynchronous response processing might interleave otherwise?
(Surely browser implementors would not do anything so silly? ;))

But it seems this module is only providing synchronous access. For
synchronous access, why do we want the responseClosure to run the
callback/handler asynchronously? (Or, if we do want it to run it
asyncronously, why don't we want to make an asynchronous request?)

http://codereview.appspot.com/8703/diff/1/20
File src/com/google/caja/parser/AncestorChain.java (right):

http://codereview.appspot.com/8703/diff/1/20#newcode11
Line 11: public final class AncestorChain<T extends ParseTreeNode> {
(echoing verbal conversation) As we transition to immutable ASTs, we
should be able to painlessly share subtrees. However (as you just
pointed out to me), if the same parent contains the same child in two
positions, the current AncestorChain structure becomes inadequate to
record context.

How about adding an "int index" instance variable, such that, if parent
!= null, then parent.children()[index] == node, but the former says
which appearance of node is being considered? If so, the constructor for
the parent-present case only needs (parent, index).

Many of the convenience methods below would become either unnecessary or
more trivial; as well as more accurate. For example, isFirstSibling()
becomes simply "index == 0".

http://codereview.appspot.com/8703/diff/1/20#newcode26
Line 26: public static <T extends ParseTreeNode> AncestorChain<T>
instance(T node) {
Why does this class have both public constructors and public static
factory methods that trivially wrap these constructors?

http://codereview.appspot.com/8703/diff/1/17
File
src/com/google/caja/parser/quasiliteral/opt/ArrayIndexOptimization.java
(right):

http://codereview.appspot.com/8703/diff/1/17#newcode47
Line 47: *   known to be an {...@code Array} or that all publicly visible
members of
As we've discussed verbally, this documentation is confusing. The actual
optimization does not care at all whether the object being indexed is an
array, nor does it care about any properties other than numbers and
"length" -- neither of which are specific to arrays.

http://codereview.appspot.com/8703/diff/1/17#newcode54
Line 54: *   {...@code NaN} instead of the name {...@code undefined}.  This is
documented as
Certainly it should be so documented, just as we should actually have a
cajoler spec. Perhaps future tense + TODO?

http://codereview.appspot.com/8703/diff/1/17#newcode56
Line 56: *     var o = { 0: 'a', NaN: 'b', undefined: 'c' };
Based on the code which follows, this should be "var a = ..."

http://codereview.appspot.com/8703/diff/1/17#newcode63
Line 63: *   use-before-initialization.
If this is a dynamic check, I suspect we'd lose all the gains this CL is
trying to gain. If it's a static check, it can't be accurate. If you
agree, please remove this line.

http://codereview.appspot.com/8703/diff/1/17#newcode92
Line 92: || key instanceof NumberLiteral)) {
Unindent this by one space, so that it lines up with the "(" of "(key"

http://codereview.appspot.com/8703/diff/1/17#newcode121
Line 121: static boolean doesVarReferenceArrayMember(
Again, the issue isn't "ArrayMember", but rather, does it reference
either a number, a stringified number or 'length'. All misleading
references to "Array member" and such should be replaced by an
appropriate phrase (I wish I had a short suggestion.)

If we want to generalize: Does it reference an unconditionally
whitelisted property name? (Though I still have no short suggestion.)

http://codereview.appspot.com/8703/diff/1/18
File src/com/google/caja/parser/quasiliteral/opt/OptimizationPass.java
(right):

http://codereview.appspot.com/8703/diff/1/18#newcode65
Line 65: // Find all the sites we can apply an optimization too.
"too" should be "to"

http://codereview.appspot.com/8703/diff/1/18#newcode116
Line 116: protected abstract boolean isOptimizationSemanticsPreserving(
(Echoes verbal discussion) Since an OptimizationPass describes multiple
possible optimizations that may apply to a given candidate
AncestorChain, this API for determining if a given *candidate
optimization* would apply isn't adequate, since it doesn't indicate
which possible optimization is being considered.

Something more like our normal rewriter structure may be more
appropriate: where a rewriter mostly consists of a sequence of candidate
Rule objects, each of which has an input and out quasi-string, but where
arbitrary code is associated with each individual input-output pair,
rather than with the rewriter pass as a whole.

http://codereview.appspot.com/8703/diff/1/18#newcode162
Line 162: for (Pair<String, String> optimization : optimizations) {
From this loop, I'd guess that the answer to my question on
OptimizationPassTest is that only the first applicable match is applied
to the input AST, independent of whether either 1) the input matched
other rules as well or 2) the output matches any rules. I think property
#1 is desirable. #2 may not be, in order to combine optimizations, but
this probably doesn't yet matter.

http://codereview.appspot.com/8703/diff/1/16
File src/com/google/caja/parser/quasiliteral/opt/ScopeTree.java (right):

http://codereview.appspot.com/8703/diff/1/16#newcode37
Line 37: private final AncestorChain<?> root;
Since we have a constructor which has parameters for initializing these
first three instance the order of instance variable decls should agree
with the constructor parameter order.

http://codereview.appspot.com/8703/diff/1/16#newcode112
Line 112: for (ScopeTree t : children) {
If this loop fails to find a match, this code will fall through to
"return this;". But musn't it find a match? If it doesn't find a match,
isn't that an internal error -- most probably a precondition violation?

http://codereview.appspot.com/8703/diff/1/16#newcode120
Line 120: return Collections.unmodifiableList(children);
Why not do "children = Collections.unmodifiableList(children);" at the
end of the constructor, in which case this can simply "return
children;"?

http://codereview.appspot.com/8703/diff/1/7
File
tests/com/google/caja/parser/quasiliteral/opt/OptimizationPassTest.java
(right):

http://codereview.appspot.com/8703/diff/1/7#newcode32
Line 32: public void testMultipleOptimizations() throws Exception {
Two untested cases where the the OptimizationPass spec is unclear:
* What if the .a portion of multiple rules match a given specimen AST
node?
* What if the result of transforming with one rule matches the .a of
another rule?

http://codereview.appspot.com/8703

Reply via email to