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
On 2008/12/20 00:22:30, MarkM wrote:
Why is this in src/../opensocial/applet instead of third_party or
tests/../demos/benchmarks ?
So that it can be loaded by the testbed.
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.
On 2008/12/20 00:22:30, MarkM wrote:
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?
This is used by the container, so shouldn't be tamed.
http://codereview.appspot.com/8703/diff/1/14#newcode51
Line 51: // http://isaacschlueter.com/2006/10/msie-memory-leaks/
On 2008/12/20 00:22:30, MarkM wrote:
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.
I don't follow.
This implementation should not have the leak problems described by those
articles.
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> {
On 2008/12/20 00:22:30, MarkM wrote:
(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".
I realized those methods were only used in one place, so I got rid of
them.
http://codereview.appspot.com/8703/diff/1/20#newcode26
Line 26: public static <T extends ParseTreeNode> AncestorChain<T>
instance(T node) {
On 2008/12/20 00:22:30, MarkM wrote:
Why does this class have both public constructors and public static
factory
methods that trivially wrap these constructors?
History. Changed to use factory methods consistently.
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
On 2008/12/20 00:22:30, MarkM wrote:
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.
Done.
http://codereview.appspot.com/8703/diff/1/17#newcode54
Line 54: * {...@code NaN} instead of the name {...@code undefined}. This is
documented as
On 2008/12/20 00:22:30, MarkM wrote:
Certainly it should be so documented, just as we should actually have
a cajoler
spec. Perhaps future tense + TODO?
Done.
http://codereview.appspot.com/8703/diff/1/17#newcode56
Line 56: * var o = { 0: 'a', NaN: 'b', undefined: 'c' };
On 2008/12/20 00:22:30, MarkM wrote:
Based on the code which follows, this should be "var a = ..."
Done.
http://codereview.appspot.com/8703/diff/1/17#newcode63
Line 63: * use-before-initialization.
On 2008/12/20 00:22:30, MarkM wrote:
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.
I disagree. We can do conservative and fairly accurate use-before
initialization checks, and simply decline to optimize when we can't.
In the common idiom:
for (var i = 0; i < array.length; ++i) {
f(arr[i]);
}
we can definitively say that the i in f(arr[i]) is not read before i has
been initialized. If f aliases eval, and arr[0] contains 'i =
undefined', then we can't guarantee that i is a number, but we can say
definitively that it has been initialized.
http://codereview.appspot.com/8703/diff/1/17#newcode92
Line 92: || key instanceof NumberLiteral)) {
On 2008/12/20 00:22:30, MarkM wrote:
Unindent this by one space, so that it lines up with the "(" of "(key"
Done.
http://codereview.appspot.com/8703/diff/1/17#newcode121
Line 121: static boolean doesVarReferenceArrayMember(
On 2008/12/20 00:22:30, MarkM wrote:
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.)
Done. Used the term "visible property" and documented it above. Should
this class change to "VisiblePropertyOptimization?"
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.
On 2008/12/20 00:22:30, MarkM wrote:
"too" should be "to"
Done.
http://codereview.appspot.com/8703/diff/1/18#newcode116
Line 116: protected abstract boolean isOptimizationSemanticsPreserving(
On 2008/12/20 00:22:30, MarkM wrote:
(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.
That sounds like a good idea, but I'd rather do that reorg in another
CL. How about I check this in without hooking it up, and rework it in a
follow-on CL?
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;
On 2008/12/20 00:22:30, MarkM wrote:
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.
Done.
http://codereview.appspot.com/8703/diff/1/16#newcode112
Line 112: for (ScopeTree t : children) {
On 2008/12/20 00:22:30, MarkM wrote:
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?
Done.
http://codereview.appspot.com/8703/diff/1/16#newcode120
Line 120: return Collections.unmodifiableList(children);
On 2008/12/20 00:22:30, MarkM wrote:
Why not do "children = Collections.unmodifiableList(children);" at the
end of
the constructor, in which case this can simply "return children;"?
Done.
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 {
On 2008/12/20 00:22:30, MarkM wrote:
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?
These might be easier to test once I switch to a more rewriter like
style.
http://codereview.appspot.com/8703