The following application prints this warning (after enabling the
commented out code in applyConstraintExpr(...)):
WARNING: Ignoring invalid dependency {c: '3'}.onc for constraint
/anonymous.text='${...}'
But actually this warning is expected:
WARNING: Unable to create dependency {c: '3'}.c for constraint
/anonymous.text='${...}'
<canvas>
<text y="20" text="${this.a + this.b + {c:'3'}.c}" >
<attribute name="a" value="1" type="string"/>
<attribute name="b" value="2" type="string"/>
</text>
</canvas>
Reason: ReferenceCollector#annotations is a Set, so it doesn't collect
the second entry for 'this' (first is 'this.a', second is 'this.b').
ReferenceCollector.java:
+ private String[] javaSucks = {
Would be easier with Java5, but that'd mean to update JavaCC, wouldn't it?
+ private HashSet pureFunctions = new HashSet(Arrays.asList(javaSucks));
You still want to use this list, although you've also said:
5) Add more exceptions to the compiler, although technically the exceptions
that I add in this change are not 100% accurate (no amount of static analysis
in ES3 can prove that `Math.round`, etc. have not been shadowed or rebound).
NodeModel.java:
+ "return " + depExpr + ";\n";
This was "return (" + depExpr + ");\n", so it was ensured it is treated
as an expression. That's no longer necessary?
LzRuntime.lzs:
+ dependencies[j] = new Error("Invalid dependency context");
+ dependencies[j + 1] = Debug.formatToString("Unable to create
dependency on %=s.%s", dc, referenceNames[i], dp);
and
+ return [new Error("Invalid dependency method"),
Debug.formatToString("Unable to create dependency on %=s.%s", context,
ctnm, fnnm)];
Creating the Error objects isn't necessary as long as
applyConstraintExpr(...) doesn't use the additional info.
Nits:
Typing is used inconsistently, e.g. $lzc$getFunctionDependencies is
specified with explicit return type, but not for
$lzc$validateReferenceDependencies.
Otherwise approved.
On 4/13/2010 5:13 PM, P T Withington wrote:
UPDATE: Per review discussion, warnings about incorrect constraint
dependencies are disabled (until we have a way for the LZX programmer to
address those warnings). Retained is the compatibility of being able to
constrain to a method without dependencies in swf10, even if the method is on a
sealed class. The previous component changes have been reverted.
---
Change 20100409-ptw-7 by [email protected] on 2010-04-09 13:47:40 EDT
in /Users/ptw/OpenLaszlo/trunk
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Make constraints and dependencies more debuggable and compatible
Bugs Fixed: LPP-7344 Attepting to constrain a non-LzEventable object property
gives ActionScript error in SWF9
Technical Reviewer: [email protected] (pending)
QA Reviewer: hminsky, max (pending)
Overview:
Removed the type declaration from LzDelegate so that a more
friendly error can be displayed. Added code in debug mode to
validate property and function dependencies. Added (but commented
out for now) code to warn when the compiler fails to create a
proper dependency for a constraint. A future change will enable
this warning, once we have implemented a way for the LZX
programmer to address the warning (by clarifying the dependencies
of the constraint).
Details:
regression: Noticed in passing: Use modern data type declaration
rather than coercion in constraint.
LzNode: Take greater care installing dependencies. Don't try to
install dependencies on non-LzEventables. Ensure that despite
failing dependencies, the constraint is at least evaluated once
(for backward compatibility with swf8 behavior). Added (but
commented out for now) debug mode code to give warnings that
relate the dependency errors to the constraint the user wrote.
LaszloEvents: Revert to runtime type-checking of LzDelegate
arguments. swf8 allows delegates on non-LzEventable for
compatibility with the swf8 kernel, but all other runtimes will
refuse to create delegates if the context is not an LzEventable or
the method is not a method. Similarly, delegates will only be
registered on LzEventable events in the modern runtimes. Also
repaired LzDelegate#_dbg_name_ to work with the new __events
Array.
LzRuntime: Add support for verifying reference dependencies and
calculating method dependencies carefully.
ReferenceCollector: Collect annotations for debug mode to support
more intelligible error messages. Removed obsolete 'subfunction'
API, no longer used. Added `pureFunctions` filter to reduce
irrelevant dependency computations.
*Generator: Remove obsolete #pragma "constraintFunction" support.
Compiler, NodeModel: Rework dependencies computation to support
better debugging.
Tests:
Test case from bug. Smokecheck. Calendar, LzPix, Amazon,
Animation demos
Files:
M test/smoke/regression.lzl
M WEB-INF/lps/lfc/core/LzNode.lzs
M WEB-INF/lps/lfc/events/LaszloEvents.lzs
M WEB-INF/lps/lfc/compiler/LzRuntime.lzs
M WEB-INF/lps/server/src/org/openlaszlo/sc/ReferenceCollector.java
M WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java
M WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
M WEB-INF/lps/server/src/org/openlaszlo/sc/CodeGenerator.java
M WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
Changeset: http://svn.openlaszlo.org/openlaszlo/patches/20100409-ptw-7.tar