incubator-flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mschma...@apache.org
Subject svn commit: r1426489 [2/4] - in /incubator/flex/whiteboard/mschmalle/falconjx: compiler.jx.tests/src/org/apache/flex/compiler/ compiler.jx.tests/src/org/apache/flex/compiler/internal/ compiler.jx.tests/src/org/apache/flex/compiler/internal/as/ compiler...
Date Fri, 28 Dec 2012 12:59:01 GMT
Added: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestStatements.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestStatements.java?rev=1426489&view=auto
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestStatements.java (added)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestStatements.java Fri Dec 28 12:59:00 2012
@@ -0,0 +1,455 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.as.codegen;
+
+import org.apache.flex.compiler.internal.tree.as.LabeledStatementNode;
+import org.apache.flex.compiler.tree.as.IFileNode;
+import org.apache.flex.compiler.tree.as.IForLoopNode;
+import org.apache.flex.compiler.tree.as.IIfNode;
+import org.apache.flex.compiler.tree.as.ISwitchNode;
+import org.apache.flex.compiler.tree.as.IThrowNode;
+import org.apache.flex.compiler.tree.as.ITryNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.apache.flex.compiler.tree.as.IWhileLoopNode;
+import org.apache.flex.compiler.tree.as.IWithNode;
+import org.junit.Test;
+
+/**
+ * @author Michael Schmalle
+ */
+public class TestStatements extends TestWalkerBase
+{
+    //--------------------------------------------------------------------------
+    // if
+    //--------------------------------------------------------------------------
+
+    //----------------------------------
+    // var declaration
+    //----------------------------------
+
+    @Test
+    public void testVarDeclaration()
+    {
+        IVariableNode node = (IVariableNode) getNode("var a;",
+                IVariableNode.class);
+        visitor.visitVariable(node);
+        assertOut("var a:*");
+    }
+
+    @Test
+    public void testVarDeclaration_withType()
+    {
+        IVariableNode node = (IVariableNode) getNode("var a:int;",
+                IVariableNode.class);
+        visitor.visitVariable(node);
+        assertOut("var a:int");
+    }
+
+    @Test
+    public void testVarDeclaration_withTypeAssignedValue()
+    {
+        IVariableNode node = (IVariableNode) getNode("var a:int = 42;",
+                IVariableNode.class);
+        visitor.visitVariable(node);
+        assertOut("var a:int = 42");
+    }
+
+    @Test
+    public void testVarDeclaration_withTypeAssignedValueComplex()
+    {
+        IVariableNode node = (IVariableNode) getNode(
+                "var a:Foo = new Foo(42, 'goo');", IVariableNode.class);
+        visitor.visitVariable(node);
+        assertOut("var a:Foo = new Foo(42, 'goo')");
+    }
+
+    @Test
+    public void testVarDeclaration_withList()
+    {
+        IVariableNode node = (IVariableNode) getNode(
+                "var a:int = 4, b:int = 11, c:int = 42;", IVariableNode.class);
+        visitor.visitVariable(node);
+        assertOut("var a:int = 4, b:int = 11, c:int = 42");
+    }
+
+    //----------------------------------
+    // const declaration
+    //----------------------------------
+
+    @Test
+    public void testConstDeclaration()
+    {
+        IVariableNode node = (IVariableNode) getNode("const a = 42;",
+                IVariableNode.class);
+        visitor.visitVariable(node);
+        assertOut("const a:* = 42");
+    }
+
+    @Test
+    public void testConstDeclaration_withType()
+    {
+        IVariableNode node = (IVariableNode) getNode("const a:int = 42;",
+                IVariableNode.class);
+        visitor.visitVariable(node);
+        assertOut("const a:int = 42");
+    }
+
+    @Test
+    public void testConstDeclaration_withList()
+    {
+        IVariableNode node = (IVariableNode) getNode(
+                "const a:int = 4, b:int = 11, c:int = 42;", IVariableNode.class);
+        visitor.visitVariable(node);
+        assertOut("const a:int = 4, b:int = 11, c:int = 42");
+    }
+
+    //----------------------------------
+    // if ()
+    //----------------------------------
+
+    @Test
+    public void testVisitIf_1()
+    {
+        IIfNode node = (IIfNode) getNode("if (a) b++;", IIfNode.class);
+        visitor.visitIf(node);
+        assertOut("if (a)\n\tb++;");
+    }
+
+    @Test
+    public void testVisitIf_2()
+    {
+        IIfNode node = (IIfNode) getNode("if (a) b++; else c++;", IIfNode.class);
+        visitor.visitIf(node);
+        assertOut("if (a)\n\tb++;\nelse\n\tc++;");
+    }
+
+    @Test
+    public void testVisitIf_4()
+    {
+        IIfNode node = (IIfNode) getNode(
+                "if (a) b++; else if (c) d++; else if(e) --f;", IIfNode.class);
+        visitor.visitIf(node);
+        assertOut("if (a)\n\tb++;\nelse if (c)\n\td++;\nelse if (e)\n\t--f;");
+    }
+
+    //----------------------------------
+    // if () { }
+    //----------------------------------
+
+    @Test
+    public void testVisitIf_1a()
+    {
+        IIfNode node = (IIfNode) getNode("if (a) { b++; }", IIfNode.class);
+        visitor.visitIf(node);
+        assertOut("if (a) {\n\tb++;\n}");
+    }
+
+    @Test
+    public void testVisitIf_1b()
+    {
+        IIfNode node = (IIfNode) getNode("if (a) { b++; } else { c++; }",
+                IIfNode.class);
+        visitor.visitIf(node);
+        assertOut("if (a) {\n\tb++;\n} else {\n\tc++;\n}");
+    }
+
+    @Test
+    public void testVisitIf_1c()
+    {
+        IIfNode node = (IIfNode) getNode(
+                "if (a) { b++; } else if (b) { c++; } else { d++; }",
+                IIfNode.class);
+        visitor.visitIf(node);
+        assertOut("if (a) {\n\tb++;\n} else if (b) {\n\tc++;\n} else {\n\td++;\n}");
+    }
+
+    @Test
+    public void testVisitIf_3()
+    {
+        IIfNode node = (IIfNode) getNode(
+                "if (a) b++; else if (c) d++; else --e;", IIfNode.class);
+        visitor.visitIf(node);
+        assertOut("if (a)\n\tb++;\nelse if (c)\n\td++;\nelse\n\t--e;");
+    }
+
+    //----------------------------------
+    // for () { }
+    //----------------------------------
+
+    @Test
+    public void testVisitFor_1a()
+    {
+        IForLoopNode node = (IForLoopNode) getNode(
+                "for (var i:int = 0; i < len; i++) { break; }",
+                IForLoopNode.class);
+        visitor.visitForLoop(node);
+        assertOut("for (var i:int = 0; i < len; i++) {\n\tbreak;\n}");
+    }
+
+    @Test
+    public void testVisitFor_1b()
+    {
+        IForLoopNode node = (IForLoopNode) getNode(
+                "for (var i:int = 0; i < len; i++) break;", IForLoopNode.class);
+        visitor.visitForLoop(node);
+        assertOut("for (var i:int = 0; i < len; i++)\n\tbreak;");
+    }
+
+    @Test
+    public void testVisitFor_2()
+    {
+        IForLoopNode node = (IForLoopNode) getNode("for (;;) { break; }",
+                IForLoopNode.class);
+        visitor.visitForLoop(node);
+        assertOut("for (;;) {\n\tbreak;\n}");
+    }
+
+    @Test
+    public void testVisitForIn_1()
+    {
+        IForLoopNode node = (IForLoopNode) getNode(
+                "for (var i:int in obj) { break; }", IForLoopNode.class);
+        visitor.visitForLoop(node);
+        assertOut("for (var i:int in obj) {\n\tbreak;\n}");
+    }
+
+    @Test
+    public void testVisitForIn_1a()
+    {
+        IForLoopNode node = (IForLoopNode) getNode(
+                "for (var i:int in obj)  break; ", IForLoopNode.class);
+        visitor.visitForLoop(node);
+        assertOut("for (var i:int in obj)\n\tbreak;");
+    }
+
+    @Test
+    public void testVisitForEach_1()
+    {
+        IForLoopNode node = (IForLoopNode) getNode(
+                "for each(var i:int in obj) { break; }", IForLoopNode.class);
+        visitor.visitForLoop(node);
+        assertOut("for each (var i:int in obj) {\n\tbreak;\n}");
+    }
+
+    @Test
+    public void testVisitForEach_1a()
+    {
+        IForLoopNode node = (IForLoopNode) getNode(
+                "for each(var i:int in obj)  break; ", IForLoopNode.class);
+        visitor.visitForLoop(node);
+        assertOut("for each (var i:int in obj)\n\tbreak;");
+    }
+
+    //----------------------------------
+    // while () { }
+    //----------------------------------
+
+    @Test
+    public void testVisitWhileLoop_1()
+    {
+        IWhileLoopNode node = (IWhileLoopNode) getNode(
+                "while(a > b){a++;--b;}", IWhileLoopNode.class);
+        visitor.visitWhileLoop(node);
+        assertOut("while (a > b) {\n\ta++;\n\t--b;\n}");
+    }
+
+    @Test
+    public void testVisitWhileLoop_1a()
+    {
+        IWhileLoopNode node = (IWhileLoopNode) getNode("while(a > b) a++;",
+                IWhileLoopNode.class);
+        visitor.visitWhileLoop(node);
+        assertOut("while (a > b)\n\ta++;");
+    }
+
+    //----------------------------------
+    // do {} while ()
+    //----------------------------------
+
+    @Test
+    public void testVisitWhileLoop_Do_1()
+    {
+        IWhileLoopNode node = (IWhileLoopNode) getNode(
+                "do {a++;--b;} while(a > b);", IWhileLoopNode.class);
+        visitor.visitWhileLoop(node);
+        assertOut("do {\n\ta++;\n\t--b;\n} while (a > b);");
+    }
+
+    @Test
+    public void testVisitWhileLoop_Do_1a()
+    {
+        IWhileLoopNode node = (IWhileLoopNode) getNode("do a++; while(a > b);",
+                IWhileLoopNode.class);
+        visitor.visitWhileLoop(node);
+        assertOut("do\n\ta++;\nwhile (a > b);");
+    }
+
+    //----------------------------------
+    // throw ()
+    //----------------------------------
+
+    @Test
+    public void testVisitThrow()
+    {
+        IThrowNode node = (IThrowNode) getNode("throw new Error('foo');",
+                IThrowNode.class);
+        visitor.visitThrow(node);
+        assertOut("throw new Error('foo')");
+    }
+
+    //----------------------------------
+    // try {} catch () {} finally {}
+    //----------------------------------
+
+    @Test
+    public void testVisitTry_Catch()
+    {
+        ITryNode node = (ITryNode) getNode("try { a; } catch (e:Error) { b; }",
+                ITryNode.class);
+        visitor.visitTry(node);
+        assertOut("try {\n\ta;\n} catch (e:Error) {\n\tb;\n}");
+    }
+
+    @Test
+    public void testVisitTry_Catch_Finally()
+    {
+        ITryNode node = (ITryNode) getNode(
+                "try { a; } catch (e:Error) { b; } finally { c; }",
+                ITryNode.class);
+        visitor.visitTry(node);
+        assertOut("try {\n\ta;\n} catch (e:Error) {\n\tb;\n} finally {\n\tc;\n}");
+    }
+
+    @Test
+    public void testVisitTry_Catch_Catch_Finally()
+    {
+        ITryNode node = (ITryNode) getNode(
+                "try { a; } catch (e:Error) { b; } catch (f:Error) { c; } finally { d; }",
+                ITryNode.class);
+        visitor.visitTry(node);
+        assertOut("try {\n\ta;\n} catch (e:Error) {\n\tb;\n} catch (f:Error) {\n\tc;\n} finally {\n\td;\n}");
+    }
+
+    @Test
+    public void testVisitTry_CatchEmpty_FinallyEmpty_()
+    {
+        ITryNode node = (ITryNode) getNode(
+                "try { a; } catch (e:Error) {  } finally {  }", ITryNode.class);
+        visitor.visitTry(node);
+        assertOut("try {\n\ta;\n} catch (e:Error) {\n} finally {\n}");
+    }
+
+    //----------------------------------
+    // switch {}
+    //----------------------------------
+
+    @Test
+    public void testVisitSwitch_1()
+    {
+        ISwitchNode node = (ISwitchNode) getNode("switch(i){case 1: break;}",
+                ISwitchNode.class);
+        visitor.visitSwitch(node);
+        assertOut("swtich (i) {\n\tcase 1:\n\t\tbreak;\n}");
+    }
+
+    @Test
+    public void testVisitSwitch_1a()
+    {
+        ISwitchNode node = (ISwitchNode) getNode(
+                "switch(i){case 1: { break; }}", ISwitchNode.class);
+        visitor.visitSwitch(node);
+        // TODO case BLOCK statements are SYNTHESIZED so they will never show BRACES
+        // without extra help from us
+        assertOut("swtich (i) {\n\tcase 1:\n\t\tbreak;\n}");
+    }
+
+    @Test
+    public void testVisitSwitch_2()
+    {
+        ISwitchNode node = (ISwitchNode) getNode(
+                "switch(i){case 1: break; default: return;}", ISwitchNode.class);
+        visitor.visitSwitch(node);
+        assertOut("swtich (i) {\n\tcase 1:\n\t\tbreak;\n\tdefault:\n\t\treturn;\n}");
+    }
+
+    //----------------------------------
+    // label : for () {}
+    //----------------------------------
+
+    @Test
+    public void testVisitLabel_1()
+    {
+        LabeledStatementNode node = (LabeledStatementNode) getNode(
+                "foo: for each(var i:int in obj) { break foo; }",
+                LabeledStatementNode.class);
+        visitor.visitLabeledStatement(node);
+        assertOut("foo : for each (var i:int in obj) {\n\tbreak foo;\n}");
+    }
+
+    @Test
+    public void testVisitLabel_1a()
+    {
+        // TODO LabelStatement messes up in finally{} block, something is wrong there
+        LabeledStatementNode node = (LabeledStatementNode) getNode(
+                "foo: for each(var i:int in obj) break foo;",
+                LabeledStatementNode.class);
+        visitor.visitLabeledStatement(node);
+        assertOut("foo : for each (var i:int in obj)\n\tbreak foo;");
+    }
+
+    //----------------------------------
+    // with () {}
+    //----------------------------------
+
+    @Test
+    public void testVisitWith()
+    {
+        IWithNode node = (IWithNode) getNode("with (a) { b; }", IWithNode.class);
+        visitor.visitWith(node);
+        assertOut("with (a) {\n\tb;\n}");
+    }
+
+    @Test
+    public void testVisitWith_1a()
+    {
+        IWithNode node = (IWithNode) getNode("with (a) b;", IWithNode.class);
+        visitor.visitWith(node);
+        assertOut("with (a)\n\tb;");
+    }
+
+    @Test
+    public void testVisit()
+    {
+        IFileNode node = (IFileNode) getNode(
+                "try { a; } catch (e:Error) { if (a) { if (b) { if (c) b; else if (f) a; else e; }} } finally {  }"
+                        + "if (d) for (var i:int = 0; i < len; i++) break;"
+                        + "if (a) { with (ab) { c(); } "
+                        + "do {a++;do a++; while(a > b);} while(c > d); }"
+                        + "if (b) { try { a; throw new Error('foo'); } catch (e:Error) { "
+                        + " switch(i){case 1: break; default: return;}"
+                        + " } catch (f:Error) { c; eee.dd; } finally { "
+                        + "  d;  var a:Object = function(foo:int, bar:String = 'goo'):int{return -1;};"
+                        + "  eee.dd; eee.dd; eee.dd; eee.dd;} }"
+                        + "foo: for each(var i:int in obj) break foo;",
+                IFileNode.class);
+        visitor.visitFile(node);
+        //assertOut("");
+    }
+}

Propchange: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestStatements.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestWalkerBase.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestWalkerBase.java?rev=1426489&view=auto
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestWalkerBase.java (added)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestWalkerBase.java Fri Dec 28 12:59:00 2012
@@ -0,0 +1,50 @@
+package org.apache.flex.compiler.internal.as.codegen;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+import org.apache.flex.compiler.clients.IBackend;
+import org.apache.flex.compiler.internal.as.codegen.ASFilterWriter;
+import org.apache.flex.compiler.internal.as.driver.ASBackend;
+import org.apache.flex.compiler.visitor.IASBlockVisitor;
+import org.junit.After;
+
+public class TestWalkerBase extends TestBase
+{
+    protected IASBlockVisitor visitor;
+
+    private IBackend backend;
+
+    private ASFilterWriter writer;
+
+    protected String mCode;
+
+    @Override
+    public void setUp()
+    {
+        super.setUp();
+
+        backend = createBackend();
+        writer = backend.createFilterWriter(project);
+        visitor = backend.createWalker(project, errors, writer);
+    }
+
+    @After
+    public void tearDown()
+    {
+        backend = null;
+        writer = null;
+        visitor = null;
+    }
+
+    protected IBackend createBackend()
+    {
+        return new ASBackend();
+    }
+
+    protected void assertOut(String code)
+    {
+        mCode = writer.toString();
+        assertThat(writer.toString(), is(code));
+    }
+}

Propchange: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/as/codegen/TestWalkerBase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/TestGoogEmiter.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/TestGoogEmiter.java?rev=1426489&view=auto
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/TestGoogEmiter.java (added)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/TestGoogEmiter.java Fri Dec 28 12:59:00 2012
@@ -0,0 +1,234 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.js.codegen;
+
+import org.apache.flex.compiler.clients.IBackend;
+import org.apache.flex.compiler.internal.as.codegen.TestWalkerBase;
+import org.apache.flex.compiler.internal.js.driver.goog.GoogBackend;
+import org.apache.flex.compiler.tree.as.IFileNode;
+import org.apache.flex.compiler.tree.as.IFunctionNode;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * This class tests the production of 'goog' JavaScript output.
+ * <p>
+ * Note; this is a complete prototype more used in figuring out where
+ * abstraction and indirection is needed concerning the AS -> JS translations.
+ * 
+ * @author Michael Schmalle
+ */
+public class TestGoogEmiter extends TestWalkerBase
+{
+    // emitPackageHeader()
+    // emitImports()
+    // emitClass()
+
+    @Test
+    public void testSimple()
+    {
+        String code = "package com.example.components {"
+                + "import org.apache.flex.html.staticControls.TextButton;"
+                + "public class MyTextButton extends TextButton {"
+                + "public function MyTextButton() {if (foo() != 42) { bar(); } }"
+                + "private var _privateVar:String = \"do \";"
+                + "public var publicProperty:Number = 100;"
+                + "public function myFunction(value: String): String{"
+                + "return \"Don't \" + _privateVar + value; }";
+        IFileNode node = getFileNode(code);
+        visitor.visitFile(node);
+        //assertOut("");
+    }
+
+    @Test
+    public void testSimpleMethod()
+    {
+        JSSharedData.OUTPUT_JSDOC = false;
+        IFunctionNode node = getMethodSimple("function method1():void{\n}");
+        visitor.visitFunction(node);
+        assertOut("A.method1 = function() {\n}");
+        JSSharedData.OUTPUT_JSDOC = true;
+    }
+
+    @Test
+    public void testSimpleParameterReturnType()
+    {
+        JSSharedData.OUTPUT_JSDOC = false;
+        IFunctionNode node = getMethod("function method1(bar:int):int{\n}");
+        visitor.visitFunction(node);
+        assertOut("foo.bar.A.method1 = function(bar) {\n}");
+        JSSharedData.OUTPUT_JSDOC = true;
+    }
+
+    @Test
+    public void testSimpleMultipleParameter()
+    {
+        JSSharedData.OUTPUT_JSDOC = false;
+        IFunctionNode node = getMethod("function method1(bar:int, baz:String, goo:A):void{\n}");
+        visitor.visitFunction(node);
+        assertOut("foo.bar.A.method1 = function(bar, baz, goo) {\n}");
+        JSSharedData.OUTPUT_JSDOC = true;
+    }
+
+    @Ignore
+    @Test
+    public void testSimpleMultipleParameter_JSDoc()
+    {
+        // jsdoc still needs to be sorted out before tests are executing
+        IFunctionNode node = getMethod("function method1(bar:int, baz:String, goo:A):void{\n}");
+        visitor.visitFunction(node);
+        assertOut("/**\n * @this {foo.bar.A}\n * @param {int} bar\n * @param {String} baz\n"
+                + " * @param {A} goo\n * @return {void}\n */\nfoo.bar.A.method1 = "
+                + "function(bar, baz, goo) {\n}");
+    }
+
+    @Test
+    public void testDefaultParameter_NoBody()
+    {
+        /*
+        foo.bar.A.method1 = function(bar, bax) {
+            if (arguments.length < 2) {
+                if (arguments.length < 1) {
+                    bar = 42;
+                }
+                bax = 4;
+            }
+        }
+        */
+        JSSharedData.OUTPUT_JSDOC = false;
+        IFunctionNode node = getMethod("function method1(bar:int = 42, bax:int = 4):void{\n}");
+        visitor.visitFunction(node);
+        assertOut("foo.bar.A.method1 = function(bar, bax) {\n\tif (arguments.length < 2) {\n\t\t"
+                + "if (arguments.length < 1) {\n\t\t\tbar = 42;\n\t\t}\n\t\tbax = 4;\n\t}\n}");
+        JSSharedData.OUTPUT_JSDOC = true;
+    }
+
+    @Test
+    public void testDefaultParameter_Body()
+    {
+        /*
+        foo.bar.A.method1 = function(bar, bax) {
+            if (arguments.length < 2) {
+                if (arguments.length < 1) {
+                    bar = 42;
+                }
+                bax = 4;
+            }
+        }
+        */
+        JSSharedData.OUTPUT_JSDOC = false;
+        IFunctionNode node = getMethod("function method1(bar:int = 42, bax:int = 4):void{if (a) foo();}");
+        visitor.visitFunction(node);
+        assertOut("foo.bar.A.method1 = function(bar, bax) {\n\tif (arguments.length < 2) {\n\t\t"
+                + "if (arguments.length < 1) {\n\t\t\tbar = 42;\n\t\t}\n\t\tbax = 4;\n\t}\n\t"
+                + "if (a)\n\t\tfoo();\n}");
+        JSSharedData.OUTPUT_JSDOC = true;
+    }
+
+    @Test
+    public void testDefaultParameter()
+    {
+        /*
+         foo.bar.A.method1 = function(p1, p2, p3, p4) {
+            if (arguments.length < 4) {
+                if (arguments.length < 3) {
+                    p3 = 3;
+                }
+                p4 = 4;
+            }
+            return p1 + p2 + p3 + p4;
+         }
+         */
+        JSSharedData.OUTPUT_JSDOC = false;
+        IFunctionNode node = getMethod("function method1(p1:int, p2:int, p3:int = 3, p4:int = 4):int{return p1 + p2 + p3 + p4;}");
+        visitor.visitFunction(node);
+        assertOut("foo.bar.A.method1 = function(p1, p2, p3, p4) {\n\tif (arguments.length < 4) "
+                + "{\n\t\tif (arguments.length < 3) {\n\t\t\tp3 = 3;\n\t\t}\n\t\tp4 = 4;\n\t}"
+                + "\n\treturn p1 + p2 + p3 + p4;\n}");
+        JSSharedData.OUTPUT_JSDOC = true;
+    }
+
+    @Test
+    public void testDefaultParameter_Alternate()
+    {
+        /*
+        foo.bar.A.method1 = function(p1, p2, p3, p4) {
+        	p3 = typeof p3 !== 'undefined' ? p3 : 3;
+        	p4 = typeof p4 !== 'undefined' ? p4 : 4;
+        		
+            return p1 + p2 + p3 + p4;
+        }
+        */
+        JSSharedData.OUTPUT_JSDOC = false;
+        JSSharedData.OUTPUT_ALTERNATE = true;
+        IFunctionNode node = getMethod("function method1(p1:int, p2:int, p3:int = 3, p4:int = 4):int{return p1 + p2 + p3 + p4;}");
+        visitor.visitFunction(node);
+        assertOut("foo.bar.A.method1 = function(p1, p2, p3, p4) {\n"
+                + "\tp3 = typeof p3 !== 'undefined' ? p3 : 3;\n"
+                + "\tp4 = typeof p4 !== 'undefined' ? p4 : 4;\n"
+                + "\treturn p1 + p2 + p3 + p4;\n}");
+        JSSharedData.OUTPUT_ALTERNATE = false;
+        JSSharedData.OUTPUT_JSDOC = true;
+    }
+
+    @Test
+    public void testDefaultParameter_AlternateNoBody()
+    {
+        /*
+        foo.bar.A.method1 = function(p1, p2, p3, p4) {
+            p3 = typeof p3 !== 'undefined' ? p3 : 3;
+            p4 = typeof p4 !== 'undefined' ? p4 : 4;
+        }
+        */
+        JSSharedData.OUTPUT_JSDOC = false;
+        JSSharedData.OUTPUT_ALTERNATE = true;
+        IFunctionNode node = getMethod("function method1(p1:int, p2:int, p3:int = 3, p4:int = 4):int{}");
+        visitor.visitFunction(node);
+        assertOut("foo.bar.A.method1 = function(p1, p2, p3, p4) {\n"
+                + "\tp3 = typeof p3 !== 'undefined' ? p3 : 3;\n"
+                + "\tp4 = typeof p4 !== 'undefined' ? p4 : 4;\n}");
+        JSSharedData.OUTPUT_ALTERNATE = false;
+        JSSharedData.OUTPUT_JSDOC = true;
+    }
+
+    @Override
+    protected IBackend createBackend()
+    {
+        return new GoogBackend();
+    }
+
+    protected IFunctionNode getMethodSimple(String code)
+    {
+        String source = "package {public class A {" + code + "}}";
+        IFileNode node = getFileNode(source);
+        IFunctionNode child = (IFunctionNode) findFirstDescendantOfType(node,
+                IFunctionNode.class);
+        return child;
+    }
+
+    protected IFunctionNode getMethod(String code)
+    {
+        String source = "package foo.bar {public class A {" + code + "}}";
+        IFileNode node = getFileNode(source);
+        IFunctionNode child = (IFunctionNode) findFirstDescendantOfType(node,
+                IFunctionNode.class);
+        return child;
+    }
+}

Propchange: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/TestGoogEmiter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogPackage.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogPackage.java?rev=1426489&view=auto
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogPackage.java (added)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogPackage.java Fri Dec 28 12:59:00 2012
@@ -0,0 +1,113 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.js.codegen.goog;
+
+import org.apache.flex.compiler.clients.IBackend;
+import org.apache.flex.compiler.internal.as.codegen.TestPackage;
+import org.apache.flex.compiler.internal.js.driver.goog.GoogBackend;
+import org.apache.flex.compiler.tree.as.IFileNode;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * This class tests the production of 'goog' JavaScript for AS package.
+ * 
+ * @author Michael Schmalle
+ * @author Erik de Bruin
+ */
+public class TestGoogPackage extends TestPackage
+{
+    // TODO (erikdebruin)
+    // 2) empty classes don't get a JS block (curly brackets)
+    //    - do we produce implicit constructors?
+    // 4) there is an extra line after the 'goog.provide' line: remove
+    // 5) there are two extra lines at the end of the code: remove
+    // 6) constructor body in 'testPackageQualified_ClassBodyMethodContents'
+    //    contains code that is not yet 'goog'-ified
+
+    @Override
+    @Test
+    public void testPackage_Simple()
+    {
+        IFileNode node = getFileNode("package{}");
+        visitor.visitFile(node);
+        assertOut("");
+    }
+
+    @Override
+    @Test
+    public void testPackage_Name()
+    {
+        IFileNode node = getFileNode("package foo.bar.baz {}");
+        visitor.visitFile(node);
+        assertOut("");
+    }
+
+    @Override
+    @Ignore
+    @Test
+    public void testPackageSimple_Class()
+    {
+        // does JS need a implicit constructor function? ... always?
+        // All class nodes in AST get either an implicit or explicit constructor
+        // this is an implicit and the way I have the before/after handler working
+        // with block disallows implicit blocks from getting { }
+        IFileNode node = getFileNode("package {public class A{}}");
+        visitor.visitFile(node);
+        assertOut("");
+    }
+
+    @Override
+    @Ignore
+    @Test
+    public void testPackageQualified_Class()
+    {
+        // same here; see testPackageSimple_Class
+        IFileNode node = getFileNode("package foo.bar.baz {public class A{}}");
+        visitor.visitFile(node);
+        assertOut("");
+    }
+
+    @Override
+    @Test
+    public void testPackageQualified_ClassBody()
+    {
+        // there is still two newlines at the end and after provide which shouldn't happen
+        // I'll look into that if you don't get to it
+        IFileNode node = getFileNode("package foo.bar.baz {public class A{public function A(){}}}");
+        visitor.visitFile(node);
+        assertOut("goog.provide('foo.bar.baz.A');\n\n\n/**\n * @constructor\n */\nfoo.bar.baz.A = function() {\n};\n\n");
+    }
+
+    @Override
+    @Test
+    public void testPackageQualified_ClassBodyMethodContents()
+    {
+        IFileNode node = getFileNode("package foo.bar.baz {public class A{public function A(){if (a){for each(var i:Object in obj){doit();}}}}}");
+        visitor.visitFile(node);
+        //assertOut("");
+    }
+
+    @Override
+    protected IBackend createBackend()
+    {
+        return new GoogBackend();
+    }
+}

Propchange: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/internal/js/codegen/goog/TestGoogPackage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/utils/EnvProperties.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/utils/EnvProperties.java?rev=1426489&view=auto
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/utils/EnvProperties.java (added)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/utils/EnvProperties.java Fri Dec 28 12:59:00 2012
@@ -0,0 +1,110 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.utils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.apache.flex.utils.FilenameNormalization;
+
+/**
+ * EnvProperties checks in following order for a value.
+ * 
+ * 1) unittest.properties 2) environment variables 3) for key FLEX_HOME &
+ * PLAYERGLOBAL_HOME sets a default value.
+ */
+public class EnvProperties
+{
+
+    /**
+     * FLEX_HOME
+     */
+    public String SDK;
+
+    /**
+     * PLAYERGLOBAL_HOME
+     */
+    public String FPSDK;
+
+    /**
+     * AIR_HOME
+     */
+    public String AIRSDK;
+
+    /**
+     * FLASHPLAYER_DEBUGGER
+     */
+    public String FDBG;
+
+    private static EnvProperties env;
+
+    public static EnvProperties initiate()
+    {
+        if (env == null)
+        {
+            env = new EnvProperties();
+            env.setup();
+        }
+        return env;
+    }
+
+    private void setup()
+    {
+        Properties p = new Properties();
+        try
+        {
+            File f = new File("unittest.properties");
+            p.load(new FileInputStream(f));
+        }
+        catch (FileNotFoundException e)
+        {
+            System.out.println("unittest.properties not found");
+        }
+        catch (IOException e)
+        {
+        }
+
+        SDK = p.getProperty("FLEX_HOME", System.getenv("FLEX_HOME"));
+        if (SDK == null)
+            SDK = FilenameNormalization
+                    .normalize("../compiler/generated/dist/sdk");
+        System.out.println("environment property - FLEX_HOME = " + SDK);
+
+        FPSDK = p.getProperty("PLAYERGLOBAL_HOME",
+                System.getenv("PLAYERGLOBAL_HOME"));
+        if (FPSDK == null)
+            FPSDK = FilenameNormalization
+                    .normalize("../compiler/generated/dist/sdk/frameworks/libs/player");
+        System.out.println("environment property - PLAYERGLOBAL_HOME = "
+                + FPSDK);
+
+        AIRSDK = p.getProperty("AIR_HOME", System.getenv("AIR_HOME"));
+        System.out.println("environment property - AIR_HOME = " + AIRSDK);
+
+        FDBG = p.getProperty("FLASHPLAYER_DEBUGGER",
+                System.getenv("FLASHPLAYER_DEBUGGER"));
+        System.out.println("environment property - FLASHPLAYER_DEBUGGER = "
+                + FDBG);
+    }
+
+}

Propchange: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/compiler/utils/EnvProperties.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/as/codegen/IASEmitter.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/as/codegen/IASEmitter.java?rev=1426489&view=auto
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/as/codegen/IASEmitter.java (added)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/as/codegen/IASEmitter.java Fri Dec 28 12:59:00 2012
@@ -0,0 +1,159 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.as.codegen;
+
+import java.io.Writer;
+
+import org.apache.flex.compiler.internal.tree.as.FunctionObjectNode;
+import org.apache.flex.compiler.tree.as.IExpressionNode;
+import org.apache.flex.compiler.tree.as.IFunctionNode;
+import org.apache.flex.compiler.tree.as.IGetterNode;
+import org.apache.flex.compiler.tree.as.IPackageNode;
+import org.apache.flex.compiler.tree.as.IParameterNode;
+import org.apache.flex.compiler.tree.as.ISetterNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.apache.flex.compiler.visitor.IASBlockWalker;
+import org.apache.flex.compiler.visitor.IASNodeStrategy;
+
+/**
+ * The {@link IASEmitter} interface allows abstraction between the
+ * {@link IASNodeStrategy} and the current output buffer {@link Writer}.
+ * 
+ * @author Michael Schmalle
+ */
+public interface IASEmitter
+{
+    IASBlockWalker getWalker();
+
+    void setWalker(IASBlockWalker asBlockWalker);
+
+    IDocEmitter getDocEmitter();
+
+    void setDocEmitter(IDocEmitter value);
+    
+    /**
+     * Writes a string to the writer.
+     * 
+     * @param value The string to write to the output buffer.
+     */
+    void write(String value);
+
+    /**
+     * Pushes an indent into the emitter so after newlines are emitted, the
+     * output is correctly formatted.
+     */
+    void indentPush();
+
+    /**
+     * Pops an indent from the emitter so after newlines are emitted, the output
+     * is correctly formatted.
+     */
+    void indentPop();
+
+    void emitPackageHeader(IPackageNode node);
+
+    void emitPackageHeaderContents(IPackageNode node);
+
+    void emitPackageContents(IPackageNode node);
+
+    void emitPackageFooter(IPackageNode node);
+
+    /**
+     * Emit a documentation comment for a Class field or constant
+     * {@link IVariableNode}.
+     * 
+     * @param node The {@link IVariableNode} class field member.
+     */
+    void emitFieldDocumentation(IVariableNode node);
+
+    /**
+     * Emit a full Class field member.
+     * 
+     * @param node The {@link IVariableNode} class field member.
+     */
+    void emitField(IVariableNode node);
+
+    /**
+     * Emit a documentation comment for a Class method {@link IFunctionNode}.
+     * 
+     * @param node The {@link IFunctionNode} class method member.
+     */
+    void emitMethodDocumentation(IFunctionNode node);
+
+    /**
+     * Emit a full Class or Interface method member.
+     * 
+     * @param node The {@link IFunctionNode} class method member.
+     */
+    void emitMethod(IFunctionNode node);
+
+    /**
+     * Emit a documentation comment for a Class method {@link IGetterNode}.
+     * 
+     * @param node The {@link IGetterNode} class accessor member.
+     */
+    void emitGetAccessorDocumentation(IGetterNode node);
+
+    /**
+     * Emit a full Class getter member.
+     * 
+     * @param node The {@link IVariableNode} class getter member.
+     */
+    void emitGetAccessor(IGetterNode node);
+
+    /**
+     * Emit a documentation comment for a Class accessor {@link IGetterNode}.
+     * 
+     * @param node The {@link ISetterNode} class accessor member.
+     */
+    void emitSetAccessorDocumentation(ISetterNode node);
+
+    /**
+     * Emit a full Class setter member.
+     * 
+     * @param node The {@link ISetterNode} class setter member.
+     */
+    void emitSetAccessor(ISetterNode node);
+
+    void emitParameter(IParameterNode node);
+
+    //--------------------------------------------------------------------------
+    // Expressions
+    //--------------------------------------------------------------------------
+
+    /**
+     * Emit a variable declaration found in expression statements within scoped
+     * blocks.
+     * 
+     * @param node The {@link IVariableNode} or chain of variable nodes.
+     */
+    void emitVarDeclaration(IVariableNode node);
+
+    // TODO (mschmalle) we need IFunctionObjectNode API for FunctionObjectNode
+    /**
+     * Emit an anonymous {@link FunctionObjectNode}.
+     * 
+     * @param node The anonymous {@link FunctionObjectNode}.
+     */
+    void emitFunctionObject(IExpressionNode node);
+
+    void emitFunctionBlockHeader(IFunctionNode node);
+
+}

Propchange: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/as/codegen/IASEmitter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/as/codegen/IASWriter.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/as/codegen/IASWriter.java?rev=1426489&view=auto
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/as/codegen/IASWriter.java (added)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/as/codegen/IASWriter.java Fri Dec 28 12:59:00 2012
@@ -0,0 +1,51 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.as.codegen;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * An ActionScript writer that outputs cross compiled string data to the
+ * output stream.
+ * 
+ * @author Michael Schmalle
+ */
+public interface IASWriter extends Closeable
+{
+    /**
+     * Start writing to output stream.
+     * 
+     * @param out output stream
+     */
+    void writeTo(OutputStream out);
+
+    /**
+     * Start writing to a file.
+     * 
+     * @param out The output {@link File}.
+     * @return The number of bytes written.
+     */
+    int writeTo(File out) throws FileNotFoundException, IOException;
+
+}

Propchange: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/as/codegen/IASWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/as/codegen/IDocEmitter.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/as/codegen/IDocEmitter.java?rev=1426489&view=auto
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/as/codegen/IDocEmitter.java (added)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/as/codegen/IDocEmitter.java Fri Dec 28 12:59:00 2012
@@ -0,0 +1,32 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.as.codegen;
+
+/**
+ * Base interface for documentation emitters.
+ * 
+ * @author Michael Schmalle
+ */
+public interface IDocEmitter
+{
+    void begin();
+
+    void end();
+}

Propchange: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/as/codegen/IDocEmitter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/clients/IBackend.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/clients/IBackend.java?rev=1426489&r1=1426488&r2=1426489&view=diff
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/clients/IBackend.java (original)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/clients/IBackend.java Fri Dec 28 12:59:00 2012
@@ -22,7 +22,9 @@ package org.apache.flex.compiler.clients
 import java.io.File;
 import java.util.List;
 
-import org.apache.flex.compiler.as.IASWriter;
+import org.apache.flex.compiler.as.codegen.IASEmitter;
+import org.apache.flex.compiler.as.codegen.IASWriter;
+import org.apache.flex.compiler.as.codegen.IDocEmitter;
 import org.apache.flex.compiler.config.Configurator;
 import org.apache.flex.compiler.internal.as.codegen.ASFilterWriter;
 import org.apache.flex.compiler.internal.projects.ISourceFileHandler;
@@ -63,7 +65,7 @@ public interface IBackend
 
     /**
      * Creates a javascript target that will be used to build the compiled
-     * javascript source file.
+     * javascript source file.  
      * 
      * @param project The current {@link ICompilerProject}.
      * @param settings The target's custom settings.
@@ -74,6 +76,8 @@ public interface IBackend
     ITarget createTarget(IASProject project, ITargetSettings settings,
             ITargetProgressMonitor monitor);
 
+    IDocEmitter createDocEmitter(IASEmitter emitter);
+
     ASFilterWriter createFilterWriter(IASProject project);
 
     IASWriter createWriter(IASProject project, List<ICompilerProblem> errors,
@@ -82,4 +86,6 @@ public interface IBackend
     IASBlockWalker createWalker(IASProject project,
             List<ICompilerProblem> errors, ASFilterWriter writer);
 
+
+
 }

Modified: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java?rev=1426489&r1=1426488&r2=1426489&view=diff
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java (original)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java Fri Dec 28 12:59:00 2012
@@ -32,7 +32,7 @@ import java.util.List;
 import java.util.Set;
 
 import org.apache.commons.io.FilenameUtils;
-import org.apache.flex.compiler.as.IASWriter;
+import org.apache.flex.compiler.as.codegen.IASWriter;
 import org.apache.flex.compiler.clients.problems.ProblemPrinter;
 import org.apache.flex.compiler.clients.problems.ProblemQuery;
 import org.apache.flex.compiler.clients.problems.WorkspaceProblemFormatter;
@@ -45,8 +45,8 @@ import org.apache.flex.compiler.exceptio
 import org.apache.flex.compiler.exceptions.ConfigurationException.IOError;
 import org.apache.flex.compiler.exceptions.ConfigurationException.MustSpecifyTarget;
 import org.apache.flex.compiler.exceptions.ConfigurationException.OnlyOneSource;
-import org.apache.flex.compiler.internal.driver.JSBackend;
-import org.apache.flex.compiler.internal.js.codgen.JSSharedData;
+import org.apache.flex.compiler.internal.js.codegen.JSSharedData;
+import org.apache.flex.compiler.internal.js.driver.JSBackend;
 import org.apache.flex.compiler.internal.projects.CompilerProject;
 import org.apache.flex.compiler.internal.projects.FlexProject;
 import org.apache.flex.compiler.internal.projects.ISourceFileHandler;
@@ -460,7 +460,7 @@ public class MXMLJSC
         // if (getTargetSettings() == null)
         //     return false;
 
-        target = (JSTarget) JSSharedData.backend.createTarget(project,
+        target = JSSharedData.backend.createTarget(project,
                 getTargetSettings(), null);
 
         return true;

Added: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASAfterNodeStrategy.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASAfterNodeStrategy.java?rev=1426489&view=auto
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASAfterNodeStrategy.java (added)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASAfterNodeStrategy.java Fri Dec 28 12:59:00 2012
@@ -0,0 +1,75 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.as.codegen;
+
+import org.apache.flex.compiler.as.codegen.IASEmitter;
+import org.apache.flex.compiler.js.codegen.IJSEmitter;
+import org.apache.flex.compiler.tree.ASTNodeID;
+import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.as.IContainerNode;
+import org.apache.flex.compiler.tree.as.IContainerNode.ContainerType;
+import org.apache.flex.compiler.visitor.IASNodeStrategy;
+
+/**
+ * A concrete implementation of the {@link IASNodeStrategy} that allows
+ * {@link IASNode} processing after the current node handler.
+ * <p>
+ * The class has access to the current {@link IJSEmitter} instance being used to
+ * output source code to the current output buffer.
+ * 
+ * @author Michael Schmalle
+ */
+public class ASAfterNodeStrategy implements IASNodeStrategy
+{
+    private final IASEmitter emitter;
+
+    public ASAfterNodeStrategy(IASEmitter emitter)
+    {
+        this.emitter = emitter;
+    }
+
+    @Override
+    public void handle(IASNode node)
+    {
+        if (node.getNodeID() == ASTNodeID.BlockID)
+        {
+            IContainerNode container = (IContainerNode) node;
+            ContainerType type = container.getContainerType();
+            if (type != ContainerType.IMPLICIT
+                    && type != ContainerType.SYNTHESIZED)
+            {
+                if (node.getChildCount() != 0)
+                {
+                    emitter.indentPop();
+                    emitter.write("\n");
+                }
+                emitter.write("}");
+            }
+            else if (type == ContainerType.IMPLICIT
+                    || type == ContainerType.SYNTHESIZED)
+            {
+                if (node.getChildCount() != 0)
+                {
+                    emitter.indentPop();
+                }
+            }
+        }
+    }
+}

Propchange: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASAfterNodeStrategy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASBeforeNodeStrategy.java
URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASBeforeNodeStrategy.java?rev=1426489&view=auto
==============================================================================
--- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASBeforeNodeStrategy.java (added)
+++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASBeforeNodeStrategy.java Fri Dec 28 12:59:00 2012
@@ -0,0 +1,73 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.as.codegen;
+
+import org.apache.flex.compiler.as.codegen.IASEmitter;
+import org.apache.flex.compiler.tree.ASTNodeID;
+import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.as.IContainerNode;
+import org.apache.flex.compiler.tree.as.IContainerNode.ContainerType;
+import org.apache.flex.compiler.visitor.IASNodeStrategy;
+
+/**
+ * A concrete implementation of the {@link IASNodeStrategy} that allows
+ * {@link IASNode} processing before the current node handler.
+ * 
+ * @author Michael Schmalle
+ */
+public class ASBeforeNodeStrategy implements IASNodeStrategy
+{
+    private final IASEmitter emitter;
+
+    public ASBeforeNodeStrategy(IASEmitter emitter)
+    {
+        this.emitter = emitter;
+    }
+
+    @Override
+    public void handle(IASNode node)
+    {
+        if (node.getNodeID() == ASTNodeID.BlockID)
+        {
+            IASNode parent = node.getParent();
+            IContainerNode container = (IContainerNode) node;
+            ContainerType type = container.getContainerType();
+
+            if (parent.getNodeID() != ASTNodeID.LabledStatementID)
+            {
+                if (node.getChildCount() != 0)
+                    emitter.indentPush();
+            }
+
+            // switch cases are SYNTHESIZED
+            if (type != ContainerType.IMPLICIT
+                    && type != ContainerType.SYNTHESIZED)
+            {
+                emitter.write("{");
+            }
+
+            if (parent.getNodeID() != ASTNodeID.LabledStatementID)
+            {
+                emitter.write("\n");
+            }
+        }
+    }
+
+}

Propchange: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx/src/org/apache/flex/compiler/internal/as/codegen/ASBeforeNodeStrategy.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message