<html>
<head>
<style><!--
body {background-color:#ffffff;}
.file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
.pathname {font-family:monospace; float:right;}
.fileheader {margin-bottom:.5em;}
.diff {margin:0;}
.tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
.tasklist ul {margin-top:0;margin-bottom:0;}
tr.alt {background-color:#eeeeee}
#added {background-color:#ddffdd;}
#addedchars {background-color:#99ff99;font-weight:bolder;}
tr.alt #added {background-color:#ccf7cc;}
#removed {background-color:#ffdddd;}
#removedchars {background-color:#ff9999;font-weight:bolder;}
tr.alt #removed {background-color:#f7cccc;}
#copied {background-color:#ccccff;}
tr.alt #copied {background-color:#bbbbf7;}
#info {color:#888888;}
#context {background-color:#eeeeee;}
td {padding-left:.3em;padding-right:.3em;}
tr.head {border-bottom-width:1px;border-bottom-style:solid;}
tr.head td {padding:0;padding-top:.2em;}
.task {background-color:#ffff00;}
.comment {white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;white-space:pre-wrap;word-wrap:break-word;padding:4px;border:1px dashed #000000;background-color:#ffffdd}
.error {color:red;}
hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="5">Commit in <b><tt>metaas/trunk/src</tt></b></td></tr>
<tr><td><tt>main/java/uk/co/badgersinfoil/metaas/<a href="#file1">ActionScriptFactory.java</a></tt> </td><td></td><td align="right" id="added">+8</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">618 -> 619</td></tr>
<tr class="alt"><td><tt>main/java/uk/co/badgersinfoil/metaas/dom/<a href="#file2"><span id="added">ASFunctionExpression.java</span></a></tt> </td><td></td><td align="right" id="added">+5</td><td></td><td nowrap="nowrap" align="right">added 619</td></tr>
<tr><td><tt> /<a href="#file3">ASMethod.java</a></tt> </td><td></td><td align="right" id="added">+3</td><td align="right" id="removed">-77</td><td nowrap="nowrap" align="center">618 -> 619</td></tr>
<tr class="alt"><td><tt> /<a href="#file4"><span id="added">FunctionCommon.java</span></a></tt> </td><td></td><td align="right" id="added">+73</td><td></td><td nowrap="nowrap" align="right">added 619</td></tr>
<tr><td><tt>main/java/uk/co/badgersinfoil/metaas/impl/<a href="#file5">ASTASArg.java</a></tt> </td><td></td><td align="right" id="added">+1</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">618 -> 619</td></tr>
<tr class="alt"><td><tt> /<a href="#file6"><span id="added">ASTASFunctionExpression.java</span></a></tt> </td><td></td><td align="right" id="added">+194</td><td></td><td nowrap="nowrap" align="right">added 619</td></tr>
<tr><td><tt> /<a href="#file7">ASTASMethod.java</a></tt> </td><td></td><td align="right" id="added">+8</td><td align="right" id="removed">-81</td><td nowrap="nowrap" align="center">618 -> 619</td></tr>
<tr class="alt"><td><tt> /<a href="#file8">ASTBuilder.java</a></tt> </td><td></td><td align="right" id="added">+12</td><td></td><td nowrap="nowrap" align="center">618 -> 619</td></tr>
<tr><td><tt> /<a href="#file9"><span id="added">ASTFunctionCommon.java</span></a></tt> </td><td></td><td align="right" id="added">+114</td><td></td><td nowrap="nowrap" align="right">added 619</td></tr>
<tr class="alt"><td><tt> /<a href="#file10">ExpressionBuilder.java</a></tt> </td><td></td><td align="right" id="added">+2</td><td></td><td nowrap="nowrap" align="center">618 -> 619</td></tr>
<tr><td><tt>test/java/uk/co/badgersinfoil/metaas/<a href="#file11"><span id="added">FunctionExpressionTests.java</span></a></tt> </td><td></td><td align="right" id="added">+49</td><td></td><td nowrap="nowrap" align="right">added 619</td></tr>
<tr><td></td><td></td><td align="right" id="added">+469</td><td align="right" id="removed">-160</td><td></td></tr>
</table>
<small id="info">5 added + 6 modified, total 11 files</small><br />
<div class="tasklist"><ul>
<li><a href="#task1">TODO: placeholder for name?</a></li>
</ul></div>
<pre class="comment">
Support for function-expression.
Reworking of ASMethod structure to factor out common code should still be
backwards compatable with old API.
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname">metaas/trunk/src/main/java/uk/co/badgersinfoil/metaas</span><br />
<div class="fileheader"><big><b>ActionScriptFactory.java</b></big> <small id="info">618 -> 619</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/metaas/ActionScriptFactory.java        2008-01-20 00:43:41 UTC (rev 618)
+++ trunk/src/main/java/uk/co/badgersinfoil/metaas/ActionScriptFactory.java        2008-01-20 13:44:42 UTC (rev 619)
@@ -17,6 +17,7 @@
</small></pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.ASConditionalExpression;
import uk.co.badgersinfoil.metaas.dom.ASExpression;
import uk.co.badgersinfoil.metaas.dom.ASFieldAccessExpression;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.metaas.dom.ASFunctionExpression;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.ASInvocationExpression;
import uk.co.badgersinfoil.metaas.dom.ASNewExpression;
import uk.co.badgersinfoil.metaas.dom.ASNullLiteral;
</pre><pre class="diff"><small id="info">@@ -31,6 +32,7 @@
</small></pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.impl.ASTASConditionalExpression;
import uk.co.badgersinfoil.metaas.impl.ASTASExpression;
import uk.co.badgersinfoil.metaas.impl.ASTASFieldAccessExpression;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.metaas.impl.ASTASFunctionExpression;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.impl.ASTASInvocationExpression;
import uk.co.badgersinfoil.metaas.impl.ASTASNewExpression;
import uk.co.badgersinfoil.metaas.impl.ASTASNullLiteral;
</pre><pre class="diff"><small id="info">@@ -444,6 +446,11 @@
</small></pre><pre class="diff" id="context">         }
        private LinkedListTree ast(ASExpression expr) {
</pre><pre class="diff" id="removed">-                return ((ASTASExpression)expr).getAST();
</pre><pre class="diff" id="added">+                return ASTUtils.ast(expr);
</pre><pre class="diff" id="context">         }
</pre><pre class="diff" id="added">+
+        public ASFunctionExpression newFunctionExpression() {
+                LinkedListTree ast = ASTBuilder.newFunctionExpression();
+                return new ASTASFunctionExpression(ast);
+        }
</pre><pre class="diff" id="context"> }
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname" id="added">metaas/trunk/src/main/java/uk/co/badgersinfoil/metaas/dom</span><br />
<div class="fileheader" id="added"><big><b>ASFunctionExpression.java</b></big> <small id="info">added at 619</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/metaas/dom/ASFunctionExpression.java         (rev 0)
+++ trunk/src/main/java/uk/co/badgersinfoil/metaas/dom/ASFunctionExpression.java        2008-01-20 13:44:42 UTC (rev 619)
@@ -0,0 +1,5 @@
</small></pre><pre class="diff" id="added">+package uk.co.badgersinfoil.metaas.dom;
+
+public interface ASFunctionExpression extends ASExpression, FunctionCommon, StatementContainer {
+
+}
</pre></div>
<hr /><a name="file3" /><div class="file">
<span class="pathname">metaas/trunk/src/main/java/uk/co/badgersinfoil/metaas/dom</span><br />
<div class="fileheader"><big><b>ASMethod.java</b></big> <small id="info">618 -> 619</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/metaas/dom/ASMethod.java        2008-01-20 00:43:41 UTC (rev 618)
+++ trunk/src/main/java/uk/co/badgersinfoil/metaas/dom/ASMethod.java        2008-01-20 13:44:42 UTC (rev 619)
@@ -6,20 +6,18 @@
</small></pre><pre class="diff" id="context">
package uk.co.badgersinfoil.metaas.dom;
</pre><pre class="diff" id="removed">-import java.util.List;
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">-
</pre><pre class="diff" id="context"> /**
* Represents an ActionScript method definition within an ActionScript class or
* interface.
*
* @see ASType#newMethod(String, Visibility, String)
*/
</pre><pre class="diff" id="removed">-public interface ASMethod extends StatementContainer, ASMember {
</pre><pre class="diff" id="added">+public interface ASMethod extends <span id="addedchars">FunctionCommon, </span>StatementContainer, ASMember {
</pre><pre class="diff" id="context">
        /**
         * Constants defined by this class denote whether a method is actually
</pre><pre class="diff" id="removed">-         * an acessor 'get' or 'set' function.
</pre><pre class="diff" id="added">+         * an ac<span id="addedchars">c</span>essor 'get' or 'set' function.
</pre><pre class="diff" id="context">          *
         * @see ASMethod#getAccessorRole()
         * @see ASMethod#setAccessorRole(AccessorRole)
</pre><pre class="diff"><small id="info">@@ -45,32 +43,6 @@
</small></pre><pre class="diff" id="context">         }
        /**
</pre><pre class="diff" id="removed">-         * Returns the name of this method.
-         */
-        public String getName();
-        
-        /**
-         * Returns a list of the formal arguments accepted by this ActionScript
-         * method. Note that the resulting list is not modifiable.
-         *
-         * @see #addParam(String, String)
-         */
-        public List getArgs();
-
-        /**
-         * Returns the name of the return type of this ActionScript
-         * method, or null if it is untyped.
-         */
-        public String getType();
-
-        /**
-         * Defines the name of the type of object returned by this ActionScript
-         * method. May be set to null, denoting that the return value is
-         * untyped.
-         */
-        public void setType(String string);
-
-        /**
</pre><pre class="diff" id="context">          * Returns a value representing any protection-against-access defined
         * for this ActionScript method.
         */
</pre><pre class="diff"><small id="info">@@ -94,55 +66,9 @@
</small></pre><pre class="diff" id="context">         public void setStatic(boolean s);
        /**
</pre><pre class="diff" id="removed">-         * Adds a formal parameter to the list of parameters supported by this
-         * ActionScript method.
-         *
-         * @param name The name for the parameter
-         * @param type The type for the parameter, or null if the parameter is
-         * to be untyped
-         * @return the newly created paremeter
-         *
-         * @see #addRestParam(String)
-         */
-        public ASArg addParam(String name, String type);
-
-        /**
-         * Adds a 'rest' parameter to the list of parameters supported by this
-         * ActionScript method.
-         *
-         * <p>e.g. The java code,</p>
-         * <pre class="eg">ASMethod meth = class.newMethod("test", Visibility.PUBLIC, "void");
-         *meth.addRestParam("foo");</pre>
-         * <p>will result in ActionScript code like,</p>
-         * <pre class="eg">public function test(...foo):void {
-         *}</pre>
-         *
-         * <p>To create an anonymous 'rest' parameter, pass the name "..."
-         * (this name can also be passed to removeParam() to remove an
-         * anonymous rest parameter).</p>
-         *
-         * @return the newly created paremeter
-         *
-         * @see #addParam(String,String)
-         */
-        public ASArg addRestParam(String name);
-
-        /**
-         * Removes the named parameter from this ActionScript methods formal
-         * parameter list. In the case of a 'rest' parameter, give the name
-         * of the parameter without the elipsis prefix (i.e. if the parameter
-         * is declared as "...foo", pass the name "foo" to this method).
-         * To remove an anonymous 'rest' parameter, pass the string "..." as
-         * the argument to this method.
-         *
-         * @return the removed parameter, if found, or null otherwise.
-         */
-        public ASArg removeParam(String string);
-
-        /**
</pre><pre class="diff" id="context">          * Returns on of {@link AccessorRole#NORMAL_METHOD},
         * {@link AccessorRole#GETTER} or {@link AccessorRole#SETTER}, with
</pre><pre class="diff" id="removed">-         * NORMAL_METHOD being the default for newly synthesi<span id="removedchars">z</span>ed methods.
</pre><pre class="diff" id="added">+         * NORMAL_METHOD being the default for newly synthesi<span id="addedchars">s</span>ed methods.
</pre><pre class="diff" id="context">          */
        public AccessorRole getAccessorRole();
</pre></div>
<hr /><a name="file4" /><div class="file">
<span class="pathname" id="added">metaas/trunk/src/main/java/uk/co/badgersinfoil/metaas/dom</span><br />
<div class="fileheader" id="added"><big><b>FunctionCommon.java</b></big> <small id="info">added at 619</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/metaas/dom/FunctionCommon.java         (rev 0)
+++ trunk/src/main/java/uk/co/badgersinfoil/metaas/dom/FunctionCommon.java        2008-01-20 13:44:42 UTC (rev 619)
@@ -0,0 +1,73 @@
</small></pre><pre class="diff" id="added">+package uk.co.badgersinfoil.metaas.dom;
+
+import java.util.List;
+
+public interface FunctionCommon {
+
+        /**
+         * Returns a list of the formal arguments accepted by this ActionScript
+         * method. Note that the resulting list is not modifiable.
+         *
+         * @see #addParam(String, String)
+         */
+        public List getArgs();
+
+        /**
+         * Returns the name of the return type of this ActionScript
+         * method, or null if it is untyped.
+         */
+        public String getType();
+
+        /**
+         * Defines the name of the type of object returned by this ActionScript
+         * method. May be set to null, denoting that the return value is
+         * untyped.
+         */
+        public void setType(String string);
+
+        /**
+         * Adds a formal parameter to the list of parameters supported by this
+         * ActionScript method.
+         *
+         * @param name The name for the parameter
+         * @param type The type for the parameter, or null if the parameter is
+         * to be untyped
+         * @return the newly created parameter
+         *
+         * @see #addRestParam(String)
+         */
+        public ASArg addParam(String name, String type);
+
+        /**
+         * Adds a 'rest' parameter to the list of parameters supported by this
+         * ActionScript method.
+         *
+         * <p>e.g. The java code,</p>
+         * <pre class="eg">ASMethod meth = class.newMethod("test", Visibility.PUBLIC, "void");
+         *meth.addRestParam("foo");</pre>
+         * <p>will result in ActionScript code like,</p>
+         * <pre class="eg">public function test(...foo):void {
+         *}</pre>
+         *
+         * <p>To create an anonymous 'rest' parameter, pass the name "..."
+         * (this name can also be passed to removeParam() to remove an
+         * anonymous rest parameter).</p>
+         *
+         * @return the newly created parameter
+         *
+         * @see #addParam(String,String)
+         */
+        public ASArg addRestParam(String name);
+
+        /**
+         * Removes the named parameter from this ActionScript methods formal
+         * parameter list. In the case of a 'rest' parameter, give the name
+         * of the parameter without the ellipsis prefix (i.e. if the parameter
+         * is declared as "...foo", pass the name "foo" to this method).
+         * To remove an anonymous 'rest' parameter, pass the string "..." as
+         * the argument to this method.
+         *
+         * @return the removed parameter, if found, or null otherwise.
+         */
+        public ASArg removeParam(String string);
+}
</pre></div>
<hr /><a name="file5" /><div class="file">
<span class="pathname">metaas/trunk/src/main/java/uk/co/badgersinfoil/metaas/impl</span><br />
<div class="fileheader"><big><b>ASTASArg.java</b></big> <small id="info">618 -> 619</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/ASTASArg.java        2008-01-20 00:43:41 UTC (rev 618)
+++ trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/ASTASArg.java        2008-01-20 13:44:42 UTC (rev 619)
@@ -26,7 +26,7 @@
</small></pre><pre class="diff" id="context">                 LinkedListTree name = ASTUtils.findChildByType(ast, AS3Parser.IDENT);
                if (name == null) {
                        if (isRest()) {
</pre><pre class="diff" id="removed">-                                return ASTASMethod.ELLIPSIS;
</pre><pre class="diff" id="added">+                                return ASTFunctionCommon.ELLIPSIS;
</pre><pre class="diff" id="context">                         }
                        throw new IllegalStateException("No parameter name, and not a 'rest' parameter");
                }
</pre></div>
<hr /><a name="file6" /><div class="file">
<span class="pathname" id="added">metaas/trunk/src/main/java/uk/co/badgersinfoil/metaas/impl</span><br />
<div class="fileheader" id="added"><big><b>ASTASFunctionExpression.java</b></big> <small id="info">added at 619</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/ASTASFunctionExpression.java         (rev 0)
+++ trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/ASTASFunctionExpression.java        2008-01-20 13:44:42 UTC (rev 619)
@@ -0,0 +1,194 @@
</small></pre><pre class="diff" id="added">+package uk.co.badgersinfoil.metaas.impl;
+
+import java.util.List;
+import org.asdt.core.internal.antlr.AS3Parser;
+import uk.co.badgersinfoil.metaas.dom.ASArg;
+import uk.co.badgersinfoil.metaas.dom.ASBreakStatement;
+import uk.co.badgersinfoil.metaas.dom.ASContinueStatement;
+import uk.co.badgersinfoil.metaas.dom.ASDeclarationStatement;
+import uk.co.badgersinfoil.metaas.dom.ASDoWhileStatement;
+import uk.co.badgersinfoil.metaas.dom.ASExpression;
+import uk.co.badgersinfoil.metaas.dom.ASExpressionStatement;
+import uk.co.badgersinfoil.metaas.dom.ASForEachInStatement;
+import uk.co.badgersinfoil.metaas.dom.ASForInStatement;
+import uk.co.badgersinfoil.metaas.dom.ASForStatement;
+import uk.co.badgersinfoil.metaas.dom.ASFunctionExpression;
+import uk.co.badgersinfoil.metaas.dom.ASIfStatement;
+import uk.co.badgersinfoil.metaas.dom.ASMethod;
+import uk.co.badgersinfoil.metaas.dom.ASReturnStatement;
+import uk.co.badgersinfoil.metaas.dom.ASSuperStatement;
+import uk.co.badgersinfoil.metaas.dom.ASSwitchStatement;
+import uk.co.badgersinfoil.metaas.dom.ASTryStatement;
+import uk.co.badgersinfoil.metaas.dom.ASWhileStatement;
+import uk.co.badgersinfoil.metaas.dom.ASWithStatement;
+import uk.co.badgersinfoil.metaas.dom.Statement;
+import uk.co.badgersinfoil.metaas.impl.antlr.LinkedListTree;
+
+public class ASTASFunctionExpression extends ASTASExpression implements ASFunctionExpression {
+
+        ASTFunctionCommon funcMixin;
+        ASTStatementList stmtListMixin;
+
+        public ASTASFunctionExpression(LinkedListTree ast) {
+                super(ast);
+                stmtListMixin = new ASTStatementList(ASTUtils.findChildByType(ast, AS3Parser.BLOCK));
+                funcMixin = new ASTFunctionCommon(ast);
+        }
+
+        public ASArg addParam(String name, String type) {
+                return funcMixin.addParam(name, type);
+        }
+
+        public ASArg addRestParam(String name) {
+                return funcMixin.addRestParam(name);
+        }
+
+        public List getArgs() {
+                return funcMixin.getArgs();
+        }
+
+        public String getType() {
+                return funcMixin.getType();
+        }
+
+        public ASArg removeParam(String name) {
+                return funcMixin.removeParam(name);
+        }
+
+        public void setType(String typeName) {
+                funcMixin.setType(typeName);
+        }
+
+        public void addComment(String text) {
+                stmtListMixin.addComment(text);
+        }
+
+        public Statement addStmt(String statement) {
+                return stmtListMixin.addStmt(statement);
+        }
+
+        public boolean containsCode() {
+                return stmtListMixin.containsCode();
+        }
+
+        public List getStatementList() {
+                return stmtListMixin.getStatementList();
+        }
+
+        public ASBreakStatement newBreak() {
+                return stmtListMixin.newBreak();
+        }
+
+        public ASContinueStatement newContinue() {
+                return stmtListMixin.newContinue();
+        }
+
+        public ASDeclarationStatement newDeclaration(ASExpression assignment) {
+                return stmtListMixin.newDeclaration(assignment);
+        }
+
+        public ASDeclarationStatement newDeclaration(String assignment) {
+                return stmtListMixin.newDeclaration(assignment);
+        }
+
+        public ASDoWhileStatement newDoWhile(ASExpression condition) {
+                return stmtListMixin.newDoWhile(condition);
+        }
+
+        public ASDoWhileStatement newDoWhile(String condition) {
+                return stmtListMixin.newDoWhile(condition);
+        }
+
+        public ASExpressionStatement newExprStmt(ASExpression expr) {
+                return stmtListMixin.newExprStmt(expr);
+        }
+
+        public ASExpressionStatement newExprStmt(String expr) {
+                return stmtListMixin.newExprStmt(expr);
+        }
+
+        public ASForStatement newFor(ASExpression init, ASExpression condition,
+                        ASExpression iterate) {
+                return stmtListMixin.newFor(init, condition, iterate);
+        }
+
+        public ASForStatement newFor(String init, String condition,
+                        String iterate) {
+                return stmtListMixin.newFor(init, condition, iterate);
+        }
+
+        public ASForEachInStatement newForEachIn(ASExpression declaration,
+                        ASExpression expression) {
+                return stmtListMixin.newForEachIn(declaration, expression);
+        }
+
+        public ASForEachInStatement newForEachIn(String declaration,
+                        String expression) {
+                return stmtListMixin.newForEachIn(declaration, expression);
+        }
+
+        public ASForInStatement newForIn(ASExpression declaration,
+                        ASExpression expression) {
+                return stmtListMixin.newForIn(declaration, expression);
+        }
+
+        public ASForInStatement newForIn(String declaration, String expression) {
+                return stmtListMixin.newForIn(declaration, expression);
+        }
+
+        public ASIfStatement newIf(ASExpression condition) {
+                return stmtListMixin.newIf(condition);
+        }
+
+        public ASIfStatement newIf(String condition) {
+                return stmtListMixin.newIf(condition);
+        }
+
+        public ASReturnStatement newReturn() {
+                return stmtListMixin.newReturn();
+        }
+
+        public ASReturnStatement newReturn(ASExpression expr) {
+                return stmtListMixin.newReturn(expr);
+        }
+
+        public ASReturnStatement newReturn(String expr) {
+                return stmtListMixin.newReturn(expr);
+        }
+
+        public ASSuperStatement newSuper(List args) {
+                return stmtListMixin.newSuper(args);
+        }
+
+        public ASSwitchStatement newSwitch(ASExpression condition) {
+                return stmtListMixin.newSwitch(condition);
+        }
+
+        public ASSwitchStatement newSwitch(String condition) {
+                return stmtListMixin.newSwitch(condition);
+        }
+
+        public ASTryStatement newTryCatch(String var, String type) {
+                return stmtListMixin.newTryCatch(var, type);
+        }
+
+        public ASTryStatement newTryFinally() {
+                return stmtListMixin.newTryFinally();
+        }
+
+        public ASWhileStatement newWhile(ASExpression condition) {
+                return stmtListMixin.newWhile(condition);
+        }
+
+        public ASWhileStatement newWhile(String condition) {
+                return stmtListMixin.newWhile(condition);
+        }
+
+        public ASWithStatement newWith(ASExpression expr) {
+                return stmtListMixin.newWith(expr);
+        }
+
+        public ASWithStatement newWith(String expr) {
+                return stmtListMixin.newWith(expr);
+        }
+}
</pre></div>
<hr /><a name="file7" /><div class="file">
<span class="pathname">metaas/trunk/src/main/java/uk/co/badgersinfoil/metaas/impl</span><br />
<div class="fileheader"><big><b>ASTASMethod.java</b></big> <small id="info">618 -> 619</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/ASTASMethod.java        2008-01-20 00:43:41 UTC (rev 618)
+++ trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/ASTASMethod.java        2008-01-20 13:44:42 UTC (rev 619)
@@ -6,13 +6,10 @@
</small></pre><pre class="diff" id="context">
package uk.co.badgersinfoil.metaas.impl;
</pre><pre class="diff" id="removed">-import java.util.Collections;
-import java.util.LinkedList;
</pre><pre class="diff" id="context"> import java.util.List;
import org.asdt.core.internal.antlr.AS3Parser;
import uk.co.badgersinfoil.metaas.SyntaxException;
import uk.co.badgersinfoil.metaas.dom.ASArg;
</pre><pre class="diff" id="removed">-import uk.co.badgersinfoil.metaas.dom.ASBinaryExpression;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.ASBreakStatement;
import uk.co.badgersinfoil.metaas.dom.ASContinueStatement;
import uk.co.badgersinfoil.metaas.dom.ASDeclarationStatement;
</pre><pre class="diff"><small id="info">@@ -37,9 +34,8 @@
</small></pre><pre class="diff" id="context">
public class ASTASMethod extends ASTASMember implements ASMethod {
</pre><pre class="diff" id="removed">-        public static final String ELLIPSIS = "...";
-
</pre><pre class="diff" id="context">         private ASTStatementList stmtList;
</pre><pre class="diff" id="added">+        private ASTFunctionCommon funcMixin;
</pre><pre class="diff" id="context">
        public ASTASMethod(LinkedListTree ast) {
                super(ast);
</pre><pre class="diff"><small id="info">@@ -48,6 +44,7 @@
</small></pre><pre class="diff" id="context">                         // class methods have BLOCK, interface methods don't,
                        stmtList = new ASTStatementList(block);
                }
</pre><pre class="diff" id="added">+                funcMixin = new ASTFunctionCommon(ast);
</pre><pre class="diff" id="context">         }
        public String getName() {
</pre><pre class="diff"><small id="info">@@ -70,34 +67,15 @@
</small></pre><pre class="diff" id="context">         }
        public List getArgs() {
</pre><pre class="diff" id="removed">-                List results = new LinkedList();
-                LinkedListTree params = ASTUtils.findChildByType(ast, AS3Parser.PARAMS);
-                for (ASTIterator i=new ASTIterator(params); i.hasNext(); ) {
-                        results.add(new ASTASArg(i.next()));
-                }
-                return Collections.unmodifiableList(results);
</pre><pre class="diff" id="added">+                return funcMixin.getArgs();
</pre><pre class="diff" id="context">         }
        public String getType() {
</pre><pre class="diff" id="removed">-                LinkedListTree typeSpec = ASTUtils.findChildByType(ast, AS3Parser.TYPE_SPEC);
-                if (typeSpec == null) return null;
-                return ASTUtils.typeSpecText(typeSpec);
</pre><pre class="diff" id="added">+                return funcMixin.getType();
</pre><pre class="diff" id="context">         }
        public void setType(String typeName) {
</pre><pre class="diff" id="removed">-                LinkedListTree type = ASTUtils.findChildByType(ast, AS3Parser.TYPE_SPEC);
-                if (typeName == null) {
-                        if (type != null) {
-                                ast.deleteChild(ast.getIndexOfChild(type));
-                        }
-                        return;
-                }
-                LinkedListTree newType = AS3FragmentParser.parseTypeSpec(typeName);
-                if (type == null) {
-                        ast.addChildWithTokens(ast.getChildCount()-1, newType);
-                } else {
-                        type.setChildWithTokens(0, newType.getFirstChild());
-                }
</pre><pre class="diff" id="added">+                funcMixin.setType(typeName);
</pre><pre class="diff" id="context">         }
        public Statement addStmt(String statement) {
</pre><pre class="diff"><small id="info">@@ -111,67 +89,16 @@
</small></pre><pre class="diff" id="context">                 return stmtList().newExprStmt(expr);
        }
</pre><pre class="diff" id="removed">-        private LinkedListTree findParams() {
-                return ASTUtils.findChildByType(ast, AS3Parser.PARAMS);
-        }
-
</pre><pre class="diff" id="context">         public ASArg addParam(String name, String type) {
</pre><pre class="diff" id="removed">-                LinkedListTree param = ASTUtils.newAST(AS3Parser.PARAM);
-                param.addChildWithTokens(ASTUtils.newAST(AS3Parser.IDENT, name));
-                if (type != null) {
-                        param.addChildWithTokens(AS3FragmentParser.parseTypeSpec(type));
-                }
-                return param(param);
</pre><pre class="diff" id="added">+                return funcMixin.addParam(name, type);
</pre><pre class="diff" id="context">         }
</pre><pre class="diff" id="removed">-        private ASArg param(LinkedListTree param) {
-                LinkedListTree params = findParams();
-                if (params.getChildCount() > 0) {
-                        params.appendToken(TokenBuilder.newComma());
-                        params.appendToken(TokenBuilder.newSpace());
-                }
-                params.addChildWithTokens(param);
-                return new ASTASArg(param);
-        }
-
</pre><pre class="diff" id="context">         public ASArg addRestParam(String name) {
</pre><pre class="diff" id="removed">-                if (ELLIPSIS.equals(name)) {
-                        return addAnonRestParam();
-                }
-                return addNamedRestParam(name);
</pre><pre class="diff" id="added">+                return funcMixin.addRestParam(name);
</pre><pre class="diff" id="context">         }
</pre><pre class="diff" id="removed">-        private ASArg addAnonRestParam() {
-                LinkedListTree param = ASTUtils.newAST(AS3Parser.PARAM);
-                param.addChildWithTokens(ASTUtils.newAST(AS3Parser.REST, ELLIPSIS));
-                return param(param);
-        }
-
-        private ASArg addNamedRestParam(String name) {
-                LinkedListTree param = ASTUtils.newAST(AS3Parser.PARAM);
-                param.addChildWithTokens(ASTUtils.newAST(AS3Parser.REST, ELLIPSIS));
-                param.addChildWithTokens(ASTUtils.newAST(AS3Parser.IDENT, name));
-                return param(param);
-        }
-
</pre><pre class="diff" id="context">         public ASArg removeParam(String name) {
</pre><pre class="diff" id="removed">-                LinkedListTree params = ASTUtils.findChildByType(ast, AS3Parser.PARAMS);
-                int count = 0;
-                for (ASTIterator i=new ASTIterator(params); i.hasNext(); ) {
-                        LinkedListTree ast = i.next();
-                        ASTASArg arg = new ASTASArg(ast);
-                        if (arg.getName().equals(name)) {
-                                if (i.hasNext()) {
-                                        ASTUtils.removeTrailingWhitespaceAndComma(ast.getStopToken());
-                                } else if (count > 0) {
-                                        ASTUtils.removePreceedingWhitespaceAndComma(ast.getStartToken());
-                                }
-                                i.remove();
-                                return arg;
-                        }
-                        count++;
-                }
-                return null;
</pre><pre class="diff" id="added">+                return funcMixin.removeParam(name);
</pre><pre class="diff" id="context">         }
        public void addComment(String text) {
</pre></div>
<hr /><a name="file8" /><div class="file">
<span class="pathname">metaas/trunk/src/main/java/uk/co/badgersinfoil/metaas/impl</span><br />
<div class="fileheader"><big><b>ASTBuilder.java</b></big> <small id="info">618 -> 619</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/ASTBuilder.java        2008-01-20 00:43:41 UTC (rev 618)
+++ trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/ASTBuilder.java        2008-01-20 13:44:42 UTC (rev 619)
@@ -585,4 +585,16 @@
</small></pre><pre class="diff" id="context">                 token.beforeInsert(TokenBuilder.newSpace());
                token.afterInsert(TokenBuilder.newSpace());
        }
</pre><pre class="diff" id="added">+
+        public static LinkedListTree newFunctionExpression() {
+                LinkedListTree def = ASTUtils.newImaginaryAST(AS3Parser.FUNC_DEF);
+                def.appendToken(TokenBuilder.newFunction());
+                def.appendToken(TokenBuilder.newSpace());
<a name="task1" />+                // <span class="task">TODO</span>: placeholder for name?
+                def.addChildWithTokens(ASTUtils.newParentheticAST(AS3Parser.PARAMS, AS3Parser.LPAREN, "(", AS3Parser.RPAREN, ")"));
+                def.appendToken(TokenBuilder.newSpace());
+                LinkedListTree block = newBlock();
+                def.addChildWithTokens(block);
+                return def;
+        }
</pre><pre class="diff" id="context"> }
</pre></div>
<hr /><a name="file9" /><div class="file">
<span class="pathname" id="added">metaas/trunk/src/main/java/uk/co/badgersinfoil/metaas/impl</span><br />
<div class="fileheader" id="added"><big><b>ASTFunctionCommon.java</b></big> <small id="info">added at 619</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/ASTFunctionCommon.java         (rev 0)
+++ trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/ASTFunctionCommon.java        2008-01-20 13:44:42 UTC (rev 619)
@@ -0,0 +1,114 @@
</small></pre><pre class="diff" id="added">+package uk.co.badgersinfoil.metaas.impl;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import org.asdt.core.internal.antlr.AS3Parser;
+import uk.co.badgersinfoil.metaas.SyntaxException;
+import uk.co.badgersinfoil.metaas.dom.ASArg;
+import uk.co.badgersinfoil.metaas.dom.FunctionCommon;
+import uk.co.badgersinfoil.metaas.impl.antlr.LinkedListTree;
+
+public class ASTFunctionCommon implements FunctionCommon {
+        public static final String ELLIPSIS = "...";
+
+        public LinkedListTree ast;
+        
+        public ASTFunctionCommon(LinkedListTree ast) {
+                this.ast = ast;
+        }
+
+        public List getArgs() {
+                List results = new LinkedList();
+                LinkedListTree params = ASTUtils.findChildByType(ast, AS3Parser.PARAMS);
+                for (ASTIterator i=new ASTIterator(params); i.hasNext(); ) {
+                        results.add(new ASTASArg(i.next()));
+                }
+                return Collections.unmodifiableList(results);
+        }
+
+        public String getType() {
+                LinkedListTree typeSpec = ASTUtils.findChildByType(ast, AS3Parser.TYPE_SPEC);
+                if (typeSpec == null) return null;
+                return ASTUtils.typeSpecText(typeSpec);
+        }
+
+        public void setType(String typeName) {
+                LinkedListTree type = ASTUtils.findChildByType(ast, AS3Parser.TYPE_SPEC);
+                if (typeName == null) {
+                        if (type != null) {
+                                ast.deleteChild(ast.getIndexOfChild(type));
+                        }
+                        return;
+                }
+                LinkedListTree newType = AS3FragmentParser.parseTypeSpec(typeName);
+                if (type == null) {
+                        ast.addChildWithTokens(ast.getChildCount()-1, newType);
+                } else {
+                        type.setChildWithTokens(0, newType.getFirstChild());
+                }
+        }
+
+        private LinkedListTree findParams() {
+                return ASTUtils.findChildByType(ast, AS3Parser.PARAMS);
+        }
+
+        public ASArg addParam(String name, String type) {
+                LinkedListTree param = ASTUtils.newAST(AS3Parser.PARAM);
+                param.addChildWithTokens(ASTUtils.newAST(AS3Parser.IDENT, name));
+                if (type != null) {
+                        param.addChildWithTokens(AS3FragmentParser.parseTypeSpec(type));
+                }
+                return param(param);
+        }
+
+        private ASArg param(LinkedListTree param) {
+                LinkedListTree params = findParams();
+                if (params.getChildCount() > 0) {
+                        params.appendToken(TokenBuilder.newComma());
+                        params.appendToken(TokenBuilder.newSpace());
+                }
+                params.addChildWithTokens(param);
+                return new ASTASArg(param);
+        }
+
+        public ASArg addRestParam(String name) {
+                if (ELLIPSIS.equals(name)) {
+                        return addAnonRestParam();
+                }
+                return addNamedRestParam(name);
+        }
+
+        private ASArg addAnonRestParam() {
+                LinkedListTree param = ASTUtils.newAST(AS3Parser.PARAM);
+                param.addChildWithTokens(ASTUtils.newAST(AS3Parser.REST, ELLIPSIS));
+                return param(param);
+        }
+
+        private ASArg addNamedRestParam(String name) {
+                LinkedListTree param = ASTUtils.newAST(AS3Parser.PARAM);
+                param.addChildWithTokens(ASTUtils.newAST(AS3Parser.REST, ELLIPSIS));
+                param.addChildWithTokens(ASTUtils.newAST(AS3Parser.IDENT, name));
+                return param(param);
+        }
+
+        public ASArg removeParam(String name) {
+                LinkedListTree params = ASTUtils.findChildByType(ast, AS3Parser.PARAMS);
+                int count = 0;
+                for (ASTIterator i=new ASTIterator(params); i.hasNext(); ) {
+                        LinkedListTree ast = i.next();
+                        ASTASArg arg = new ASTASArg(ast);
+                        if (arg.getName().equals(name)) {
+                                if (i.hasNext()) {
+                                        ASTUtils.removeTrailingWhitespaceAndComma(ast.getStopToken());
+                                } else if (count > 0) {
+                                        ASTUtils.removePreceedingWhitespaceAndComma(ast.getStartToken());
+                                }
+                                i.remove();
+                                return arg;
+                        }
+                        count++;
+                }
+                return null;
+        }
+}
</pre></div>
<hr /><a name="file10" /><div class="file">
<span class="pathname">metaas/trunk/src/main/java/uk/co/badgersinfoil/metaas/impl</span><br />
<div class="fileheader"><big><b>ExpressionBuilder.java</b></big> <small id="info">618 -> 619</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/ExpressionBuilder.java        2008-01-20 00:43:41 UTC (rev 618)
+++ trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/ExpressionBuilder.java        2008-01-20 13:44:42 UTC (rev 619)
@@ -76,6 +76,8 @@
</small></pre><pre class="diff" id="context">                                 return new ASTASConditionalExpression(ast);
                        case AS3Parser.UNDEFINED:
                                return new ASTASUndefinedLiteral(ast);
</pre><pre class="diff" id="added">+                        case AS3Parser.FUNC_DEF:
+                                return new ASTASFunctionExpression(ast);
</pre><pre class="diff" id="context">                         default:
                                throw new IllegalArgumentException("unhandled expression node type: "+ASTUtils.tokenName(ast));
                }
</pre></div>
<hr /><a name="file11" /><div class="file">
<span class="pathname" id="added">metaas/trunk/src/test/java/uk/co/badgersinfoil/metaas</span><br />
<div class="fileheader" id="added"><big><b>FunctionExpressionTests.java</b></big> <small id="info">added at 619</small></div>
<pre class="diff"><small id="info">--- trunk/src/test/java/uk/co/badgersinfoil/metaas/FunctionExpressionTests.java         (rev 0)
+++ trunk/src/test/java/uk/co/badgersinfoil/metaas/FunctionExpressionTests.java        2008-01-20 13:44:42 UTC (rev 619)
@@ -0,0 +1,49 @@
</small></pre><pre class="diff" id="added">+package uk.co.badgersinfoil.metaas;
+
+import java.io.IOException;
+import uk.co.badgersinfoil.metaas.dom.ASAssignmentExpression;
+import uk.co.badgersinfoil.metaas.dom.ASClassType;
+import uk.co.badgersinfoil.metaas.dom.ASCompilationUnit;
+import uk.co.badgersinfoil.metaas.dom.ASExpressionStatement;
+import uk.co.badgersinfoil.metaas.dom.ASFunctionExpression;
+import uk.co.badgersinfoil.metaas.dom.ASMethod;
+import uk.co.badgersinfoil.metaas.dom.Visibility;
+import junit.framework.TestCase;
+
+public class FunctionExpressionTests extends TestCase {
+        private ActionScriptFactory fact = new ActionScriptFactory();
+        private ASCompilationUnit unit;
+        private ASMethod meth;
+        private ASCompilationUnit reflect;
+
+        protected void setUp() {
+                unit = fact.newClass("Test");
+                ASClassType clazz = (ASClassType)unit.getType();
+                meth = clazz.newMethod("test", Visibility.PUBLIC, null);
+                reflect = null;
+        }
+
+        protected void tearDown() throws IOException {
+                if (reflect == null) {
+                        reflect = assertReflection();
+                }
+        }
+
+        private ASCompilationUnit assertReflection() throws IOException {
+                return CodeMirror.assertReflection(fact, unit);
+        }
+
+        public void testIt() {
+                ASFunctionExpression func = fact.newFunctionExpression();
+                assertNotNull(func);
+                func.addParam("foo", "String");
+                meth.newExprStmt(fact.newAssignExpression(fact.newExpression("myFunc"), func));
+                func.addStmt("trace('hello world')");
+        }
+
+        public void testParse() {
+                ASExpressionStatement exprStmt = (ASExpressionStatement)meth.addStmt("theFunc = function () { trace('foo!'); }");
+                ASAssignmentExpression assign = (ASAssignmentExpression)exprStmt.getExpression();
+                ExtraAssertions.assertInstanceof(assign.getRightSubexpression(), ASFunctionExpression.class);
+        }
+}
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -> email">CVSspam</a> 0.2.12</small></center>
</body></html>