incubator-flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: [FlaconJS] pseudo emitter algorithm
Date Thu, 29 Nov 2012 17:23:10 GMT
Very nice.  Have you figured out the role of the generated CMCEmitter in
this process?


On 11/29/12 7:30 AM, "Michael Schmalle" <apache@teotigraphix.com> wrote:

> Hi,
> 
> For those asking question about "where to alter" code, it's not pretty
> but I think I know exactly what is going on now.
> 
> If you can understand below, you will now have some insight to where
> and how the JS code actually gets created.
> 
> 
> ! Call the compiler load config compile().
> 
> 
> JSGenerator.generate() - creates the package, class, member traits
> 
>   - DirectiveProcessor.processNode(IFileNode)
>     - recusrsivly fill traits
> 
> -----------------------------------------------------
> 
> Basically a snippet of the recursion;
> 
> DirectiveProcessor.processNode(IFileNode)
>    - declarePackage(PackageNode)
>      - emitter.visitPackage(packageName)
>      - data.registerPackage(packageName)
>      - super.declarePackage(PackageNode)
>        - DirectiveProcessor.traverse(p.getScopedNode()) <- ClassNode (class
> {})
>          - for each ClassNode.getChild(i)
>            - processNode(ScopedBlockNode)
>              - JSGlobalDirectiveProcessor.declareClass(ClassNode)
>                - verifyClassModifiers(ClassNode)
>                - skins
>                - JSClassDirectiveProcessor cp =
> backend.createClassDirectiveProcessor()
>                - cp.traverse(ClassNode.getScopedNode()) <- TypeScope
>                  - for each TypeScope.getChild(i)
>                    - processNode(TypeScope)
>                      -
> JSGlobalDirectiveProcessor.declareFunction(FunctionNode)
> 
> 
> --------------------------------------------------------
> 
> !!!!
> JavaScript source code creation after class traits have been traversed
> and created;
> 
> 
> JSEmiter.emit()
>    - emitClass(EmitterClassVisitor)
>      - IClassDefinition = getDefinition(ii.name)
>      - write class JSDoc
> 
> 
> 
> - JSEmitter.emitClass()
>    - Line: 3267 - 3269 is What creates a class
>      - "MainCode=adobe.extend("MainCode",Object,{ ... });"
> 
> 
> 
> - JSEmitter.emitInstanceTraits() is then called to write out the class traits
>    - emitTraits() is then called to do the specific if the closure
> compiler flag is not set
>      1. emitCtor() emit constructor
>       - emit comma
>      2. emit all variables before methods
>        - assembles the code "MainCode.foo"
>          - warns if there is a private namespace collision
>        -
>      3. emit all methods other than constructor
>        - emit ",\n"
>          - emitMethod()
>            - emitJSDocForMethod()
>            - write("\tget_baz")
>            - write(" : ") <- assignmentOp
>            - write("function(")
>              - emitParameters(methodInfo)
>                - write("baz")
>            - write(")")
>            - if (returnType != null)
>              - write(JSDoc for return type)
>            - if interface method
>              - write(" {};\n")
>            - else
>              - write("\n")
>              - write("  {")
>              - write("\n")
>              - emitMethodBody()
>                ... you get the drift
>              - write("  }")
> 
> - After all traits are written, control flow goes back to
> JSEmitter.emitClass() line 3269
>    - write("\n});\n\n") // end class
> - add _CLASS member to instance
>    - add JSDoc for prototype._CLASS
>    - write("MainCode.prototype._CLASS = MainCode;\n")
> 
> It will then go onto
>    - emitClassInfo()
>    - emitNamespaceInfo()
>    - emitJSONInfo()
> 
> if (JSSharedData.JS_FRAMEWORK_NAME)
>    - emitFrameworkInit();
> 
> It will then finally emit register class
>    - "adobe.classes.MainCode=MainCode;"
> 
> ---------------
> MainCode._PACKAGE=adobe.globals;MainCode._NAME="MainCode";
> MainCode._FULLNAME="MainCode";
> MainCode._SUPER=Object;
> MainCode._NAMESPACES={"foo::2":!0,"bar::7:MainCode":!0,"baz::2":!0,"baz::2":!0
> };
> adobe.classes.MainCode=MainCode;
> ---------------
> 
> Mike
> 
> 
> 
> 

-- 
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui


Mime
View raw message