From bb6c34adc762828c5dcb2822e70b06cf8696b198 Mon Sep 17 00:00:00 2001
From: Athijegannathan Sundararajan While creating a Java object is the same as in Java, to create
-Java arrays in JavaScript we can use Java reflection
-explicitly. But once created the element access or length access is
+
+Array element access or length access is
the same as in Java. Also, a script array can be used when a Java
method expects a Java array (auto conversion). So in most cases we
don't have to create Java arrays explicitly.
Creating, Converting and Using Java Arrays
-
- * TODO Currently not in use. Would make e.g. accept methods simple and unified - * @see jdk.nashorn.internal.ir.Node - */ -@Retention(value=RetentionPolicy.RUNTIME) -public @interface ChildNode { - /** order of traversal compared to other children */ - public int order() default -1; -} diff --git a/nashorn/src/jdk/nashorn/internal/ir/annotations/ParentNode.java b/nashorn/src/jdk/nashorn/internal/ir/annotations/ParentNode.java deleted file mode 100644 index 6a9de3a455d..00000000000 --- a/nashorn/src/jdk/nashorn/internal/ir/annotations/ParentNode.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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. 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.annotations; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * Signifies a parent of a node, i.e. node that should not be traversed if we - * go down the AST. In automatic parsing this can be handled by @Reference - * annotations instead, as all parents are references. - *
- * TODO The use case is automating and creating one implementation of something like - * Node.getParent() - * - * @see jdk.nashorn.internal.ir.Node - */ -@Retention(value=RetentionPolicy.RUNTIME) -public @interface ParentNode { - // EMPTY -} diff --git a/nashorn/src/jdk/nashorn/internal/ir/annotations/Reference.java b/nashorn/src/jdk/nashorn/internal/ir/annotations/Reference.java index 1dd002c1f5f..20c8ffca53b 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/annotations/Reference.java +++ b/nashorn/src/jdk/nashorn/internal/ir/annotations/Reference.java @@ -33,7 +33,6 @@ import java.lang.annotation.RetentionPolicy; * AST traversal and cloning. Cloning currently as a rule uses * existingOrSame for references and otherwise existingOrCopy *
- * TODO this could probably be automated using the @Reference annotation.
*/
@Retention(value=RetentionPolicy.RUNTIME)
diff --git a/nashorn/src/jdk/nashorn/internal/ir/debug/ASTWriter.java b/nashorn/src/jdk/nashorn/internal/ir/debug/ASTWriter.java
index 3c66aa12d0e..7bbe3836694 100644
--- a/nashorn/src/jdk/nashorn/internal/ir/debug/ASTWriter.java
+++ b/nashorn/src/jdk/nashorn/internal/ir/debug/ASTWriter.java
@@ -27,6 +27,7 @@ package jdk.nashorn.internal.ir.debug;
import java.lang.reflect.Field;
import java.util.ArrayDeque;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;
import java.util.Iterator;
@@ -36,10 +37,10 @@ import jdk.nashorn.internal.ir.BinaryNode;
import jdk.nashorn.internal.ir.Node;
import jdk.nashorn.internal.ir.TernaryNode;
import jdk.nashorn.internal.ir.annotations.Ignore;
-import jdk.nashorn.internal.ir.annotations.ParentNode;
import jdk.nashorn.internal.ir.annotations.Reference;
import jdk.nashorn.internal.parser.Token;
import jdk.nashorn.internal.runtime.Context;
+import jdk.nashorn.internal.runtime.Debug;
/**
* AST-as-text visualizer. Sometimes you want tree form and not source
@@ -47,7 +48,6 @@ import jdk.nashorn.internal.runtime.Context;
*
* see the flags --print-ast and --print-ast-lower
*/
-
public final class ASTWriter {
/** Root node from which to start the traversal */
private final Node root;
@@ -71,12 +71,22 @@ public final class ASTWriter {
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
- printAST(sb, null, "root", root, 0);
+ printAST(sb, null, null, "root", root, 0);
return sb.toString();
}
+ /**
+ * Return the visited nodes in an ordered list
+ * @return the list of nodes in order
+ */
+ public Node[] toArray() {
+ final List