On 3/14/2010 3:05 PM, P T Withington wrote:
On 2010-03-13, at 20:47, André Bargull wrote:
It seems the JS2Doc_Test test-case is broken. I've changed the following things
to make it almost working again:
- updated the expected output to the newer "except $runtime" syntax in
JS2Doc_Test
- added if-case for ASTVariableDeclarationList in
"JS2Doc#collectVariableDeclarations(..)"
- replaced loop over falseDirective children with visit call for falseDirective in
"JS2Doc#visitIfDirective(..)"
Now there's only one remaining issue for function declarations, here's an
example:
identical: false
input: function foo () { }
output:<?xml version="1.0" encoding="UTF-8"?><js2doc buildoptions="debug profile" runtimeoptions="dhtml swf8 swf9"><property id="prototype"
name="prototype"><object><property id="prototype.foo" name="foo"><function/></property></object></property></js2doc>
expect:<?xml version="1.0" encoding="UTF-8"?><js2doc buildoptions="debug profile" runtimeoptions="dhtml swf8
swf9"><property id="foo" name="foo"><function/></property></js2doc>
Somehow the function declaration is wrapped in a ASTModifiedDefinition, this causes a call to
"JS2Doc#ensurePrototypeNode(..)" in "JS2Doc#visitMethodDeclaration(..)". The stacktrace
is like: visitToplevelStatement(..) -> visitModifiedDefinition(..) -> visitMethodDeclaration(..)
-> ensurePrototypeNode(..)
I wonder why the compiler wraps a simple function declaration outside of a
class in a ASTModifiedDefinition at all. It's possible to work around this
issue in JS2Doc, but I think this could be a bug in the compiler. Any thoughts?
That's just the way Don wrote the parser. All function and class declarations
are always going to be wrapped in a modified definition. I don't think there's
necessarily a right or wrong way to do this. The parser definition is in
WEB-INF/lps/server/sc/src/org/openlaszlo.
I still think it's a bug, global function declarations must not have one
of these modifiers: static/final/override or a namespace.
Here's a simple test-case which works in swf8 and dhtml because all
modifiers are removed, but fails to compile for swf10.
---
<canvas debug="true">
<script when="immediate"><![CDATA[
// illegal namespace and override modifier
public override function bla () {
Debug.write("called bla");
}
// invalid namespace modifier
public function blubb () {
Debug.write("called blubb");
}
// ok, this fails to compile with
// > Syntax error: the token "var" was not expected at this
position.
// public var foo = 0;
]]></script>
</canvas>
---