author | hannesw |
Wed, 27 Apr 2016 15:50:33 +0200 | |
changeset 37732 | 3673fec68d16 |
parent 27102 | c64b3468d51d |
child 39662 | e2b36a3779b9 |
permissions | -rw-r--r-- |
27102
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
1 |
/* |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
4 |
* |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
10 |
* |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
15 |
* accompanied this code). |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
16 |
* |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
20 |
* |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
23 |
* questions. |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
24 |
*/ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
25 |
package jdk.nashorn.internal.parser; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
26 |
|
37732 | 27 |
import java.util.HashSet; |
27102
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
28 |
import java.util.List; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
29 |
import jdk.nashorn.internal.codegen.Namespace; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
30 |
import jdk.nashorn.internal.ir.FunctionNode; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
31 |
import jdk.nashorn.internal.ir.IdentNode; |
37732 | 32 |
import jdk.nashorn.internal.ir.Module; |
27102
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
33 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
34 |
/** |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
35 |
* ParserContextNode that represents a function that is currently being parsed |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
36 |
*/ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
37 |
class ParserContextFunctionNode extends ParserContextBaseNode { |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
38 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
39 |
/** Function name */ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
40 |
private final String name; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
41 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
42 |
/** Function identifier node */ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
43 |
private final IdentNode ident; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
44 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
45 |
/** Name space for function */ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
46 |
private final Namespace namespace; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
47 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
48 |
/** Line number for function declaration */ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
49 |
private final int line; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
50 |
|
37732 | 51 |
/** Function node kind, see {@link FunctionNode.Kind} */ |
27102
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
52 |
private final FunctionNode.Kind kind; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
53 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
54 |
/** List of parameter identifiers for function */ |
37732 | 55 |
private List<IdentNode> parameters; |
27102
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
56 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
57 |
/** Token for function start */ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
58 |
private final long token; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
59 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
60 |
/** Last function token */ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
61 |
private long lastToken; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
62 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
63 |
/** Opaque node for parser end state, see {@link Parser} */ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
64 |
private Object endParserState; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
65 |
|
37732 | 66 |
private HashSet<String> parameterBoundNames; |
67 |
private IdentNode duplicateParameterBinding; |
|
68 |
private boolean simpleParameterList = true; |
|
69 |
||
70 |
private Module module; |
|
71 |
||
72 |
private int debugFlags; |
|
73 |
||
27102
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
74 |
/** |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
75 |
* @param token The token for the function |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
76 |
* @param ident External function name |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
77 |
* @param name Internal name of the function |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
78 |
* @param namespace Function's namespace |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
79 |
* @param line The source line of the function |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
80 |
* @param kind Function kind |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
81 |
* @param parameters The parameters of the function |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
82 |
*/ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
83 |
public ParserContextFunctionNode(final long token, final IdentNode ident, final String name, final Namespace namespace, final int line, final FunctionNode.Kind kind, final List<IdentNode> parameters) { |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
84 |
this.ident = ident; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
85 |
this.namespace = namespace; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
86 |
this.line = line; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
87 |
this.kind = kind; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
88 |
this.name = name; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
89 |
this.parameters = parameters; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
90 |
this.token = token; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
91 |
} |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
92 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
93 |
/** |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
94 |
* @return Internal name of the function |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
95 |
*/ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
96 |
public String getName() { |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
97 |
return name; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
98 |
} |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
99 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
100 |
/** |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
101 |
* @return The external identifier for the function |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
102 |
*/ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
103 |
public IdentNode getIdent() { |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
104 |
return ident; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
105 |
} |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
106 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
107 |
/** |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
108 |
* |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
109 |
* @return true if function is the program function |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
110 |
*/ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
111 |
public boolean isProgram() { |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
112 |
return getFlag(FunctionNode.IS_PROGRAM) != 0; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
113 |
} |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
114 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
115 |
/** |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
116 |
* @return if function in strict mode |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
117 |
*/ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
118 |
public boolean isStrict() { |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
119 |
return getFlag(FunctionNode.IS_STRICT) != 0; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
120 |
} |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
121 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
122 |
/** |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
123 |
* @return true if the function has nested evals |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
124 |
*/ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
125 |
public boolean hasNestedEval() { |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
126 |
return getFlag(FunctionNode.HAS_NESTED_EVAL) != 0; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
127 |
} |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
128 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
129 |
/** |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
130 |
* Returns true if any of the blocks in this function create their own scope. |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
131 |
* @return true if any of the blocks in this function create their own scope. |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
132 |
*/ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
133 |
public boolean hasScopeBlock() { |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
134 |
return getFlag(FunctionNode.HAS_SCOPE_BLOCK) != 0; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
135 |
} |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
136 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
137 |
/** |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
138 |
* Create a unique name in the namespace of this FunctionNode |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
139 |
* @param base prefix for name |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
140 |
* @return base if no collision exists, otherwise a name prefix with base |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
141 |
*/ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
142 |
public String uniqueName(final String base) { |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
143 |
return namespace.uniqueName(base); |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
144 |
} |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
145 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
146 |
/** |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
147 |
* @return line number of the function |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
148 |
*/ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
149 |
public int getLineNumber() { |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
150 |
return line; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
151 |
} |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
152 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
153 |
/** |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
154 |
* @return The kind if function |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
155 |
*/ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
156 |
public FunctionNode.Kind getKind() { |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
157 |
return kind; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
158 |
} |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
159 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
160 |
/** |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
161 |
* Get parameters |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
162 |
* @return The parameters of the function |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
163 |
*/ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
164 |
public List<IdentNode> getParameters() { |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
165 |
return parameters; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
166 |
} |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
167 |
|
37732 | 168 |
void setParameters(List<IdentNode> parameters) { |
169 |
this.parameters = parameters; |
|
170 |
} |
|
171 |
||
27102
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
172 |
/** |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
173 |
* Set last token |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
174 |
* @param token New last token |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
175 |
*/ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
176 |
public void setLastToken(final long token) { |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
177 |
this.lastToken = token; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
178 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
179 |
} |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
180 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
181 |
/** |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
182 |
* @return lastToken Function's last token |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
183 |
*/ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
184 |
public long getLastToken() { |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
185 |
return lastToken; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
186 |
} |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
187 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
188 |
/** |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
189 |
* Returns the ParserState of when the parsing of this function was ended |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
190 |
* @return endParserState The end parser state |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
191 |
*/ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
192 |
public Object getEndParserState() { |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
193 |
return endParserState; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
194 |
} |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
195 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
196 |
/** |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
197 |
* Sets the ParserState of when the parsing of this function was ended |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
198 |
* @param endParserState The end parser state |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
199 |
*/ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
200 |
public void setEndParserState(final Object endParserState) { |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
201 |
this.endParserState = endParserState; |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
202 |
} |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
203 |
|
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
204 |
/** |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
205 |
* Returns the if of this function |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
206 |
* @return The function id |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
207 |
*/ |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
208 |
public int getId() { |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
209 |
return isProgram() ? -1 : Token.descPosition(token); |
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
210 |
} |
37732 | 211 |
|
212 |
/** |
|
213 |
* Returns the debug flags for this function. |
|
214 |
* |
|
215 |
* @return the debug flags |
|
216 |
*/ |
|
217 |
int getDebugFlags() { |
|
218 |
return debugFlags; |
|
219 |
} |
|
220 |
||
221 |
/** |
|
222 |
* Sets a debug flag for this function. |
|
223 |
* |
|
224 |
* @param debugFlag the debug flag |
|
225 |
*/ |
|
226 |
void setDebugFlag(final int debugFlag) { |
|
227 |
debugFlags |= debugFlag; |
|
228 |
} |
|
229 |
||
230 |
public boolean isMethod() { |
|
231 |
return getFlag(FunctionNode.ES6_IS_METHOD) != 0; |
|
232 |
} |
|
233 |
||
234 |
public boolean isClassConstructor() { |
|
235 |
return getFlag(FunctionNode.ES6_IS_CLASS_CONSTRUCTOR) != 0; |
|
236 |
} |
|
237 |
||
238 |
public boolean isSubclassConstructor() { |
|
239 |
return getFlag(FunctionNode.ES6_IS_SUBCLASS_CONSTRUCTOR) != 0; |
|
240 |
} |
|
241 |
||
242 |
boolean addParameterBinding(final IdentNode bindingIdentifier) { |
|
243 |
if (Parser.isArguments(bindingIdentifier)) { |
|
244 |
setFlag(FunctionNode.DEFINES_ARGUMENTS); |
|
245 |
} |
|
246 |
||
247 |
if (parameterBoundNames == null) { |
|
248 |
parameterBoundNames = new HashSet<>(); |
|
249 |
} |
|
250 |
if (parameterBoundNames.add(bindingIdentifier.getName())) { |
|
251 |
return true; |
|
252 |
} else { |
|
253 |
duplicateParameterBinding = bindingIdentifier; |
|
254 |
return false; |
|
255 |
} |
|
256 |
} |
|
257 |
||
258 |
public IdentNode getDuplicateParameterBinding() { |
|
259 |
return duplicateParameterBinding; |
|
260 |
} |
|
261 |
||
262 |
public boolean isSimpleParameterList() { |
|
263 |
return simpleParameterList; |
|
264 |
} |
|
265 |
||
266 |
public void setSimpleParameterList(final boolean simpleParameterList) { |
|
267 |
this.simpleParameterList = simpleParameterList; |
|
268 |
} |
|
269 |
||
270 |
public Module getModule() { |
|
271 |
return module; |
|
272 |
} |
|
273 |
||
274 |
public void setModule(final Module module) { |
|
275 |
this.module = module; |
|
276 |
} |
|
27102
c64b3468d51d
8012518: Reengineer Parser.java to make it play well with the copy-on-write IR.
lagergren
parents:
diff
changeset
|
277 |
} |