[Laszlo-dev] For Review: Change 20071205-dda-z Summary: Initial support for keywords in script compiler
P T Withington
ptw at pobox.com
Thu Dec 6 12:25:59 PST 2007
Approved!
On 2007-12-05, at 13:27 EST, Donald Anderson wrote:
> Change 20071205-dda-z by dda at freddie.local on 2007-12-05 10:32:16 EST
> in /Users/dda/laszlo/src/svn/openlaszlo/trunk
> for http://svn.openlaszlo.org/openlaszlo/trunk
>
> Summary: Initial support for keywords in script compiler
>
> New Features: no exposed features yet
>
> Bugs Fixed: LPP-5175
>
> Technical Reviewer: ptw
> QA Reviewer: hminsky
> Doc Reviewer: (pending)
>
> Documentation:
> Nothing here affects .lzx files, and even for lzs coders, there
> is no effect
> unless the new keywords are used. Even so -- they don't do
> anything for SWF8/9,DHTML,
> they are merely accepted.. Some of these keywords will be used
> internally
> to help implement SWF9 (in later reviews), some may be exposed to
> users indirectly
> via .lzx tags in the future, at which time they may be documented.
> All keywords used in accordance with ActionScript 3.0 and the
> Ecmascript draft standard.
>
> Release Notes:
> None.
>
> Details:
> Initial support for several JS2 keywords: 'dynamic', 'override',
> 'final',
> 'private', 'protected', 'public', 'internal'. The keyword
> 'static', although previously
> supported, is now handled in same way as the new group. In fact
> new keyword modifiers (I just
> noticed const) should now be easy to add. These keywords are all
> modifiers,
> in that they appear as part of a function, class, var definition,
> before
> the keywords 'function', 'class', 'var'. Multiple keywords can
> of course appear, for example, 'public static var x;'
> Also name space names can appear in this position, for example,
> mynamespace function f1() { }
> final override mynamespace function f2() { }
>
> There is no specific ordering of keywords enforced, and there are
> few
> restrictions: override is only for methods, dynamic is only for
> classes,
> only a single namespace name can appear, and a namespace cannot
> appear
> along with a visibility modifier ('public', 'private',
> 'protected', 'internal').
>
> By 'initial support', I mean that the keywords are now accepted,
> in the proper
> place and the infrastructure is available to take advantage of
> them.
> For SWF9, we plan to implement most or all of these keywords.
> Any code in the compilers or doc tools that already knew about
> 'static',
> has been changed to use this new modifier class.
>
> To make for easy handling of these modifiers (and potentially new
> ones), there
> is a new AST type: ASTModifiedDefinition. This can generally
> appear in the AST
> wherever a ClassDefinition, FunctionDeclaration or
> VariableStatement appears,
> and it has a child which is the ClassDefinition,
> FunctionDeclaration, VariableStatement.
> There is only one of these objects in the tree for any definition/
> declaration,
> and it holds information about all modifiers, including namespace
> names for the
> given declaration. This should make it easy to change any
> specifics about
> the modifiers, which ones are supported, etc. and allows each
> runtime to make
> its own decisions about how to treat the modifiers.
>
> Tests:
> smoketest for SWF7/8 and DHTML
> exact comparison of LFC binaries (using
> 'generatePredictableTemps' option)
> comparison of JS2doc outputs for representative classes
> to ensure that no visible changes.
> A basic .lzs test to test that various keyword combinations are
> accepted/rejected.
> since 'test/' directory does not have .lzs files, I only
> include it here:
>
> ///////////////////////
> // tests for new script compiler keywords
> // to test keyword combinations that should
> // give errors, uncomment lines beginning with //XXXX
>
> function f1() { }
> static function f2() { }
> private static function f3() { }
> static protected function f4() { }
> static override function f5() { }
> ns1 function f6() { }
> ns1 final function f7() { }
> final ns1 function f8() { }
>
> var v1;
> // Not allowed outside of class:
> //XXXX public var badv1;
> //XXXX static var badv2;
> //XXXX protected static var badv3;
>
> class c1 {
> function cf1() { }
> static function cf2() { }
> private static function cf3() { }
> static protected function cf4() { }
> static override function cf5() { }
> ns1 function cf6() { }
> ns1 final function cf7() { }
> final ns1 function cf8() { }
>
> var cv1;
> public var cv2;
> static var cv3;
> protected static var cv4;
> }
>
> private class c2 {}
> ns2 class c3 {}
> dynamic class c4 {}
>
> // Multiple namespace names not allowed
> //XXXX ns1 ns2 class badc1{}
> // namespace not allowed with public/private/etc.
> //XXXX public ns1 class badc2{}
> //XXXX ns2 protected class badc3{}
> // Inappropriate combinations
> //XXXX override var badv4;
> //XXXX dynamic function badf1() {}
> //XXXX dynamic var badv5;
> //XXXX override class badc4{}
> ///////////////////////
>
>
> Files:
> M WEB-INF/lps/lfc/build.xml
> M WEB-INF/lps/server/src/org/openlaszlo/js2doc/JS2Doc.java
> M WEB-INF/lps/server/src/org/openlaszlo/sc/
> JavascriptGenerator.java
> M WEB-INF/lps/server/src/org/openlaszlo/sc/CommonGenerator.java
> M WEB-INF/lps/server/src/org/openlaszlo/sc/CodeGenerator.java
> M WEB-INF/lps/server/sc/src/org/openlaszlo/sc/Parser.jjt
> A WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/
> ASTModifiedDefinition.java
>
> Changeset: http://svn.openlaszlo.org/openlaszlo/patches/20071205-dda-z.tar
>
>
>
> --
>
> Don Anderson
> Java/C/C++, Berkeley DB, systems consultant
>
> Voice: 617-547-7881
> Email: dda at ddanderson.com
> WWW: http://www.ddanderson.com
>
More information about the Laszlo-dev
mailing list