On 1/20/2011 1:33 PM, P T Withington wrote:
Fabulous!  Approved.

Please file an improvement to remove unnecessary #passthrough blocks once this 
is checked in.

LPP-9692


Supposedly all 'modern' browser JS engines support getter/setter 
implementations.  I wonder if it is feasible to implement the JS back end?  Or 
are the browsers too different?

Accessor methods are not supported in IE7/8. IE8 has preliminary support, but it is restricted to DOM elements. IE9 will eventually support getters and setters through the new ES5 interfaces.



Replacing setAttribute is a much larger project, but if we had native 
getter/setter in all our target runtimes, it would make that project more 
feasible.

On 2011-01-19, at 20:00, André Bargull wrote:

Change bargull-20110120-qPw by bargull@Bargull02 on 2011-01-20 00:04:21
in /home/anba/src/svn/openlaszlo/trunk
for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Implement support for accessor methods in SWF10

New Features: LPP-9692 (Accept get/set functions in Parser for ActionScript3 
targets)

Technical Reviewer: ptw
QA Reviewer: (pending)

Overview:
With this change accessor methods (getter/setter) are allowed for script classes. They 
will only be passed down for swf9/10 and report an error otherwise. The accessor methods 
won't be translated to our internal "$lzsc$set_property" methods.


Details:
Parser.jjt:
- add "get" and "set" to the tokens
- "get"/"set" may appear as variable names, therefore added to 
IdentifierOrAS3Keyword() production
- altered MethodDeclaration() to accept accessor methods
-- getters don't allow any arguments, therefore FormalGetParameterList() only accepts 
"()"
-- setters only allow one argument, therefore FormalSetParameterList() only 
accept one argument, this argument must not have a default value or rest 
arguments
-- getters may return any type except for "void"
-- setters may only return "void"

ASTMethodDeclaration:
- copy of the generated file amended with a new field for the method-type 
(default, getter, setter)

JavascriptGenerator:
- throw compile-time error for accessor methods
- remove/comment out dead code

CodeGenerator:
- throw compile-time error for accessor methods

SWF9Generator:
- intercept JavascriptGenerator method
- remove/comment out dead code
- use class reference for static class members

ParseTreePrinter:
- add "get" resp "set" to function name, throw a compiler warning if the 
function is unnamed


Tests:
see testcases

Files:
M WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java
M WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
M WEB-INF/lps/server/src/org/openlaszlo/sc/CodeGenerator.java
M WEB-INF/lps/server/src/org/openlaszlo/sc/ParseTreePrinter.java
M WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt
A WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/ASTMethodDeclaration.java
A test/compiler_errors/js2-getters-setters.lzx
A test/smoke/js2-getters-setters.lzl
M test/smoke/smokecheck.lzx

Changeset: http://svn.openlaszlo.org/openlaszlo/patches/bargull-20110120-qPw.tar



Reply via email to