changeset 1203:9597425b6b38

8074671: Nashorn Parser API Reviewed-by: darcy, forax, attila, hannesw
author sundar
date Mon, 09 Mar 2015 20:14:10 +0530
parents b4d62e7260a4
children dec3faccd3de
files make/build.xml make/nbproject/project.xml make/project.properties samples/evalcheck.js samples/withcheck.js src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ArrayAccessTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ArrayAccessTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ArrayLiteralTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ArrayLiteralTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/AssignmentTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/AssignmentTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/BinaryTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/BinaryTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/BlockTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/BlockTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/BreakTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/BreakTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CaseTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CaseTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CatchTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CatchTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CompilationUnitTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CompilationUnitTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CompoundAssignmentTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CompoundAssignmentTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ConditionalExpressionTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ConditionalExpressionTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ConditionalLoopTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ContinueTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ContinueTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/DebuggerTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/DebuggerTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/Diagnostic.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/DiagnosticImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/DiagnosticListener.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/DoWhileLoopTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/DoWhileLoopTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/EmptyStatementTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/EmptyStatementTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ErroneousTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ErroneousTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ExpressionStatementTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ExpressionStatementTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ExpressionTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ExpressionTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ForInLoopTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ForInLoopTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ForLoopTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ForLoopTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionCallTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionCallTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionDeclarationTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionDeclarationTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionExpressionTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionExpressionTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/GotoTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IRTranslator.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IdentifierTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IdentifierTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IfTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IfTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/InstanceOfTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/InstanceOfTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/LabeledStatementTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/LabeledStatementTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/LineMap.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/LineMapImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/LiteralTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/LiteralTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/LoopTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/MemberSelectTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/MemberSelectTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/NewTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/NewTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ObjectLiteralTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ObjectLiteralTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ParenthesizedTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/Parser.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ParserImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/PropertyTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/PropertyTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/RegExpLiteralTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/RegExpLiteralTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ReturnTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ReturnTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SimpleTreeVisitorES5_1.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/StatementTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/StatementTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SwitchTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SwitchTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ThrowTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ThrowTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/Tree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/TreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/TreeVisitor.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/TryTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/TryTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/UnaryTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/UnaryTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/UnknownTreeException.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/VariableTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/VariableTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/WhileLoopTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/WhileLoopTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/WithTree.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/WithTreeImpl.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/package-info.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Lower.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/Block.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/BlockStatement.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/DebuggerNode.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/ErrorNode.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/LiteralNode.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/debug/JSONWriter.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/visitor/NodeVisitor.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Source.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/options/Options.java test/script/basic/parser/tryCatchStat.js.EXPECTED test/script/basic/parser/util.js test/script/nosecurity/parserapi.js test/script/nosecurity/parserapi.js.EXPECTED test/script/nosecurity/parserapi_const_as_var.js test/script/nosecurity/parserapi_const_as_var.js.EXPECTED test/script/nosecurity/parserapi_empty_stat.js test/script/nosecurity/parserapi_empty_stat.js.EXPECTED test/script/nosecurity/parserapi_nse.js test/script/nosecurity/parserapi_nse.js.EXPECTED test/script/nosecurity/parserapi_scripting.js test/script/nosecurity/parserapi_scripting.js.EXPECTED test/script/nosecurity/parserapi_strict.js test/script/nosecurity/parserapi_strict.js.EXPECTED test/script/nosecurity/parsernegativetests/caseoutofswitch.js test/script/nosecurity/parsernegativetests/illegalbreak.js test/script/nosecurity/parsernegativetests/illegalcontinue.js test/script/nosecurity/parsernegativetests/illegallvalue.js test/script/nosecurity/parsernegativetests/illegaloperator.js test/script/nosecurity/parsernegativetests/keywordident.js test/script/nosecurity/parsernegativetests/parenmissing.js test/script/nosecurity/parsernegativetests/repeatedproperty.js test/script/nosecurity/parsernegativetests/strict_repeatedproperty.js test/script/nosecurity/parsernegativetests/strict_repeatparam.js test/script/nosecurity/parsernegativetests/strict_with.js test/script/nosecurity/parsernegativetests/toplevelreturn.js test/script/nosecurity/parsertests/array_literal.js test/script/nosecurity/parsertests/assignmentExpr.js test/script/nosecurity/parsertests/binaryExpr.js test/script/nosecurity/parsertests/block.js test/script/nosecurity/parsertests/breakStat.js test/script/nosecurity/parsertests/condExpr.js test/script/nosecurity/parsertests/continueStat.js test/script/nosecurity/parsertests/debuggerStat.js test/script/nosecurity/parsertests/functions.js test/script/nosecurity/parsertests/ifStat.js test/script/nosecurity/parsertests/labelledStat.js test/script/nosecurity/parsertests/lhsExpr.js test/script/nosecurity/parsertests/loopStat.js test/script/nosecurity/parsertests/objectLitExpr.js test/script/nosecurity/parsertests/parenExpr.js test/script/nosecurity/parsertests/primaryExpr.js test/script/nosecurity/parsertests/regexp_literal.js test/script/nosecurity/parsertests/returnStat.js test/script/nosecurity/parsertests/switchStat.js test/script/nosecurity/parsertests/throwStat.js test/script/nosecurity/parsertests/tryCatchStat.js test/script/nosecurity/parsertests/unaryExpr.js test/script/nosecurity/parsertests/useStrict.js test/script/nosecurity/parsertests/varDecl.js test/script/nosecurity/parsertests/withStat.js test/script/nosecurity/parservisitor.js test/script/nosecurity/parservisitor.js.EXPECTED test/src/jdk/nashorn/api/tree/ParseAPITest.java test/src/jdk/nashorn/internal/codegen/CompilerTest.java test/src/jdk/nashorn/internal/parser/ParserTest.java
diffstat 174 files changed, 17889 insertions(+), 313 deletions(-) [+]
line wrap: on
line diff
--- a/make/build.xml	Mon Mar 09 11:34:48 2015 +0100
+++ b/make/build.xml	Mon Mar 09 20:14:10 2015 +0530
@@ -98,7 +98,7 @@
     <fail message="Unsupported Java version: ${ant.java.version}. Please use Java version 1.8 or greater." unless="jdk1.8+">
     </fail>
   </target>
-  
+
   <target name="init" depends="check-ant-version, check-java-version, init-conditions, init-cc">
     <!-- extends jvm args -->
     <property name="run.test.jvmargs" value="${run.test.jvmargs.main} ${run.test.cc.jvmargs} ${jfr.options}"/>
@@ -209,7 +209,7 @@
   </target>
 
   <target name="javadoc" depends="jar">
-    <javadoc destdir="${dist.javadoc.dir}" use="yes" overview="${src.dir}/overview.html" 
+    <javadoc destdir="${dist.javadoc.dir}" use="yes" overview="${src.dir}/overview.html"
         extdirs="${nashorn.ext.path}" windowtitle="${nashorn.product.name} ${nashorn.version}"
         additionalparam="-quiet" failonerror="true">
       <classpath>
@@ -227,7 +227,7 @@
 
   <!-- generate javadoc only for nashorn extension api classes -->
   <target name="javadocapi" depends="jar">
-    <javadoc destdir="${dist.javadoc.dir}" use="yes" extdirs="${nashorn.ext.path}" 
+    <javadoc destdir="${dist.javadoc.dir}" use="yes" extdirs="${nashorn.ext.path}"
         windowtitle="${nashorn.product.name}" additionalparam="-quiet" failonerror="true">
       <classpath>
         <pathelement location="${build.classes.dir}"/>
@@ -314,6 +314,15 @@
     permission java.security.AllPermission;
 };
 
+grant codeBase "file:/${basedir}/${nashorn.api.tests.jar}" {
+    permission java.util.PropertyPermission "parserapitest.*", "read";
+    permission java.util.PropertyPermission "test.*", "read";
+    permission java.util.PropertyPermission "test262.*", "read";
+    permission java.io.FilePermission "${basedir}/test/-","read";
+    permission java.io.FilePermission "$${user.dir}", "read";
+    permission java.util.PropertyPermission "user.dir", "read";
+};
+
 grant codeBase "file:/${basedir}/${file.reference.testng.jar}" {
     permission java.security.AllPermission;
 };
@@ -395,6 +404,7 @@
       <fileset id="test.classes" dir="${build.test.classes.dir}">
           <include name="**/api/javaaccess/*Test.class"/>
           <include name="**/api/scripting/*Test.class"/>
+          <include name="**/api/tree/*Test.class"/>
           <include name="**/codegen/*Test.class"/>
           <include name="**/parser/*Test.class"/>
           <include name="**/runtime/*Test.class"/>
@@ -440,7 +450,7 @@
     <delete dir="${build.dir}/nashorn_code_cache"/>
     <property name="debug.test.jvmargs" value=""/>
     <testng outputdir="${build.test.results.dir}/${testResultsSubDir}" classfilesetref="test.classes"
-	    verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
+            verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
       <jvmarg line="${boot.class.path}"/>
       <jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/>
       <jvmarg line="${debug.test.jvmargs}"/>
@@ -466,7 +476,7 @@
     <antcall target="-test-nosecurity" inheritRefs="true">
       <param name="optimistic" value="true"/>
       <param name="testResultsSubDir" value="optimistic"/>
-    </antcall>    
+    </antcall>
     <antcall target="-test-security" inheritRefs="true">
       <param name="optimistic" value="true"/>
       <param name="testResultsSubDir" value="optimistic"/>
@@ -478,7 +488,7 @@
     <antcall target="-test-nosecurity" inheritRefs="true">
       <param name="optimistic" value="false"/>
       <param name="testResultsSubDir" value="pessimistic"/>
-    </antcall>    
+    </antcall>
     <antcall target="-test-security" inheritRefs="true">
       <param name="optimistic" value="false"/>
       <param name="testResultsSubDir" value="pessimistic"/>
--- a/make/nbproject/project.xml	Mon Mar 09 11:34:48 2015 +0100
+++ b/make/nbproject/project.xml	Mon Mar 09 20:14:10 2015 +0530
@@ -2,21 +2,21 @@
 <!--
  Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- 
+
  This code is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License version 2 only, as
  published by the Free Software Foundation.
- 
+
  This code is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  version 2 for more details (a copy is included in the LICENSE file that
  accompanied this code).
- 
+
  You should have received a copy of the GNU General Public License version
  2 along with this work; if not, write to the Free Software Foundation,
  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- 
+
  Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  or visit www.oracle.com if you need additional information or have any
  questions.
@@ -155,7 +155,7 @@
             </view>
             <subprojects/>
         </general-data>
-        <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/3">
+        <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/4">
             <compilation-unit>
                 <package-root>../test/src</package-root>
                 <unit-tests/>
--- a/make/project.properties	Mon Mar 09 11:34:48 2015 +0100
+++ b/make/project.properties	Mon Mar 09 20:14:10 2015 +0530
@@ -1,21 +1,21 @@
 #
 # Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-# 
+#
 # This code is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License version 2 only, as
 # published by the Free Software Foundation.
-# 
+#
 # This code is distributed in the hope that it will be useful, but WITHOUT
 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 # version 2 for more details (a copy is included in the LICENSE file that
 # accompanied this code).
-# 
+#
 # You should have received a copy of the GNU General Public License version
 # 2 along with this work; if not, write to the Free Software Foundation,
 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-# 
+#
 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 # or visit www.oracle.com if you need additional information or have any
 # questions.
@@ -81,8 +81,8 @@
 file.reference.testng.jar=test/lib/testng.jar
 
 # Set testng verbose level
-# From TestNG docs: "the verbosity level (0 to 10 where 10 is most detailed) 
-# Actually, this is a lie: you can specify -1 and this will put TestNG in 
+# From TestNG docs: "the verbosity level (0 to 10 where 10 is most detailed)
+# Actually, this is a lie: you can specify -1 and this will put TestNG in
 # debug mode (no longer slicing off stack traces and all)."
 
 testng.verbose=2
@@ -134,6 +134,10 @@
 test-sys-prop.test262.suite.dir=${test262.suite.dir}
 test-sys-prop.es5conform.testcases.dir=${test.external.dir}/ES5Conform/TestCases
 test-sys-prop.test.basic.dir=${test.basic.dir}
+test-sys-prop.test.external.dir=${test.external.dir}
+test-sys-prop.test.maptests.dir=${test.maptests.dir}
+test-sys-prop.test.sandbox.dir=${test.sandbox.dir}
+test-sys-prop.test.trusted.dir=${test.trusted.dir}
 
 test-sys-prop-no-security.test.dir=${test.dir}
 test-sys-prop-no-security.test.js.roots=${test.nosecurity.dir}
@@ -147,9 +151,11 @@
 
 # turn on/off scripting mode for parser tests
 test-sys-prop.parsertest.scripting=true
+test-sys-prop.parserapitest.verbose=false
 
 # turn on/off test262 scripts for parser tests
 test-sys-prop.parsertest.test262=false
+test-sys-prop.parserapitest.test262=false
 
 # Control the verbosity of the CompilerTest
 test-sys-prop.compilertest.verbose=false
@@ -289,19 +295,19 @@
 # Extra jvmargs that might be useful for debugging
 # and performance improvements/monitoring
 #
-# -XX:+UnlockDiagnosticVMOptions 
+# -XX:+UnlockDiagnosticVMOptions
 #
 # turn off compressed class pointers in metaspace
-# -XX:-UseCompressedKlassPointers  
+# -XX:-UseCompressedKlassPointers
 #
 # dump the heap after every GC
 # -XX:+PrintHeapAtGC
 #
-# manually set a metaspace size for class data 
+# manually set a metaspace size for class data
 # -XX:ClassMetaspaceSize=300M
 #
 # print out methods compiled
-# -XX:+PrintCompilation 
+# -XX:+PrintCompilation
 #
 # print all compiled nmethods with oopmaps and lots of other info
 # -XX:+PrintNMethods
@@ -311,7 +317,7 @@
 # feature in HotSpot - for example, the uncommon trap placement fix
 # was hidden behind this flag before it became the default
 #
-# -XX:+UnlockDiagnosticVMOptions -XX:+UseNewCode 
+# -XX:+UnlockDiagnosticVMOptions -XX:+UseNewCode
 #
 # Crank up the type profile level to 222, which has some warmup
 # penalties, but produces much better code for JavaScript, where better
@@ -342,7 +348,7 @@
 octane.iterations=25
 
 # List of octane tests to run, as properties prefixed with
-# "octane.benchmark." mapping to the benchmark name in 
+# "octane.benchmark." mapping to the benchmark name in
 # the test harness
 #
 # Octane tests that are disabled should have their entire line
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samples/evalcheck.js	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+// Simple demo of Nashorn Parser API
+
+var Parser = Java.type("jdk.nashorn.api.tree.Parser");
+var SimpleTreeVisitor = Java.type("jdk.nashorn.api.tree.SimpleTreeVisitorES5_1");
+var IdentifierTree = Java.type("jdk.nashorn.api.tree.IdentifierTree");
+
+var parser = Parser.create();
+var ast = parser.parse("t", "eval('hello');\n  eval(2 + 3)", print);
+// locate 'eval' calls in the script
+ast.accept(visitor = new (Java.extend(SimpleTreeVisitor)) {
+    lineMap: null,
+    visitCompilationUnit: function(node, extra) {
+        this.lineMap = node.lineMap;
+        Java.super(visitor).visitCompilationUnit(node, extra);
+    },
+
+    visitFunctionCall: function(node, extra) {
+       var func = node.functionSelect;
+       if (func instanceof IdentifierTree && func.name == "eval") {
+           var pos = node.startPosition;
+           var line = this.lineMap.getLineNumber(pos);
+           var column = this.lineMap.getColumnNumber(pos);
+           print("eval call found @ " + line + ":" + column);
+       } 
+    } 
+}, null);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samples/withcheck.js	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+// Simple demo of Nashorn Parser API
+
+var Parser = Java.type("jdk.nashorn.api.tree.Parser");
+var parser = Parser.create("-strict");
+// you'll get diagnostic message for 'with'
+parser.parse("t", "with({}){}", print);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ArrayAccessTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for an array access expression.
+ *
+ * For example:
+ * <pre>
+ *   <em>expression</em> [ <em>index</em> ]
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface ArrayAccessTree extends ExpressionTree {
+    /**
+     * Returns the array that is accessed.
+     *
+     * @return the array that is accessed
+     */
+    ExpressionTree getExpression();
+
+    /**
+     * Returns the index of the array element accessed.
+     *
+     * @return the index expression
+     */
+    ExpressionTree getIndex();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ArrayAccessTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.Expression;
+
+final class ArrayAccessTreeImpl extends ExpressionTreeImpl implements ArrayAccessTree {
+
+    private final ExpressionTree base, index;
+
+    ArrayAccessTreeImpl(final Expression node, final ExpressionTree base, final ExpressionTree index) {
+        super(node);
+        this.base = base;
+        this.index = index;
+    }
+
+    @Override
+    public Tree.Kind getKind() {
+        return Tree.Kind.ARRAY_ACCESS;
+    }
+
+    @Override
+    public ExpressionTree getExpression() {
+        return base;
+    }
+
+    @Override
+    public ExpressionTree getIndex() {
+        return index;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitArrayAccess(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ArrayLiteralTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.util.List;
+
+/**
+ * Represents ECMAScript array literal expression.
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface ArrayLiteralTree extends ExpressionTree {
+    /**
+     * Returns the list of Array element expressions.
+     *
+     * @return array element expressions
+     */
+    public List<? extends ExpressionTree> getElements();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ArrayLiteralTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.util.List;
+import jdk.nashorn.internal.ir.LiteralNode;
+
+final class ArrayLiteralTreeImpl extends ExpressionTreeImpl
+    implements ArrayLiteralTree {
+    private final List<? extends ExpressionTree> elements;
+    ArrayLiteralTreeImpl(final LiteralNode<?> node, final List<? extends ExpressionTree> elements) {
+        super(node);
+        this.elements = elements;
+    }
+
+    @Override
+    public Tree.Kind getKind() {
+        return Tree.Kind.ARRAY_LITERAL;
+    }
+
+    @Override
+    public List<? extends ExpressionTree> getElements() {
+        return elements;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitArrayLiteral(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/AssignmentTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for an assignment expression.
+ *
+ * For example:
+ * <pre>
+ *   <em>variable</em> = <em>expression</em>
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface AssignmentTree extends ExpressionTree {
+    /**
+     * Returns the left hand side (LHS) of this assignment.
+     *
+     * @return left hand side (LHS) expression
+     */
+    ExpressionTree getVariable();
+
+    /**
+     * Returns the right hand side (RHS) of this assignment.
+     *
+     * @return right hand side (RHS) expression
+     */
+    ExpressionTree getExpression();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/AssignmentTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.BinaryNode;
+
+final class AssignmentTreeImpl extends ExpressionTreeImpl implements AssignmentTree {
+    private final Tree.Kind kind;
+    private final ExpressionTree var, expr;
+
+    AssignmentTreeImpl(final BinaryNode node, final ExpressionTree left, final ExpressionTree right) {
+        super(node);
+        assert node.isAssignment() : "assignment node expected";
+        this.var = left;
+        this.expr = right;
+        this.kind = getOperator(node.tokenType());
+    }
+
+    @Override
+    public Tree.Kind getKind() {
+        return kind;
+    }
+
+    @Override
+    public ExpressionTree getVariable() {
+        return var;
+    }
+
+    @Override
+    public ExpressionTree getExpression() {
+        return expr;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitAssignment(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/BinaryTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for a binary expression.
+ * Use {@link #getKind getKind} to determine the kind of operator.
+ *
+ * For example:
+ * <pre>
+ *   <em>leftOperand</em> <em>operator</em> <em>rightOperand</em>
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface BinaryTree extends ExpressionTree {
+    /**
+     * Returns left hand side (LHS) of this binary expression.
+     *
+     * @return left hand side (LHS) of this binary expression
+     */
+    ExpressionTree getLeftOperand();
+
+    /**
+     * Returns right hand side (RHS) of this binary expression.
+     *
+     * @return right hand side (RHS) of this binary expression
+     */
+    ExpressionTree getRightOperand();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/BinaryTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.BinaryNode;
+
+class BinaryTreeImpl extends ExpressionTreeImpl implements BinaryTree {
+    private final Tree.Kind kind;
+    private final ExpressionTree left, right;
+
+    BinaryTreeImpl(final BinaryNode node, final ExpressionTree left, final ExpressionTree right) {
+        super(node);
+        assert !node.isAssignment() : "assignment node";
+        this.left = left;
+        this.right = right;
+        this.kind = getOperator(node.tokenType());
+    }
+
+    @Override
+    public Tree.Kind getKind() {
+        return kind;
+    }
+
+    @Override
+    public ExpressionTree getLeftOperand() {
+        return left;
+    }
+
+    @Override
+    public ExpressionTree getRightOperand() {
+        return right;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitBinary(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/BlockTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.util.List;
+
+/**
+ * A tree node for a statement block.
+ *
+ * For example:
+ * <pre>
+ *   { }
+ *
+ *   { <em>statements</em> }
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface BlockTree extends StatementTree {
+    /**
+     * Returns the list of statements in this block.
+     *
+     * @return the list of statements in this block
+     */
+    List<? extends StatementTree> getStatements();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/BlockTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.util.List;
+import jdk.nashorn.internal.ir.Block;
+import jdk.nashorn.internal.ir.BlockStatement;
+
+final class BlockTreeImpl extends StatementTreeImpl implements BlockTree {
+    private final List<? extends StatementTree> statements;
+
+    BlockTreeImpl(final BlockStatement node, final List<? extends StatementTree> statements) {
+        super(node);
+        this.statements = statements;
+    }
+
+    BlockTreeImpl(final Block node, final List<? extends StatementTree> statements) {
+        super(node);
+        this.statements = statements;
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.BLOCK;
+    }
+
+    @Override
+    public List<? extends StatementTree> getStatements() {
+        return statements;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitBlock(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/BreakTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for a 'break' statement.
+ *
+ * For example:
+ * <pre>
+ *   break;
+ *
+ *   break <em>label</em> ;
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface BreakTree extends GotoTree {
+    /**
+     * Label associated with this break statement. This is null
+     * if there is no label associated with this break statement.
+     *
+     * @return label associated with this break statement.
+     */
+    String getLabel();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/BreakTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.BreakNode;
+import jdk.nashorn.internal.ir.IdentNode;
+
+final class BreakTreeImpl extends StatementTreeImpl implements BreakTree {
+    private final String label;
+
+    BreakTreeImpl(final BreakNode node) {
+        super(node);
+        this.label = node.getLabelName();
+    }
+
+    @Override
+    public Tree.Kind getKind() {
+        return Tree.Kind.BREAK;
+    }
+
+    @Override
+    public String getLabel() {
+        return label;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitBreak(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CaseTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.util.List;
+
+/**
+ * A tree node for a 'case' in a 'switch' statement.
+ *
+ * For example:
+ * <pre>
+ *   case <em>expression</em> :
+ *       <em>statements</em>
+ *
+ *   default :
+ *       <em>statements</em>
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface CaseTree extends Tree {
+    /**
+     * Case expression of this 'case' statement.
+     *
+     * @return null if and only if this Case is {@code default:}
+     */
+    ExpressionTree getExpression();
+
+    /**
+     * Return the list of statements for this 'case'.
+     *
+     * @return list of statements for this 'case'
+     */
+    List<? extends StatementTree> getStatements();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CaseTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.util.List;
+import jdk.nashorn.internal.ir.CaseNode;
+
+final class CaseTreeImpl extends TreeImpl implements CaseTree {
+    private final ExpressionTree expression;
+    private final List<? extends StatementTree> statements;
+
+    public CaseTreeImpl(final CaseNode node,
+        final ExpressionTree expression,
+        final List<? extends StatementTree> statements) {
+        super(node);
+        this.expression = expression;
+        this.statements = statements;
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.CASE;
+    }
+
+    @Override
+    public ExpressionTree getExpression() {
+        return expression;
+    }
+
+    @Override
+    public List<? extends StatementTree> getStatements() {
+        return statements;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitCase(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CatchTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for a 'catch' block in a 'try' statement.
+ *
+ * For example:
+ * <pre>
+ *   catch ( <em>parameter</em> )
+ *       <em>block</em>
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface CatchTree extends Tree {
+    /**
+     * Returns the catch parameter identifier of the exception caught.
+     *
+     * @return the catch parameter identifier
+     */
+    IdentifierTree getParameter();
+
+    /**
+     * Returns the code block of this catch block.
+     *
+     * @return the code block
+     */
+    BlockTree getBlock();
+
+    /**
+     * Returns the optional catch condition expression. This is null
+     * if this is an unconditional catch statement.
+     *
+     * @return the optional catch condition expression.
+     */
+    ExpressionTree getCondition();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CatchTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.CatchNode;
+
+final class CatchTreeImpl extends TreeImpl implements CatchTree {
+    private final IdentifierTree param;
+    private final BlockTree block;
+    private final ExpressionTree condition;
+
+    CatchTreeImpl(final CatchNode node,
+            final IdentifierTree param,
+            final BlockTree block,
+            final ExpressionTree condition) {
+        super(node);
+        this.param = param;
+        this.block = block;
+        this.condition = condition;
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.CATCH;
+    }
+
+    @Override
+    public IdentifierTree getParameter() {
+        return param;
+    }
+
+    @Override
+    public BlockTree getBlock() {
+        return block;
+    }
+
+    @Override
+    public ExpressionTree getCondition() {
+        return condition;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitCatch(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CompilationUnitTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.util.List;
+
+/**
+ * Represents the abstract syntax tree for compilation units (source
+ * files)
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface CompilationUnitTree extends Tree {
+    /**
+     * Return the list of source elements in this compilation unit.
+     *
+     * @return the list of source elements in this compilation unit
+     */
+    List<? extends Tree> getSourceElements();
+
+    /**
+     * Return the source name of this script compilation unit.
+     *
+     * @return the source name of this script compilation unit
+     */
+    String getSourceName();
+
+    /**
+     * Returns if this is a ECMAScript "strict" compilation unit or not.
+     *
+     * @return true if this compilation unit is declared "strict"
+     */
+    boolean isStrict();
+
+    /**
+     * Returns the line map for this compilation unit, if available.
+     * Returns null if the line map is not available.
+     *
+     * @return the line map for this compilation unit
+     */
+    LineMap getLineMap();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CompilationUnitTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.util.List;
+import jdk.nashorn.internal.ir.FunctionNode;
+
+final class CompilationUnitTreeImpl extends TreeImpl
+    implements CompilationUnitTree {
+    private final FunctionNode funcNode;
+    private final List<? extends Tree> elements;
+
+    CompilationUnitTreeImpl(final FunctionNode node,
+            final List<? extends Tree> elements) {
+        super(node);
+        this.funcNode = node;
+        assert funcNode.getKind() == FunctionNode.Kind.SCRIPT : "script function expected";
+        this.elements = elements;
+    }
+
+    @Override
+    public Tree.Kind getKind() {
+        return Tree.Kind.COMPILATION_UNIT;
+    }
+
+    @Override
+    public List<? extends Tree> getSourceElements() {
+        return elements;
+    }
+
+    @Override
+    public String getSourceName() {
+        return funcNode.getSourceName();
+    }
+
+    @Override
+    public boolean isStrict() {
+        return funcNode.isStrict();
+    }
+
+    @Override
+    public LineMap getLineMap() {
+        return new LineMapImpl(funcNode.getSource());
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitCompilationUnit(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CompoundAssignmentTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for compound assignment operator.
+ * Use {@link #getKind getKind} to determine the kind of operator.
+ *
+ * For example:
+ * <pre>
+ *   <em>variable</em> <em>operator</em> <em>expression</em>
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface CompoundAssignmentTree extends ExpressionTree {
+    /**
+     * Returns the left hand side (LHS) of this assignment.
+     *
+     * @return left hand side (LHS) expression
+     */
+    ExpressionTree getVariable();
+
+    /**
+     * Returns the right hand side (RHS) of this assignment.
+     *
+     * @return right hand side (RHS) expression
+     */
+    ExpressionTree getExpression();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/CompoundAssignmentTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.BinaryNode;
+
+final class CompoundAssignmentTreeImpl extends ExpressionTreeImpl implements CompoundAssignmentTree {
+
+    private final ExpressionTree var, expr;
+    private final Kind kind;
+
+    CompoundAssignmentTreeImpl(final BinaryNode node, final ExpressionTree left, final ExpressionTree right) {
+        super(node);
+        assert node.isAssignment() : "not an assignment node";
+        this.var = left;
+        this.expr = right;
+        this.kind = getOperator(node.tokenType());
+        assert kind != Tree.Kind.ASSIGNMENT : "compound assignment expected";
+    }
+
+    @Override
+    public Kind getKind() {
+        return kind;
+    }
+
+    @Override
+    public ExpressionTree getVariable() {
+        return var;
+    }
+
+    @Override
+    public ExpressionTree getExpression() {
+        return expr;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitCompoundAssignment(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ConditionalExpressionTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for the conditional operator ? :.
+ *
+ * For example:
+ * <pre>
+ *   <em>condition</em> ? <em>trueExpression</em> : <em>falseExpression</em>
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface ConditionalExpressionTree extends ExpressionTree {
+    /**
+     * Returns the condition expression of this ternary expression.
+     *
+     * @return the condition expression
+     */
+    ExpressionTree getCondition();
+
+    /**
+     * Returns the true part of this ternary expression.
+     *
+     * @return the 'true' part expression
+     */
+    ExpressionTree getTrueExpression();
+
+    /**
+     * Returns the false part of this ternary expression.
+     *
+     * @return the 'false' part expression
+     */
+    ExpressionTree getFalseExpression();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ConditionalExpressionTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.TernaryNode;
+
+final class ConditionalExpressionTreeImpl extends ExpressionTreeImpl implements ConditionalExpressionTree {
+    private final ExpressionTree condExpr, trueExpr, falseExpr;
+
+    ConditionalExpressionTreeImpl(final TernaryNode node,
+            final ExpressionTree condExpr, final ExpressionTree trueExpr,
+            final ExpressionTree falseExpr) {
+        super(node);
+        this.condExpr = condExpr;
+        this.trueExpr = trueExpr;
+        this.falseExpr = falseExpr;
+
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.CONDITIONAL_EXPRESSION;
+    }
+
+    @Override
+    public ExpressionTree getCondition() {
+        return condExpr;
+    }
+
+    @Override
+    public ExpressionTree getTrueExpression() {
+        return trueExpr;
+    }
+
+    @Override
+    public ExpressionTree getFalseExpression() {
+        return falseExpr;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitConditionalExpression(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ConditionalLoopTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A mixin for conditional "loop" statements.
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface ConditionalLoopTree extends LoopTree {
+    /**
+     * Returns the condition expression of this 'loop' statement.
+     *
+     * @return the condition expression
+     */
+    ExpressionTree getCondition();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ContinueTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for a 'continue' statement.
+ *
+ * For example:
+ * <pre>
+ *   continue;
+ *   continue <em>label</em> ;
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface ContinueTree extends GotoTree {
+    /**
+     * Label associated with this continue statement. This is null
+     * if there is no label associated with this continue statement.
+     *
+     * @return label associated with this continue statement.
+     */
+    String getLabel();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ContinueTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.ContinueNode;
+import jdk.nashorn.internal.ir.IdentNode;
+
+final class ContinueTreeImpl extends StatementTreeImpl implements ContinueTree {
+    private final String label;
+
+    ContinueTreeImpl(final ContinueNode node) {
+        super(node);
+        this.label = node.getLabelName();
+    }
+
+    @Override
+    public Tree.Kind getKind() {
+        return Tree.Kind.CONTINUE;
+    }
+
+    @Override
+    public String getLabel() {
+        return label;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitContinue(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/DebuggerTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for a 'debugger' statement.
+ *
+ * For example:
+ * <pre>
+ *     <em>debugger;</em>
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface DebuggerTree extends StatementTree {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/DebuggerTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.DebuggerNode;
+
+final class DebuggerTreeImpl extends StatementTreeImpl implements DebuggerTree {
+    DebuggerTreeImpl(final DebuggerNode node) {
+        super(node);
+    }
+
+    @Override
+    public Tree.Kind getKind() {
+        return Tree.Kind.DEBUGGER;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitDebugger(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/Diagnostic.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * Interface for diagnostics from tools.  A diagnostic usually reports
+ * a problem at a specific position in a source file.  However, not
+ * all diagnostics are associated with a position or a file.
+ *
+ * <p>A position is a zero-based character offset from the beginning of
+ * a file.  Negative values (except {@link #NOPOS}) are not valid
+ * positions.
+ *
+ * <p>Line and column numbers begin at 1.  Negative values (except
+ * {@link #NOPOS}) and 0 are not valid line or column numbers.
+ *
+ * <p>Line terminator is as defined in ECMAScript specification which is one
+ * of { &#92;u000A, &#92;u000B, &#92;u2028, &#92;u2029 }.
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface Diagnostic {
+
+    /**
+     * Kinds of diagnostics, for example, error or warning.
+     *
+     * The kind of a diagnostic can be used to determine how the
+     * diagnostic should be presented to the user. For example,
+     * errors might be colored red or prefixed with the word "Error",
+     * while warnings might be colored yellow or prefixed with the
+     * word "Warning". There is no requirement that the Kind
+     * should imply any inherent semantic meaning to the message
+     * of the diagnostic: for example, a tool might provide an
+     * option to report all warnings as errors.
+     */
+    enum Kind {
+        /**
+         * Problem which prevents the tool's normal completion.
+         */
+        ERROR,
+        /**
+         * Problem which does not usually prevent the tool from
+         * completing normally.
+         */
+        WARNING,
+        /**
+         * Problem similar to a warning, but is mandated by the tool's
+         * specification.  For example, the Java&trade; Language
+         * Specification mandates warnings on certain
+         * unchecked operations and the use of deprecated methods.
+         */
+        MANDATORY_WARNING,
+        /**
+         * Informative message from the tool.
+         */
+        NOTE,
+        /**
+         * Diagnostic which does not fit within the other kinds.
+         */
+        OTHER,
+    }
+
+    /**
+     * Used to signal that no position is available.
+     */
+    public final static long NOPOS = -1;
+
+    /**
+     * Gets the kind of this diagnostic, for example, error or
+     * warning.
+     * @return the kind of this diagnostic
+     */
+    Kind getKind();
+
+    /**
+     * Gets a character offset from the beginning of the source object
+     * associated with this diagnostic that indicates the location of
+     * the problem.  In addition, the following must be true:
+     *
+     * <p>{@code getStartPostion() <= getPosition()}
+     * <p>{@code getPosition() <= getEndPosition()}
+     *
+     * @return character offset from beginning of source; {@link
+     * #NOPOS} if no location is suitable
+     */
+    long getPosition();
+
+    /**
+     * Gets the source file name.
+     *
+     * @return the file name or null if not available
+     */
+    String getFileName();
+
+    /**
+     * Gets the line number of the character offset returned by
+     * {@linkplain #getPosition()}.
+     *
+     * @return a line number or {@link #NOPOS} if and only if {@link
+     * #getPosition()} returns {@link #NOPOS}
+     */
+    long getLineNumber();
+
+    /**
+     * Gets the column number of the character offset returned by
+     * {@linkplain #getPosition()}.
+     *
+     * @return a column number or {@link #NOPOS} if and only if {@link
+     * #getPosition()} returns {@link #NOPOS}
+     */
+    long getColumnNumber();
+
+    /**
+     * Gets a diagnostic code indicating the type of diagnostic.  The
+     * code is implementation-dependent and might be {@code null}.
+     *
+     * @return a diagnostic code
+     */
+    String getCode();
+
+    /**
+     * Gets a message for this diagnostic.
+     *
+     * @return a message
+     */
+    String getMessage();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/DiagnosticImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.parser.Token;
+import jdk.nashorn.internal.runtime.ParserException;
+import jdk.nashorn.internal.runtime.Source;
+
+final class DiagnosticImpl implements Diagnostic {
+    private final ParserException exp;
+    private final Kind kind;
+
+    DiagnosticImpl(final ParserException exp, final Kind kind) {
+        this.exp = exp;
+        this.kind = kind;
+    }
+
+    @Override
+    public Kind getKind() {
+        return kind;
+    }
+
+    @Override
+    public long getPosition() {
+        return exp.getPosition();
+    }
+
+    @Override
+    public String getFileName() {
+        return exp.getFileName();
+    }
+
+    @Override
+    public long getLineNumber() {
+        return exp.getLineNumber();
+    }
+
+    @Override
+    public long getColumnNumber() {
+        return exp.getColumnNumber();
+    }
+
+    @Override
+    public String getCode() {
+        final long token = exp.getToken();
+        return (token < 0)? null : Token.toString(null, token, true);
+    }
+
+    @Override
+    public String getMessage() {
+        return exp.getMessage();
+    }
+
+    @Override
+    public String toString() {
+        return getMessage();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/DiagnosticListener.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * Interface for receiving diagnostics from Nashorn parser.
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+@FunctionalInterface
+public interface DiagnosticListener {
+    /**
+     * Invoked whenever a parsing problem is found.
+     *
+     * @param diagnostic additional information errors, warnings detected during parsing.
+     */
+    void report(Diagnostic diagnostic);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/DoWhileLoopTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for a 'do' statement.
+ *
+ * For example:
+ * <pre>
+ *   do
+ *       <em>statement</em>
+ *   while ( <em>expression</em> );
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface DoWhileLoopTree extends ConditionalLoopTree {
+    /**
+     * Returns the condition expression of this do-while statement.
+     *
+     * @return the condition expression
+     */
+    ExpressionTree getCondition();
+
+    /**
+     * The statement contained within this do-while statement.
+     *
+     * @return the statement
+     */
+    StatementTree getStatement();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/DoWhileLoopTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.WhileNode;
+
+final class DoWhileLoopTreeImpl extends StatementTreeImpl implements DoWhileLoopTree {
+    private final ExpressionTree cond;
+    private final StatementTree stat;
+
+    DoWhileLoopTreeImpl(final WhileNode node, final ExpressionTree cond, final StatementTree stat) {
+        super(node);
+        assert node.isDoWhile() : "do while expected";
+        this.cond = cond;
+        this.stat = stat;
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.DO_WHILE_LOOP;
+    }
+
+    @Override
+    public ExpressionTree getCondition() {
+        return cond;
+    }
+
+    @Override
+    public StatementTree getStatement() {
+        return stat;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitDoWhileLoop(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/EmptyStatementTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for an empty (skip) statement.
+ *
+ * For example:
+ * <pre>
+ *    ;
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface EmptyStatementTree extends StatementTree {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/EmptyStatementTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.EmptyNode;
+
+final class EmptyStatementTreeImpl extends StatementTreeImpl implements EmptyStatementTree {
+    EmptyStatementTreeImpl(final EmptyNode node) {
+        super(node);
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.EMPTY_STATEMENT;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitEmptyStatement(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ErroneousTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node to stand in for a malformed expression.
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface ErroneousTree extends ExpressionTree {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ErroneousTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.ErrorNode;
+
+final class ErroneousTreeImpl extends ExpressionTreeImpl implements ErroneousTree {
+    ErroneousTreeImpl(final ErrorNode errorNode) {
+        super(errorNode);
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.ERROR;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitErroneous(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ExpressionStatementTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for an expression statement.
+ *
+ * For example:
+ * <pre>
+ *   <em>expression</em> ;
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface ExpressionStatementTree extends StatementTree {
+    /**
+     * Returns the expression of this expression statement.
+     *
+     * @return the expression
+     */
+    ExpressionTree getExpression();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ExpressionStatementTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.ExpressionStatement;
+
+final class ExpressionStatementTreeImpl extends StatementTreeImpl implements ExpressionStatementTree {
+    private final ExpressionTree expr;
+
+    ExpressionStatementTreeImpl(final ExpressionStatement es, final ExpressionTree expr) {
+        super(es);
+        this.expr = expr;
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.EXPRESSION_STATEMENT;
+    }
+
+    @Override
+    public ExpressionTree getExpression() {
+        return expr;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitExpressionStatement(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ExpressionTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node used as the base class for the different types of
+ * expressions.
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface ExpressionTree extends Tree {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ExpressionTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.Expression;
+
+abstract class ExpressionTreeImpl extends TreeImpl implements ExpressionTree {
+    ExpressionTreeImpl(final Expression expr) {
+        super(expr);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ForInLoopTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for for..in statement
+ *
+ * For example:
+ * <pre>
+ *   for ( <em>variable</em> in <em>expression</em> )
+ *       <em>statement</em>
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface ForInLoopTree extends LoopTree {
+    /**
+     * The for..in left hand side expression.
+     *
+     * @return the left hand side expression
+     */
+    ExpressionTree getVariable();
+
+    /**
+     * The object or array being whose properties are iterated.
+     *
+     * @return the object or array expression being iterated
+     */
+    ExpressionTree getExpression();
+
+    /**
+     * The statement contained in this for..in statement.
+     *
+     * @return the statement
+     */
+    StatementTree getStatement();
+
+    /**
+     * Returns if this is a for..each..in statement or not.
+     *
+     * @return true if this is a for..each..in statement
+     */
+    boolean isForEach();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ForInLoopTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.ForNode;
+
+final class ForInLoopTreeImpl extends StatementTreeImpl implements ForInLoopTree {
+    private final ExpressionTree lhsExpr;
+    private final ExpressionTree expr;
+    private final StatementTree stat;
+    private final boolean forEach;
+
+    ForInLoopTreeImpl(final ForNode node,
+            final ExpressionTree lhsExpr,
+            final ExpressionTree expr,
+            final StatementTree stat) {
+        super(node);
+        assert node.isForIn() : "for ..in expected";
+        this.lhsExpr = lhsExpr;
+        this.expr = expr;
+        this.stat = stat;
+        this.forEach = node.isForEach();
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.FOR_IN_LOOP;
+    }
+
+    @Override
+    public ExpressionTree getVariable() {
+        return lhsExpr;
+    }
+
+    @Override
+    public ExpressionTree getExpression() {
+        return expr;
+    }
+
+    @Override
+    public StatementTree getStatement() {
+        return stat;
+    }
+
+    @Override
+    public boolean isForEach() {
+        return forEach;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitForInLoop(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ForLoopTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for a basic 'for' loop statement.
+ *
+ * For example:
+ * <pre>
+ *   for ( <em>initializer</em> ; <em>condition</em> ; <em>update</em> )
+ *       <em>statement</em>
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface ForLoopTree extends ConditionalLoopTree {
+    /**
+     * Returns the initializer expression of this 'for' statement.
+     *
+     * @return the initializer expression
+     */
+    ExpressionTree getInitializer();
+
+    /**
+     * Returns the condition expression of this 'for' statement.
+     *
+     * @return the condition expression
+     */
+    ExpressionTree getCondition();
+
+    /**
+     * Returns the update expression of this 'for' statement.
+     *
+     * @return the update expression
+     */
+    ExpressionTree getUpdate();
+
+    /**
+     * Returns the statement contained in this 'for' statement.
+     *
+     * @return the statement
+     */
+    StatementTree getStatement();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ForLoopTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.util.List;
+import jdk.nashorn.internal.ir.ForNode;
+
+final class ForLoopTreeImpl extends StatementTreeImpl implements ForLoopTree {
+    private final ExpressionTree init;
+    private final ExpressionTree cond;
+    private final ExpressionTree update;
+    private final StatementTree stat;
+
+    ForLoopTreeImpl(final ForNode node,
+        final ExpressionTree init,
+        final ExpressionTree cond,
+        final ExpressionTree update,
+        final StatementTree  stat) {
+        super(node);
+        assert !node.isForIn() : "for statement expected";
+        this.init = init;
+        this.cond = cond;
+        this.update = update;
+        this.stat = stat;
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.FOR_LOOP;
+    }
+
+    @Override
+    public ExpressionTree getInitializer() {
+        return init;
+    }
+
+    @Override
+    public ExpressionTree getCondition() {
+        return cond;
+    }
+
+    @Override
+    public ExpressionTree getUpdate() {
+        return update;
+    }
+
+    @Override
+    public StatementTree getStatement() {
+        return stat;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitForLoop(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionCallTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.util.List;
+
+/**
+ * A tree node for a function call expression.
+ *
+ * For example:
+ * <pre>
+ *   <em>identifier</em> ( <em>arguments</em> )
+ *
+ *   this . <em>identifier</em> ( <em>arguments</em> )
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface FunctionCallTree extends ExpressionTree {
+    /**
+     * Returns the function being called.
+     *
+     * @return the function being called
+     */
+    ExpressionTree getFunctionSelect();
+
+    /**
+     * Returns the list of arguments being passed to this function call.
+     *
+     * @return the list of argument expressions
+     */
+    List<? extends ExpressionTree> getArguments();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionCallTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.util.List;
+import jdk.nashorn.internal.ir.CallNode;
+
+class FunctionCallTreeImpl extends ExpressionTreeImpl implements FunctionCallTree {
+    private final List<? extends ExpressionTree> arguments;
+    private final ExpressionTree function;
+    FunctionCallTreeImpl(final CallNode node,
+            final ExpressionTree function,
+            final List<? extends ExpressionTree> arguments) {
+        super(node);
+        this.function = function;
+        this.arguments = arguments;
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.FUNCTION_INVOCATION;
+    }
+
+    @Override
+    public ExpressionTree getFunctionSelect() {
+        return function;
+    }
+
+    @Override
+    public List<? extends ExpressionTree> getArguments() {
+        return arguments;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitFunctionCall(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionDeclarationTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.util.List;
+
+/**
+ * A tree node for a function declaration.
+ *
+ * For example:
+ * <pre>
+ *   <em>function</em> <em>name</em>
+ *      ( <em>parameters</em> )
+ *      <em>body</em>
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface FunctionDeclarationTree extends StatementTree {
+    /**
+     * Returns the name of the function being declared.
+     *
+     * @return name the function declared
+     */
+    String getName();
+
+    /**
+     * Returns the parameters of this function.
+     *
+     * @return the list of parameters
+     */
+    List<? extends ExpressionTree> getParameters();
+
+    /**
+     * Returns the body of code of this function.
+     *
+     * @return the body of code
+     */
+    BlockTree getBody();
+
+    /**
+     * Is this a strict function?
+     *
+     * @return true if this function is strict
+     */
+    boolean isStrict();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionDeclarationTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.util.List;
+import jdk.nashorn.internal.ir.FunctionNode;
+import jdk.nashorn.internal.ir.VarNode;
+
+final class FunctionDeclarationTreeImpl extends StatementTreeImpl
+    implements FunctionDeclarationTree {
+    private final FunctionNode funcNode;
+    private final String funcName;
+    private final List<? extends ExpressionTree> params;
+    private final BlockTree body;
+
+    FunctionDeclarationTreeImpl(final VarNode node,
+            final List<? extends ExpressionTree> params,
+            final BlockTree body) {
+        super(node);
+        assert node.getInit() instanceof FunctionNode : "function expected";
+        funcNode = (FunctionNode)node.getInit();
+        assert funcNode.isDeclared() : "function declaration expected";
+        funcName = node.getName().getName();
+        this.params = params;
+        this.body = body;
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.FUNCTION;
+    }
+
+    @Override
+    public String getName() {
+        return funcName;
+    }
+
+    @Override
+    public List<? extends ExpressionTree> getParameters() {
+        return params;
+    }
+
+    @Override
+    public BlockTree getBody() {
+        return body;
+    }
+
+    @Override
+    public boolean isStrict() {
+        return funcNode.isStrict();
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitFunctionDeclaration(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionExpressionTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.util.List;
+
+/**
+ * A tree node for a function expression.
+ *
+ * For example:
+ * <pre>
+ *   <em>var</em> func = <em>function</em>
+ *      ( <em>parameters</em> )
+ *      <em>body</em>
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface FunctionExpressionTree extends ExpressionTree {
+    /**
+     * Returns the name of the function being declared.
+     *
+     * @return name the function declared
+     */
+    String getName();
+
+    /**
+     * Returns the parameters of this function.
+     *
+     * @return the list of parameters
+     */
+    List<? extends ExpressionTree> getParameters();
+
+    /**
+     * Returns the body of code of this function.
+     *
+     * @return the body of code
+     */
+    BlockTree getBody();
+
+    /**
+     * Is this a strict function?
+     *
+     * @return true if this function is strict
+     */
+    boolean isStrict();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/FunctionExpressionTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.util.List;
+import jdk.nashorn.internal.ir.FunctionNode;
+
+final class FunctionExpressionTreeImpl extends ExpressionTreeImpl
+    implements FunctionExpressionTree {
+    private final FunctionNode funcNode;
+    private final String funcName;
+    private final List<? extends ExpressionTree> params;
+    private final BlockTree body;
+
+    FunctionExpressionTreeImpl(final FunctionNode node,
+            final List<? extends ExpressionTree> params,
+            final BlockTree body) {
+        super(node);
+        funcNode = node;
+        assert !funcNode.isDeclared() : "function expression expected";
+
+        final FunctionNode.Kind kind = node.getKind();
+        if (node.isAnonymous() || kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) {
+            funcName = null;
+        } else {
+            funcName = node.getIdent().getName();
+        }
+
+        this.params = params;
+        this.body = body;
+    }
+
+    @Override
+    public Tree.Kind getKind() {
+        return Tree.Kind.FUNCTION_EXPRESSION;
+    }
+
+    @Override
+    public String getName() {
+        return funcName;
+    }
+
+    @Override
+    public List<? extends ExpressionTree> getParameters() {
+        return params;
+    }
+
+    @Override
+    public BlockTree getBody() {
+        return body;
+    }
+
+    @Override
+    public boolean isStrict() {
+        return funcNode.isStrict();
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitFunctionExpression(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/GotoTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for a statement that jumps to a target. Note that
+ * ECMAScript does not support a goto statement. But, this Tree
+ * type serves as a super interface for {@link BreakTree} and
+ * {@link ContinueTree}.
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface GotoTree extends StatementTree {
+    /**
+     * Label associated with this goto statement. This is null
+     * if there is no label associated with this goto statement.
+     *
+     * @return label associated with this goto statement.
+     */
+    String getLabel();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IRTranslator.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,517 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.nashorn.api.tree;
+
+import java.util.ArrayList;
+import java.util.List;
+import jdk.nashorn.internal.ir.AccessNode;
+import jdk.nashorn.internal.ir.BinaryNode;
+import jdk.nashorn.internal.ir.Block;
+import jdk.nashorn.internal.ir.BlockStatement;
+import jdk.nashorn.internal.ir.BreakNode;
+import jdk.nashorn.internal.ir.CallNode;
+import jdk.nashorn.internal.ir.CaseNode;
+import jdk.nashorn.internal.ir.CatchNode;
+import jdk.nashorn.internal.ir.ContinueNode;
+import jdk.nashorn.internal.ir.DebuggerNode;
+import jdk.nashorn.internal.ir.EmptyNode;
+import jdk.nashorn.internal.ir.ErrorNode;
+import jdk.nashorn.internal.ir.Expression;
+import jdk.nashorn.internal.ir.ExpressionStatement;
+import jdk.nashorn.internal.ir.ForNode;
+import jdk.nashorn.internal.ir.FunctionNode;
+import jdk.nashorn.internal.ir.IdentNode;
+import jdk.nashorn.internal.ir.IfNode;
+import jdk.nashorn.internal.ir.IndexNode;
+import jdk.nashorn.internal.ir.LabelNode;
+import jdk.nashorn.internal.ir.LexicalContext;
+import jdk.nashorn.internal.ir.LiteralNode;
+import jdk.nashorn.internal.ir.Node;
+import jdk.nashorn.internal.ir.ObjectNode;
+import jdk.nashorn.internal.ir.PropertyNode;
+import jdk.nashorn.internal.ir.ReturnNode;
+import jdk.nashorn.internal.ir.RuntimeNode;
+import jdk.nashorn.internal.ir.SplitNode;
+import jdk.nashorn.internal.ir.Statement;
+import jdk.nashorn.internal.ir.SwitchNode;
+import jdk.nashorn.internal.ir.TernaryNode;
+import jdk.nashorn.internal.ir.ThrowNode;
+import jdk.nashorn.internal.ir.TryNode;
+import jdk.nashorn.internal.ir.UnaryNode;
+import jdk.nashorn.internal.ir.VarNode;
+import jdk.nashorn.internal.ir.WhileNode;
+import jdk.nashorn.internal.ir.WithNode;
+import jdk.nashorn.internal.ir.visitor.NodeVisitor;
+import jdk.nashorn.internal.parser.Lexer;
+import jdk.nashorn.internal.parser.TokenType;
+
+/**
+ * This class translates from nashorn IR Node objects
+ * to nashorn parser API Tree objects.
+ */
+final class IRTranslator extends NodeVisitor<LexicalContext> {
+
+    public IRTranslator() {
+        super(new LexicalContext());
+    }
+
+    // currently translated Statement
+    private StatementTreeImpl curStat;
+    // currently translated Expression
+    private ExpressionTreeImpl curExpr;
+
+    // entry point for translator
+    CompilationUnitTree translate(final FunctionNode node) {
+        if (node == null) {
+            return null;
+        }
+
+        assert (node.getKind() == FunctionNode.Kind.SCRIPT) : "script function expected";
+
+        final Block body = node.getBody();
+        return new CompilationUnitTreeImpl(node,
+                translateStats(body != null? body.getStatements() : null));
+    }
+
+    @Override
+    public boolean enterAccessNode(final AccessNode accessNode) {
+        curExpr = new MemberSelectTreeImpl(accessNode, translateExpr(accessNode.getBase()));
+        return false;
+    }
+
+    @Override
+    public boolean enterBlock(final Block block) {
+        // FIXME: revisit this!
+        if (block.isSynthetic()) {
+            final int statCount = block.getStatementCount();
+            switch (statCount) {
+                case 0: {
+                    final EmptyNode emptyNode = new EmptyNode(-1, block.getToken(), block.getFinish());
+                    curStat = new EmptyStatementTreeImpl(emptyNode);
+                    return false;
+                }
+                case 1: {
+                    curStat = translateStat(block.getStatements().get(0));
+                    return false;
+                }
+            }
+        }
+
+        curStat = new BlockTreeImpl(block,
+            translateStats(block.getStatements()));
+        return false;
+    }
+
+    @Override
+    public boolean enterBinaryNode(final BinaryNode binaryNode) {
+        if (binaryNode.isAssignment()) {
+            final ExpressionTree srcTree = translateExpr(binaryNode.getAssignmentSource());
+            final ExpressionTree destTree = translateExpr(binaryNode.getAssignmentDest());
+
+            if (binaryNode.tokenType() == TokenType.ASSIGN) {
+                curExpr = new AssignmentTreeImpl(binaryNode, destTree, srcTree);
+            } else {
+                curExpr = new CompoundAssignmentTreeImpl(binaryNode, destTree, srcTree);
+            }
+        } else {
+            final ExpressionTree leftTree = translateExpr(binaryNode.lhs());
+            final ExpressionTree rightTree = translateExpr(binaryNode.rhs());
+
+            if (binaryNode.tokenType() == TokenType.INSTANCEOF) {
+                curExpr = new InstanceOfTreeImpl(binaryNode, leftTree, rightTree);
+            } else {
+                curExpr = new BinaryTreeImpl(binaryNode, leftTree, rightTree);
+            }
+        }
+
+        return false;
+    }
+
+    @Override
+    public boolean enterBreakNode(final BreakNode breakNode) {
+        curStat = new BreakTreeImpl(breakNode);
+        return false;
+    }
+
+    @Override
+    public boolean enterCallNode(final CallNode callNode) {
+        curExpr = null;
+        callNode.getFunction().accept(this);
+        final ExpressionTree funcTree = curExpr;
+        final List<? extends ExpressionTree> argTrees = translateExprs(callNode.getArgs());
+        curExpr = new FunctionCallTreeImpl(callNode, funcTree, argTrees);
+        return false;
+    }
+
+    @Override
+    public boolean enterCaseNode(final CaseNode caseNode) {
+        assert false : "should not reach here!";
+        return false;
+    }
+
+    @Override
+    public boolean enterCatchNode(final CatchNode catchNode) {
+        assert false : "should not reach here";
+        return false;
+    }
+
+    @Override
+    public boolean enterContinueNode(final ContinueNode continueNode) {
+        curStat = new ContinueTreeImpl(continueNode);
+        return false;
+    }
+
+    @Override
+    public boolean enterDebuggerNode(final DebuggerNode debuggerNode) {
+        curStat = new DebuggerTreeImpl(debuggerNode);
+        return false;
+    }
+
+    @Override
+    public boolean enterEmptyNode(final EmptyNode emptyNode) {
+        curStat = new EmptyStatementTreeImpl(emptyNode);
+        return false;
+    }
+
+    @Override
+    public boolean enterErrorNode(final ErrorNode errorNode) {
+        curExpr = new ErroneousTreeImpl(errorNode);
+        return false;
+    }
+
+    @Override
+    public boolean enterExpressionStatement(final ExpressionStatement expressionStatement) {
+        curStat = new ExpressionStatementTreeImpl(expressionStatement,
+                translateExpr(expressionStatement.getExpression()));
+        return false;
+    }
+
+    @Override
+    public boolean enterBlockStatement(final BlockStatement blockStatement) {
+        final Block block = blockStatement.getBlock();
+        if (blockStatement.isSynthetic()) {
+            assert block != null && block.getStatements() != null && block.getStatements().size() == 1;
+            curStat = translateStat(block.getStatements().get(0));
+        } else {
+            curStat = new BlockTreeImpl(blockStatement,
+                translateStats(block != null? block.getStatements() : null));
+        }
+        return false;
+    }
+
+    @Override
+    public boolean enterForNode(final ForNode forNode) {
+        if (forNode.isForIn()) {
+            curStat = new ForInLoopTreeImpl(forNode,
+                    translateExpr(forNode.getInit()),
+                    translateExpr(forNode.getModify()),
+                    translateBlock(forNode.getBody()));
+        } else {
+            curStat = new ForLoopTreeImpl(forNode,
+                    translateExpr(forNode.getInit()),
+                    translateExpr(forNode.getTest()),
+                    translateExpr(forNode.getModify()),
+                    translateBlock(forNode.getBody()));
+        }
+
+        return false;
+    }
+
+    @Override
+    public boolean enterFunctionNode(final FunctionNode functionNode) {
+        assert !functionNode.isDeclared() : "should not reach here for function declaration";
+
+        final List<? extends ExpressionTree> paramTrees
+                    = translateExprs(functionNode.getParameters());
+        final BlockTree blockTree = (BlockTree) translateBlock(functionNode.getBody());
+        curExpr = new FunctionExpressionTreeImpl(functionNode, paramTrees, blockTree);
+
+        return false;
+    }
+
+    @Override
+    public boolean enterIdentNode(final IdentNode identNode) {
+        curExpr = new IdentifierTreeImpl(identNode);
+        return false;
+    }
+
+    @Override
+    public boolean enterIfNode(final IfNode ifNode) {
+        curStat = new IfTreeImpl(ifNode,
+                translateExpr(ifNode.getTest()),
+                translateBlock(ifNode.getPass()),
+                translateBlock(ifNode.getFail()));
+        return false;
+    }
+
+    @Override
+    public boolean enterIndexNode(final IndexNode indexNode) {
+        curExpr = new ArrayAccessTreeImpl(indexNode,
+                translateExpr(indexNode.getBase()),
+                translateExpr(indexNode.getIndex()));
+        return false;
+    }
+
+    @Override
+    public boolean enterLabelNode(final LabelNode labelNode) {
+        curStat = new LabeledStatementTreeImpl(labelNode,
+                translateBlock(labelNode.getBody()));
+        return false;
+    }
+
+    @Override
+    public boolean enterLiteralNode(final LiteralNode<?> literalNode) {
+        final Object value = literalNode.getValue();
+        if (value instanceof Lexer.RegexToken) {
+            curExpr = new RegExpLiteralTreeImpl(literalNode);
+        } else if (literalNode.isArray()) {
+            final List<Expression> exprNodes = literalNode.getElementExpressions();
+            final List<ExpressionTreeImpl> exprTrees = new ArrayList<>(exprNodes.size());
+            for (final Node node : exprNodes) {
+                if (node == null) {
+                    exprTrees.add(null);
+                } else {
+                    curExpr = null;
+                    node.accept(this);
+                    assert curExpr != null : "null for " + node;
+                    exprTrees.add(curExpr);
+                }
+            }
+            curExpr = new ArrayLiteralTreeImpl(literalNode, exprTrees);
+        } else {
+            curExpr = new LiteralTreeImpl(literalNode);
+        }
+
+        return false;
+    }
+
+    @Override
+    public boolean enterObjectNode(final ObjectNode objectNode) {
+        final List<PropertyNode> propNodes = objectNode.getElements();
+        final List<PropertyTreeImpl> propTrees = new ArrayList<>(propNodes.size());
+        for (final PropertyNode propNode : propNodes) {
+            propTrees.add(new PropertyTreeImpl(propNode,
+                    translateExpr(propNode.getKey()),
+                    translateExpr(propNode.getValue()),
+                    (FunctionExpressionTree) translateExpr(propNode.getGetter()),
+                    (FunctionExpressionTree) translateExpr(propNode.getSetter())));
+        }
+        curExpr = new ObjectLiteralTreeImpl(objectNode, propTrees);
+        return false;
+    }
+
+    @Override
+    public boolean enterPropertyNode(final PropertyNode propertyNode) {
+        assert false : "should not reach here!";
+        return false;
+    }
+
+    @Override
+    public boolean enterReturnNode(final ReturnNode returnNode) {
+        curStat = new ReturnTreeImpl(returnNode,
+                translateExpr(returnNode.getExpression()));
+        return false;
+    }
+
+    @Override
+    public boolean enterRuntimeNode(final RuntimeNode runtimeNode) {
+        assert false : "should not reach here: RuntimeNode";
+        return false;
+    }
+
+    @Override
+    public boolean enterSplitNode(final SplitNode splitNode) {
+        assert false : "should not reach here!";
+        return false;
+    }
+
+    @Override
+    public boolean enterSwitchNode(final SwitchNode switchNode) {
+        final List<CaseNode> caseNodes = switchNode.getCases();
+        final List<CaseTreeImpl> caseTrees = new ArrayList<>(caseNodes.size());
+        for (final CaseNode caseNode : caseNodes) {
+            final Block body = caseNode.getBody();
+            caseTrees.add(
+                    new CaseTreeImpl(caseNode,
+                            translateExpr(caseNode.getTest()),
+                            translateStats(body != null? body.getStatements() : null)));
+        }
+
+        curStat = new SwitchTreeImpl(switchNode,
+                translateExpr(switchNode.getExpression()),
+                caseTrees);
+        return false;
+    }
+
+    @Override
+    public boolean enterTernaryNode(final TernaryNode ternaryNode) {
+        curExpr = new ConditionalExpressionTreeImpl(ternaryNode,
+                translateExpr(ternaryNode.getTest()),
+                translateExpr(ternaryNode.getTrueExpression()),
+                translateExpr(ternaryNode.getFalseExpression()));
+        return false;
+    }
+
+    @Override
+    public boolean enterThrowNode(final ThrowNode throwNode) {
+        curStat = new ThrowTreeImpl(throwNode,
+                translateExpr(throwNode.getExpression()));
+        return false;
+    }
+
+    @Override
+    public boolean enterTryNode(final TryNode tryNode) {
+        final List<? extends CatchNode> catchNodes = tryNode.getCatches();
+        final List<CatchTreeImpl> catchTrees = new ArrayList<>(catchNodes.size());
+        for (final CatchNode catchNode : catchNodes) {
+            catchTrees.add(new CatchTreeImpl(catchNode,
+                    translateIdent(catchNode.getException()),
+                    (BlockTree) translateBlock(catchNode.getBody()),
+                    translateExpr(catchNode.getExceptionCondition())));
+        }
+
+        curStat = new TryTreeImpl(tryNode,
+                (BlockTree) translateBlock(tryNode.getBody()),
+                catchTrees,
+                (BlockTree) translateBlock(tryNode.getFinallyBody()));
+
+        return false;
+    }
+
+    @Override
+    public boolean enterUnaryNode(final UnaryNode unaryNode) {
+        if (unaryNode.tokenType() == TokenType.NEW) {
+            curExpr = new NewTreeImpl(unaryNode,
+                    translateExpr(unaryNode.getExpression()));
+        } else {
+            curExpr = new UnaryTreeImpl(unaryNode,
+                    translateExpr(unaryNode.getExpression()));
+        }
+        return false;
+    }
+
+    @Override
+    public boolean enterVarNode(final VarNode varNode) {
+        final Expression initNode = varNode.getInit();
+        if (initNode instanceof FunctionNode && ((FunctionNode)initNode).isDeclared()) {
+            final FunctionNode funcNode = (FunctionNode) initNode;
+
+            final List<? extends ExpressionTree> paramTrees
+                    = translateExprs(funcNode.getParameters());
+            final BlockTree blockTree = (BlockTree) translateBlock(funcNode.getBody());
+            curStat = new FunctionDeclarationTreeImpl(varNode, paramTrees, blockTree);
+        } else {
+            curStat = new VariableTreeImpl(varNode, translateExpr(initNode));
+        }
+
+        return false;
+    }
+
+    @Override
+    public boolean enterWhileNode(final WhileNode whileNode) {
+        final ExpressionTree condTree = translateExpr(whileNode.getTest());
+        final StatementTree statTree = translateBlock(whileNode.getBody());
+
+        if (whileNode.isDoWhile()) {
+            curStat = new DoWhileLoopTreeImpl(whileNode, condTree, statTree);
+        } else {
+            curStat = new WhileLoopTreeImpl(whileNode, condTree, statTree);
+        }
+
+        return false;
+    }
+
+    @Override
+    public boolean enterWithNode(final WithNode withNode) {
+        curStat = new WithTreeImpl(withNode,
+                translateExpr(withNode.getExpression()),
+                translateBlock(withNode.getBody()));
+
+        return false;
+    }
+
+    private StatementTree translateBlock(final Block blockNode) {
+        if (blockNode == null) {
+            return null;
+        }
+        curStat = null;
+        blockNode.accept(this);
+        return curStat;
+    }
+
+    private List<? extends StatementTree> translateStats(final List<? extends Statement> stats) {
+        if (stats == null) {
+            return null;
+        }
+        final List<StatementTreeImpl> statTrees = new ArrayList<>(stats.size());
+        for (final Statement stat : stats) {
+            curStat = null;
+            stat.accept(this);
+            assert curStat != null;
+            statTrees.add(curStat);
+        }
+        return statTrees;
+    }
+
+    private List<? extends ExpressionTree> translateExprs(final List<? extends Expression> exprs) {
+        if (exprs == null) {
+            return null;
+        }
+        final List<ExpressionTreeImpl> exprTrees = new ArrayList<>(exprs.size());
+        for (final Expression expr : exprs) {
+            curExpr = null;
+            expr.accept(this);
+            assert curExpr != null;
+            exprTrees.add(curExpr);
+        }
+        return exprTrees;
+    }
+
+    private ExpressionTreeImpl translateExpr(final Expression expr) {
+        if (expr == null) {
+            return null;
+        }
+
+        curExpr = null;
+        expr.accept(this);
+        assert curExpr != null : "null for " + expr;
+        return curExpr;
+    }
+
+    private StatementTreeImpl translateStat(final Statement stat) {
+        if (stat == null) {
+            return null;
+        }
+
+        curStat = null;
+        stat.accept(this);
+        assert curStat != null : "null for " + stat;
+        return curStat;
+    }
+
+    private IdentifierTree translateIdent(final IdentNode ident) {
+        return new IdentifierTreeImpl(ident);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IdentifierTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for an identifier expression.
+ *
+ * For example:
+ * <pre>
+ *   <em>name</em>
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface IdentifierTree extends ExpressionTree {
+    /**
+     * Returns the name of this identifier.
+     *
+     * @return the name of this identifier
+     */
+    String getName();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IdentifierTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.IdentNode;
+
+final class IdentifierTreeImpl extends ExpressionTreeImpl implements IdentifierTree {
+    private final String name;
+
+    IdentifierTreeImpl(final IdentNode node) {
+        super(node);
+        this.name = node.getName();
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.IDENTIFIER;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitIdentifier(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IfTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for an 'if' statement.
+ *
+ * For example:
+ * <pre>
+ *   if ( <em>condition</em> )
+ *      <em>thenStatement</em>
+ *
+ *   if ( <em>condition</em> )
+ *       <em>thenStatement</em>
+ *   else
+ *       <em>elseStatement</em>
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface IfTree extends StatementTree {
+    /**
+     * Returns the condition expression of this 'if' statement.
+     *
+     * @return the condition expression
+     */
+    ExpressionTree getCondition();
+
+    /**
+     * Returns the 'then' statement of this 'if' statement.
+     *
+     * @return the 'then' statement
+     */
+    StatementTree getThenStatement();
+
+    /**
+     * Returns the then statement of this 'if' statement.
+     * null if this if statement has no else branch.
+     *
+     * @return the 'else' statement
+     */
+    StatementTree getElseStatement();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/IfTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.IfNode;
+
+final class IfTreeImpl extends StatementTreeImpl implements IfTree {
+    private final ExpressionTree cond;
+    private final StatementTree thenStat;
+    private final StatementTree elseStat;
+    IfTreeImpl(final IfNode node, final ExpressionTree cond,
+            final StatementTree thenStat, final StatementTree elseStat) {
+        super(node);
+        this.cond = cond;
+        this.thenStat = thenStat;
+        this.elseStat = elseStat;
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.IF;
+    }
+
+    @Override
+    public ExpressionTree getCondition() {
+        return cond;
+    }
+
+    @Override
+    public StatementTree getThenStatement() {
+        return thenStat;
+    }
+
+    /**
+     * @return null if this if statement has no else branch.
+     */
+    @Override
+    public StatementTree getElseStatement() {
+        return elseStat;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitIf(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/InstanceOfTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for an 'instanceof' expression.
+ *
+ * For example:
+ * <pre>
+ *   <em>expression</em> instanceof <em>type</em>
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface InstanceOfTree extends ExpressionTree {
+    /**
+     * Returns the expression whose type is being checked.
+     *
+     * @return the expression whose type is being checked
+     */
+    ExpressionTree getExpression();
+
+    /**
+     * Returns the type expression.
+     *
+     * @return the type expression
+     */
+    Tree getType();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/InstanceOfTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.BinaryNode;
+import jdk.nashorn.internal.parser.TokenType;
+
+final class InstanceOfTreeImpl extends BinaryTreeImpl implements InstanceOfTree {
+    InstanceOfTreeImpl(final BinaryNode node,
+            final ExpressionTree expr,
+            final ExpressionTree type) {
+        super(node, expr, type);
+        assert node.tokenType() == TokenType.INSTANCEOF : "instanceof expected";
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.INSTANCE_OF;
+    }
+
+    @Override
+    public ExpressionTree getExpression() {
+        return getLeftOperand();
+    }
+
+    @Override
+    public Tree getType() {
+        return getRightOperand();
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitInstanceOf(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/LabeledStatementTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for a labeled statement.
+ *
+ * For example:
+ * <pre>
+ *   <em>label</em> : <em>statement</em>
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface LabeledStatementTree extends StatementTree {
+    /**
+     * Returns the label associated with this statement.
+     *
+     * @return the label
+     */
+    String getLabel();
+
+    /**
+     * Returns the statement being labeled.
+     *
+     * @return the statement labeled
+     */
+    StatementTree getStatement();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/LabeledStatementTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.LabelNode;
+
+final class LabeledStatementTreeImpl extends StatementTreeImpl
+    implements LabeledStatementTree {
+    private final String name;
+    private final StatementTree stat;
+
+    LabeledStatementTreeImpl(final LabelNode node, final StatementTree stat) {
+        super(node);
+        this.name = node.getLabelName();
+        this.stat = stat;
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.LABELED_STATEMENT;
+    }
+
+    @Override
+    public String getLabel() {
+        return name;
+    }
+
+    @Override
+    public StatementTree getStatement() {
+        return stat;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitLabeledStatement(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/LineMap.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * Provides methods to convert between character positions and line numbers
+ * for a compilation unit.
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface LineMap {
+    /**
+     * Find the line containing a position; a line termination
+     * character is on the line it terminates.
+     *
+     * @param   pos  character offset of the position
+     * @return the line number of pos (first line is 1)
+     */
+    long getLineNumber(long pos);
+
+    /**
+     * Find the column for a character position.
+     * Tab characters preceding the position on the same line
+     * will be expanded when calculating the column number.
+     *
+     * @param  pos   character offset of the position
+     * @return       the tab-expanded column number of pos (first column is 1)
+     */
+    long getColumnNumber(long pos);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/LineMapImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.runtime.Source;
+
+final class LineMapImpl implements LineMap {
+    private final Source source;
+
+    LineMapImpl(final Source source) {
+        this.source = source;
+    }
+
+    @Override
+    public long getLineNumber(long pos) {
+        return source.getLine((int)pos);
+    }
+
+    @Override
+    public long getColumnNumber(long pos) {
+        return source.getColumn((int)pos);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/LiteralTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for a literal expression.
+ * Use {@link #getKind getKind} to determine the kind of literal.
+ *
+ * For example:
+ * <pre>
+ *   <em>value</em>
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface LiteralTree extends ExpressionTree {
+    /**
+     * Returns the value of this literal.
+     *
+     * @return the value of this literal
+     */
+    Object getValue();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/LiteralTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.LiteralNode;
+
+final class LiteralTreeImpl extends ExpressionTreeImpl implements LiteralTree {
+    private final Object value;
+    private final Kind kind;
+    LiteralTreeImpl(final LiteralNode<?> node) {
+        super(node);
+        this.kind = literalKind(node);
+        this.value = node.getValue();
+    }
+
+    @Override
+    public Kind getKind() {
+        return kind;
+    }
+
+    @Override
+    public Object getValue() {
+        return value;
+    }
+
+    private static Kind literalKind(final LiteralNode<?> node) {
+        if (node.isBoolean()) {
+            return Kind.BOOLEAN_LITERAL;
+        } else if (node.isNumeric()) {
+            return Kind.NUMBER_LITERAL;
+        } else if (node.isString()) {
+            return Kind.STRING_LITERAL;
+        } else if (node.isNull()) {
+            return Kind.NULL_LITERAL;
+        } else {
+            throw new AssertionError("should not reach here: " + node.getValue());
+        }
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitLiteral(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/LoopTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A mixin for "loop" statements.
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface LoopTree extends StatementTree {
+    /**
+     * Returns the statement contained in this 'loop' statement.
+     *
+     * @return the statement
+     */
+    StatementTree getStatement();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/MemberSelectTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for a member access expression.
+ *
+ * For example:
+ * <pre>
+ *   <em>expression</em> . <em>identifier</em>
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface MemberSelectTree extends ExpressionTree {
+    /**
+     * The object expression whose member is being selected.
+     *
+     * @return the object whose member is selected
+     */
+    ExpressionTree getExpression();
+
+    /**
+     * Returns the name of the property.
+     *
+     * @return the name of the property
+     */
+    String getIdentifier();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/MemberSelectTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.AccessNode;
+
+final class MemberSelectTreeImpl extends ExpressionTreeImpl
+    implements MemberSelectTree {
+    private final String ident;
+    private final ExpressionTree expr;
+    MemberSelectTreeImpl(final AccessNode node, final ExpressionTree expr) {
+        super(node);
+        this.ident = node.getProperty();
+        this.expr = expr;
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.MEMBER_SELECT;
+    }
+
+    @Override
+    public ExpressionTree getExpression() {
+        return expr;
+    }
+
+    @Override
+    public String getIdentifier() {
+        return ident;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitMemberSelect(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/NewTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.util.List;
+
+/**
+ * A tree node to declare a new instance of a class.
+ *
+ * For example:
+ * <pre>
+ *   new <em>identifier</em> ( )
+ *
+ *   new <em>identifier</em> ( <em>arguments</em> )
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface NewTree extends ExpressionTree {
+    /**
+     * Returns the constructor expression of this 'new' expression.
+     *
+     * @return the constructor expression of this 'new' expression
+     */
+    ExpressionTree getConstructorExpression();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/NewTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.UnaryNode;
+import jdk.nashorn.internal.parser.TokenType;
+
+final class NewTreeImpl extends ExpressionTreeImpl implements NewTree {
+    private final ExpressionTree constrExpr;
+
+    NewTreeImpl(final UnaryNode node, final ExpressionTree constrExpr) {
+        super(node);
+        assert (node.tokenType() == TokenType.NEW) : "new expected";
+        this.constrExpr = constrExpr;
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.NEW;
+    }
+
+    @Override
+    public ExpressionTree getConstructorExpression() {
+        return constrExpr;
+    }
+
+    @Override
+    public <R, D> R accept(TreeVisitor<R, D> visitor, D data) {
+        return visitor.visitNew(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ObjectLiteralTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.util.List;
+
+/**
+ * Represents ECMAScript object literal expression.
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface ObjectLiteralTree extends ExpressionTree {
+    /**
+     * Returns the list of properties of this object literal.
+     *
+     * @return the list of properties of this object literal
+     */
+    public List<? extends PropertyTree> getProperties();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ObjectLiteralTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.util.List;
+import jdk.nashorn.internal.ir.ObjectNode;
+
+final class ObjectLiteralTreeImpl extends ExpressionTreeImpl
+    implements ObjectLiteralTree {
+    private final List<? extends PropertyTree> props;
+    ObjectLiteralTreeImpl(final ObjectNode node, final List<? extends PropertyTree> props) {
+        super(node);
+        this.props = props;
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.OBJECT_LITERAL;
+    }
+
+    @Override
+    public List<? extends PropertyTree> getProperties() {
+        return props;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitObjectLiteral(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ParenthesizedTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for a parenthesized expression.  Note: parentheses
+ * not be preserved by the parser.
+ *
+ * For example:
+ * <pre>
+ *   ( <em>expression</em> )
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface ParenthesizedTree extends ExpressionTree {
+    /**
+     * Returns the expression within the parenthesis.
+     *
+     * @return the expression within the parenthesis
+     */
+    ExpressionTree getExpression();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/Parser.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Reader;
+import java.net.URL;
+import java.nio.file.Path;
+import jdk.nashorn.api.scripting.NashornException;
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
+
+/**
+ * Represents nashorn ECMAScript parser instance.
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface Parser {
+    /**
+     * Parses the source file and returns compilation unit tree
+     *
+     * @param file source file to parse
+     * @param listener to receive diagnostic messages from the parser. This can be null.
+     * if null is passed, a NashornException is thrown on the first parse error.
+     * @return compilation unit tree
+     * @throws NullPointerException if file is null
+     * @throws IOException if parse source read fails
+     * @throws NashornException is thrown if no listener is supplied and parser encounters error
+     */
+    public CompilationUnitTree parse(final File file, final DiagnosticListener listener) throws IOException, NashornException;
+
+    /**
+     * Parses the source Path and returns compilation unit tree
+     *
+     * @param path source Path to parse
+     * @param listener to receive diagnostic messages from the parser. This can be null.
+     * if null is passed, a NashornException is thrown on the first parse error.
+     * @return compilation unit tree
+     * @throws NullPointerException if path is null
+     * @throws IOException if parse source read fails
+     * @throws NashornException is thrown if no listener is supplied and parser encounters error
+     */
+    public CompilationUnitTree parse(final Path path, final DiagnosticListener listener) throws IOException, NashornException;
+
+    /**
+     * Parses the source url and returns compilation unit tree
+     *
+     * @param url source file to parse
+     * @param listener to receive diagnostic messages from the parser. This can be null.
+     * if null is passed, a NashornException is thrown on the first parse error.
+     * @return compilation unit tree
+     * @throws NullPointerException if url is null
+     * @throws IOException if parse source read fails
+     * @throws NashornException is thrown if no listener is supplied and parser encounters error
+     */
+    public CompilationUnitTree parse(final URL url, final DiagnosticListener listener) throws IOException, NashornException;
+
+    /**
+     * Parses the readerand returns compilation unit tree
+     *
+     * @param name name of the source file to parse
+     * @param reader from which source is read
+     * @param listener to receive diagnostic messages from the parser. This can be null.
+     * if null is passed, a NashornException is thrown on the first parse error.
+     * @return compilation unit tree
+     * @throws NullPointerException if name or reader is null
+     * @throws IOException if parse source read fails
+     * @throws NashornException is thrown if no listener is supplied and parser encounters error
+     */
+    public CompilationUnitTree parse(final String name, Reader reader, final DiagnosticListener listener) throws IOException, NashornException;
+
+    /**
+     * Parses the string source and returns compilation unit tree
+     *
+     * @param name of the source
+     * @param code string source
+     * @param listener to receive diagnostic messages from the parser. This can be null.
+     * if null is passed, a NashornException is thrown on the first parse error.
+     * @return compilation unit tree
+     * @throws NullPointerException if name or code is null
+     * @throws NashornException is thrown if no listener is supplied and parser encounters error
+     */
+    public CompilationUnitTree parse(final String name, String code, final DiagnosticListener listener) throws NashornException;
+
+    /**
+     * Parses the source from script object and returns compilation unit tree
+     *
+     * @param scriptObj script object whose script and name properties are used for script source
+     * @param listener to receive diagnostic messages from the parser. This can be null.
+     * if null is passed, a NashornException is thrown on the first parse error.
+     * @return compilation unit tree
+     * @throws NullPointerException if scriptObj is null
+     * @throws NashornException is thrown if no listener is supplied and parser encounters error
+     */
+    public CompilationUnitTree parse(final ScriptObjectMirror scriptObj, final DiagnosticListener listener) throws NashornException;
+
+    /**
+     * Factory method to create a new instance of Parser.
+     *
+     * @param options configuration options to initialize the Parser.
+     *         Currently the following options are supported:
+     *
+     * <dl>
+     * <dt>"--const-as-var"</dt><dd>treat "const" declaration as "var"</dd>
+     * <dt>"-dump-on-error" or "-doe"</dt><dd>dump stack trace on error</dd>
+     * <dt>"--empty-statements"</dt><dd>include empty statement nodes</dd>
+     * <dt>"--no-syntax-extensions" or "-nse"</dt><dd>disable ECMAScript syntax extensions</dd>
+     * <dt>"-scripting"</dt><dd>enable scripting mode extensions</dd>
+     * <dt>"-strict"</dt><dd>enable ECMAScript strict mode</dd>
+     * </dl>
+     *
+     * @throws NullPointerException if options arrry or any of it's element is null
+     * @throws IllegalArgumentException on unsupported option value.
+     * @return a new Parser instance.
+     */
+    public static Parser create(final String... options) throws IllegalArgumentException {
+        options.getClass();
+        for (String opt : options) {
+            switch (opt) {
+                case "--const-as-var":
+                case "-dump-on-error":
+                case "-doe":
+                case "--empty-statements":
+                case "--no-syntax-extensions":
+                case "-nse":
+                case "-scripting":
+                case "-strict":
+                    break;
+                default:
+                    throw new IllegalArgumentException(opt);
+            }
+        }
+
+        return new ParserImpl(options);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ParserImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.net.URL;
+import java.nio.file.Path;
+import java.util.Map;
+import java.util.Objects;
+import jdk.nashorn.api.scripting.NashornException;
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
+import jdk.nashorn.internal.ir.FunctionNode;
+import jdk.nashorn.internal.runtime.Context;
+import jdk.nashorn.internal.runtime.ErrorManager;
+import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.ParserException;
+import jdk.nashorn.internal.runtime.ScriptEnvironment;
+import jdk.nashorn.internal.runtime.Source;
+import jdk.nashorn.internal.runtime.options.Options;
+
+final class ParserImpl implements Parser {
+
+    private final ScriptEnvironment env;
+
+    ParserImpl(final String... args) throws IllegalArgumentException {
+       Objects.requireNonNull(args);
+       Options options = new Options("nashorn");
+       options.process(args);
+       this.env = new ScriptEnvironment(options,
+               new PrintWriter(System.out), new PrintWriter(System.err));
+    }
+
+    @Override
+    public CompilationUnitTree parse(final File file, final DiagnosticListener listener) throws IOException, NashornException {
+        Objects.requireNonNull(file);
+        final Source src = Source.sourceFor(file.getName(), file);
+        return translate(makeParser(src, listener).parse());
+    }
+
+    @Override
+    public CompilationUnitTree parse(final Path path, final DiagnosticListener listener) throws IOException, NashornException {
+        Objects.requireNonNull(path);
+        final Source src = Source.sourceFor(path.toString(), path);
+        return translate(makeParser(src, listener).parse());
+    }
+
+    @Override
+    public CompilationUnitTree parse(final URL url, final DiagnosticListener listener) throws IOException, NashornException {
+        final Source src = Source.sourceFor(url.toString(), url);
+        return translate(makeParser(src, listener).parse());
+    }
+
+    @Override
+    public CompilationUnitTree parse(final String name, final Reader reader, final DiagnosticListener listener) throws IOException, NashornException {
+        Objects.requireNonNull(name);
+        Objects.requireNonNull(reader);
+        final Source src = Source.sourceFor(name, reader);
+        return translate(makeParser(src, listener).parse());
+    }
+
+    @Override
+    public CompilationUnitTree parse(final String name, final String code, final DiagnosticListener listener) throws NashornException {
+        final Source src = Source.sourceFor(name, code);
+        return translate(makeParser(src, listener).parse());
+    }
+
+    @Override
+    public CompilationUnitTree parse(final ScriptObjectMirror scriptObj, final DiagnosticListener listener) throws NashornException {
+        Objects.requireNonNull(scriptObj);
+        final Map<?,?> map = scriptObj;
+        if (map.containsKey("script") && map.containsKey("name")) {
+            final String script = JSType.toString(map.get("script"));
+            final String name   = JSType.toString(map.get("name"));
+            final Source src = Source.sourceFor(name, script);
+            return translate(makeParser(src, listener).parse());
+        } else {
+            throw new IllegalArgumentException("can't find 'script' and 'name' properties");
+        }
+    }
+
+    private jdk.nashorn.internal.parser.Parser makeParser(final Source source, final DiagnosticListener listener) {
+        final ErrorManager errMgr = listener != null? new ListenerErrorManager(listener) : new Context.ThrowErrorManager();
+        return new jdk.nashorn.internal.parser.Parser(env, source, errMgr);
+    }
+
+    private static class ListenerErrorManager extends ErrorManager {
+        private final DiagnosticListener listener;
+
+        ListenerErrorManager(final DiagnosticListener listener) {
+            // null check
+            listener.getClass();
+            this.listener = listener;
+        }
+
+        @Override
+        public void error(final String msg) {
+            error(new ParserException(msg));
+        }
+
+        @Override
+        public void error(final ParserException e) {
+            listener.report(new DiagnosticImpl(e, Diagnostic.Kind.ERROR));
+        }
+
+        @Override
+        public void warning(final String msg) {
+            warning(new ParserException(msg));
+        }
+
+        @Override
+        public void warning(final ParserException e) {
+            listener.report(new DiagnosticImpl(e, Diagnostic.Kind.WARNING));
+        }
+    }
+
+    private CompilationUnitTree translate(final FunctionNode node) {
+        return new IRTranslator().translate(node);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/PropertyTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * To represent property setting in an object literal tree.
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface PropertyTree extends Tree {
+    /**
+     * Returns the name of this property.
+     *
+     * @return the name of the property
+     */
+    public ExpressionTree getKey();
+
+    /**
+     * Returns the value of this property. This is null for accessor properties.
+     *
+     * @return the value of the property
+     */
+    public ExpressionTree getValue();
+
+    /**
+     * Returns the setter function of this property if this
+     * is an accessor property. This is null for data properties.
+     *
+     * @return the setter function of the property
+     */
+    public FunctionExpressionTree getGetter();
+
+    /**
+     * Returns the getter function of this property if this
+     * is an accessor property. This is null for data properties.
+     *
+     * @return the getter function of the property
+     */
+    public FunctionExpressionTree getSetter();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/PropertyTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.PropertyNode;
+
+final class PropertyTreeImpl extends TreeImpl implements PropertyTree  {
+    private final ExpressionTree key;
+    private final ExpressionTree value;
+    private final FunctionExpressionTree getter;
+    private final FunctionExpressionTree setter;
+    PropertyTreeImpl(final PropertyNode node,
+            final ExpressionTree key,
+            final ExpressionTree value,
+            final FunctionExpressionTree getter,
+            final FunctionExpressionTree setter) {
+        super(node);
+        this.key    = key;
+        this.value  = value;
+        this.getter = getter;
+        this.setter = setter;
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.PROPERTY;
+    }
+
+    @Override
+    public ExpressionTree getKey() {
+        return key;
+    }
+
+    @Override
+    public ExpressionTree getValue() {
+        return value;
+    }
+
+    @Override
+    public FunctionExpressionTree getGetter() {
+        return getter;
+    }
+
+    @Override
+    public FunctionExpressionTree getSetter() {
+        return setter;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitProperty(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/RegExpLiteralTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * Represents regular expression literal in the source code.
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface RegExpLiteralTree extends Tree {
+    /**
+     * Regular expression pattern to match.
+     *
+     * @return regular expression patten
+     */
+    public String getPattern();
+
+    /**
+     * Regular expression matching options.
+     *
+     * @return options like "i" for ignoreCase used
+     */
+    public String getOptions();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/RegExpLiteralTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.LiteralNode;
+import jdk.nashorn.internal.parser.Lexer;
+
+final class RegExpLiteralTreeImpl extends ExpressionTreeImpl
+    implements RegExpLiteralTree {
+    private final String pattern;
+    private final String options;
+    RegExpLiteralTreeImpl(final LiteralNode<?> node) {
+        super(node);
+        assert node.getValue() instanceof Lexer.RegexToken : "regexp expected";
+        final Lexer.RegexToken regex = (Lexer.RegexToken) node.getValue();
+        this.pattern = regex.getExpression();
+        this.options = regex.getOptions();
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.REGEXP_LITERAL;
+    }
+
+    @Override
+    public String getPattern() {
+        return pattern;
+    }
+
+    @Override
+    public String getOptions() {
+        return options;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitRegExpLiteral(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ReturnTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for a 'return' statement.
+ *
+ * For example:
+ * <pre>
+ *   return;
+ *   return <em>expression</em>;
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface ReturnTree extends StatementTree {
+    /**
+     * Returns the expression being returned. This is null if no value
+     * is being returned. i.e., empty return statement.
+     *
+     * @return the returned expression
+     */
+    ExpressionTree getExpression();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ReturnTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.ReturnNode;
+
+final class ReturnTreeImpl extends StatementTreeImpl implements ReturnTree {
+    private final ExpressionTree expr;
+
+    ReturnTreeImpl(final ReturnNode returnNode, final ExpressionTree expr) {
+        super(returnNode);
+        this.expr = expr;
+    }
+
+    @Override
+    public Tree.Kind getKind() {
+        return Tree.Kind.RETURN;
+    }
+
+    @Override
+    public ExpressionTree getExpression() {
+        return expr;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitReturn(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SimpleTreeVisitorES5_1.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,390 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A simple implementation of the TreeVisitor for ECMAScript edition 5.1.
+ *
+ * <p>The visit methods corresponding to ES 5.1 language constructs walk the
+ * "components" of the given tree by calling accept method passing the
+ * current visitor and the additional parameter.
+ *
+ * <p>For constructs introduced in later versions, {@code visitUnknown}
+ * is called instead which throws {@link UnknownTreeException}.
+ *
+ * <p> Methods in this class may be overridden subject to their
+ * general contract.  Note that annotating methods in concrete
+ * subclasses with {@link java.lang.Override @Override} will help
+ * ensure that methods are overridden as intended.
+ *
+ * @param <R> the return type of this visitor's methods.  Use {@link
+ *            Void} for visitors that do not need to return results.
+ * @param <P> the type of the additional parameter to this visitor's
+ *            methods.  Use {@code Void} for visitors that do not need an
+ *            additional parameter.
+ */
+public class SimpleTreeVisitorES5_1<R, P> implements TreeVisitor<R, P> {
+    @Override
+    public R visitAssignment(AssignmentTree node, P r) {
+        node.getVariable().accept(this, r);
+        node.getExpression().accept(this, r);
+        return null;
+    }
+
+    @Override
+    public R visitCompoundAssignment(CompoundAssignmentTree node, P r) {
+        node.getVariable().accept(this, r);
+        node.getExpression().accept(this, r);
+        return null;
+    }
+
+    @Override
+    public R visitBinary(BinaryTree node, P r) {
+        node.getLeftOperand().accept(this, r);
+        node.getRightOperand().accept(this, r);
+        return null;
+    }
+
+    @Override
+    public R visitBlock(BlockTree node, P r) {
+        node.getStatements().forEach((tree) -> {
+            tree.accept(this, r);
+        });
+        return null;
+    }
+
+    @Override
+    public R visitBreak(BreakTree node, P r) {
+        return null;
+    }
+
+    @Override
+    public R visitCase(CaseTree node, P r) {
+        final Tree caseVal = node.getExpression();
+        if (caseVal != null) {
+            caseVal.accept(this, r);
+        }
+
+        node.getStatements().forEach((tree) -> {
+            tree.accept(this, r);
+        });
+        return null;
+    }
+
+    @Override
+    public R visitCatch(CatchTree node, P r) {
+        final Tree cond = node.getCondition();
+        if (cond != null) {
+            cond.accept(this, r);
+        }
+        node.getParameter().accept(this, r);
+        node.getBlock().accept(this, r);
+        return null;
+    }
+
+    @Override
+    public R visitConditionalExpression(ConditionalExpressionTree node, P r) {
+        node.getCondition().accept(this, r);
+        node.getTrueExpression().accept(this, r);
+        node.getFalseExpression().accept(this, r);
+        return null;
+    }
+
+    @Override
+    public R visitContinue(ContinueTree node, P r) {
+        return null;
+    }
+
+    @Override
+    public R visitDebugger(DebuggerTree node, P r) {
+        return null;
+    }
+
+    @Override
+    public R visitDoWhileLoop(DoWhileLoopTree node, P r) {
+        node.getStatement().accept(this, r);
+        node.getCondition().accept(this, r);
+        return null;
+    }
+
+    @Override
+    public R visitErroneous(ErroneousTree node, P r) {
+        return null;
+    }
+
+    @Override
+    public R visitExpressionStatement(ExpressionStatementTree node, P r) {
+        node.getExpression().accept(this, r);
+        return null;
+    }
+
+    @Override
+    public R visitForLoop(ForLoopTree node, P r) {
+        final Tree init = node.getInitializer();
+        if (init != null) {
+            init.accept(this, r);
+        }
+
+        final Tree cond = node.getCondition();
+        if (cond != null) {
+            cond.accept(this, r);
+        }
+
+        final Tree update = node.getUpdate();
+        if (update != null) {
+            update.accept(this, r);
+        }
+
+        node.getStatement().accept(this, r);
+        return null;
+    }
+
+    @Override
+    public R visitForInLoop(ForInLoopTree node, P r) {
+        node.getVariable().accept(this, r);
+        node.getExpression().accept(this, r);
+        final StatementTree stat = node.getStatement();
+        if (stat != null) {
+            stat.accept(this, r);
+        }
+        return null;
+    }
+
+    @Override
+    public R visitFunctionCall(FunctionCallTree node, P r) {
+        node.getFunctionSelect().accept(this, r);
+        node.getArguments().forEach((tree) -> {
+            tree.accept(this, r);
+        });
+        return null;
+    }
+
+    @Override
+    public R visitFunctionDeclaration(FunctionDeclarationTree node, P r) {
+        node.getParameters().forEach((tree) -> {
+            tree.accept(this, r);
+        });
+        node.getBody().accept(this, r);
+        return null;
+    }
+
+    @Override
+    public R visitFunctionExpression(FunctionExpressionTree node, P r) {
+        node.getParameters().forEach((tree) -> {
+            tree.accept(this, r);
+        });
+        node.getBody().accept(this, r);
+        return null;
+    }
+
+    @Override
+    public R visitIdentifier(IdentifierTree node, P r) {
+        return null;
+    }
+
+    @Override
+    public R visitIf(IfTree node, P r) {
+        node.getCondition().accept(this, r);
+        node.getThenStatement().accept(this, r);
+        final Tree elseStat = node.getElseStatement();
+        if (elseStat != null) {
+            elseStat.accept(this, r);
+        }
+        return null;
+    }
+
+    @Override
+    public R visitArrayAccess(ArrayAccessTree node, P r) {
+        node.getExpression().accept(this, r);
+        node.getIndex().accept(this, r);
+        return null;
+    }
+
+    @Override
+    public R visitArrayLiteral(ArrayLiteralTree node, P r) {
+        node.getElements().stream().filter((tree) -> (tree != null)).forEach((tree) -> {
+            tree.accept(this, r);
+        });
+        return null;
+    }
+
+    @Override
+    public R visitLabeledStatement(LabeledStatementTree node, P r) {
+        node.getStatement().accept(this, r);
+        return null;
+    }
+
+    @Override
+    public R visitLiteral(LiteralTree node, P r) {
+        return null;
+    }
+
+    @Override
+    public R visitParenthesized(ParenthesizedTree node, P r) {
+        node.getExpression().accept(this, r);
+        return null;
+    }
+
+    @Override
+    public R visitReturn(ReturnTree node, P r) {
+        final Tree retExpr = node.getExpression();
+        if (retExpr != null) {
+            retExpr.accept(this, r);
+        }
+        return null;
+    }
+
+    @Override
+    public R visitMemberSelect(MemberSelectTree node, P r) {
+        node.getExpression().accept(this, r);
+        return null;
+    }
+
+    @Override
+    public R visitNew(NewTree node, P r) {
+        node.getConstructorExpression().accept(this, r);
+        return null;
+    }
+
+    @Override
+    public R visitObjectLiteral(ObjectLiteralTree node, P r) {
+        node.getProperties().forEach((tree) -> {
+            tree.accept(this, r);
+        });
+        return null;
+    }
+
+    @Override
+    public R visitProperty(PropertyTree node, P r) {
+        FunctionExpressionTree getter = node.getGetter();
+        if (getter != null) {
+            getter.accept(this, r);
+        }
+        ExpressionTree key = node.getKey();
+        if (key != null) {
+            key.accept(this, r);
+        }
+
+        FunctionExpressionTree setter = node.getSetter();
+        if (setter != null) {
+            setter.accept(this, r);
+        }
+
+        ExpressionTree value = node.getValue();
+        if (value != null) {
+            value.accept(this, r);
+        }
+        return null;
+    }
+
+    @Override
+    public R visitRegExpLiteral(RegExpLiteralTree node, P r) {
+        return null;
+    }
+
+    @Override
+    public R visitEmptyStatement(EmptyStatementTree node, P r) {
+        return null;
+    }
+
+    @Override
+    public R visitSwitch(SwitchTree node, P r) {
+        node.getExpression().accept(this, r);
+        node.getCases().forEach((tree) -> {
+            tree.accept(this, r);
+        });
+        return null;
+    }
+
+    @Override
+    public R visitThrow(ThrowTree node, P r) {
+        node.getExpression().accept(this, r);
+        return null;
+    }
+
+    @Override
+    public R visitCompilationUnit(CompilationUnitTree node, P r) {
+        node.getSourceElements().forEach((tree) -> {
+            tree.accept(this, r);
+        });
+        return null;
+    }
+
+    @Override
+    public R visitTry(TryTree node, P r) {
+        node.getBlock().accept(this, r);
+        node.getCatches().forEach((tree) -> {
+            tree.accept(this, r);
+        });
+
+        final Tree finallyBlock = node.getFinallyBlock();
+        if (finallyBlock != null) {
+            finallyBlock.accept(this, r);
+        }
+        return null;
+    }
+
+    @Override
+    public R visitInstanceOf(InstanceOfTree node, P r) {
+        node.getType().accept(this, r);
+        node.getExpression().accept(this, r);
+        return null;
+    }
+
+    @Override
+    public R visitUnary(UnaryTree node, P r) {
+        node.getExpression().accept(this, r);
+        return null;
+    }
+
+    @Override
+    public R visitVariable(VariableTree node, P r) {
+        if (node.getInitializer() != null) {
+            node.getInitializer().accept(this, r);
+        }
+        return null;
+    }
+
+    @Override
+    public R visitWhileLoop(WhileLoopTree node, P r) {
+        node.getCondition().accept(this, r);
+        node.getStatement().accept(this, r);
+        return null;
+    }
+
+    @Override
+    public R visitWith(WithTree node, P r) {
+        node.getScope().accept(this, r);
+        node.getStatement().accept(this, r);
+        return null;
+    }
+
+    @Override
+    public R visitUnknown(Tree node, P r) {
+        // unknown in ECMAScript 5.1 edition
+        throw new UnknownTreeException(node, r);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/StatementTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node used as the base class for the different kinds of
+ * statements.
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface StatementTree extends Tree {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/StatementTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.Block;
+import jdk.nashorn.internal.ir.Statement;
+
+abstract class StatementTreeImpl extends TreeImpl implements StatementTree {
+    StatementTreeImpl(final Statement stat) {
+        super(stat);
+    }
+
+    StatementTreeImpl(final Block stat) {
+        super(stat);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SwitchTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.util.List;
+
+/**
+ * A tree node for a 'switch' statement.
+ *
+ * For example:
+ * <pre>
+ *   switch ( <em>expression</em> ) {
+ *     <em>cases</em>
+ *   }
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface SwitchTree extends StatementTree {
+    /**
+     * Returns the expression on which this statement switches.
+     *
+     * @return the switch expression
+     */
+    ExpressionTree getExpression();
+
+
+    /**
+     * Returns the list of 'case' statements.
+     *
+     * @return the 'case' statements
+     */
+    List<? extends CaseTree> getCases();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SwitchTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.util.List;
+import jdk.nashorn.internal.ir.SwitchNode;
+
+final class SwitchTreeImpl extends StatementTreeImpl implements SwitchTree {
+    private final ExpressionTree expr;
+    private final List<? extends CaseTree> cases;
+    SwitchTreeImpl(final SwitchNode node,
+            final ExpressionTree expr,
+            List<? extends CaseTree> cases) {
+        super(node);
+        this.expr = expr;
+        this.cases = cases;
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.SWITCH;
+    }
+
+    @Override
+    public ExpressionTree getExpression() {
+        return expr;
+    }
+
+    @Override
+    public List<? extends CaseTree> getCases() {
+        return cases;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitSwitch(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ThrowTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for a 'throw' statement.
+ *
+ * For example:
+ * <pre>
+ *   throw <em>expression</em>;
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface ThrowTree extends StatementTree {
+    /**
+     * Returns the expression being thrown.
+     *
+     * @return the expression being thrown.
+     */
+    ExpressionTree getExpression();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/ThrowTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.ThrowNode;
+
+final class ThrowTreeImpl extends StatementTreeImpl implements ThrowTree {
+    private final ExpressionTree expr;
+    ThrowTreeImpl(final ThrowNode node, final ExpressionTree expr) {
+        super(node);
+        this.expr = expr;
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.THROW;
+    }
+
+    @Override
+    public ExpressionTree getExpression() {
+        return expr;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitThrow(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/Tree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,599 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * Common interface for all nodes in an abstract syntax tree.
+ *
+ * <p><b>WARNING:</b> This interface and its sub-interfaces are
+ * subject to change as the ECMAScript  programming language evolves.
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface Tree {
+
+    /**
+     * Enumerates all kinds of trees.
+     */
+    @jdk.Exported
+    public enum Kind {
+        /**
+         * Used for instances of {@link ArrayAccessTree}.
+         */
+        ARRAY_ACCESS(ArrayAccessTree.class),
+
+        /**
+         * Used for instances of {@link ArrayLiteralTree}.
+         */
+        ARRAY_LITERAL(ArrayLiteralTree.class),
+
+        /**
+         * Used for instances of {@link AssignmentTree}.
+         */
+        ASSIGNMENT(AssignmentTree.class),
+
+        /**
+         * Used for instances of {@link BlockTree}.
+         */
+        BLOCK(BlockTree.class),
+
+        /**
+         * Used for instances of {@link BreakTree}.
+         */
+        BREAK(BreakTree.class),
+
+        /**
+         * Used for instances of {@link CaseTree}.
+         */
+        CASE(CaseTree.class),
+
+        /**
+         * Used for instances of {@link CatchTree}.
+         */
+        CATCH(CatchTree.class),
+
+        /**
+         * Used for instances of {@link CompilationUnitTree}.
+         */
+        COMPILATION_UNIT(CompilationUnitTree.class),
+
+        /**
+         * Used for instances of {@link ConditionalExpressionTree}.
+         */
+        CONDITIONAL_EXPRESSION(ConditionalExpressionTree.class),
+
+        /**
+         * Used for instances of {@link ContinueTree}.
+         */
+        CONTINUE(ContinueTree.class),
+
+        /**
+         * Used for instances of {@link DoWhileLoopTree}.
+         */
+        DO_WHILE_LOOP(DoWhileLoopTree.class),
+
+        /**
+         * Used for instances of {@link DebuggerTree}.
+         */
+        DEBUGGER(DebuggerTree.class),
+
+        /**
+         * Used for instances of {@link ForInLoopTree}.
+         */
+        FOR_IN_LOOP(ForInLoopTree.class),
+
+        /**
+         * Used for instances of {@link FunctionExpressionTree}.
+         */
+        FUNCTION_EXPRESSION(FunctionExpressionTree.class),
+
+        /**
+         * Used for instances of {@link ErroneousTree}.
+         */
+        ERROR(ErroneousTree.class),
+
+        /**
+         * Used for instances of {@link ExpressionStatementTree}.
+         */
+        EXPRESSION_STATEMENT(ExpressionStatementTree.class),
+
+        /**
+         * Used for instances of {@link MemberSelectTree}.
+         */
+        MEMBER_SELECT(MemberSelectTree.class),
+
+        /**
+         * Used for instances of {@link ForLoopTree}.
+         */
+        FOR_LOOP(ForLoopTree.class),
+
+        /**
+         * Used for instances of {@link IdentifierTree}.
+         */
+        IDENTIFIER(IdentifierTree.class),
+
+        /**
+         * Used for instances of {@link IfTree}.
+         */
+        IF(IfTree.class),
+
+        /**
+         * Used for instances of {@link InstanceOfTree}.
+         */
+        INSTANCE_OF(InstanceOfTree.class),
+
+        /**
+         * Used for instances of {@link LabeledStatementTree}.
+         */
+        LABELED_STATEMENT(LabeledStatementTree.class),
+
+        /**
+         * Used for instances of {@link FunctionDeclarationTree}.
+         */
+        FUNCTION(FunctionDeclarationTree.class),
+
+        /**
+         * Used for instances of {@link FunctionCallTree}.
+         */
+        FUNCTION_INVOCATION(FunctionCallTree.class),
+
+        /**
+         * Used for instances of {@link NewTree}.
+         */
+        NEW(NewTree.class),
+
+        /**
+         * Used for instances of {@link ObjectLiteralTree}.
+         */
+        OBJECT_LITERAL(ObjectLiteralTree.class),
+
+        /**
+         * Used for instances of {@link ParenthesizedTree}.
+         */
+        PARENTHESIZED(ParenthesizedTree.class),
+
+        /**
+         * Used for instances of {@link PropertyTree}.
+         */
+        PROPERTY(PropertyTree.class),
+
+        /**
+         * Used for instances of {@link RegExpLiteralTree}.
+         */
+        REGEXP_LITERAL(RegExpLiteralTree.class),
+
+        /**
+         * Used for instances of {@link ReturnTree}.
+         */
+        RETURN(ReturnTree.class),
+
+        /**
+         * Used for instances of {@link EmptyStatementTree}.
+         */
+        EMPTY_STATEMENT(EmptyStatementTree.class),
+
+        /**
+         * Used for instances of {@link SwitchTree}.
+         */
+        SWITCH(SwitchTree.class),
+
+        /**
+         * Used for instances of {@link ThrowTree}.
+         */
+        THROW(ThrowTree.class),
+
+        /**
+         * Used for instances of {@link TryTree}.
+         */
+        TRY(TryTree.class),
+
+        /**
+         * Used for instances of {@link VariableTree}.
+         */
+        VARIABLE(VariableTree.class),
+
+        /**
+         * Used for instances of {@link WhileLoopTree}.
+         */
+        WHILE_LOOP(WhileLoopTree.class),
+
+        /**
+         * Used for instances of {@link WithTree}.
+         */
+        WITH(WithTree.class),
+
+        /**
+         * Used for instances of {@link UnaryTree} representing postfix
+         * increment operator {@code ++}.
+         */
+        POSTFIX_INCREMENT(UnaryTree.class),
+
+        /**
+         * Used for instances of {@link UnaryTree} representing postfix
+         * decrement operator {@code --}.
+         */
+        POSTFIX_DECREMENT(UnaryTree.class),
+
+        /**
+         * Used for instances of {@link UnaryTree} representing prefix
+         * increment operator {@code ++}.
+         */
+        PREFIX_INCREMENT(UnaryTree.class),
+
+        /**
+         * Used for instances of {@link UnaryTree} representing prefix
+         * decrement operator {@code --}.
+         */
+        PREFIX_DECREMENT(UnaryTree.class),
+
+        /**
+         * Used for instances of {@link UnaryTree} representing unary plus
+         * operator {@code +}.
+         */
+        UNARY_PLUS(UnaryTree.class),
+
+        /**
+         * Used for instances of {@link UnaryTree} representing unary minus
+         * operator {@code -}.
+         */
+        UNARY_MINUS(UnaryTree.class),
+
+        /**
+         * Used for instances of {@link UnaryTree} representing bitwise
+         * complement operator {@code ~}.
+         */
+        BITWISE_COMPLEMENT(UnaryTree.class),
+
+        /**
+         * Used for instances of {@link UnaryTree} representing logical
+         * complement operator {@code !}.
+         */
+        LOGICAL_COMPLEMENT(UnaryTree.class),
+
+        /**
+         * Used for instances of {@link UnaryTree} representing logical
+         * delete operator {@code delete}.
+         */
+        DELETE(UnaryTree.class),
+
+        /**
+         * Used for instances of {@link UnaryTree} representing logical
+         * typeof operator {@code typeof}.
+         */
+        TYPEOF(UnaryTree.class),
+
+        /**
+         * Used for instances of {@link UnaryTree} representing logical
+         * void operator {@code typeof}.
+         */
+        VOID(UnaryTree.class),
+
+        /**
+         * Used for instances of {@link BinaryTree} representing
+         * comma {@code ,}.
+         */
+        COMMA(BinaryTree.class),
+
+        /**
+         * Used for instances of {@link BinaryTree} representing
+         * multiplication {@code *}.
+         */
+        MULTIPLY(BinaryTree.class),
+
+        /**
+         * Used for instances of {@link BinaryTree} representing
+         * division {@code /}.
+         */
+        DIVIDE(BinaryTree.class),
+
+        /**
+         * Used for instances of {@link BinaryTree} representing
+         * remainder {@code %}.
+         */
+        REMAINDER(BinaryTree.class),
+
+         /**
+         * Used for instances of {@link BinaryTree} representing
+         * addition or string concatenation {@code +}.
+         */
+        PLUS(BinaryTree.class),
+
+        /**
+         * Used for instances of {@link BinaryTree} representing
+         * subtraction {@code -}.
+         */
+        MINUS(BinaryTree.class),
+
+        /**
+         * Used for instances of {@link BinaryTree} representing
+         * left shift {@code <<}.
+         */
+        LEFT_SHIFT(BinaryTree.class),
+
+        /**
+         * Used for instances of {@link BinaryTree} representing
+         * right shift {@code >>}.
+         */
+        RIGHT_SHIFT(BinaryTree.class),
+
+        /**
+         * Used for instances of {@link BinaryTree} representing
+         * unsigned right shift {@code >>>}.
+         */
+        UNSIGNED_RIGHT_SHIFT(BinaryTree.class),
+
+        /**
+         * Used for instances of {@link BinaryTree} representing
+         * less-than {@code <}.
+         */
+        LESS_THAN(BinaryTree.class),
+
+        /**
+         * Used for instances of {@link BinaryTree} representing
+         * greater-than {@code >}.
+         */
+        GREATER_THAN(BinaryTree.class),
+
+        /**
+         * Used for instances of {@link BinaryTree} representing
+         * less-than-equal {@code <=}.
+         */
+        LESS_THAN_EQUAL(BinaryTree.class),
+
+        /**
+         * Used for instances of {@link BinaryTree} representing
+         * greater-than-equal {@code >=}.
+         */
+        GREATER_THAN_EQUAL(BinaryTree.class),
+
+        /**
+         * Used for instances of {@link BinaryTree} representing
+         * in operator {@code in}.
+         */
+        IN(BinaryTree.class),
+
+        /**
+         * Used for instances of {@link BinaryTree} representing
+         * equal-to {@code ==}.
+         */
+        EQUAL_TO(BinaryTree.class),
+
+        /**
+         * Used for instances of {@link BinaryTree} representing
+         * not-equal-to {@code !=}.
+         */
+        NOT_EQUAL_TO(BinaryTree.class),
+
+        /**
+         * Used for instances of {@link BinaryTree} representing
+         * equal-to {@code ===}.
+         */
+        STRICT_EQUAL_TO(BinaryTree.class),
+
+        /**
+         * Used for instances of {@link BinaryTree} representing
+         * not-equal-to {@code !==}.
+         */
+        STRICT_NOT_EQUAL_TO(BinaryTree.class),
+
+        /**
+         * Used for instances of {@link BinaryTree} representing
+         * bitwise and logical "and" {@code &}.
+         */
+        AND(BinaryTree.class),
+
+        /**
+         * Used for instances of {@link BinaryTree} representing
+         * bitwise and logical "xor" {@code ^}.
+         */
+        XOR(BinaryTree.class),
+
+        /**
+         * Used for instances of {@link BinaryTree} representing
+         * bitwise and logical "or" {@code |}.
+         */
+        OR(BinaryTree.class),
+
+        /**
+         * Used for instances of {@link BinaryTree} representing
+         * conditional-and {@code &&}.
+         */
+        CONDITIONAL_AND(BinaryTree.class),
+
+        /**
+         * Used for instances of {@link BinaryTree} representing
+         * conditional-or {@code ||}.
+         */
+        CONDITIONAL_OR(BinaryTree.class),
+
+        /**
+         * Used for instances of {@link CompoundAssignmentTree} representing
+         * multiplication assignment {@code *=}.
+         */
+        MULTIPLY_ASSIGNMENT(CompoundAssignmentTree.class),
+
+        /**
+         * Used for instances of {@link CompoundAssignmentTree} representing
+         * division assignment {@code /=}.
+         */
+        DIVIDE_ASSIGNMENT(CompoundAssignmentTree.class),
+
+        /**
+         * Used for instances of {@link CompoundAssignmentTree} representing
+         * remainder assignment {@code %=}.
+         */
+        REMAINDER_ASSIGNMENT(CompoundAssignmentTree.class),
+
+        /**
+         * Used for instances of {@link CompoundAssignmentTree} representing
+         * addition or string concatenation assignment {@code +=}.
+         */
+        PLUS_ASSIGNMENT(CompoundAssignmentTree.class),
+
+        /**
+         * Used for instances of {@link CompoundAssignmentTree} representing
+         * subtraction assignment {@code -=}.
+         */
+        MINUS_ASSIGNMENT(CompoundAssignmentTree.class),
+
+        /**
+         * Used for instances of {@link CompoundAssignmentTree} representing
+         * left shift assignment {@code <<=}.
+         */
+        LEFT_SHIFT_ASSIGNMENT(CompoundAssignmentTree.class),
+
+        /**
+         * Used for instances of {@link CompoundAssignmentTree} representing
+         * right shift assignment {@code >>=}.
+         */
+        RIGHT_SHIFT_ASSIGNMENT(CompoundAssignmentTree.class),
+
+        /**
+         * Used for instances of {@link CompoundAssignmentTree} representing
+         * unsigned right shift assignment {@code >>>=}.
+         */
+        UNSIGNED_RIGHT_SHIFT_ASSIGNMENT(CompoundAssignmentTree.class),
+
+        /**
+         * Used for instances of {@link CompoundAssignmentTree} representing
+         * bitwise and logical "and" assignment {@code &=}.
+         */
+        AND_ASSIGNMENT(CompoundAssignmentTree.class),
+
+        /**
+         * Used for instances of {@link CompoundAssignmentTree} representing
+         * bitwise and logical "xor" assignment {@code ^=}.
+         */
+        XOR_ASSIGNMENT(CompoundAssignmentTree.class),
+
+        /**
+         * Used for instances of {@link CompoundAssignmentTree} representing
+         * bitwise and logical "or" assignment {@code |=}.
+         */
+        OR_ASSIGNMENT(CompoundAssignmentTree.class),
+
+        /**
+         * Used for instances of {@link LiteralTree} representing
+         * a number literal expression of type {@code double}.
+         */
+        NUMBER_LITERAL(LiteralTree.class),
+
+        /**
+         * Used for instances of {@link LiteralTree} representing
+         * a boolean literal expression of type {@code boolean}.
+         */
+        BOOLEAN_LITERAL(LiteralTree.class),
+
+        /**
+         * Used for instances of {@link LiteralTree} representing
+         * a string literal expression of type {@link String}.
+         */
+        STRING_LITERAL(LiteralTree.class),
+
+        /**
+         * Used for instances of {@link LiteralTree} representing
+         * the use of {@code null}.
+         */
+        NULL_LITERAL(LiteralTree.class),
+
+        /**
+         * An implementation-reserved node. This is the not the node
+         * you are looking for.
+         */
+        OTHER(null);
+
+        Kind(Class<? extends Tree> intf) {
+            associatedInterface = intf;
+        }
+
+        public Class<? extends Tree> asInterface() {
+            return associatedInterface;
+        }
+
+        /**
+         * Returns if this is a literal tree kind or not.
+         *
+         * @return true if this is a literal tree kind, false otherwise
+         */
+        public boolean isLiteral() {
+            return associatedInterface == LiteralTree.class;
+        }
+
+        /**
+         * Returns if this is an expression tree kind or not.
+         *
+         * @return true if this is an expression tree kind, false otherwise
+         */
+        public boolean isExpression() {
+            return ExpressionTree.class.isAssignableFrom(associatedInterface);
+        }
+
+        /**
+         * Returns if this is a statement tree kind or not.
+         *
+         * @return true if this is a statement tree kind, false otherwise
+         */
+        public boolean isStatement() {
+            return StatementTree.class.isAssignableFrom(associatedInterface);
+        }
+
+        private final Class<? extends Tree> associatedInterface;
+    }
+
+    /**
+     * Start character offset of this Tree within the source.
+     *
+     * @return the position
+     */
+    long getStartPosition();
+
+    /**
+     * End character offset of this Tree within the source.
+     *
+     * @return the position
+     */
+    long getEndPosition();
+
+    /**
+     * Gets the kind of this tree.
+     *
+     * @return the kind of this tree.
+     */
+    Kind getKind();
+
+    /**
+     * Accept method used to implement the visitor pattern.  The
+     * visitor pattern is used to implement operations on trees.
+     *
+     * @param <R> result type of this operation.
+     * @param <D> type of additional data.
+     * @param visitor tree visitor
+     * @param data additional data passed to visitor methods
+     * @return the value from visitor's visit methods
+     */
+    <R,D> R accept(TreeVisitor<R,D> visitor, D data);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/TreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.Node;
+
+import jdk.nashorn.internal.parser.TokenType;
+
+abstract class TreeImpl implements Tree {
+    protected final Node node;
+
+    TreeImpl(final Node node) {
+        this.node = node;
+    }
+
+    @Override
+    public long getStartPosition() {
+        return node.getStart();
+    }
+
+    @Override
+    public long getEndPosition() {
+        return node.getFinish();
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitUnknown(this, data);
+    }
+
+    static Kind getOperator(final TokenType tt) {
+        switch(tt) {
+            case NEW:
+                return Kind.NEW;
+            case NOT:
+                return Kind.LOGICAL_COMPLEMENT;
+            case NE:
+                return Kind.NOT_EQUAL_TO;
+            case NE_STRICT:
+                return Kind.STRICT_NOT_EQUAL_TO;
+            case MOD:
+                return Kind.REMAINDER;
+            case ASSIGN_MOD:
+                return Kind.REMAINDER_ASSIGNMENT;
+            case BIT_AND:
+                return Kind.AND;
+            case AND:
+                return Kind.CONDITIONAL_AND;
+            case ASSIGN_BIT_AND:
+                return Kind.AND_ASSIGNMENT;
+            case MUL:
+                return Kind.MULTIPLY;
+            case ASSIGN_MUL:
+                return Kind.MULTIPLY_ASSIGNMENT;
+            case ADD:
+                return Kind.PLUS;
+            case INCPREFIX:
+                return Kind.PREFIX_INCREMENT;
+            case INCPOSTFIX:
+                return Kind.POSTFIX_INCREMENT;
+            case ASSIGN_ADD:
+                return Kind.PLUS_ASSIGNMENT;
+            case SUB:
+                return Kind.MINUS;
+            case DECPREFIX:
+                return Kind.PREFIX_DECREMENT;
+            case DECPOSTFIX:
+                return Kind.POSTFIX_DECREMENT;
+            case ASSIGN_SUB:
+                return Kind.MINUS_ASSIGNMENT;
+            case DIV:
+                return Kind.DIVIDE;
+            case ASSIGN_DIV:
+                return Kind.DIVIDE_ASSIGNMENT;
+            case LT:
+                return Kind.LESS_THAN;
+            case SHL:
+                return Kind.LEFT_SHIFT;
+            case ASSIGN_SHL:
+                return Kind.LEFT_SHIFT_ASSIGNMENT;
+            case LE:
+                return Kind.LESS_THAN_EQUAL;
+            case ASSIGN:
+                return Kind.ASSIGNMENT;
+            case EQ:
+                return Kind.EQUAL_TO;
+            case EQ_STRICT:
+                return Kind.STRICT_EQUAL_TO;
+            case GT:
+                return Kind.GREATER_THAN;
+            case GE:
+                return Kind.GREATER_THAN_EQUAL;
+            case SAR:
+                return Kind.RIGHT_SHIFT;
+            case ASSIGN_SAR:
+                return Kind.RIGHT_SHIFT_ASSIGNMENT;
+            case SHR:
+                return Kind.UNSIGNED_RIGHT_SHIFT;
+            case ASSIGN_SHR:
+                return Kind.UNSIGNED_RIGHT_SHIFT_ASSIGNMENT;
+            case TERNARY:
+                return Kind.CONDITIONAL_EXPRESSION;
+            case BIT_XOR:
+                return Kind.XOR;
+            case ASSIGN_BIT_XOR:
+                return Kind.XOR_ASSIGNMENT;
+            case BIT_OR:
+                return Kind.OR;
+            case ASSIGN_BIT_OR:
+                return Kind.OR_ASSIGNMENT;
+            case OR:
+                return Kind.CONDITIONAL_OR;
+            case BIT_NOT:
+                return Kind.BITWISE_COMPLEMENT;
+            case DELETE:
+                return Kind.DELETE;
+            case TYPEOF:
+                return Kind.TYPEOF;
+            case VOID:
+                return Kind.VOID;
+            case IN:
+                return Kind.IN;
+            case INSTANCEOF:
+                return Kind.INSTANCE_OF;
+            case COMMARIGHT:
+                return Kind.COMMA;
+            default:
+                throw new AssertionError("should not reach here: " + tt);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/TreeVisitor.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,438 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A visitor of trees, in the style of the visitor design pattern.
+ * Classes implementing this interface are used to operate
+ * on a tree when the kind of tree is unknown at compile time.
+ * When a visitor is passed to an tree's {@link Tree#accept
+ * accept} method, the <tt>visit<i>XYZ</i></tt> method most applicable
+ * to that tree is invoked.
+ *
+ * <p> Classes implementing this interface may or may not throw a
+ * {@code NullPointerException} if the additional parameter {@code p}
+ * is {@code null}; see documentation of the implementing class for
+ * details.
+ *
+ * <p> <b>WARNING:</b> It is possible that methods will be added to
+ this interface to accommodate new, currently unknown, language
+ structures added to future versions of the ECMAScript programming
+ language. When new visit methods are added for new Tree subtypes,
+ default method bodies will be introduced which will call visitUnknown
+ method as a fallback.
+ *
+ * @param <R> the return type of this visitor's methods.  Use {@link
+ *            Void} for visitors that do not need to return results.
+ * @param <P> the type of the additional parameter to this visitor's
+ *            methods.  Use {@code Void} for visitors that do not need an
+ *            additional parameter.
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface TreeVisitor<R,P> {
+    /**
+     * Visit assignment tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitAssignment(AssignmentTree node, P p);
+
+    /**
+     * Visit compound assignment tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitCompoundAssignment(CompoundAssignmentTree node, P p);
+
+    /**
+     * Visit binary expression tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitBinary(BinaryTree node, P p);
+
+    /**
+     * Visit block statement tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitBlock(BlockTree node, P p);
+
+    /**
+     * Visit break statement tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitBreak(BreakTree node, P p);
+
+    /**
+     * Visit case statement tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitCase(CaseTree node, P p);
+
+    /**
+     * Visit catch block statement tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitCatch(CatchTree node, P p);
+
+    /**
+     * Visit conditional expression tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitConditionalExpression(ConditionalExpressionTree node, P p);
+
+    /**
+     * Visit continue statement tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitContinue(ContinueTree node, P p);
+
+    /**
+     * Visit debugger statement tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitDebugger(DebuggerTree node, P p);
+
+    /**
+     * Visit do-while statement tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitDoWhileLoop(DoWhileLoopTree node, P p);
+
+    /**
+     * Visit error expression tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitErroneous(ErroneousTree node, P p);
+
+    /**
+     * Visit expression statement tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitExpressionStatement(ExpressionStatementTree node, P p);
+
+    /**
+     * Visit 'for' statement tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitForLoop(ForLoopTree node, P p);
+
+    /**
+     * Visit for..in statement tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitForInLoop(ForInLoopTree node, P p);
+
+    /**
+     * Visit function call expression tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitFunctionCall(FunctionCallTree node, P p);
+
+    /**
+     * Visit function declaration tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitFunctionDeclaration(FunctionDeclarationTree node, P p);
+
+    /**
+     * Visit function expression tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitFunctionExpression(FunctionExpressionTree node, P p);
+
+        /**
+     * Visit identifier tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitIdentifier(IdentifierTree node, P p);
+
+    /**
+     * Visit 'if' statement tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitIf(IfTree node, P p);
+
+    /**
+     * Visit array access expression tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitArrayAccess(ArrayAccessTree node, P p);
+
+    /**
+     * Visit array literal expression tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitArrayLiteral(ArrayLiteralTree node, P p);
+
+    /**
+     * Visit labeled statement tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitLabeledStatement(LabeledStatementTree node, P p);
+
+    /**
+     * Visit literal expression tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitLiteral(LiteralTree node, P p);
+
+    /**
+     * Visit parenthesized expression tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitParenthesized(ParenthesizedTree node, P p);
+
+    /**
+     * Visit return statement tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitReturn(ReturnTree node, P p);
+
+    /**
+     * Visit member select expression tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitMemberSelect(MemberSelectTree node, P p);
+
+    /**
+     * Visit 'new' expression tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitNew(NewTree node, P p);
+
+    /**
+     * Visit object literal tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitObjectLiteral(ObjectLiteralTree node, P p);
+
+    /**
+     * Visit a property of an object literal expression tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitProperty(PropertyTree node, P p);
+
+    /**
+     * Visit regular expression literal tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitRegExpLiteral(RegExpLiteralTree node, P p);
+
+    /**
+     * Visit an empty statement tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitEmptyStatement(EmptyStatementTree node, P p);
+
+    /**
+     * Visit 'switch' statement tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitSwitch(SwitchTree node, P p);
+
+    /**
+     * Visit 'throw' expression tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitThrow(ThrowTree node, P p);
+
+    /**
+     * Visit compilation unit tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitCompilationUnit(CompilationUnitTree node, P p);
+
+    /**
+     * Visit 'try' statement tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitTry(TryTree node, P p);
+
+    /**
+     * Visit 'instanceof' expression tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitInstanceOf(InstanceOfTree node, P p);
+
+    /**
+     * Visit unary expression tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitUnary(UnaryTree node, P p);
+
+    /**
+     * Visit variable declaration tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitVariable(VariableTree node, P p);
+
+    /**
+     * Visit 'while' statement tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitWhileLoop(WhileLoopTree node, P p);
+
+    /**
+     * Visit 'with' statement tree.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitWith(WithTree node, P p);
+
+    /**
+     * Visit unknown expression/statement tree. This fallback will be
+     * called if new Tree subtypes are introduced in future. A specific
+     * implementation may throw {{@linkplain UnknownTreeException unknown tree exception}
+     * if the visitor implementation was for an older language version.
+     *
+     * @param node node being visited
+     * @param p extra parameter passed to the visitor
+     * @return value from the visitor
+     */
+    R visitUnknown(Tree node, P p);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/TryTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.util.List;
+
+/**
+ * A tree node for a 'try' statement.
+ *
+ * For example:
+ * <pre>
+ *   try
+ *       <em>block</em>
+ *   <em>catches</em>
+ *   finally
+ *       <em>finallyBlock</em>
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface TryTree extends StatementTree {
+    /**
+     * Returns the 'try' block of this 'try' statement.
+     *
+     * @return the 'try' block
+     */
+    BlockTree getBlock();
+
+    /**
+     * Returns the list of 'catch' statements associated with this 'try'.
+     *
+     * @return the list of 'catch' statements associated with this 'try'.
+     */
+    List<? extends CatchTree> getCatches();
+
+    /**
+     * Returns the 'finally' block associated with this 'try'. This is
+     * null if there is no 'finally' block associated with this 'try'.
+     *
+     * @return the 'finally' block associated with this 'try'.
+     */
+    BlockTree getFinallyBlock();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/TryTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import java.util.List;
+import jdk.nashorn.internal.ir.TryNode;
+
+final class TryTreeImpl extends StatementTreeImpl implements TryTree {
+    private final BlockTree block;
+    private final List<? extends CatchTree> catches;
+    private final BlockTree finallyBlock;
+    TryTreeImpl(final TryNode node,
+            final BlockTree block,
+            final List<? extends CatchTree> catches,
+            final BlockTree finallyBlock) {
+        super(node);
+        this.block = block;
+        this.catches = catches;
+        this.finallyBlock = finallyBlock;
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.TRY;
+    }
+
+    @Override
+    public BlockTree getBlock() {
+        return block;
+    }
+
+    @Override
+    public List<? extends CatchTree> getCatches() {
+        return catches;
+    }
+
+    @Override
+    public BlockTree getFinallyBlock() {
+        return finallyBlock;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitTry(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/UnaryTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for postfix and unary expressions.
+ * Use {@link #getKind getKind} to determine the kind of operator.
+ *
+ * For example:
+ * <pre>
+ *   <em>operator</em> <em>expression</em>
+ *
+ *   <em>expression</em> <em>operator</em>
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface UnaryTree extends ExpressionTree {
+    /**
+     * Returns the expression operated by the unary operator.
+     *
+     * @return The expression operated by the unary operator.
+     */
+    ExpressionTree getExpression();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/UnaryTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.UnaryNode;
+
+class UnaryTreeImpl extends ExpressionTreeImpl implements UnaryTree {
+    private final ExpressionTree expr;
+    private final Kind kind;
+    UnaryTreeImpl(final UnaryNode node, final ExpressionTree expr) {
+        super(node);
+        this.expr = expr;
+        this.kind = getOperator(node.tokenType());
+    }
+
+    @Override
+    public Kind getKind() {
+        return kind;
+    }
+
+    @Override
+    public ExpressionTree getExpression() {
+        return expr;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitUnary(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/UnknownTreeException.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+
+/**
+ * Indicates that an unknown kind of Tree was encountered.  This
+ * can occur if the language evolves and new kinds of Trees are
+ * added to the {@code Tree} hierarchy.  May be thrown by a
+ * {@linkplain TreeVisitor tree visitor} to indicate that the
+ * visitor was created for a prior version of the language.
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public class UnknownTreeException extends RuntimeException {
+
+    private static final long serialVersionUID = 1L;
+
+    private transient final Tree tree;
+    private transient final Object parameter;
+
+    /**
+     * Creates a new {@code UnknownTreeException}.  The {@code p}
+     * parameter may be used to pass in an additional argument with
+     * information about the context in which the unknown element was
+     * encountered; for example, the visit methods of {@link
+     * TreeVisitor} may pass in their additional parameter.
+     *
+     * @param t the unknown tree, may be {@code null}
+     * @param p an additional parameter, may be {@code null}
+     */
+    public UnknownTreeException(Tree t, Object p) {
+        super("Unknown tree: " + t);
+        this.tree = t;
+        this.parameter = p;
+    }
+
+    /**
+     * Returns the unknown tree.
+     * The value may be unavailable if this exception has been
+     * serialized and then read back in.
+     *
+     * @return the unknown element, or {@code null} if unavailable
+     */
+    public Tree getUnknownTree() {
+        return tree;
+    }
+
+    /**
+     * Returns the additional argument.
+     * The value may be unavailable if this exception has been
+     * serialized and then read back in.
+     *
+     * @return the additional argument
+     */
+    public Object getArgument() {
+        return parameter;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/VariableTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for a variable declaration.
+ *
+ * For example:
+ * <pre>
+ *   <em>var</em> <em>name</em> <em>initializer</em> ;
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface VariableTree extends StatementTree {
+    /**
+     * Returns the name of this variable.
+     *
+     * @return the name of this variable
+     */
+    String getName();
+
+    /**
+     * Returns the initial value expression for this variable. This is
+     * null if no initial value for this variable.
+     *
+     * @return the initial value expression
+     */
+    ExpressionTree getInitializer();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/VariableTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.VarNode;
+
+final class VariableTreeImpl extends StatementTreeImpl implements VariableTree {
+    private final String name;
+    private final ExpressionTree init;
+
+    VariableTreeImpl(final VarNode node, final ExpressionTree init) {
+        super(node);
+        this.name = node.getName().getName();
+        this.init = init;
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.VARIABLE;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public ExpressionTree getInitializer() {
+        return init;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitVariable(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/WhileLoopTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for a 'while' loop statement.
+ *
+ * For example:
+ * <pre>
+ *   while ( <em>condition</em> )
+ *     <em>statement</em>
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface WhileLoopTree extends ConditionalLoopTree {
+    /**
+     * The condition expression of this 'while' statement.
+     *
+     * @return the condition expression
+     */
+    ExpressionTree getCondition();
+
+    /**
+     * The statement contained in this 'while' statement.
+     *
+     * @return the statement contained
+     */
+    StatementTree getStatement();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/WhileLoopTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.WhileNode;
+
+final class WhileLoopTreeImpl extends StatementTreeImpl implements WhileLoopTree {
+    private final ExpressionTree cond;
+    private final StatementTree stat;
+
+    WhileLoopTreeImpl(final WhileNode node, final ExpressionTree cond, final StatementTree stat) {
+        super(node);
+        assert !node.isDoWhile() : "while expected";
+        this.cond = cond;
+        this.stat = stat;
+    }
+
+    @Override
+    public Tree.Kind getKind() {
+        return Tree.Kind.WHILE_LOOP;
+    }
+
+    @Override
+    public ExpressionTree getCondition() {
+        return cond;
+    }
+
+    @Override
+    public StatementTree getStatement() {
+        return stat;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitWhileLoop(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/WithTree.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+/**
+ * A tree node for a 'with' statement.
+ *
+ * For example:
+ * <pre>
+ *   with ( <em>scope</em> )
+ *     <em>statement</em>
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public interface WithTree extends StatementTree {
+    /**
+     * The scope object expression for this 'with' statement.
+     *
+     * @return the scope object
+     */
+    ExpressionTree getScope();
+
+    /**
+     * The statement contained in this 'with' statement.
+     *
+     * @return the statement contained
+     */
+    StatementTree getStatement();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/WithTreeImpl.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api.tree;
+
+import jdk.nashorn.internal.ir.WithNode;
+
+final class WithTreeImpl extends StatementTreeImpl implements WithTree {
+    private final ExpressionTree scope;
+    private final StatementTree stat;
+    WithTreeImpl(final WithNode node, final ExpressionTree scope,
+            final StatementTree stat) {
+        super(node);
+        this.scope = scope;
+        this.stat = stat;
+    }
+
+    @Override
+    public Kind getKind() {
+        return Kind.WITH;
+    }
+
+    @Override
+    public ExpressionTree getScope() {
+        return scope;
+    }
+
+    @Override
+    public StatementTree getStatement() {
+        return stat;
+    }
+
+    @Override
+    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
+        return visitor.visitWith(this, data);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/package-info.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * <p>
+ * Nashorn parser API provides interfaces to represent ECMAScript source code
+ * as abstract syntax trees (AST) and Parser to parse ECMAScript source scripts.
+ * </p>
+ * <p>
+ * Using parser API user can write Java code to access parse tree
+ * representation of ECMAScript source. Script source may be a file,
+ * a URL or a String. Unless stated otherwise null argument in methods of this
+ * package result in NullPointerException being thrown.
+ * </p>
+ *
+ * <pre>
+ * <code>
+ * import jdk.nashorn.api.tree.*;
+ * import java.io.File;
+ *
+ * // Simple example that prints warning on 'with' statements
+ * public class Main {
+ *     public static void main(String[] args) throws Exception {
+ *         // Create a new parser instance
+ *         Parser parser = Parser.create();
+ *         File sourceFile = new File(args[0]);
+ *
+ *         // Parse given source File using parse method.
+ *         // Pass a diagnostic listener to print error messages.
+ *         CompilationUnitTree cut = parser.parse(sourceFile,
+ *             (d) -&gt; { System.out.println(d); });
+ *
+ *         if (cut != null) {
+ *             // call Tree.accept method passing a SimpleTreeVisitor
+ *             cut.accept(new SimpleTreeVisitor&lt;Void, Void&gt;() {
+ *                 // visit method for 'with' statement
+ *                 public Void visitWith(WithTree wt, Void v) {
+ *                     // print warning on 'with' statement
+ *                     System.out.println("Warning: using 'with' statement!");
+ *                     return null;
+ *                 }
+ *             }, null);
+ *         }
+ *     }
+ * }
+ * </code>
+ * </pre>
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+package jdk.nashorn.api.tree;
+
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Lower.java	Mon Mar 09 11:34:48 2015 +0100
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Lower.java	Mon Mar 09 20:14:10 2015 +0530
@@ -45,6 +45,7 @@
 import jdk.nashorn.internal.ir.CallNode;
 import jdk.nashorn.internal.ir.CaseNode;
 import jdk.nashorn.internal.ir.CatchNode;
+import jdk.nashorn.internal.ir.DebuggerNode;
 import jdk.nashorn.internal.ir.ContinueNode;
 import jdk.nashorn.internal.ir.EmptyNode;
 import jdk.nashorn.internal.ir.Expression;
@@ -185,6 +186,15 @@
     }
 
     @Override
+    public boolean enterDebuggerNode(final DebuggerNode debuggerNode) {
+        final int line = debuggerNode.getLineNumber();
+        final long token = debuggerNode.getToken();
+        final int finish = debuggerNode.getFinish();
+        addStatement(new ExpressionStatement(line, token, finish, new RuntimeNode(token, finish, RuntimeNode.Request.DEBUGGER, new ArrayList<Expression>())));
+        return false;
+    }
+
+    @Override
     public boolean enterJumpToInlinedFinally(final JumpToInlinedFinally jumpToInlinedFinally) {
         addStatement(jumpToInlinedFinally);
         return false;
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/Block.java	Mon Mar 09 11:34:48 2015 +0100
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/Block.java	Mon Mar 09 20:14:10 2015 +0530
@@ -56,7 +56,7 @@
     /** Break label. */
     private final Label breakLabel;
 
-    /** Does the block/function need a new scope? */
+    /** Does the block/function need a new scope? Is this synthetic? */
     protected final int flags;
 
     /**
@@ -80,6 +80,11 @@
     public static final int IS_GLOBAL_SCOPE = 1 << 3;
 
     /**
+     * Is this block a synthetic one introduced by Parser?
+     */
+    public static final int IS_SYNTHETIC = 1 << 4;
+
+    /**
      * Constructor
      *
      * @param token      The first token of the block
@@ -108,7 +113,7 @@
      * @param statements All statements in the block
      */
     public Block(final long token, final int finish, final Statement...statements){
-        this(token, finish, 0, statements);
+        this(token, finish, IS_SYNTHETIC, statements);
     }
 
     /**
@@ -119,7 +124,7 @@
      * @param statements All statements in the block
      */
     public Block(final long token, final int finish, final List<Statement> statements){
-        this(token, finish, 0, statements);
+        this(token, finish, IS_SYNTHETIC, statements);
     }
 
     /**
@@ -366,6 +371,15 @@
         return (flags & NEEDS_SCOPE) == NEEDS_SCOPE;
     }
 
+    /**
+     * Check whether this block is synthetic or not.
+     *
+     * @return true if this is a synthetic block
+     */
+    public boolean isSynthetic() {
+        return (flags & IS_SYNTHETIC) == IS_SYNTHETIC;
+    }
+
     @Override
     public Block setFlags(final LexicalContext lc, final int flags) {
         if (this.flags == flags) {
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/BlockStatement.java	Mon Mar 09 11:34:48 2015 +0100
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/BlockStatement.java	Mon Mar 09 20:14:10 2015 +0530
@@ -90,6 +90,15 @@
         return block.isTerminal();
     }
 
+    /**
+     * Tells if this is a synthetic block statement or not.
+     *
+     * @return true if this is a synthetic statement
+     */
+    public boolean isSynthetic() {
+        return block.isSynthetic();
+    }
+
     @Override
     public Node accept(final NodeVisitor<? extends LexicalContext> visitor) {
         if (visitor.enterBlockStatement(this)) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/DebuggerNode.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.ir;
+
+import jdk.nashorn.internal.ir.annotations.Immutable;
+import jdk.nashorn.internal.ir.visitor.NodeVisitor;
+
+/**
+ * IR representation for a debugger statement.
+ */
+@Immutable
+public final class DebuggerNode extends Statement {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Constructor
+     *
+     * @param lineNumber line number
+     * @param token      token
+     * @param finish     finish
+     */
+    public DebuggerNode(final int lineNumber, final long token, final int finish) {
+        super(lineNumber, token, finish);
+    }
+
+    @Override
+    public Node accept(final NodeVisitor<? extends LexicalContext> visitor) {
+        if (visitor.enterDebuggerNode(this)) {
+            return visitor.leaveDebuggerNode(this);
+        }
+
+        return this;
+    }
+
+    @Override
+    public void toString(final StringBuilder sb, final boolean printType) {
+        sb.append("debugger");
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/ErrorNode.java	Mon Mar 09 20:14:10 2015 +0530
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.internal.ir;
+
+import java.util.function.Function;
+import jdk.nashorn.internal.codegen.types.Type;
+import jdk.nashorn.internal.ir.annotations.Immutable;
+import jdk.nashorn.internal.ir.visitor.NodeVisitor;
+
+/**
+ * IR representation for an error expression.
+ */
+@Immutable
+public final class ErrorNode extends Expression {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Constructor
+     *
+     * @param token      token
+     * @param finish     finish
+     */
+    public ErrorNode(final long token, final int finish) {
+        super(token, finish);
+    }
+
+    @Override
+    public Type getType() {
+        return Type.OBJECT;
+    }
+
+    @Override
+    public Node accept(final NodeVisitor<? extends LexicalContext> visitor) {
+        if (visitor.enterErrorNode(this)) {
+            return visitor.leaveErrorNode(this);
+        }
+
+        return this;
+    }
+
+    @Override
+    public void toString(final StringBuilder sb, final boolean printType) {
+        sb.append("<error>");
+    }
+}
+
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/LiteralNode.java	Mon Mar 09 11:34:48 2015 +0100
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/LiteralNode.java	Mon Mar 09 20:14:10 2015 +0530
@@ -181,6 +181,28 @@
     }
 
     /**
+     * Test if the value is an array
+     *
+     * @return True if value is an array
+     */
+    public boolean isArray() {
+        return false;
+    }
+
+    public List<Expression> getElementExpressions() {
+        return null;
+    }
+
+    /**
+     * Test if the value is a boolean.
+     *
+     * @return True if value is a boolean.
+     */
+    public boolean isBoolean() {
+        return value instanceof Boolean;
+    }
+
+    /**
      * Test if the value is a string.
      *
      * @return True if value is a string.
@@ -607,6 +629,12 @@
         /** Sub units with indexes ranges, in which to split up code generation, for large literals */
         private final List<ArrayUnit> units;
 
+        @Override
+        public boolean isArray() {
+            return true;
+        }
+
+
         /**
          * An ArrayUnit is a range in an ArrayLiteral. ArrayLiterals can
          * be split if they are too large, for bytecode generation reasons
@@ -834,6 +862,7 @@
          * null.
          * @return a list of array element expressions.
          */
+        @Override
         public List<Expression> getElementExpressions() {
             return Collections.unmodifiableList(Arrays.asList(value));
         }
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/debug/JSONWriter.java	Mon Mar 09 11:34:48 2015 +0100
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/debug/JSONWriter.java	Mon Mar 09 20:14:10 2015 +0530
@@ -38,6 +38,7 @@
 import jdk.nashorn.internal.ir.CaseNode;
 import jdk.nashorn.internal.ir.CatchNode;
 import jdk.nashorn.internal.ir.ContinueNode;
+import jdk.nashorn.internal.ir.DebuggerNode;
 import jdk.nashorn.internal.ir.EmptyNode;
 import jdk.nashorn.internal.ir.Expression;
 import jdk.nashorn.internal.ir.ExpressionStatement;
@@ -289,6 +290,13 @@
     }
 
     @Override
+    public boolean enterDebuggerNode(final DebuggerNode debuggerNode) {
+        enterDefault(debuggerNode);
+        type("DebuggerStatement");
+        return leave();
+    }
+
+    @Override
     public boolean enterEmptyNode(final EmptyNode emptyNode) {
         enterDefault(emptyNode);
 
@@ -302,7 +310,7 @@
         // handle debugger statement
         final Node expression = expressionStatement.getExpression();
         if (expression instanceof RuntimeNode) {
-            expression.accept(this);
+            assert false : "should not reach here: RuntimeNode";
             return false;
         }
 
@@ -319,14 +327,18 @@
 
     @Override
     public boolean enterBlockStatement(final BlockStatement blockStatement) {
+        if (blockStatement.isSynthetic()) {
+            final Block blk = blockStatement.getBlock();
+            blk.getStatements().get(0).accept(this);
+            return false;
+        }
+
         enterDefault(blockStatement);
 
         type("BlockStatement");
         comma();
 
-        property("block");
-        blockStatement.getBlock().accept(this);
-
+        array("body", blockStatement.getBlock().getStatements());
         return leave();
     }
 
@@ -677,19 +689,13 @@
 
     @Override
     public boolean enterRuntimeNode(final RuntimeNode runtimeNode) {
-        final RuntimeNode.Request req = runtimeNode.getRequest();
-
-        if (req == RuntimeNode.Request.DEBUGGER) {
-            enterDefault(runtimeNode);
-            type("DebuggerStatement");
-            return leave();
-        }
-
+        assert false : "should not reach here: RuntimeNode";
         return false;
     }
 
     @Override
     public boolean enterSplitNode(final SplitNode splitNode) {
+        assert false : "should not reach here: SplitNode";
         return false;
     }
 
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/visitor/NodeVisitor.java	Mon Mar 09 11:34:48 2015 +0100
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/visitor/NodeVisitor.java	Mon Mar 09 20:14:10 2015 +0530
@@ -34,7 +34,9 @@
 import jdk.nashorn.internal.ir.CaseNode;
 import jdk.nashorn.internal.ir.CatchNode;
 import jdk.nashorn.internal.ir.ContinueNode;
+import jdk.nashorn.internal.ir.DebuggerNode;
 import jdk.nashorn.internal.ir.EmptyNode;
+import jdk.nashorn.internal.ir.ErrorNode;
 import jdk.nashorn.internal.ir.ExpressionStatement;
 import jdk.nashorn.internal.ir.ForNode;
 import jdk.nashorn.internal.ir.FunctionNode;
@@ -293,6 +295,27 @@
         return leaveDefault(continueNode);
     }
 
+
+    /**
+     * Callback for entering a DebuggerNode
+     *
+     * @param  debuggerNode the node
+     * @return true if traversal should continue and node children be traversed, false otherwise
+     */
+    public boolean enterDebuggerNode(final DebuggerNode debuggerNode) {
+        return enterDefault(debuggerNode);
+    }
+
+    /**
+     * Callback for leaving a DebuggerNode
+     *
+     * @param  debuggerNode the node
+     * @return processed node, which will replace the original one, or the original node
+     */
+    public Node leaveDebuggerNode(final DebuggerNode debuggerNode) {
+        return leaveDefault(debuggerNode);
+    }
+
     /**
      * Callback for entering an EmptyNode
      *
@@ -314,6 +337,26 @@
     }
 
     /**
+     * Callback for entering an ErrorNode
+     *
+     * @param  errorNode   the node
+     * @return true if traversal should continue and node children be traversed, false otherwise
+     */
+    public boolean enterErrorNode(final ErrorNode errorNode) {
+        return enterDefault(errorNode);
+    }
+
+    /**
+     * Callback for leaving an ErrorNode
+     *
+     * @param  errorNode the node
+     * @return processed node, which will replace the original one, or the original node
+     */
+    public Node leaveErrorNode(final ErrorNode errorNode) {
+        return leaveDefault(errorNode);
+    }
+
+    /**
      * Callback for entering an ExpressionStatement
      *
      * @param  expressionStatement the node
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java	Mon Mar 09 11:34:48 2015 +0100
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java	Mon Mar 09 20:14:10 2015 +0530
@@ -77,7 +77,9 @@
 import jdk.nashorn.internal.ir.CaseNode;
 import jdk.nashorn.internal.ir.CatchNode;
 import jdk.nashorn.internal.ir.ContinueNode;
+import jdk.nashorn.internal.ir.DebuggerNode;
 import jdk.nashorn.internal.ir.EmptyNode;
+import jdk.nashorn.internal.ir.ErrorNode;
 import jdk.nashorn.internal.ir.Expression;
 import jdk.nashorn.internal.ir.ExpressionStatement;
 import jdk.nashorn.internal.ir.ForNode;
@@ -356,7 +358,8 @@
             restoreBlock(body);
             body.setFlag(Block.NEEDS_SCOPE);
 
-            final Block functionBody = new Block(functionToken, source.getLength() - 1, body.getFlags(), body.getStatements());
+            final Block functionBody = new Block(functionToken, source.getLength() - 1,
+                body.getFlags() | Block.IS_SYNTHETIC, body.getStatements());
             lc.pop(function);
 
             expect(EOF);
@@ -540,7 +543,8 @@
             expect(RBRACE);
         }
 
-        return new Block(blockToken, finish, newBlock.getFlags(), newBlock.getStatements());
+        final int flags = newBlock.getFlags() | (needsBraces? 0 : Block.IS_SYNTHETIC);
+        return new Block(blockToken, finish, flags, newBlock.getStatements());
     }
 
 
@@ -559,7 +563,7 @@
         } finally {
             restoreBlock(newBlock);
         }
-        return new Block(newBlock.getToken(), finish, newBlock.getFlags(), newBlock.getStatements());
+        return new Block(newBlock.getToken(), finish, newBlock.getFlags() | Block.IS_SYNTHETIC, newBlock.getStatements());
     }
 
     /**
@@ -712,7 +716,7 @@
 
         restoreBlock(body);
         body.setFlag(Block.NEEDS_SCOPE);
-        final Block programBody = new Block(functionToken, functionLine, body.getFlags(), body.getStatements());
+        final Block programBody = new Block(functionToken, functionLine, body.getFlags() | Block.IS_SYNTHETIC, body.getStatements());
         lc.pop(script);
         script.setLastToken(token);
 
@@ -826,8 +830,13 @@
                         }
                     }
                 } catch (final Exception e) {
+                    final int errorLine = line;
+                    final long errorToken = token;
                     //recover parsing
                     recover(e);
+                    final ErrorNode errorExpr = new ErrorNode(errorToken, finish);
+                    final ExpressionStatement expressionStatement = new ExpressionStatement(errorLine, errorToken, finish, errorExpr);
+                    appendStatement(expressionStatement);
                 }
 
                 // No backtracking from here on.
@@ -1853,7 +1862,7 @@
                     appendStatement(catchNode);
                 } finally {
                     restoreBlock(catchBlock);
-                    catchBlocks.add(new Block(catchBlock.getToken(), finish, catchBlock.getFlags(), catchBlock.getStatements()));
+                    catchBlocks.add(new Block(catchBlock.getToken(), finish, catchBlock.getFlags() | Block.IS_SYNTHETIC, catchBlock.getStatements()));
                 }
 
                 // If unconditional catch then should to be the end.
@@ -1883,7 +1892,7 @@
             restoreBlock(outer);
         }
 
-        appendStatement(new BlockStatement(startLine, new Block(tryToken, finish, outer.getFlags(), outer.getStatements())));
+        appendStatement(new BlockStatement(startLine, new Block(tryToken, finish, outer.getFlags() | Block.IS_SYNTHETIC, outer.getStatements())));
     }
 
     /**
@@ -1901,7 +1910,7 @@
         // DEBUGGER tested in caller.
         next();
         endOfLine();
-        appendStatement(new ExpressionStatement(debuggerLine, debuggerToken, finish, new RuntimeNode(debuggerToken, finish, RuntimeNode.Request.DEBUGGER, Collections.<Expression>emptyList())));
+        appendStatement(new DebuggerNode(debuggerLine, debuggerToken, finish));
     }
 
     /**
@@ -2882,7 +2891,6 @@
         Block functionBody;
         int bodyFinish = 0;
 
-
         final boolean parseBody;
         Object endParserState = null;
         try {
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Source.java	Mon Mar 09 11:34:48 2015 +0100
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Source.java	Mon Mar 09 20:14:10 2015 +0530
@@ -484,6 +484,30 @@
      * Constructor
      *
      * @param name  source name
+     * @param path  path from which source can be loaded
+     *
+     * @return source instance
+     *
+     * @throws IOException if source cannot be loaded
+     */
+    public static Source sourceFor(final String name, final Path path) throws IOException {
+        File file = null;
+        try {
+            file = path.toFile();
+        } catch (final UnsupportedOperationException uoe) {
+        }
+
+        if (file != null) {
+            return sourceFor(name, file);
+        } else {
+            return sourceFor(name, Files.newBufferedReader(path));
+        }
+    }
+
+    /**
+     * Constructor
+     *
+     * @param name  source name
      * @param file  file from which source can be loaded
      * @param cs    Charset used to convert bytes to chars
      *
@@ -601,7 +625,7 @@
 
     /**
      * Get explicit source URL.
-     * @return URL set vial sourceURL directive
+     * @return URL set via sourceURL directive
      */
     public String getExplicitURL() {
         return explicitURL;
--- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/options/Options.java	Mon Mar 09 11:34:48 2015 +0100
+++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/options/Options.java	Mon Mar 09 20:14:10 2015 +0530
@@ -429,6 +429,7 @@
 
         while (!argList.isEmpty()) {
             final String arg = argList.remove(0);
+            Objects.requireNonNull(arg);
 
             // skip empty args
             if (arg.isEmpty()) {
--- a/test/script/basic/parser/tryCatchStat.js.EXPECTED	Mon Mar 09 11:34:48 2015 +0100
+++ b/test/script/basic/parser/tryCatchStat.js.EXPECTED	Mon Mar 09 20:14:10 2015 +0530
@@ -2,31 +2,51 @@
     "type": "Program",
     "body": [
         {
-            "type": "BlockStatement",
+            "type": "TryStatement",
             "block": {
                 "type": "BlockStatement",
-                "body": [
-                    {
-                        "type": "TryStatement",
-                        "block": {
-                            "type": "BlockStatement",
-                            "body": []
-                        },
-                        "guardedHandlers": [],
-                        "handler": {
-                            "type": "CatchClause",
-                            "param": {
-                                "type": "Identifier",
-                                "name": "e"
-                            },
-                            "body": {
-                                "type": "BlockStatement",
-                                "body": []
-                            }
-                        },
-                        "finalizer": null
-                    }
-                ]
+                "body": []
+            },
+            "guardedHandlers": [],
+            "handler": {
+                "type": "CatchClause",
+                "param": {
+                    "type": "Identifier",
+                    "name": "e"
+                },
+                "body": {
+                    "type": "BlockStatement",
+                    "body": []
+                }
+            },
+            "finalizer": null
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "TryStatement",
+            "block": {
+                "type": "BlockStatement",
+                "body": []
+            },
+            "guardedHandlers": [],
+            "handler": {
+                "type": "CatchClause",
+                "param": {
+                    "type": "Identifier",
+                    "name": "e"
+                },
+                "body": {
+                    "type": "BlockStatement",
+                    "body": []
+                }
+            },
+            "finalizer": {
+                "type": "BlockStatement",
+                "body": []
             }
         }
     ]
@@ -35,31 +55,114 @@
     "type": "Program",
     "body": [
         {
-            "type": "BlockStatement",
+            "type": "TryStatement",
+            "block": {
+                "type": "BlockStatement",
+                "body": []
+            },
+            "guardedHandlers": [],
+            "handler": null,
+            "finalizer": {
+                "type": "BlockStatement",
+                "body": []
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "TryStatement",
+            "block": {
+                "type": "BlockStatement",
+                "body": []
+            },
+            "guardedHandlers": [],
+            "handler": {
+                "type": "CatchClause",
+                "param": {
+                    "type": "Identifier",
+                    "name": "e"
+                },
+                "body": {
+                    "type": "BlockStatement",
+                    "body": [
+                        {
+                            "type": "ExpressionStatement",
+                            "expression": {
+                                "type": "CallExpression",
+                                "callee": {
+                                    "type": "Identifier",
+                                    "name": "handle"
+                                },
+                                "arguments": []
+                            }
+                        }
+                    ]
+                }
+            },
+            "finalizer": null
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "TryStatement",
             "block": {
                 "type": "BlockStatement",
                 "body": [
                     {
-                        "type": "TryStatement",
-                        "block": {
-                            "type": "BlockStatement",
-                            "body": []
-                        },
-                        "guardedHandlers": [],
-                        "handler": {
-                            "type": "CatchClause",
-                            "param": {
+                        "type": "ExpressionStatement",
+                        "expression": {
+                            "type": "CallExpression",
+                            "callee": {
                                 "type": "Identifier",
-                                "name": "e"
+                                "name": "that"
                             },
-                            "body": {
-                                "type": "BlockStatement",
-                                "body": []
+                            "arguments": []
+                        }
+                    }
+                ]
+            },
+            "guardedHandlers": [],
+            "handler": {
+                "type": "CatchClause",
+                "param": {
+                    "type": "Identifier",
+                    "name": "e"
+                },
+                "body": {
+                    "type": "BlockStatement",
+                    "body": [
+                        {
+                            "type": "ExpressionStatement",
+                            "expression": {
+                                "type": "CallExpression",
+                                "callee": {
+                                    "type": "Identifier",
+                                    "name": "handle"
+                                },
+                                "arguments": []
                             }
-                        },
-                        "finalizer": {
-                            "type": "BlockStatement",
-                            "body": []
+                        }
+                    ]
+                }
+            },
+            "finalizer": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "ExpressionStatement",
+                        "expression": {
+                            "type": "CallExpression",
+                            "callee": {
+                                "type": "Identifier",
+                                "name": "clean"
+                            },
+                            "arguments": []
                         }
                     }
                 ]
@@ -71,235 +174,84 @@
     "type": "Program",
     "body": [
         {
-            "type": "BlockStatement",
+            "type": "TryStatement",
             "block": {
                 "type": "BlockStatement",
                 "body": [
                     {
-                        "type": "TryStatement",
-                        "block": {
-                            "type": "BlockStatement",
-                            "body": []
-                        },
-                        "guardedHandlers": [],
-                        "handler": null,
-                        "finalizer": {
-                            "type": "BlockStatement",
-                            "body": []
+                        "type": "ExpressionStatement",
+                        "expression": {
+                            "type": "CallExpression",
+                            "callee": {
+                                "type": "Identifier",
+                                "name": "that"
+                            },
+                            "arguments": []
                         }
                     }
                 ]
-            }
+            },
+            "guardedHandlers": [
+                {
+                    "type": "CatchClause",
+