Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_nashorn
提交
5546c448
D
dragonwell8_nashorn
项目概览
openanolis
/
dragonwell8_nashorn
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_nashorn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5546c448
编写于
5月 07, 2013
作者:
L
lagergren
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8013913: Removed Source field from all nodes except FunctionNode in order to save footprint
Reviewed-by: jlaskey, attila
上级
24cbc14c
变更
55
展开全部
隐藏空白更改
内联
并排
Showing
55 changed file
with
366 addition
and
515 deletion
+366
-515
src/jdk/nashorn/api/scripting/NashornScriptEngine.java
src/jdk/nashorn/api/scripting/NashornScriptEngine.java
+1
-2
src/jdk/nashorn/internal/codegen/Attr.java
src/jdk/nashorn/internal/codegen/Attr.java
+1
-2
src/jdk/nashorn/internal/codegen/CodeGenerator.java
src/jdk/nashorn/internal/codegen/CodeGenerator.java
+7
-6
src/jdk/nashorn/internal/codegen/FinalizeTypes.java
src/jdk/nashorn/internal/codegen/FinalizeTypes.java
+8
-8
src/jdk/nashorn/internal/codegen/FoldConstants.java
src/jdk/nashorn/internal/codegen/FoldConstants.java
+24
-27
src/jdk/nashorn/internal/codegen/Lower.java
src/jdk/nashorn/internal/codegen/Lower.java
+20
-22
src/jdk/nashorn/internal/codegen/Splitter.java
src/jdk/nashorn/internal/codegen/Splitter.java
+1
-3
src/jdk/nashorn/internal/ir/AccessNode.java
src/jdk/nashorn/internal/ir/AccessNode.java
+2
-4
src/jdk/nashorn/internal/ir/BaseNode.java
src/jdk/nashorn/internal/ir/BaseNode.java
+2
-4
src/jdk/nashorn/internal/ir/BinaryNode.java
src/jdk/nashorn/internal/ir/BinaryNode.java
+2
-4
src/jdk/nashorn/internal/ir/Block.java
src/jdk/nashorn/internal/ir/Block.java
+4
-7
src/jdk/nashorn/internal/ir/BreakNode.java
src/jdk/nashorn/internal/ir/BreakNode.java
+2
-4
src/jdk/nashorn/internal/ir/BreakableNode.java
src/jdk/nashorn/internal/ir/BreakableNode.java
+2
-4
src/jdk/nashorn/internal/ir/CallNode.java
src/jdk/nashorn/internal/ir/CallNode.java
+2
-4
src/jdk/nashorn/internal/ir/CaseNode.java
src/jdk/nashorn/internal/ir/CaseNode.java
+2
-4
src/jdk/nashorn/internal/ir/CatchNode.java
src/jdk/nashorn/internal/ir/CatchNode.java
+2
-6
src/jdk/nashorn/internal/ir/ContinueNode.java
src/jdk/nashorn/internal/ir/ContinueNode.java
+2
-4
src/jdk/nashorn/internal/ir/EmptyNode.java
src/jdk/nashorn/internal/ir/EmptyNode.java
+2
-4
src/jdk/nashorn/internal/ir/ExecuteNode.java
src/jdk/nashorn/internal/ir/ExecuteNode.java
+3
-5
src/jdk/nashorn/internal/ir/ForNode.java
src/jdk/nashorn/internal/ir/ForNode.java
+2
-4
src/jdk/nashorn/internal/ir/FunctionNode.java
src/jdk/nashorn/internal/ir/FunctionNode.java
+16
-1
src/jdk/nashorn/internal/ir/IdentNode.java
src/jdk/nashorn/internal/ir/IdentNode.java
+2
-4
src/jdk/nashorn/internal/ir/IfNode.java
src/jdk/nashorn/internal/ir/IfNode.java
+2
-4
src/jdk/nashorn/internal/ir/IndexNode.java
src/jdk/nashorn/internal/ir/IndexNode.java
+2
-4
src/jdk/nashorn/internal/ir/LabelNode.java
src/jdk/nashorn/internal/ir/LabelNode.java
+2
-4
src/jdk/nashorn/internal/ir/LexicalContext.java
src/jdk/nashorn/internal/ir/LexicalContext.java
+10
-8
src/jdk/nashorn/internal/ir/LexicalContextNode.java
src/jdk/nashorn/internal/ir/LexicalContextNode.java
+2
-4
src/jdk/nashorn/internal/ir/LineNumberNode.java
src/jdk/nashorn/internal/ir/LineNumberNode.java
+2
-4
src/jdk/nashorn/internal/ir/LiteralNode.java
src/jdk/nashorn/internal/ir/LiteralNode.java
+45
-57
src/jdk/nashorn/internal/ir/Location.java
src/jdk/nashorn/internal/ir/Location.java
+0
-134
src/jdk/nashorn/internal/ir/LoopNode.java
src/jdk/nashorn/internal/ir/LoopNode.java
+2
-4
src/jdk/nashorn/internal/ir/Node.java
src/jdk/nashorn/internal/ir/Node.java
+75
-12
src/jdk/nashorn/internal/ir/ObjectNode.java
src/jdk/nashorn/internal/ir/ObjectNode.java
+2
-4
src/jdk/nashorn/internal/ir/PropertyNode.java
src/jdk/nashorn/internal/ir/PropertyNode.java
+2
-4
src/jdk/nashorn/internal/ir/ReturnNode.java
src/jdk/nashorn/internal/ir/ReturnNode.java
+2
-4
src/jdk/nashorn/internal/ir/RuntimeNode.java
src/jdk/nashorn/internal/ir/RuntimeNode.java
+4
-7
src/jdk/nashorn/internal/ir/SplitNode.java
src/jdk/nashorn/internal/ir/SplitNode.java
+1
-1
src/jdk/nashorn/internal/ir/SwitchNode.java
src/jdk/nashorn/internal/ir/SwitchNode.java
+2
-4
src/jdk/nashorn/internal/ir/TernaryNode.java
src/jdk/nashorn/internal/ir/TernaryNode.java
+2
-4
src/jdk/nashorn/internal/ir/ThrowNode.java
src/jdk/nashorn/internal/ir/ThrowNode.java
+2
-5
src/jdk/nashorn/internal/ir/TryNode.java
src/jdk/nashorn/internal/ir/TryNode.java
+2
-4
src/jdk/nashorn/internal/ir/UnaryNode.java
src/jdk/nashorn/internal/ir/UnaryNode.java
+5
-7
src/jdk/nashorn/internal/ir/VarNode.java
src/jdk/nashorn/internal/ir/VarNode.java
+4
-7
src/jdk/nashorn/internal/ir/WhileNode.java
src/jdk/nashorn/internal/ir/WhileNode.java
+2
-4
src/jdk/nashorn/internal/ir/WithNode.java
src/jdk/nashorn/internal/ir/WithNode.java
+2
-6
src/jdk/nashorn/internal/ir/debug/JSONWriter.java
src/jdk/nashorn/internal/ir/debug/JSONWriter.java
+1
-1
src/jdk/nashorn/internal/objects/NativeDebug.java
src/jdk/nashorn/internal/objects/NativeDebug.java
+0
-1
src/jdk/nashorn/internal/parser/AbstractParser.java
src/jdk/nashorn/internal/parser/AbstractParser.java
+7
-7
src/jdk/nashorn/internal/parser/JSONParser.java
src/jdk/nashorn/internal/parser/JSONParser.java
+7
-7
src/jdk/nashorn/internal/parser/Parser.java
src/jdk/nashorn/internal/parser/Parser.java
+62
-63
src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java
...horn/internal/runtime/RecompilableScriptFunctionData.java
+4
-0
src/jdk/nashorn/internal/runtime/ScriptObject.java
src/jdk/nashorn/internal/runtime/ScriptObject.java
+0
-2
src/jdk/nashorn/internal/runtime/arrays/ArrayLikeIterator.java
...dk/nashorn/internal/runtime/arrays/ArrayLikeIterator.java
+0
-1
src/jdk/nashorn/internal/runtime/linker/LinkerCallSite.java
src/jdk/nashorn/internal/runtime/linker/LinkerCallSite.java
+2
-3
src/jdk/nashorn/tools/Shell.java
src/jdk/nashorn/tools/Shell.java
+0
-1
未找到文件。
src/jdk/nashorn/api/scripting/NashornScriptEngine.java
浏览文件 @
5546c448
...
...
@@ -78,7 +78,6 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C
this
(
factory
,
DEFAULT_OPTIONS
,
appLoader
);
}
@SuppressWarnings
(
"LeakingThisInConstructor"
)
NashornScriptEngine
(
final
NashornScriptEngineFactory
factory
,
final
String
[]
args
,
final
ClassLoader
appLoader
)
{
this
.
factory
=
factory
;
final
Options
options
=
new
Options
(
"nashorn"
);
...
...
@@ -102,7 +101,7 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C
});
// create new global object
this
.
global
=
createNashornGlobal
();
this
.
global
=
createNashornGlobal
();
// set the default engine scope for the default context
context
.
setBindings
(
new
ScriptObjectMirror
(
global
,
global
),
ScriptContext
.
ENGINE_SCOPE
);
...
...
src/jdk/nashorn/internal/codegen/Attr.java
浏览文件 @
5546c448
...
...
@@ -435,7 +435,6 @@ final class Attr extends NodeOperatorVisitor {
final
IdentNode
callee
=
compilerConstant
(
CALLEE
);
VarNode
selfInit
=
new
VarNode
(
newFunctionNode
.
getSource
(),
newFunctionNode
.
getToken
(),
newFunctionNode
.
getFinish
(),
newFunctionNode
.
getIdent
(),
...
...
@@ -531,6 +530,7 @@ final class Attr extends NodeOperatorVisitor {
setBlockScope
(
name
,
symbol
);
if
(
symbol
!=
null
&&
!
identNode
.
isInitializedHere
())
{
symbol
.
increaseUseCount
();
}
addLocalUse
(
identNode
.
getName
());
...
...
@@ -914,7 +914,6 @@ final class Attr extends NodeOperatorVisitor {
final
FunctionNode
functionNode
=
getLexicalContext
().
getCurrentFunction
();
return
(
IdentNode
)
new
IdentNode
(
functionNode
.
getSource
(),
functionNode
.
getToken
(),
functionNode
.
getFinish
(),
cc
.
symbolName
()).
...
...
src/jdk/nashorn/internal/codegen/CodeGenerator.java
浏览文件 @
5546c448
...
...
@@ -261,14 +261,15 @@ final class CodeGenerator extends NodeOperatorVisitor {
return
method
.
load
(
symbol
);
}
final
String
name
=
symbol
.
getName
();
final
String
name
=
symbol
.
getName
();
final
Source
source
=
getLexicalContext
().
getCurrentFunction
().
getSource
();
if
(
CompilerConstants
.
__FILE__
.
name
().
equals
(
name
))
{
return
method
.
load
(
identNode
.
getSource
()
.
getName
());
return
method
.
load
(
source
.
getName
());
}
else
if
(
CompilerConstants
.
__DIR__
.
name
().
equals
(
name
))
{
return
method
.
load
(
identNode
.
getSource
()
.
getBase
());
return
method
.
load
(
source
.
getBase
());
}
else
if
(
CompilerConstants
.
__LINE__
.
name
().
equals
(
name
))
{
return
method
.
load
(
identNode
.
getSource
()
.
getLine
(
identNode
.
position
())).
convert
(
Type
.
OBJECT
);
return
method
.
load
(
source
.
getLine
(
identNode
.
position
())).
convert
(
Type
.
OBJECT
);
}
else
{
assert
identNode
.
getSymbol
().
isScope
()
:
identNode
+
" is not in scope!"
;
...
...
@@ -2005,8 +2006,9 @@ final class CodeGenerator extends NodeOperatorVisitor {
public
boolean
enterThrowNode
(
final
ThrowNode
throwNode
)
{
method
.
_new
(
ECMAException
.
class
).
dup
();
final
Source
source
=
getLexicalContext
().
getCurrentFunction
().
getSource
();
final
Node
expression
=
throwNode
.
getExpression
();
final
Source
source
=
throwNode
.
getSource
();
final
int
position
=
throwNode
.
position
();
final
int
line
=
source
.
getLine
(
position
);
final
int
column
=
source
.
getColumn
(
position
);
...
...
@@ -3013,7 +3015,6 @@ final class CodeGenerator extends NodeOperatorVisitor {
return
;
}
@SuppressWarnings
(
"resource"
)
final
PrintWriter
out
=
compiler
.
getEnv
().
getErr
();
out
.
println
(
"[BLOCK in '"
+
ident
+
"']"
);
if
(!
block
.
printSymbols
(
out
))
{
...
...
src/jdk/nashorn/internal/codegen/FinalizeTypes.java
浏览文件 @
5546c448
...
...
@@ -773,7 +773,7 @@ final class FinalizeTypes extends NodeOperatorVisitor {
private
Node
convert
(
final
Node
node
,
final
Type
to
)
{
assert
!
to
.
isUnknown
()
:
"unknown type for "
+
node
+
" class="
+
node
.
getClass
();
assert
node
!=
null
:
"node is null"
;
assert
node
.
getSymbol
()
!=
null
:
"node "
+
node
+
" "
+
node
.
getClass
()
+
" has no symbol! "
+
getLexicalContext
().
getCurrentFunction
()
+
" "
+
node
.
getSource
()
;
assert
node
.
getSymbol
()
!=
null
:
"node "
+
node
+
" "
+
node
.
getClass
()
+
" has no symbol! "
+
getLexicalContext
().
getCurrentFunction
();
assert
node
.
tokenType
()
!=
TokenType
.
CONVERT
:
"assert convert in convert "
+
node
+
" in "
+
getLexicalContext
().
getCurrentFunction
();
final
Type
from
=
node
.
getType
();
...
...
@@ -798,7 +798,7 @@ final class FinalizeTypes extends NodeOperatorVisitor {
assert
node
instanceof
TypeOverride
;
return
setTypeOverride
(
node
,
to
);
}
resultNode
=
new
UnaryNode
(
node
.
getSource
(),
Token
.
recast
(
node
.
getToken
(),
TokenType
.
CONVERT
),
node
);
resultNode
=
new
UnaryNode
(
Token
.
recast
(
node
.
getToken
(),
TokenType
.
CONVERT
),
node
);
}
LOG
.
info
(
"CONVERT('"
,
node
,
"', "
,
to
,
") => '"
,
resultNode
,
"'"
);
...
...
@@ -813,7 +813,7 @@ final class FinalizeTypes extends NodeOperatorVisitor {
private
static
Node
discard
(
final
Node
node
)
{
if
(
node
.
getSymbol
()
!=
null
)
{
final
Node
discard
=
new
UnaryNode
(
node
.
getSource
(),
Token
.
recast
(
node
.
getToken
(),
TokenType
.
DISCARD
),
node
);
final
Node
discard
=
new
UnaryNode
(
Token
.
recast
(
node
.
getToken
(),
TokenType
.
DISCARD
),
node
);
//discard never has a symbol in the discard node - then it would be a nop
assert
!
node
.
isTerminal
();
return
discard
;
...
...
@@ -881,15 +881,15 @@ final class FinalizeTypes extends NodeOperatorVisitor {
LiteralNode
<?>
literalNode
=
null
;
if
(
type
.
isString
())
{
literalNode
=
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
JSType
.
toString
(
value
));
literalNode
=
LiteralNode
.
newInstance
(
token
,
finish
,
JSType
.
toString
(
value
));
}
else
if
(
type
.
isBoolean
())
{
literalNode
=
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
JSType
.
toBoolean
(
value
));
literalNode
=
LiteralNode
.
newInstance
(
token
,
finish
,
JSType
.
toBoolean
(
value
));
}
else
if
(
type
.
isInteger
())
{
literalNode
=
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
JSType
.
toInt32
(
value
));
literalNode
=
LiteralNode
.
newInstance
(
token
,
finish
,
JSType
.
toInt32
(
value
));
}
else
if
(
type
.
isLong
())
{
literalNode
=
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
JSType
.
toLong
(
value
));
literalNode
=
LiteralNode
.
newInstance
(
token
,
finish
,
JSType
.
toLong
(
value
));
}
else
if
(
type
.
isNumber
()
||
parent
.
getType
().
isNumeric
()
&&
!
parent
.
getType
().
isNumber
())
{
literalNode
=
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
JSType
.
toNumber
(
value
));
literalNode
=
LiteralNode
.
newInstance
(
token
,
finish
,
JSType
.
toNumber
(
value
));
}
if
(
literalNode
!=
null
)
{
...
...
src/jdk/nashorn/internal/codegen/FoldConstants.java
浏览文件 @
5546c448
...
...
@@ -41,7 +41,6 @@ import jdk.nashorn.internal.ir.visitor.NodeVisitor;
import
jdk.nashorn.internal.runtime.DebugLogger
;
import
jdk.nashorn.internal.runtime.JSType
;
import
jdk.nashorn.internal.runtime.ScriptRuntime
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* Simple constant folding pass, executed before IR is starting to be lowered.
...
...
@@ -112,13 +111,11 @@ final class FoldConstants extends NodeVisitor {
*/
abstract
static
class
ConstantEvaluator
<
T
extends
Node
>
{
protected
T
parent
;
protected
final
Source
source
;
protected
final
long
token
;
protected
final
int
finish
;
protected
ConstantEvaluator
(
final
T
parent
)
{
this
.
parent
=
parent
;
this
.
source
=
parent
.
getSource
();
this
.
token
=
parent
.
getToken
();
this
.
finish
=
parent
.
getFinish
();
}
...
...
@@ -152,23 +149,23 @@ final class FoldConstants extends NodeVisitor {
switch
(
parent
.
tokenType
())
{
case
ADD:
if
(
rhsInteger
)
{
literalNode
=
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
rhs
.
getInt32
());
literalNode
=
LiteralNode
.
newInstance
(
token
,
finish
,
rhs
.
getInt32
());
}
else
{
literalNode
=
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
rhs
.
getNumber
());
literalNode
=
LiteralNode
.
newInstance
(
token
,
finish
,
rhs
.
getNumber
());
}
break
;
case
SUB:
if
(
rhsInteger
&&
rhs
.
getInt32
()
!=
0
)
{
// @see test/script/basic/minuszero.js
literalNode
=
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
-
rhs
.
getInt32
());
literalNode
=
LiteralNode
.
newInstance
(
token
,
finish
,
-
rhs
.
getInt32
());
}
else
{
literalNode
=
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
-
rhs
.
getNumber
());
literalNode
=
LiteralNode
.
newInstance
(
token
,
finish
,
-
rhs
.
getNumber
());
}
break
;
case
NOT:
literalNode
=
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
!
rhs
.
getBoolean
());
literalNode
=
LiteralNode
.
newInstance
(
token
,
finish
,
!
rhs
.
getBoolean
());
break
;
case
BIT_NOT:
literalNode
=
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
~
rhs
.
getInt32
());
literalNode
=
LiteralNode
.
newInstance
(
token
,
finish
,
~
rhs
.
getInt32
());
break
;
default
:
return
null
;
...
...
@@ -234,7 +231,7 @@ final class FoldConstants extends NodeVisitor {
break
;
}
assert
res
instanceof
CharSequence
:
res
+
" was not a CharSequence, it was a "
+
res
.
getClass
();
return
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
res
.
toString
());
return
LiteralNode
.
newInstance
(
token
,
finish
,
res
.
toString
());
}
return
null
;
case
MUL:
...
...
@@ -247,33 +244,33 @@ final class FoldConstants extends NodeVisitor {
value
=
lhs
.
getNumber
()
-
rhs
.
getNumber
();
break
;
case
SHR:
return
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
(
lhs
.
getInt32
()
>>>
rhs
.
getInt32
())
&
JSType
.
MAX_UINT
);
return
LiteralNode
.
newInstance
(
token
,
finish
,
(
lhs
.
getInt32
()
>>>
rhs
.
getInt32
())
&
JSType
.
MAX_UINT
);
case
SAR:
return
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
lhs
.
getInt32
()
>>
rhs
.
getInt32
());
return
LiteralNode
.
newInstance
(
token
,
finish
,
lhs
.
getInt32
()
>>
rhs
.
getInt32
());
case
SHL:
return
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
lhs
.
getInt32
()
<<
rhs
.
getInt32
());
return
LiteralNode
.
newInstance
(
token
,
finish
,
lhs
.
getInt32
()
<<
rhs
.
getInt32
());
case
BIT_XOR:
return
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
lhs
.
getInt32
()
^
rhs
.
getInt32
());
return
LiteralNode
.
newInstance
(
token
,
finish
,
lhs
.
getInt32
()
^
rhs
.
getInt32
());
case
BIT_AND:
return
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
lhs
.
getInt32
()
&
rhs
.
getInt32
());
return
LiteralNode
.
newInstance
(
token
,
finish
,
lhs
.
getInt32
()
&
rhs
.
getInt32
());
case
BIT_OR:
return
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
lhs
.
getInt32
()
|
rhs
.
getInt32
());
return
LiteralNode
.
newInstance
(
token
,
finish
,
lhs
.
getInt32
()
|
rhs
.
getInt32
());
case
GE:
return
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
ScriptRuntime
.
GE
(
lhs
.
getObject
(),
rhs
.
getObject
()));
return
LiteralNode
.
newInstance
(
token
,
finish
,
ScriptRuntime
.
GE
(
lhs
.
getObject
(),
rhs
.
getObject
()));
case
LE:
return
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
ScriptRuntime
.
LE
(
lhs
.
getObject
(),
rhs
.
getObject
()));
return
LiteralNode
.
newInstance
(
token
,
finish
,
ScriptRuntime
.
LE
(
lhs
.
getObject
(),
rhs
.
getObject
()));
case
GT:
return
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
ScriptRuntime
.
GT
(
lhs
.
getObject
(),
rhs
.
getObject
()));
return
LiteralNode
.
newInstance
(
token
,
finish
,
ScriptRuntime
.
GT
(
lhs
.
getObject
(),
rhs
.
getObject
()));
case
LT:
return
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
ScriptRuntime
.
LT
(
lhs
.
getObject
(),
rhs
.
getObject
()));
return
LiteralNode
.
newInstance
(
token
,
finish
,
ScriptRuntime
.
LT
(
lhs
.
getObject
(),
rhs
.
getObject
()));
case
NE:
return
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
ScriptRuntime
.
NE
(
lhs
.
getObject
(),
rhs
.
getObject
()));
return
LiteralNode
.
newInstance
(
token
,
finish
,
ScriptRuntime
.
NE
(
lhs
.
getObject
(),
rhs
.
getObject
()));
case
NE_STRICT:
return
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
ScriptRuntime
.
NE_STRICT
(
lhs
.
getObject
(),
rhs
.
getObject
()));
return
LiteralNode
.
newInstance
(
token
,
finish
,
ScriptRuntime
.
NE_STRICT
(
lhs
.
getObject
(),
rhs
.
getObject
()));
case
EQ:
return
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
ScriptRuntime
.
EQ
(
lhs
.
getObject
(),
rhs
.
getObject
()));
return
LiteralNode
.
newInstance
(
token
,
finish
,
ScriptRuntime
.
EQ
(
lhs
.
getObject
(),
rhs
.
getObject
()));
case
EQ_STRICT:
return
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
ScriptRuntime
.
EQ_STRICT
(
lhs
.
getObject
(),
rhs
.
getObject
()));
return
LiteralNode
.
newInstance
(
token
,
finish
,
ScriptRuntime
.
EQ_STRICT
(
lhs
.
getObject
(),
rhs
.
getObject
()));
default
:
return
null
;
}
...
...
@@ -282,12 +279,12 @@ final class FoldConstants extends NodeVisitor {
isLong
&=
value
!=
0.0
&&
JSType
.
isRepresentableAsLong
(
value
);
if
(
isInteger
)
{
return
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
JSType
.
toInt32
(
value
));
return
LiteralNode
.
newInstance
(
token
,
finish
,
JSType
.
toInt32
(
value
));
}
else
if
(
isLong
)
{
return
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
JSType
.
toLong
(
value
));
return
LiteralNode
.
newInstance
(
token
,
finish
,
JSType
.
toLong
(
value
));
}
return
LiteralNode
.
newInstance
(
source
,
token
,
finish
,
value
);
return
LiteralNode
.
newInstance
(
token
,
finish
,
value
);
}
}
}
src/jdk/nashorn/internal/codegen/Lower.java
浏览文件 @
5546c448
...
...
@@ -118,8 +118,9 @@ final class Lower extends NodeOperatorVisitor {
@Override
public
boolean
enterBlock
(
final
Block
block
)
{
final
LexicalContext
lc
=
getLexicalContext
();
if
(
lc
.
isFunctionBody
()
&&
lc
.
getCurrentFunction
().
isProgram
()
&&
!
lc
.
getCurrentFunction
().
hasDeclaredFunctions
())
{
new
ExecuteNode
(
block
.
getSource
(),
block
.
getToken
(),
block
.
getFinish
(),
LiteralNode
.
newInstance
(
block
,
ScriptRuntime
.
UNDEFINED
)).
accept
(
this
);
final
FunctionNode
function
=
lc
.
getCurrentFunction
();
if
(
lc
.
isFunctionBody
()
&&
function
.
isProgram
()
&&
!
function
.
hasDeclaredFunctions
())
{
new
ExecuteNode
(
block
.
getToken
(),
block
.
getFinish
(),
LiteralNode
.
newInstance
(
block
,
ScriptRuntime
.
UNDEFINED
)).
accept
(
this
);
}
return
true
;
}
...
...
@@ -137,7 +138,6 @@ final class Lower extends NodeOperatorVisitor {
final
FunctionNode
currentFunction
=
getLexicalContext
().
getCurrentFunction
();
final
boolean
isProgram
=
currentFunction
.
isProgram
();
final
ReturnNode
returnNode
=
new
ReturnNode
(
currentFunction
.
getSource
(),
currentFunction
.
getToken
(),
currentFunction
.
getFinish
(),
isProgram
?
...
...
@@ -193,7 +193,6 @@ final class Lower extends NodeOperatorVisitor {
if
(!
isInternalExpression
(
expr
)
&&
!
isEvalResultAssignment
(
expr
))
{
node
=
executeNode
.
setExpression
(
new
BinaryNode
(
executeNode
.
getSource
(),
Token
.
recast
(
executeNode
.
getToken
(),
TokenType
.
ASSIGN
),
...
...
@@ -284,17 +283,16 @@ final class Lower extends NodeOperatorVisitor {
}
private
Block
catchAllBlock
(
final
TryNode
tryNode
)
{
final
Source
source
=
tryNode
.
getSource
();
final
long
token
=
tryNode
.
getToken
();
final
int
finish
=
tryNode
.
getFinish
();
final
IdentNode
exception
=
new
IdentNode
(
source
,
token
,
finish
,
getLexicalContext
().
getCurrentFunction
().
uniqueName
(
"catch_all"
));
final
IdentNode
exception
=
new
IdentNode
(
token
,
finish
,
getLexicalContext
().
getCurrentFunction
().
uniqueName
(
"catch_all"
));
final
Block
catchBody
=
new
Block
(
source
,
token
,
finish
,
new
ThrowNode
(
source
,
token
,
finish
,
new
IdentNode
(
exception
))).
final
Block
catchBody
=
new
Block
(
token
,
finish
,
new
ThrowNode
(
token
,
finish
,
new
IdentNode
(
exception
))).
setIsTerminal
(
getLexicalContext
(),
true
);
//ends with throw, so terminal
final
CatchNode
catchAllNode
=
new
CatchNode
(
source
,
token
,
finish
,
new
IdentNode
(
exception
),
null
,
catchBody
);
final
Block
catchAllBlock
=
new
Block
(
source
,
token
,
finish
,
catchAllNode
);
final
CatchNode
catchAllNode
=
new
CatchNode
(
token
,
finish
,
new
IdentNode
(
exception
),
null
,
catchBody
);
final
Block
catchAllBlock
=
new
Block
(
token
,
finish
,
catchAllNode
);
//catchallblock -> catchallnode (catchnode) -> exception -> throw
...
...
@@ -303,7 +301,7 @@ final class Lower extends NodeOperatorVisitor {
private
IdentNode
compilerConstant
(
final
CompilerConstants
cc
)
{
final
FunctionNode
functionNode
=
getLexicalContext
().
getCurrentFunction
();
return
new
IdentNode
(
functionNode
.
get
Source
(),
functionNode
.
get
Token
(),
functionNode
.
getFinish
(),
cc
.
symbolName
());
return
new
IdentNode
(
functionNode
.
getToken
(),
functionNode
.
getFinish
(),
cc
.
symbolName
());
}
private
static
boolean
isTerminal
(
final
List
<
Node
>
statements
)
{
...
...
@@ -318,7 +316,6 @@ final class Lower extends NodeOperatorVisitor {
* @return new try node after splicing finally code (same if nop)
*/
private
Node
spliceFinally
(
final
TryNode
tryNode
,
final
List
<
ThrowNode
>
rethrows
,
final
Block
finallyBody
)
{
final
Source
source
=
tryNode
.
getSource
();
final
int
finish
=
tryNode
.
getFinish
();
assert
tryNode
.
getFinallyBody
()
==
null
;
...
...
@@ -345,7 +342,7 @@ final class Lower extends NodeOperatorVisitor {
if
(!
isTerminal
(
newStatements
))
{
newStatements
.
add
(
throwNode
);
}
return
new
Block
(
source
,
throwNode
.
getToken
(),
throwNode
.
getFinish
(),
newStatements
);
return
new
Block
(
throwNode
.
getToken
(),
throwNode
.
getFinish
(),
newStatements
);
}
return
throwNode
;
}
...
...
@@ -370,7 +367,7 @@ final class Lower extends NodeOperatorVisitor {
//we need to evaluate the result of the return in case it is complex while
//still in the try block, store it in a result value and return it afterwards
resultNode
=
new
IdentNode
(
Lower
.
this
.
compilerConstant
(
RETURN
));
newStatements
.
add
(
new
ExecuteNode
(
new
BinaryNode
(
source
,
Token
.
recast
(
returnNode
.
getToken
(),
TokenType
.
ASSIGN
),
resultNode
,
expr
)));
newStatements
.
add
(
new
ExecuteNode
(
new
BinaryNode
(
Token
.
recast
(
returnNode
.
getToken
(),
TokenType
.
ASSIGN
),
resultNode
,
expr
)));
}
else
{
resultNode
=
null
;
}
...
...
@@ -380,7 +377,7 @@ final class Lower extends NodeOperatorVisitor {
newStatements
.
add
(
expr
==
null
?
returnNode
:
returnNode
.
setExpression
(
resultNode
));
}
return
new
ExecuteNode
(
new
Block
(
source
,
returnNode
.
getToken
(),
getLexicalContext
().
getCurrentBlock
().
getFinish
(),
newStatements
));
return
new
ExecuteNode
(
new
Block
(
returnNode
.
getToken
(),
getLexicalContext
().
getCurrentBlock
().
getFinish
(),
newStatements
));
}
private
Node
copy
(
final
Node
endpoint
,
final
Node
targetNode
)
{
...
...
@@ -389,7 +386,7 @@ final class Lower extends NodeOperatorVisitor {
if
(!
isTerminal
(
newStatements
))
{
newStatements
.
add
(
endpoint
);
}
return
new
ExecuteNode
(
new
Block
(
source
,
endpoint
.
getToken
(),
finish
,
newStatements
));
return
new
ExecuteNode
(
new
Block
(
endpoint
.
getToken
(),
finish
,
newStatements
));
}
return
endpoint
;
}
...
...
@@ -451,7 +448,7 @@ final class Lower extends NodeOperatorVisitor {
if
(
tryNode
.
getCatchBlocks
().
isEmpty
())
{
newTryNode
=
tryNode
.
setFinallyBody
(
null
);
}
else
{
Block
outerBody
=
new
Block
(
tryNode
.
get
Source
(),
tryNode
.
get
Token
(),
tryNode
.
getFinish
(),
new
ArrayList
<
Node
>(
Arrays
.
asList
(
tryNode
.
setFinallyBody
(
null
))));
Block
outerBody
=
new
Block
(
tryNode
.
getToken
(),
tryNode
.
getFinish
(),
new
ArrayList
<
Node
>(
Arrays
.
asList
(
tryNode
.
setFinallyBody
(
null
))));
newTryNode
=
tryNode
.
setBody
(
outerBody
).
setCatchBlocks
(
null
);
}
...
...
@@ -468,19 +465,19 @@ final class Lower extends NodeOperatorVisitor {
public
Node
leaveVarNode
(
final
VarNode
varNode
)
{
addStatement
(
varNode
);
if
(
varNode
.
getFlag
(
VarNode
.
IS_LAST_FUNCTION_DECLARATION
)
&&
getLexicalContext
().
getCurrentFunction
().
isProgram
())
{
new
ExecuteNode
(
varNode
.
get
Source
(),
varNode
.
get
Token
(),
varNode
.
getFinish
(),
new
IdentNode
(
varNode
.
getName
())).
accept
(
this
);
new
ExecuteNode
(
varNode
.
getToken
(),
varNode
.
getFinish
(),
new
IdentNode
(
varNode
.
getName
())).
accept
(
this
);
}
return
varNode
;
}
@Override
public
Node
leaveWhileNode
(
final
WhileNode
whileNode
)
{
final
Node
test
=
whileNode
.
getTest
();
final
Node
test
=
whileNode
.
getTest
();
final
Block
body
=
whileNode
.
getBody
();
if
(
conservativeAlwaysTrue
(
test
))
{
//turn it into a for node without a test.
final
ForNode
forNode
=
(
ForNode
)
new
ForNode
(
whileNode
.
get
Source
(),
whileNode
.
get
Token
(),
whileNode
.
getFinish
(),
null
,
null
,
body
,
null
,
ForNode
.
IS_FOR
).
accept
(
this
);
final
ForNode
forNode
=
(
ForNode
)
new
ForNode
(
whileNode
.
getToken
(),
whileNode
.
getFinish
(),
null
,
null
,
body
,
null
,
ForNode
.
IS_FOR
).
accept
(
this
);
getLexicalContext
().
replace
(
whileNode
,
forNode
);
return
forNode
;
}
...
...
@@ -525,11 +522,12 @@ final class Lower extends NodeOperatorVisitor {
* @param node a node
* @return eval location
*/
private
static
String
evalLocation
(
final
IdentNode
node
)
{
private
String
evalLocation
(
final
IdentNode
node
)
{
final
Source
source
=
getLexicalContext
().
getCurrentFunction
().
getSource
();
return
new
StringBuilder
().
append
(
node
.
getSource
()
.
getName
()).
append
(
source
.
getName
()).
append
(
'#'
).
append
(
node
.
getSource
()
.
getLine
(
node
.
position
())).
append
(
source
.
getLine
(
node
.
position
())).
append
(
"<eval>"
).
toString
();
}
...
...
src/jdk/nashorn/internal/codegen/Splitter.java
浏览文件 @
5546c448
...
...
@@ -42,7 +42,6 @@ import jdk.nashorn.internal.ir.Node;
import
jdk.nashorn.internal.ir.SplitNode
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.DebugLogger
;
import
jdk.nashorn.internal.runtime.Source
;
import
jdk.nashorn.internal.runtime.options.Options
;
/**
...
...
@@ -221,12 +220,11 @@ final class Splitter extends NodeVisitor {
* @return New split node.
*/
private
SplitNode
createBlockSplitNode
(
final
Block
parent
,
final
FunctionNode
function
,
final
List
<
Node
>
statements
,
final
long
weight
)
{
final
Source
source
=
parent
.
getSource
();
final
long
token
=
parent
.
getToken
();
final
int
finish
=
parent
.
getFinish
();
final
String
name
=
function
.
uniqueName
(
SPLIT_PREFIX
.
symbolName
());
final
Block
newBlock
=
new
Block
(
source
,
token
,
finish
,
statements
);
final
Block
newBlock
=
new
Block
(
token
,
finish
,
statements
);
return
new
SplitNode
(
name
,
newBlock
,
compiler
.
findUnit
(
weight
+
WeighNodes
.
FUNCTION_WEIGHT
));
}
...
...
src/jdk/nashorn/internal/ir/AccessNode.java
浏览文件 @
5546c448
...
...
@@ -28,7 +28,6 @@ package jdk.nashorn.internal.ir;
import
jdk.nashorn.internal.codegen.types.Type
;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representation of a property access (period operator.)
...
...
@@ -41,14 +40,13 @@ public final class AccessNode extends BaseNode {
/**
* Constructor
*
* @param source source code
* @param token token
* @param finish finish
* @param base base node
* @param property property
*/
public
AccessNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Node
base
,
final
IdentNode
property
)
{
super
(
source
,
token
,
finish
,
base
,
false
,
false
);
public
AccessNode
(
final
long
token
,
final
int
finish
,
final
Node
base
,
final
IdentNode
property
)
{
super
(
token
,
finish
,
base
,
false
,
false
);
this
.
property
=
property
.
setIsPropertyName
();
}
...
...
src/jdk/nashorn/internal/ir/BaseNode.java
浏览文件 @
5546c448
...
...
@@ -29,7 +29,6 @@ import static jdk.nashorn.internal.codegen.ObjectClassGenerator.DEBUG_FIELDS;
import
jdk.nashorn.internal.codegen.ObjectClassGenerator
;
import
jdk.nashorn.internal.codegen.types.Type
;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR base for accessing/indexing nodes.
...
...
@@ -50,15 +49,14 @@ public abstract class BaseNode extends Node implements FunctionCall, TypeOverrid
/**
* Constructor
*
* @param source source code
* @param token token
* @param finish finish
* @param base base node
* @param isFunction is this a function
* @param hasCallSiteType does this access have a callsite type
*/
public
BaseNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Node
base
,
final
boolean
isFunction
,
final
boolean
hasCallSiteType
)
{
super
(
source
,
token
,
base
.
getStart
(),
finish
);
public
BaseNode
(
final
long
token
,
final
int
finish
,
final
Node
base
,
final
boolean
isFunction
,
final
boolean
hasCallSiteType
)
{
super
(
token
,
base
.
getStart
(),
finish
);
this
.
base
=
base
;
this
.
isFunction
=
isFunction
;
this
.
hasCallSiteType
=
hasCallSiteType
;
...
...
src/jdk/nashorn/internal/ir/BinaryNode.java
浏览文件 @
5546c448
...
...
@@ -29,7 +29,6 @@ import jdk.nashorn.internal.codegen.types.Type;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.parser.TokenType
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* BinaryNode nodes represent two operand operations.
...
...
@@ -44,13 +43,12 @@ public final class BinaryNode extends Node implements Assignment<Node> {
/**
* Constructor
*
* @param source source code
* @param token token
* @param lhs left hand side
* @param rhs right hand side
*/
public
BinaryNode
(
final
Source
source
,
final
long
token
,
final
Node
lhs
,
final
Node
rhs
)
{
super
(
source
,
token
,
lhs
.
getStart
(),
rhs
.
getFinish
());
public
BinaryNode
(
final
long
token
,
final
Node
lhs
,
final
Node
rhs
)
{
super
(
token
,
lhs
.
getStart
(),
rhs
.
getFinish
());
this
.
lhs
=
lhs
;
this
.
rhs
=
rhs
;
}
...
...
src/jdk/nashorn/internal/ir/Block.java
浏览文件 @
5546c448
...
...
@@ -36,7 +36,6 @@ import java.util.Map;
import
jdk.nashorn.internal.codegen.Label
;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representation for a list of statements and functions. All provides the
...
...
@@ -77,13 +76,12 @@ public class Block extends BreakableNode implements Flags<Block> {
/**
* Constructor
*
* @param source source code
* @param token token
* @param finish finish
* @param statements statements
*/
public
Block
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Node
...
statements
)
{
super
(
source
,
token
,
finish
,
new
Label
(
"block_break"
));
public
Block
(
final
long
token
,
final
int
finish
,
final
Node
...
statements
)
{
super
(
token
,
finish
,
new
Label
(
"block_break"
));
this
.
statements
=
Arrays
.
asList
(
statements
);
this
.
symbols
=
new
LinkedHashMap
<>();
...
...
@@ -94,13 +92,12 @@ public class Block extends BreakableNode implements Flags<Block> {
/**
* Constructor
*
* @param source source code
* @param token token
* @param finish finish
* @param statements statements
*/
public
Block
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
List
<
Node
>
statements
)
{
this
(
source
,
token
,
finish
,
statements
.
toArray
(
new
Node
[
statements
.
size
()]));
public
Block
(
final
long
token
,
final
int
finish
,
final
List
<
Node
>
statements
)
{
this
(
token
,
finish
,
statements
.
toArray
(
new
Node
[
statements
.
size
()]));
}
private
Block
(
final
Block
block
,
final
int
finish
,
final
List
<
Node
>
statements
,
final
int
flags
,
final
Map
<
String
,
Symbol
>
symbols
)
{
...
...
src/jdk/nashorn/internal/ir/BreakNode.java
浏览文件 @
5546c448
...
...
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representation for {@code break} statements.
...
...
@@ -40,13 +39,12 @@ public final class BreakNode extends Node {
/**
* Constructor
*
* @param source source code
* @param token token
* @param finish finish
* @param label label for break or null if none
*/
public
BreakNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
IdentNode
label
)
{
super
(
source
,
token
,
finish
);
public
BreakNode
(
final
long
token
,
final
int
finish
,
final
IdentNode
label
)
{
super
(
token
,
finish
);
this
.
label
=
label
;
}
...
...
src/jdk/nashorn/internal/ir/BreakableNode.java
浏览文件 @
5546c448
...
...
@@ -30,7 +30,6 @@ import java.util.List;
import
jdk.nashorn.internal.codegen.Label
;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* This class represents a node from which control flow can execute
...
...
@@ -45,13 +44,12 @@ public abstract class BreakableNode extends LexicalContextNode {
/**
* Constructor
*
* @param source source code
* @param token token
* @param finish finish
* @param breakLabel break label
*/
protected
BreakableNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Label
breakLabel
)
{
super
(
source
,
token
,
finish
);
protected
BreakableNode
(
final
long
token
,
final
int
finish
,
final
Label
breakLabel
)
{
super
(
token
,
finish
);
this
.
breakLabel
=
breakLabel
;
}
...
...
src/jdk/nashorn/internal/ir/CallNode.java
浏览文件 @
5546c448
...
...
@@ -31,7 +31,6 @@ import jdk.nashorn.internal.codegen.types.Type;
import
jdk.nashorn.internal.ir.annotations.Ignore
;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representation for a function call.
...
...
@@ -137,14 +136,13 @@ public final class CallNode extends LexicalContextNode implements TypeOverride<C
/**
* Constructors
*
* @param source the source
* @param token token
* @param finish finish
* @param function the function to call
* @param args args to the call
*/
public
CallNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Node
function
,
final
List
<
Node
>
args
)
{
super
(
source
,
token
,
finish
);
public
CallNode
(
final
long
token
,
final
int
finish
,
final
Node
function
,
final
List
<
Node
>
args
)
{
super
(
token
,
finish
);
this
.
function
=
function
;
this
.
args
=
args
;
...
...
src/jdk/nashorn/internal/ir/CaseNode.java
浏览文件 @
5546c448
...
...
@@ -28,7 +28,6 @@ package jdk.nashorn.internal.ir;
import
jdk.nashorn.internal.codegen.Label
;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representation of CASE clause.
...
...
@@ -48,14 +47,13 @@ public final class CaseNode extends Node {
/**
* Constructors
*
* @param source the source
* @param token token
* @param finish finish
* @param test case test node, can be any node in JavaScript
* @param body case body
*/
public
CaseNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Node
test
,
final
Block
body
)
{
super
(
source
,
token
,
finish
);
public
CaseNode
(
final
long
token
,
final
int
finish
,
final
Node
test
,
final
Block
body
)
{
super
(
token
,
finish
);
this
.
test
=
test
;
this
.
body
=
body
;
...
...
src/jdk/nashorn/internal/ir/CatchNode.java
浏览文件 @
5546c448
...
...
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representation of a catch clause.
...
...
@@ -46,16 +45,14 @@ public final class CatchNode extends Node {
/**
* Constructors
*
* @param source the source
* @param token token
* @param finish finish
* @param exception variable name of exception
* @param exceptionCondition exception condition
* @param body catch body
*/
public
CatchNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
IdentNode
exception
,
final
Node
exceptionCondition
,
final
Block
body
)
{
super
(
source
,
token
,
finish
);
public
CatchNode
(
final
long
token
,
final
int
finish
,
final
IdentNode
exception
,
final
Node
exceptionCondition
,
final
Block
body
)
{
super
(
token
,
finish
);
this
.
exception
=
exception
;
this
.
exceptionCondition
=
exceptionCondition
;
this
.
body
=
body
;
...
...
@@ -63,7 +60,6 @@ public final class CatchNode extends Node {
private
CatchNode
(
final
CatchNode
catchNode
,
final
IdentNode
exception
,
final
Node
exceptionCondition
,
final
Block
body
)
{
super
(
catchNode
);
this
.
exception
=
exception
;
this
.
exceptionCondition
=
exceptionCondition
;
this
.
body
=
body
;
...
...
src/jdk/nashorn/internal/ir/ContinueNode.java
浏览文件 @
5546c448
...
...
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representation for CONTINUE statements.
...
...
@@ -40,13 +39,12 @@ public class ContinueNode extends Node {
/**
* Constructor
*
* @param source source code
* @param token token
* @param finish finish
* @param label label for break or null if none
*/
public
ContinueNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
IdentNode
label
)
{
super
(
source
,
token
,
finish
);
public
ContinueNode
(
final
long
token
,
final
int
finish
,
final
IdentNode
label
)
{
super
(
token
,
finish
);
this
.
label
=
label
;
}
...
...
src/jdk/nashorn/internal/ir/EmptyNode.java
浏览文件 @
5546c448
...
...
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representation for an empty statement.
...
...
@@ -47,12 +46,11 @@ public final class EmptyNode extends Node {
/**
* Constructor
*
* @param source the source
* @param token token
* @param finish finish
*/
public
EmptyNode
(
final
Source
source
,
final
long
token
,
final
int
finish
)
{
super
(
source
,
token
,
finish
);
public
EmptyNode
(
final
long
token
,
final
int
finish
)
{
super
(
token
,
finish
);
}
...
...
src/jdk/nashorn/internal/ir/ExecuteNode.java
浏览文件 @
5546c448
...
...
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representation for executing bare expressions. Basically, an expression
...
...
@@ -42,13 +41,12 @@ public final class ExecuteNode extends Node {
/**
* Constructor
*
* @param source the source
* @param token token
* @param finish finish
* @param expression the expression to execute
*/
public
ExecuteNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Node
expression
)
{
super
(
source
,
token
,
finish
);
public
ExecuteNode
(
final
long
token
,
final
int
finish
,
final
Node
expression
)
{
super
(
token
,
finish
);
this
.
expression
=
expression
;
}
...
...
@@ -63,7 +61,7 @@ public final class ExecuteNode extends Node {
* @param expression an expression to wrap, from which source, tokens and finish are also inherited
*/
public
ExecuteNode
(
final
Node
expression
)
{
super
(
expression
.
get
Source
(),
expression
.
get
Token
(),
expression
.
getFinish
());
super
(
expression
.
getToken
(),
expression
.
getFinish
());
this
.
expression
=
expression
;
}
...
...
src/jdk/nashorn/internal/ir/ForNode.java
浏览文件 @
5546c448
...
...
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representing a FOR statement.
...
...
@@ -57,7 +56,6 @@ public final class ForNode extends LoopNode {
/**
* Constructor
*
* @param source the source
* @param token token
* @param finish finish
* @param init init
...
...
@@ -66,8 +64,8 @@ public final class ForNode extends LoopNode {
* @param modify modify
* @param flags flags
*/
public
ForNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Node
init
,
final
Node
test
,
final
Block
body
,
final
Node
modify
,
final
int
flags
)
{
super
(
source
,
token
,
finish
,
test
,
body
,
false
);
public
ForNode
(
final
long
token
,
final
int
finish
,
final
Node
init
,
final
Node
test
,
final
Block
body
,
final
Node
modify
,
final
int
flags
)
{
super
(
token
,
finish
,
test
,
body
,
false
);
this
.
init
=
init
;
this
.
modify
=
modify
;
this
.
flags
=
flags
;
...
...
src/jdk/nashorn/internal/ir/FunctionNode.java
浏览文件 @
5546c448
...
...
@@ -86,6 +86,8 @@ public final class FunctionNode extends LexicalContextNode implements Flags<Func
/** method has been emitted to bytecode */
EMITTED
}
/** Source of entity. */
private
final
Source
source
;
/** External function identifier. */
@Ignore
...
...
@@ -223,8 +225,9 @@ public final class FunctionNode extends LexicalContextNode implements Flags<Func
final
List
<
IdentNode
>
parameters
,
final
FunctionNode
.
Kind
kind
,
final
int
flags
)
{
super
(
source
,
token
,
finish
);
super
(
token
,
finish
);
this
.
source
=
source
;
this
.
ident
=
ident
;
this
.
name
=
name
;
this
.
kind
=
kind
;
...
...
@@ -265,6 +268,7 @@ public final class FunctionNode extends LexicalContextNode implements Flags<Func
this
.
hints
=
hints
;
// the fields below never change - they are final and assigned in constructor
this
.
source
=
functionNode
.
source
;
this
.
name
=
functionNode
.
name
;
this
.
ident
=
functionNode
.
ident
;
this
.
namespace
=
functionNode
.
namespace
;
...
...
@@ -281,6 +285,14 @@ public final class FunctionNode extends LexicalContextNode implements Flags<Func
return
this
;
}
/**
* Get the source for this function
* @return the source
*/
public
Source
getSource
()
{
return
source
;
}
/**
* Get the version of this function node's code as it looked upon construction
* i.e typically parsed and nothing else
...
...
@@ -300,6 +312,9 @@ public final class FunctionNode extends LexicalContextNode implements Flags<Func
if
(
this
.
snapshot
==
this
)
{
return
this
;
}
if
(
isProgram
()
||
parameters
.
isEmpty
())
{
return
this
;
//never specialize anything that won't be recompiled
}
return
Node
.
replaceInLexicalContext
(
lc
,
this
,
new
FunctionNode
(
this
,
lastToken
,
flags
,
returnType
,
compileUnit
,
compilationState
,
body
,
parameters
,
this
,
hints
));
}
...
...
src/jdk/nashorn/internal/ir/IdentNode.java
浏览文件 @
5546c448
...
...
@@ -34,7 +34,6 @@ import jdk.nashorn.internal.codegen.ObjectClassGenerator;
import
jdk.nashorn.internal.codegen.types.Type
;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representation for an identifier.
...
...
@@ -56,13 +55,12 @@ public final class IdentNode extends Node implements PropertyKey, TypeOverride<I
/**
* Constructor
*
* @param source the source
* @param token token
* @param finish finish position
* @param name name of identifier
*/
public
IdentNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
String
name
)
{
super
(
source
,
token
,
finish
);
public
IdentNode
(
final
long
token
,
final
int
finish
,
final
String
name
)
{
super
(
token
,
finish
);
this
.
name
=
name
;
this
.
callSiteType
=
null
;
this
.
flags
=
0
;
...
...
src/jdk/nashorn/internal/ir/IfNode.java
浏览文件 @
5546c448
...
...
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representation for an IF statement.
...
...
@@ -46,15 +45,14 @@ public final class IfNode extends Node {
/**
* Constructor
*
* @param source the source
* @param token token
* @param finish finish
* @param test test
* @param pass block to execute when test passes
* @param fail block to execute when test fails or null
*/
public
IfNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Node
test
,
final
Block
pass
,
final
Block
fail
)
{
super
(
source
,
token
,
finish
);
public
IfNode
(
final
long
token
,
final
int
finish
,
final
Node
test
,
final
Block
pass
,
final
Block
fail
)
{
super
(
token
,
finish
);
this
.
test
=
test
;
this
.
pass
=
pass
;
this
.
fail
=
fail
;
...
...
src/jdk/nashorn/internal/ir/IndexNode.java
浏览文件 @
5546c448
...
...
@@ -28,7 +28,6 @@ package jdk.nashorn.internal.ir;
import
jdk.nashorn.internal.codegen.types.Type
;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representation of an indexed access (brackets operator.)
...
...
@@ -41,14 +40,13 @@ public final class IndexNode extends BaseNode {
/**
* Constructors
*
* @param source the source
* @param token token
* @param finish finish
* @param base base node for access
* @param index index for access
*/
public
IndexNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Node
base
,
final
Node
index
)
{
super
(
source
,
token
,
finish
,
base
,
false
,
false
);
public
IndexNode
(
final
long
token
,
final
int
finish
,
final
Node
base
,
final
Node
index
)
{
super
(
token
,
finish
,
base
,
false
,
false
);
this
.
index
=
index
;
}
...
...
src/jdk/nashorn/internal/ir/LabelNode.java
浏览文件 @
5546c448
...
...
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representation for a labeled statement.
...
...
@@ -43,14 +42,13 @@ public final class LabelNode extends LexicalContextNode {
/**
* Constructor
*
* @param source the source
* @param token token
* @param finish finish
* @param label label identifier
* @param body body of label node
*/
public
LabelNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
IdentNode
label
,
final
Block
body
)
{
super
(
source
,
token
,
finish
);
public
LabelNode
(
final
long
token
,
final
int
finish
,
final
IdentNode
label
,
final
Block
body
)
{
super
(
token
,
finish
);
this
.
label
=
label
;
this
.
body
=
body
;
...
...
src/jdk/nashorn/internal/ir/LexicalContext.java
浏览文件 @
5546c448
...
...
@@ -392,8 +392,7 @@ public class LexicalContext {
*/
public
boolean
isFunctionDefinedInCurrentCall
(
FunctionNode
functionNode
)
{
final
LexicalContextNode
parent
=
stack
[
sp
-
2
];
if
(
parent
instanceof
CallNode
&&
((
CallNode
)
parent
).
getFunction
()
==
functionNode
)
{
assert
functionNode
.
getSource
()
==
peek
().
getSource
();
if
(
parent
instanceof
CallNode
&&
((
CallNode
)
parent
).
getFunction
()
==
functionNode
)
{
return
true
;
}
return
false
;
...
...
@@ -540,13 +539,16 @@ public class LexicalContext {
sb
.
append
(
'@'
);
sb
.
append
(
Debug
.
id
(
node
));
sb
.
append
(
':'
);
final
Source
source
=
node
.
getSource
();
String
src
=
source
.
toString
();
if
(
src
.
indexOf
(
File
.
pathSeparator
)
!=
-
1
)
{
src
=
src
.
substring
(
src
.
lastIndexOf
(
File
.
pathSeparator
));
if
(
node
instanceof
FunctionNode
)
{
final
Source
source
=
((
FunctionNode
)
node
).
getSource
();
String
src
=
source
.
toString
();
if
(
src
.
indexOf
(
File
.
pathSeparator
)
!=
-
1
)
{
src
=
src
.
substring
(
src
.
lastIndexOf
(
File
.
pathSeparator
));
}
src
+=
' '
;
src
+=
source
.
getLine
(
node
.
getStart
());
sb
.
append
(
src
);
}
src
+=
' '
;
src
+=
source
.
getLine
(
node
.
getStart
());
sb
.
append
(
' '
);
}
sb
.
append
(
" ==> ]"
);
...
...
src/jdk/nashorn/internal/ir/LexicalContextNode.java
浏览文件 @
5546c448
...
...
@@ -25,7 +25,6 @@
package
jdk.nashorn.internal.ir
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* Superclass for nodes that can be part of the lexical context
...
...
@@ -35,12 +34,11 @@ public abstract class LexicalContextNode extends Node {
/**
* Constructor
*
* @param source source
* @param token token
* @param finish finish
*/
protected
LexicalContextNode
(
final
Source
source
,
final
long
token
,
final
int
finish
)
{
super
(
source
,
token
,
finish
);
protected
LexicalContextNode
(
final
long
token
,
final
int
finish
)
{
super
(
token
,
finish
);
}
/**
...
...
src/jdk/nashorn/internal/ir/LineNumberNode.java
浏览文件 @
5546c448
...
...
@@ -28,7 +28,6 @@ package jdk.nashorn.internal.ir;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.parser.Token
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR Node representing a line number
...
...
@@ -41,12 +40,11 @@ public final class LineNumberNode extends Node {
/**
* Constructor
*
* @param source the source
* @param token token
* @param lineNumber the line number
*/
public
LineNumberNode
(
final
Source
source
,
final
long
token
,
final
int
lineNumber
)
{
super
(
source
,
token
,
Token
.
descPosition
(
token
));
public
LineNumberNode
(
final
long
token
,
final
int
lineNumber
)
{
super
(
token
,
Token
.
descPosition
(
token
));
this
.
lineNumber
=
lineNumber
;
}
...
...
src/jdk/nashorn/internal/ir/LiteralNode.java
浏览文件 @
5546c448
...
...
@@ -37,7 +37,6 @@ import jdk.nashorn.internal.parser.Token;
import
jdk.nashorn.internal.parser.TokenType
;
import
jdk.nashorn.internal.runtime.JSType
;
import
jdk.nashorn.internal.runtime.ScriptRuntime
;
import
jdk.nashorn.internal.runtime.Source
;
import
jdk.nashorn.internal.runtime.Undefined
;
/**
...
...
@@ -50,16 +49,15 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
/** Literal value */
protected
final
T
value
;
/**
/**
* Constructor
*
* @param source the source
* @param token token
* @param finish finish
* @param value the value of the literal
*/
protected
LiteralNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
T
value
)
{
super
(
source
,
token
,
finish
);
protected
LiteralNode
(
final
long
token
,
final
int
finish
,
final
T
value
)
{
super
(
token
,
finish
);
this
.
value
=
value
;
}
...
...
@@ -238,14 +236,13 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
/**
* Create a new null literal
*
* @param source the source
* @param token token
* @param finish finish
*
* @return the new literal node
*/
public
static
LiteralNode
<
Node
>
newInstance
(
final
Source
source
,
final
long
token
,
final
int
finish
)
{
return
new
NodeLiteralNode
(
source
,
token
,
finish
);
public
static
LiteralNode
<
Node
>
newInstance
(
final
long
token
,
final
int
finish
)
{
return
new
NodeLiteralNode
(
token
,
finish
);
}
/**
...
...
@@ -256,14 +253,14 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
* @return the new literal node
*/
public
static
LiteralNode
<?>
newInstance
(
final
Node
parent
)
{
return
new
NodeLiteralNode
(
parent
.
get
Source
(),
parent
.
get
Token
(),
parent
.
getFinish
());
return
new
NodeLiteralNode
(
parent
.
getToken
(),
parent
.
getFinish
());
}
@Immutable
private
static
final
class
BooleanLiteralNode
extends
LiteralNode
<
Boolean
>
{
private
BooleanLiteralNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
boolean
value
)
{
super
(
source
,
Token
.
recast
(
token
,
value
?
TokenType
.
TRUE
:
TokenType
.
FALSE
),
finish
,
value
);
private
BooleanLiteralNode
(
final
long
token
,
final
int
finish
,
final
boolean
value
)
{
super
(
Token
.
recast
(
token
,
value
?
TokenType
.
TRUE
:
TokenType
.
FALSE
),
finish
,
value
);
}
private
BooleanLiteralNode
(
final
BooleanLiteralNode
literalNode
)
{
...
...
@@ -289,15 +286,14 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
/**
* Create a new boolean literal
*
* @param source the source
* @param token token
* @param finish finish
* @param value true or false
*
* @return the new literal node
*/
public
static
LiteralNode
<
Boolean
>
newInstance
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
boolean
value
)
{
return
new
BooleanLiteralNode
(
source
,
token
,
finish
,
value
);
public
static
LiteralNode
<
Boolean
>
newInstance
(
final
long
token
,
final
int
finish
,
final
boolean
value
)
{
return
new
BooleanLiteralNode
(
token
,
finish
,
value
);
}
/**
...
...
@@ -309,7 +305,7 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
* @return the new literal node
*/
public
static
LiteralNode
<?>
newInstance
(
final
Node
parent
,
final
boolean
value
)
{
return
new
BooleanLiteralNode
(
parent
.
get
Source
(),
parent
.
get
Token
(),
parent
.
getFinish
(),
value
);
return
new
BooleanLiteralNode
(
parent
.
getToken
(),
parent
.
getFinish
(),
value
);
}
@Immutable
...
...
@@ -317,8 +313,8 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
private
final
Type
type
=
numberGetType
(
value
);
private
NumberLiteralNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Number
value
)
{
super
(
source
,
Token
.
recast
(
token
,
TokenType
.
DECIMAL
),
finish
,
value
);
private
NumberLiteralNode
(
final
long
token
,
final
int
finish
,
final
Number
value
)
{
super
(
Token
.
recast
(
token
,
TokenType
.
DECIMAL
),
finish
,
value
);
}
private
NumberLiteralNode
(
final
NumberLiteralNode
literalNode
)
{
...
...
@@ -353,15 +349,14 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
/**
* Create a new number literal
*
* @param source the source
* @param token token
* @param finish finish
* @param value literal value
*
* @return the new literal node
*/
public
static
LiteralNode
<
Number
>
newInstance
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Number
value
)
{
return
new
NumberLiteralNode
(
source
,
token
,
finish
,
value
);
public
static
LiteralNode
<
Number
>
newInstance
(
final
long
token
,
final
int
finish
,
final
Number
value
)
{
return
new
NumberLiteralNode
(
token
,
finish
,
value
);
}
/**
...
...
@@ -373,12 +368,12 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
* @return the new literal node
*/
public
static
LiteralNode
<?>
newInstance
(
final
Node
parent
,
final
Number
value
)
{
return
new
NumberLiteralNode
(
parent
.
get
Source
(),
parent
.
get
Token
(),
parent
.
getFinish
(),
value
);
return
new
NumberLiteralNode
(
parent
.
getToken
(),
parent
.
getFinish
(),
value
);
}
private
static
class
UndefinedLiteralNode
extends
LiteralNode
<
Undefined
>
{
private
UndefinedLiteralNode
(
final
Source
source
,
final
long
token
,
final
int
finish
)
{
super
(
source
,
Token
.
recast
(
token
,
TokenType
.
OBJECT
),
finish
,
ScriptRuntime
.
UNDEFINED
);
private
UndefinedLiteralNode
(
final
long
token
,
final
int
finish
)
{
super
(
Token
.
recast
(
token
,
TokenType
.
OBJECT
),
finish
,
ScriptRuntime
.
UNDEFINED
);
}
private
UndefinedLiteralNode
(
final
UndefinedLiteralNode
literalNode
)
{
...
...
@@ -389,15 +384,14 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
/**
* Create a new undefined literal
*
* @param source the source
* @param token token
* @param finish finish
* @param value undefined value, passed only for polymorphisism discrimination
*
* @return the new literal node
*/
public
static
LiteralNode
<
Undefined
>
newInstance
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Undefined
value
)
{
return
new
UndefinedLiteralNode
(
source
,
token
,
finish
);
public
static
LiteralNode
<
Undefined
>
newInstance
(
final
long
token
,
final
int
finish
,
final
Undefined
value
)
{
return
new
UndefinedLiteralNode
(
token
,
finish
);
}
/**
...
...
@@ -409,13 +403,13 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
* @return the new literal node
*/
public
static
LiteralNode
<?>
newInstance
(
final
Node
parent
,
final
Undefined
value
)
{
return
new
UndefinedLiteralNode
(
parent
.
get
Source
(),
parent
.
get
Token
(),
parent
.
getFinish
());
return
new
UndefinedLiteralNode
(
parent
.
getToken
(),
parent
.
getFinish
());
}
@Immutable
private
static
class
StringLiteralNode
extends
LiteralNode
<
String
>
{
private
StringLiteralNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
String
value
)
{
super
(
source
,
Token
.
recast
(
token
,
TokenType
.
STRING
),
finish
,
value
);
private
StringLiteralNode
(
final
long
token
,
final
int
finish
,
final
String
value
)
{
super
(
Token
.
recast
(
token
,
TokenType
.
STRING
),
finish
,
value
);
}
private
StringLiteralNode
(
final
StringLiteralNode
literalNode
)
{
...
...
@@ -433,15 +427,14 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
/**
* Create a new string literal
*
* @param source the source
* @param token token
* @param finish finish
* @param value string value
*
* @return the new literal node
*/
public
static
LiteralNode
<
String
>
newInstance
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
String
value
)
{
return
new
StringLiteralNode
(
source
,
token
,
finish
,
value
);
public
static
LiteralNode
<
String
>
newInstance
(
final
long
token
,
final
int
finish
,
final
String
value
)
{
return
new
StringLiteralNode
(
token
,
finish
,
value
);
}
/**
...
...
@@ -453,13 +446,13 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
* @return the new literal node
*/
public
static
LiteralNode
<?>
newInstance
(
final
Node
parent
,
final
String
value
)
{
return
new
StringLiteralNode
(
parent
.
get
Source
(),
parent
.
get
Token
(),
parent
.
getFinish
(),
value
);
return
new
StringLiteralNode
(
parent
.
getToken
(),
parent
.
getFinish
(),
value
);
}
@Immutable
private
static
class
LexerTokenLiteralNode
extends
LiteralNode
<
LexerToken
>
{
private
LexerTokenLiteralNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
LexerToken
value
)
{
super
(
source
,
Token
.
recast
(
token
,
TokenType
.
STRING
),
finish
,
value
);
//TODO is string the correct token type here?
private
LexerTokenLiteralNode
(
final
long
token
,
final
int
finish
,
final
LexerToken
value
)
{
super
(
Token
.
recast
(
token
,
TokenType
.
STRING
),
finish
,
value
);
//TODO is string the correct token type here?
}
private
LexerTokenLiteralNode
(
final
LexerTokenLiteralNode
literalNode
)
{
...
...
@@ -480,15 +473,14 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
/**
* Create a new literal node for a lexer token
*
* @param source the source
* @param token token
* @param finish finish
* @param value lexer token value
*
* @return the new literal node
*/
public
static
LiteralNode
<
LexerToken
>
newInstance
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
LexerToken
value
)
{
return
new
LexerTokenLiteralNode
(
source
,
token
,
finish
,
value
);
public
static
LiteralNode
<
LexerToken
>
newInstance
(
final
long
token
,
final
int
finish
,
final
LexerToken
value
)
{
return
new
LexerTokenLiteralNode
(
token
,
finish
,
value
);
}
/**
...
...
@@ -500,17 +492,17 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
* @return the new literal node
*/
public
static
LiteralNode
<?>
newInstance
(
final
Node
parent
,
final
LexerToken
value
)
{
return
new
LexerTokenLiteralNode
(
parent
.
get
Source
(),
parent
.
get
Token
(),
parent
.
getFinish
(),
value
);
return
new
LexerTokenLiteralNode
(
parent
.
getToken
(),
parent
.
getFinish
(),
value
);
}
private
static
final
class
NodeLiteralNode
extends
LiteralNode
<
Node
>
{
private
NodeLiteralNode
(
final
Source
source
,
final
long
token
,
final
int
finish
)
{
this
(
source
,
token
,
finish
,
null
);
private
NodeLiteralNode
(
final
long
token
,
final
int
finish
)
{
this
(
token
,
finish
,
null
);
}
private
NodeLiteralNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Node
value
)
{
super
(
source
,
Token
.
recast
(
token
,
TokenType
.
OBJECT
),
finish
,
value
);
private
NodeLiteralNode
(
final
long
token
,
final
int
finish
,
final
Node
value
)
{
super
(
Token
.
recast
(
token
,
TokenType
.
OBJECT
),
finish
,
value
);
}
private
NodeLiteralNode
(
final
LiteralNode
<
Node
>
literalNode
)
{
...
...
@@ -550,15 +542,14 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
/**
* Create a new node literal for an arbitrary node
*
* @param source the source
* @param token token
* @param finish finish
* @param value the literal value node
*
* @return the new literal node
*/
public
static
LiteralNode
<
Node
>
newInstance
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Node
value
)
{
return
new
NodeLiteralNode
(
source
,
token
,
finish
,
value
);
public
static
LiteralNode
<
Node
>
newInstance
(
final
long
token
,
final
int
finish
,
final
Node
value
)
{
return
new
NodeLiteralNode
(
token
,
finish
,
value
);
}
/**
...
...
@@ -570,7 +561,7 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
* @return the new literal node
*/
public
static
LiteralNode
<?>
newInstance
(
final
Node
parent
,
final
Node
value
)
{
return
new
NodeLiteralNode
(
parent
.
get
Source
(),
parent
.
get
Token
(),
parent
.
getFinish
(),
value
);
return
new
NodeLiteralNode
(
parent
.
getToken
(),
parent
.
getFinish
(),
value
);
}
/**
...
...
@@ -645,13 +636,12 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
/**
* Constructor
*
* @param source the source
* @param token token
* @param finish finish
* @param value array literal value, a Node array
*/
protected
ArrayLiteralNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Node
[]
value
)
{
super
(
source
,
Token
.
recast
(
token
,
TokenType
.
ARRAY
),
finish
,
value
);
protected
ArrayLiteralNode
(
final
long
token
,
final
int
finish
,
final
Node
[]
value
)
{
super
(
Token
.
recast
(
token
,
TokenType
.
ARRAY
),
finish
,
value
);
this
.
elementType
=
Type
.
UNKNOWN
;
}
...
...
@@ -886,15 +876,14 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
/**
* Create a new array literal of Nodes from a list of Node values
*
* @param source the source
* @param token token
* @param finish finish
* @param value literal value list
*
* @return the new literal node
*/
public
static
LiteralNode
<
Node
[]>
newInstance
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
List
<
Node
>
value
)
{
return
new
ArrayLiteralNode
(
source
,
token
,
finish
,
value
.
toArray
(
new
Node
[
value
.
size
()]));
public
static
LiteralNode
<
Node
[]>
newInstance
(
final
long
token
,
final
int
finish
,
final
List
<
Node
>
value
)
{
return
new
ArrayLiteralNode
(
token
,
finish
,
value
.
toArray
(
new
Node
[
value
.
size
()]));
}
...
...
@@ -907,20 +896,19 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
* @return the new literal node
*/
public
static
LiteralNode
<?>
newInstance
(
final
Node
parent
,
final
List
<
Node
>
value
)
{
return
new
ArrayLiteralNode
(
parent
.
get
Source
(),
parent
.
get
Token
(),
parent
.
getFinish
(),
value
.
toArray
(
new
Node
[
value
.
size
()]));
return
new
ArrayLiteralNode
(
parent
.
getToken
(),
parent
.
getFinish
(),
value
.
toArray
(
new
Node
[
value
.
size
()]));
}
/**
* Create a new array literal of Nodes
*
* @param source the source
* @param token token
* @param finish finish
* @param value literal value array
*
* @return the new literal node
*/
public
static
LiteralNode
<
Node
[]>
newInstance
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Node
[]
value
)
{
return
new
ArrayLiteralNode
(
source
,
token
,
finish
,
value
);
public
static
LiteralNode
<
Node
[]>
newInstance
(
final
long
token
,
final
int
finish
,
final
Node
[]
value
)
{
return
new
ArrayLiteralNode
(
token
,
finish
,
value
);
}
}
src/jdk/nashorn/internal/ir/Location.java
已删除
100644 → 0
浏览文件 @
24cbc14c
/*
* 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
;
import
jdk.nashorn.internal.parser.Token
;
import
jdk.nashorn.internal.parser.TokenType
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* Used to locate an entity back to it's source file.
*/
public
class
Location
implements
Cloneable
{
/** Source of entity. */
private
final
Source
source
;
/** Token descriptor. */
private
final
long
token
;
/**
* Constructor
*
* @param source the source
* @param token token
*/
public
Location
(
final
Source
source
,
final
long
token
)
{
this
.
source
=
source
;
this
.
token
=
token
;
}
/**
* Copy constructor
*
* @param location source node
*/
protected
Location
(
final
Location
location
)
{
this
.
source
=
location
.
source
;
this
.
token
=
location
.
token
;
}
@Override
protected
Object
clone
()
{
try
{
return
super
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
throw
new
AssertionError
(
e
);
}
}
@Override
public
final
boolean
equals
(
final
Object
other
)
{
return
super
.
equals
(
other
);
}
@Override
public
final
int
hashCode
()
{
return
super
.
hashCode
();
}
/**
* Return token position from a token descriptor.
*
* @return Start position of the token in the source.
*/
public
int
position
()
{
return
Token
.
descPosition
(
token
);
}
/**
* Return token length from a token descriptor.
*
* @return Length of the token.
*/
public
int
length
()
{
return
Token
.
descLength
(
token
);
}
/**
* Return token tokenType from a token descriptor.
*
* @return Type of token.
*/
public
TokenType
tokenType
()
{
return
Token
.
descType
(
token
);
}
/**
* Test token tokenType.
*
* @param type a type to check this token against
* @return true if token types match.
*/
public
boolean
isTokenType
(
final
TokenType
type
)
{
return
Token
.
descType
(
token
)
==
type
;
}
/**
* Get the source for this location
* @return the source
*/
public
Source
getSource
()
{
return
source
;
}
/**
* Get the token for this location
* @return the token
*/
public
long
getToken
()
{
return
token
;
}
}
src/jdk/nashorn/internal/ir/LoopNode.java
浏览文件 @
5546c448
...
...
@@ -29,7 +29,6 @@ import java.util.Arrays;
import
java.util.List
;
import
jdk.nashorn.internal.codegen.Label
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* A loop node, for example a while node, do while node or for node
...
...
@@ -50,15 +49,14 @@ public abstract class LoopNode extends BreakableNode {
/**
* Constructor
*
* @param source source
* @param token token
* @param finish finish
* @param test test, or null if infinite loop
* @param body loop body
* @param controlFlowEscapes controlFlowEscapes
*/
protected
LoopNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Node
test
,
final
Block
body
,
final
boolean
controlFlowEscapes
)
{
super
(
source
,
token
,
finish
,
new
Label
(
"while_break"
));
protected
LoopNode
(
final
long
token
,
final
int
finish
,
final
Node
test
,
final
Block
body
,
final
boolean
controlFlowEscapes
)
{
super
(
token
,
finish
,
new
Label
(
"while_break"
));
this
.
continueLabel
=
new
Label
(
"while_continue"
);
this
.
test
=
test
;
this
.
body
=
body
;
...
...
src/jdk/nashorn/internal/ir/Node.java
浏览文件 @
5546c448
...
...
@@ -31,12 +31,12 @@ import java.util.List;
import
jdk.nashorn.internal.codegen.types.Type
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.parser.Token
;
import
jdk.nashorn.internal.
runtime.Sourc
e
;
import
jdk.nashorn.internal.
parser.TokenTyp
e
;
/**
* Nodes are used to compose Abstract Syntax Trees.
*/
public
abstract
class
Node
extends
Location
{
public
abstract
class
Node
implements
Cloneable
{
/** Node symbol. */
private
Symbol
symbol
;
...
...
@@ -46,16 +46,17 @@ public abstract class Node extends Location {
/** End of source range. */
protected
int
finish
;
/** Token descriptor. */
private
final
long
token
;
/**
* Constructor
*
* @param source the source
* @param token token
* @param finish finish
*/
public
Node
(
final
Source
source
,
final
long
token
,
final
int
finish
)
{
super
(
source
,
token
);
public
Node
(
final
long
token
,
final
int
finish
)
{
this
.
token
=
token
;
this
.
start
=
Token
.
descPosition
(
token
);
this
.
finish
=
finish
;
}
...
...
@@ -63,16 +64,14 @@ public abstract class Node extends Location {
/**
* Constructor
*
* @param source source
* @param token token
* @param start start
* @param finish finish
*/
protected
Node
(
final
Source
source
,
final
long
token
,
final
int
start
,
final
int
finish
)
{
super
(
source
,
token
);
protected
Node
(
final
long
token
,
final
int
start
,
final
int
finish
)
{
this
.
start
=
start
;
this
.
finish
=
finish
;
this
.
token
=
token
;
}
/**
...
...
@@ -81,8 +80,7 @@ public abstract class Node extends Location {
* @param node source node
*/
protected
Node
(
final
Node
node
)
{
super
(
node
);
this
.
token
=
node
.
token
;
this
.
symbol
=
node
.
symbol
;
this
.
start
=
node
.
start
;
this
.
finish
=
node
.
finish
;
...
...
@@ -248,6 +246,15 @@ public abstract class Node extends Location {
return
symbol
;
}
@Override
protected
Object
clone
()
{
try
{
return
super
.
clone
();
}
catch
(
final
CloneNotSupportedException
e
)
{
throw
new
AssertionError
(
e
);
}
}
/**
* Assign a symbol to this node. See {@link Node#getSymbol()} for explanation
* of what a symbol is
...
...
@@ -265,6 +272,62 @@ public abstract class Node extends Location {
return
newNode
;
}
@Override
public
final
boolean
equals
(
final
Object
other
)
{
return
super
.
equals
(
other
);
}
@Override
public
final
int
hashCode
()
{
return
super
.
hashCode
();
}
/**
* Return token position from a token descriptor.
*
* @return Start position of the token in the source.
*/
public
int
position
()
{
return
Token
.
descPosition
(
token
);
}
/**
* Return token length from a token descriptor.
*
* @return Length of the token.
*/
public
int
length
()
{
return
Token
.
descLength
(
token
);
}
/**
* Return token tokenType from a token descriptor.
*
* @return Type of token.
*/
public
TokenType
tokenType
()
{
return
Token
.
descType
(
token
);
}
/**
* Test token tokenType.
*
* @param type a type to check this token against
* @return true if token types match.
*/
public
boolean
isTokenType
(
final
TokenType
type
)
{
return
Token
.
descType
(
token
)
==
type
;
}
/**
* Get the token for this location
* @return the token
*/
public
long
getToken
()
{
return
token
;
}
/**
* Is this a terminal Node, i.e. does it end control flow like a throw or return
* expression does?
...
...
src/jdk/nashorn/internal/ir/ObjectNode.java
浏览文件 @
5546c448
...
...
@@ -30,7 +30,6 @@ import java.util.List;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representation of an object literal.
...
...
@@ -44,13 +43,12 @@ public final class ObjectNode extends Node {
/**
* Constructor
*
* @param source the source
* @param token token
* @param finish finish
* @param elements the elements used to initialize this ObjectNode
*/
public
ObjectNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
List
<
Node
>
elements
)
{
super
(
source
,
token
,
finish
);
public
ObjectNode
(
final
long
token
,
final
int
finish
,
final
List
<
Node
>
elements
)
{
super
(
token
,
finish
);
this
.
elements
=
elements
;
}
...
...
src/jdk/nashorn/internal/ir/PropertyNode.java
浏览文件 @
5546c448
...
...
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representation of an object literal property.
...
...
@@ -50,7 +49,6 @@ public final class PropertyNode extends Node {
/**
* Constructor
*
* @param source the source
* @param token token
* @param finish finish
* @param key the key of this property
...
...
@@ -58,8 +56,8 @@ public final class PropertyNode extends Node {
* @param getter getter function body
* @param setter setter function body
*/
public
PropertyNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
PropertyKey
key
,
final
Node
value
,
final
FunctionNode
getter
,
final
FunctionNode
setter
)
{
super
(
source
,
token
,
finish
);
public
PropertyNode
(
final
long
token
,
final
int
finish
,
final
PropertyKey
key
,
final
Node
value
,
final
FunctionNode
getter
,
final
FunctionNode
setter
)
{
super
(
token
,
finish
);
this
.
key
=
key
;
this
.
value
=
value
;
this
.
getter
=
getter
;
...
...
src/jdk/nashorn/internal/ir/ReturnNode.java
浏览文件 @
5546c448
...
...
@@ -29,7 +29,6 @@ import static jdk.nashorn.internal.parser.TokenType.RETURN;
import
static
jdk
.
nashorn
.
internal
.
parser
.
TokenType
.
YIELD
;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representation for RETURN or YIELD statements.
...
...
@@ -42,13 +41,12 @@ public class ReturnNode extends Node {
/**
* Constructor
*
* @param source the source
* @param token token
* @param finish finish
* @param expression expression to return
*/
public
ReturnNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Node
expression
)
{
super
(
source
,
token
,
finish
);
public
ReturnNode
(
final
long
token
,
final
int
finish
,
final
Node
expression
)
{
super
(
token
,
finish
);
this
.
expression
=
expression
;
}
...
...
src/jdk/nashorn/internal/ir/RuntimeNode.java
浏览文件 @
5546c448
...
...
@@ -33,7 +33,6 @@ import jdk.nashorn.internal.codegen.types.Type;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.parser.TokenType
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representation for a runtime call.
...
...
@@ -280,14 +279,13 @@ public class RuntimeNode extends Node implements TypeOverride<RuntimeNode> {
/**
* Constructor
*
* @param source the source
* @param token token
* @param finish finish
* @param request the request
* @param args arguments to request
*/
public
RuntimeNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Request
request
,
final
List
<
Node
>
args
)
{
super
(
source
,
token
,
finish
);
public
RuntimeNode
(
final
long
token
,
final
int
finish
,
final
Request
request
,
final
List
<
Node
>
args
)
{
super
(
token
,
finish
);
this
.
request
=
request
;
this
.
args
=
args
;
...
...
@@ -307,14 +305,13 @@ public class RuntimeNode extends Node implements TypeOverride<RuntimeNode> {
/**
* Constructor
*
* @param source the source
* @param token token
* @param finish finish
* @param request the request
* @param args arguments to request
*/
public
RuntimeNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Request
request
,
final
Node
...
args
)
{
this
(
source
,
token
,
finish
,
request
,
Arrays
.
asList
(
args
));
public
RuntimeNode
(
final
long
token
,
final
int
finish
,
final
Request
request
,
final
Node
...
args
)
{
this
(
token
,
finish
,
request
,
Arrays
.
asList
(
args
));
}
/**
...
...
src/jdk/nashorn/internal/ir/SplitNode.java
浏览文件 @
5546c448
...
...
@@ -51,7 +51,7 @@ public class SplitNode extends LexicalContextNode {
* @param compileUnit compile unit to use for the body
*/
public
SplitNode
(
final
String
name
,
final
Node
body
,
final
CompileUnit
compileUnit
)
{
super
(
body
.
get
Source
(),
body
.
get
Token
(),
body
.
getFinish
());
super
(
body
.
getToken
(),
body
.
getFinish
());
this
.
name
=
name
;
this
.
body
=
body
;
this
.
compileUnit
=
compileUnit
;
...
...
src/jdk/nashorn/internal/ir/SwitchNode.java
浏览文件 @
5546c448
...
...
@@ -32,7 +32,6 @@ import java.util.List;
import
jdk.nashorn.internal.codegen.Label
;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representation of a SWITCH statement.
...
...
@@ -54,15 +53,14 @@ public final class SwitchNode extends BreakableNode {
/**
* Constructor
*
* @param source the source
* @param token token
* @param finish finish
* @param expression switch expression
* @param cases cases
* @param defaultCase the default case node - null if none, otherwise has to be present in cases list
*/
public
SwitchNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Node
expression
,
final
List
<
CaseNode
>
cases
,
final
CaseNode
defaultCase
)
{
super
(
source
,
token
,
finish
,
new
Label
(
"switch_break"
));
public
SwitchNode
(
final
long
token
,
final
int
finish
,
final
Node
expression
,
final
List
<
CaseNode
>
cases
,
final
CaseNode
defaultCase
)
{
super
(
token
,
finish
,
new
Label
(
"switch_break"
));
this
.
expression
=
expression
;
this
.
cases
=
cases
;
this
.
defaultCaseIndex
=
defaultCase
==
null
?
-
1
:
cases
.
indexOf
(
defaultCase
);
...
...
src/jdk/nashorn/internal/ir/TernaryNode.java
浏览文件 @
5546c448
...
...
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* TernaryNode nodes represent three operand operations (?:).
...
...
@@ -44,14 +43,13 @@ public final class TernaryNode extends Node {
/**
* Constructor
*
* @param source the source
* @param token token
* @param lhs left hand side node
* @param rhs right hand side node
* @param third third node
*/
public
TernaryNode
(
final
Source
source
,
final
long
token
,
final
Node
lhs
,
final
Node
rhs
,
final
Node
third
)
{
super
(
source
,
token
,
third
.
getFinish
());
public
TernaryNode
(
final
long
token
,
final
Node
lhs
,
final
Node
rhs
,
final
Node
third
)
{
super
(
token
,
third
.
getFinish
());
this
.
lhs
=
lhs
;
this
.
rhs
=
rhs
;
this
.
third
=
third
;
...
...
src/jdk/nashorn/internal/ir/ThrowNode.java
浏览文件 @
5546c448
...
...
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representation for THROW statements.
...
...
@@ -40,14 +39,12 @@ public final class ThrowNode extends Node {
/**
* Constructor
*
* @param source the source
* @param token token
* @param finish finish
* @param expression expression to throw
*/
public
ThrowNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Node
expression
)
{
super
(
source
,
token
,
finish
);
public
ThrowNode
(
final
long
token
,
final
int
finish
,
final
Node
expression
)
{
super
(
token
,
finish
);
this
.
expression
=
expression
;
}
...
...
src/jdk/nashorn/internal/ir/TryNode.java
浏览文件 @
5546c448
...
...
@@ -32,7 +32,6 @@ import java.util.List;
import
jdk.nashorn.internal.codegen.Label
;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representation of a TRY statement.
...
...
@@ -60,15 +59,14 @@ public final class TryNode extends Node {
/**
* Constructor
*
* @param source the source
* @param token token
* @param finish finish
* @param body try node body
* @param catchBlocks list of catch blocks in order
* @param finallyBody body of finally block or null if none
*/
public
TryNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
Block
body
,
final
List
<
Block
>
catchBlocks
,
final
Block
finallyBody
)
{
super
(
source
,
token
,
finish
);
public
TryNode
(
final
long
token
,
final
int
finish
,
final
Block
body
,
final
List
<
Block
>
catchBlocks
,
final
Block
finallyBody
)
{
super
(
token
,
finish
);
this
.
body
=
body
;
this
.
catchBlocks
=
catchBlocks
;
this
.
finallyBody
=
finallyBody
;
...
...
src/jdk/nashorn/internal/ir/UnaryNode.java
浏览文件 @
5546c448
...
...
@@ -35,7 +35,6 @@ import jdk.nashorn.internal.ir.annotations.Immutable;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.parser.Token
;
import
jdk.nashorn.internal.parser.TokenType
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* UnaryNode nodes represent single operand operations.
...
...
@@ -48,24 +47,23 @@ public final class UnaryNode extends Node implements Assignment<Node> {
/**
* Constructor
*
* @param source the source
* @param token token
* @param rhs expression
*/
public
UnaryNode
(
final
Source
source
,
final
long
token
,
final
Node
rhs
)
{
this
(
source
,
token
,
Math
.
min
(
rhs
.
getStart
(),
Token
.
descPosition
(
token
)),
Math
.
max
(
Token
.
descPosition
(
token
)
+
Token
.
descLength
(
token
),
rhs
.
getFinish
()),
rhs
);
public
UnaryNode
(
final
long
token
,
final
Node
rhs
)
{
this
(
token
,
Math
.
min
(
rhs
.
getStart
(),
Token
.
descPosition
(
token
)),
Math
.
max
(
Token
.
descPosition
(
token
)
+
Token
.
descLength
(
token
),
rhs
.
getFinish
()),
rhs
);
}
/**
* Constructor
*
@param source the source
*
* @param token token
* @param start start
* @param finish finish
* @param rhs expression
*/
public
UnaryNode
(
final
Source
source
,
final
long
token
,
final
int
start
,
final
int
finish
,
final
Node
rhs
)
{
super
(
source
,
token
,
start
,
finish
);
public
UnaryNode
(
final
long
token
,
final
int
start
,
final
int
finish
,
final
Node
rhs
)
{
super
(
token
,
start
,
finish
);
this
.
rhs
=
rhs
;
}
...
...
src/jdk/nashorn/internal/ir/VarNode.java
浏览文件 @
5546c448
...
...
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* Node represents a var/let declaration.
...
...
@@ -54,14 +53,13 @@ public final class VarNode extends Node implements Assignment<IdentNode> {
/**
* Constructor
*
* @param source the source
* @param token token
* @param finish finish
* @param name name of variable
* @param init init node or null if just a declaration
*/
public
VarNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
IdentNode
name
,
final
Node
init
)
{
this
(
source
,
token
,
finish
,
name
,
init
,
IS_STATEMENT
);
public
VarNode
(
final
long
token
,
final
int
finish
,
final
IdentNode
name
,
final
Node
init
)
{
this
(
token
,
finish
,
name
,
init
,
IS_STATEMENT
);
}
private
VarNode
(
final
VarNode
varNode
,
final
IdentNode
name
,
final
Node
init
,
final
int
flags
)
{
...
...
@@ -74,15 +72,14 @@ public final class VarNode extends Node implements Assignment<IdentNode> {
/**
* Constructor
*
* @param source the source
* @param token token
* @param finish finish
* @param name name of variable
* @param init init node or null if just a declaration
* @param flags flags
*/
public
VarNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
IdentNode
name
,
final
Node
init
,
final
int
flags
)
{
super
(
source
,
token
,
finish
);
public
VarNode
(
final
long
token
,
final
int
finish
,
final
IdentNode
name
,
final
Node
init
,
final
int
flags
)
{
super
(
token
,
finish
);
this
.
name
=
init
==
null
?
name
:
name
.
setIsInitializedHere
();
this
.
init
=
init
;
...
...
src/jdk/nashorn/internal/ir/WhileNode.java
浏览文件 @
5546c448
...
...
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representation for a WHILE statement. This is the superclass of all
...
...
@@ -42,13 +41,12 @@ public final class WhileNode extends LoopNode {
/**
* Constructor
*
* @param source the source
* @param token token
* @param finish finish
* @param isDoWhile is this a do while loop?
*/
public
WhileNode
(
final
Source
source
,
final
long
token
,
final
int
finish
,
final
boolean
isDoWhile
)
{
super
(
source
,
token
,
finish
,
null
,
null
,
false
);
public
WhileNode
(
final
long
token
,
final
int
finish
,
final
boolean
isDoWhile
)
{
super
(
token
,
finish
,
null
,
null
,
false
);
this
.
isDoWhile
=
isDoWhile
;
}
...
...
src/jdk/nashorn/internal/ir/WithNode.java
浏览文件 @
5546c448
...
...
@@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
jdk.nashorn.internal.ir.visitor.NodeVisitor
;
import
jdk.nashorn.internal.runtime.Source
;
/**
* IR representation for {@code with} statements.
...
...
@@ -43,20 +42,17 @@ public final class WithNode extends LexicalContextNode {
/**
* Constructor
*
* @param source the source
* @param token token
* @param finish finish
*/
public
WithNode
(
final
Source
source
,
final
long
token
,
final
int
finish
)
{
super
(
source
,
token
,
finish
);
public
WithNode
(
final
long
token
,
final
int
finish
)
{
super
(
token
,
finish
);
this
.
expression
=
null
;
this
.
body
=
null
;
}
private
WithNode
(
final
WithNode
node
,
final
Node
expression
,
final
Block
body
)
{
super
(
node
);
this
.
expression
=
expression
;
this
.
body
=
body
;
}
...
...
src/jdk/nashorn/internal/ir/debug/JSONWriter.java
浏览文件 @
5546c448
...
...
@@ -971,7 +971,7 @@ public final class JSONWriter extends NodeVisitor {
objectStart
(
"loc"
);
// source name
final
Source
src
=
node
.
getSource
();
final
Source
src
=
getLexicalContext
().
getCurrentFunction
()
.
getSource
();
property
(
"source"
,
src
.
getName
());
comma
();
...
...
src/jdk/nashorn/internal/objects/NativeDebug.java
浏览文件 @
5546c448
...
...
@@ -178,7 +178,6 @@ public final class NativeDebug extends ScriptObject {
* @param self self reference
* @return undefined
*/
@SuppressWarnings
(
"resource"
)
@Function
(
attributes
=
Attribute
.
NOT_ENUMERABLE
,
where
=
Where
.
CONSTRUCTOR
)
public
static
Object
dumpCounters
(
final
Object
self
)
{
final
PrintWriter
out
=
Context
.
getCurrentErr
();
...
...
src/jdk/nashorn/internal/parser/AbstractParser.java
浏览文件 @
5546c448
...
...
@@ -364,7 +364,7 @@ public abstract class AbstractParser {
next
();
// Create IDENT node.
return
new
IdentNode
(
source
,
identToken
,
finish
,
ident
);
return
new
IdentNode
(
identToken
,
finish
,
ident
);
}
// Get IDENT.
...
...
@@ -373,7 +373,7 @@ public abstract class AbstractParser {
return
null
;
}
// Create IDENT node.
return
new
IdentNode
(
source
,
identToken
,
finish
,
ident
);
return
new
IdentNode
(
identToken
,
finish
,
ident
);
}
/**
...
...
@@ -408,7 +408,7 @@ public abstract class AbstractParser {
final
String
ident
=
(
String
)
getValue
(
identToken
);
next
();
// Create IDENT node.
return
new
IdentNode
(
source
,
identToken
,
finish
,
ident
);
return
new
IdentNode
(
identToken
,
finish
,
ident
);
}
else
{
expect
(
IDENT
);
return
null
;
...
...
@@ -433,11 +433,11 @@ public abstract class AbstractParser {
LiteralNode
<?>
node
=
null
;
if
(
value
==
null
)
{
node
=
LiteralNode
.
newInstance
(
source
,
literalToken
,
finish
);
node
=
LiteralNode
.
newInstance
(
literalToken
,
finish
);
}
else
if
(
value
instanceof
Number
)
{
node
=
LiteralNode
.
newInstance
(
source
,
literalToken
,
finish
,
(
Number
)
value
);
node
=
LiteralNode
.
newInstance
(
literalToken
,
finish
,
(
Number
)
value
);
}
else
if
(
value
instanceof
String
)
{
node
=
LiteralNode
.
newInstance
(
source
,
literalToken
,
finish
,
(
String
)
value
);
node
=
LiteralNode
.
newInstance
(
literalToken
,
finish
,
(
String
)
value
);
}
else
if
(
value
instanceof
LexerToken
)
{
if
(
value
instanceof
RegexToken
)
{
final
RegexToken
regex
=
(
RegexToken
)
value
;
...
...
@@ -447,7 +447,7 @@ public abstract class AbstractParser {
throw
error
(
e
.
getMessage
());
}
}
node
=
LiteralNode
.
newInstance
(
source
,
literalToken
,
finish
,
(
LexerToken
)
value
);
node
=
LiteralNode
.
newInstance
(
literalToken
,
finish
,
(
LexerToken
)
value
);
}
else
{
assert
false
:
"unknown type for LiteralNode: "
+
value
.
getClass
();
}
...
...
src/jdk/nashorn/internal/parser/JSONParser.java
浏览文件 @
5546c448
...
...
@@ -193,13 +193,13 @@ public class JSONParser extends AbstractParser {
return
getLiteral
();
case
FALSE:
next
();
return
LiteralNode
.
newInstance
(
source
,
literalToken
,
finish
,
false
);
return
LiteralNode
.
newInstance
(
literalToken
,
finish
,
false
);
case
TRUE:
next
();
return
LiteralNode
.
newInstance
(
source
,
literalToken
,
finish
,
true
);
return
LiteralNode
.
newInstance
(
literalToken
,
finish
,
true
);
case
NULL:
next
();
return
LiteralNode
.
newInstance
(
source
,
literalToken
,
finish
);
return
LiteralNode
.
newInstance
(
literalToken
,
finish
);
case
LBRACKET:
return
arrayLiteral
();
case
LBRACE:
...
...
@@ -218,7 +218,7 @@ public class JSONParser extends AbstractParser {
if
(
value
instanceof
Number
)
{
next
();
return
new
UnaryNode
(
source
,
literalToken
,
LiteralNode
.
newInstance
(
source
,
realToken
,
finish
,
(
Number
)
value
));
return
new
UnaryNode
(
literalToken
,
LiteralNode
.
newInstance
(
realToken
,
finish
,
(
Number
)
value
));
}
throw
error
(
AbstractParser
.
message
(
"expected"
,
"number"
,
type
.
getNameOrType
()));
...
...
@@ -250,7 +250,7 @@ loop:
switch
(
type
)
{
case
RBRACKET:
next
();
result
=
LiteralNode
.
newInstance
(
source
,
arrayToken
,
finish
,
elements
);
result
=
LiteralNode
.
newInstance
(
arrayToken
,
finish
,
elements
);
break
loop
;
case
COMMARIGHT:
...
...
@@ -310,7 +310,7 @@ loop:
}
// Construct new object literal.
return
new
ObjectNode
(
source
,
objectToken
,
finish
,
elements
);
return
new
ObjectNode
(
objectToken
,
finish
,
elements
);
}
/**
...
...
@@ -331,7 +331,7 @@ loop:
if
(
name
!=
null
)
{
expect
(
COLON
);
final
Node
value
=
jsonLiteral
();
return
new
PropertyNode
(
source
,
propertyToken
,
value
.
getFinish
(),
name
,
value
,
null
,
null
);
return
new
PropertyNode
(
propertyToken
,
value
.
getFinish
(),
name
,
value
,
null
,
null
);
}
// Raise an error.
...
...
src/jdk/nashorn/internal/parser/Parser.java
浏览文件 @
5546c448
此差异已折叠。
点击以展开。
src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java
浏览文件 @
5546c448
...
...
@@ -229,6 +229,10 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData {
}
final
FunctionNode
snapshot
=
functionNode
.
getSnapshot
();
if
(
snapshot
==
null
)
{
return
mh
;
}
int
i
;
//classes known at runtime
...
...
src/jdk/nashorn/internal/runtime/ScriptObject.java
浏览文件 @
5546c448
...
...
@@ -970,9 +970,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr
* @param bindName null or name to bind to second argument (property not found method.)
*
* @return value of property as a MethodHandle or null.
*
*/
@SuppressWarnings
(
"static-method"
)
protected
MethodHandle
getCallMethodHandle
(
final
FindProperty
find
,
final
MethodType
type
,
final
String
bindName
)
{
return
getCallMethodHandle
(
getObjectValue
(
find
),
type
,
bindName
);
}
...
...
src/jdk/nashorn/internal/runtime/arrays/ArrayLikeIterator.java
浏览文件 @
5546c448
...
...
@@ -57,7 +57,6 @@ abstract public class ArrayLikeIterator<T> implements Iterator<T> {
* Is this a reverse order iteration?
* @return true if reverse
*/
@SuppressWarnings
(
"static-method"
)
public
boolean
isReverse
()
{
return
false
;
}
...
...
src/jdk/nashorn/internal/runtime/linker/LinkerCallSite.java
浏览文件 @
5546c448
...
...
@@ -275,7 +275,6 @@ public class LinkerCallSite extends ChainedCallSite {
}
static
class
ProfileDumper
implements
Runnable
{
@SuppressWarnings
(
"resource"
)
@Override
public
void
run
()
{
PrintWriter
out
=
null
;
...
...
@@ -447,7 +446,7 @@ public class LinkerCallSite extends ChainedCallSite {
*
* @throws Throwable if invocation fails or throws exception/error
*/
@SuppressWarnings
(
{
"unused"
,
"resource"
}
)
@SuppressWarnings
(
"unused"
)
public
Object
traceObject
(
final
MethodHandle
mh
,
final
Object
...
args
)
throws
Throwable
{
final
PrintWriter
out
=
Context
.
getCurrentErr
();
tracePrint
(
out
,
"ENTER "
,
args
,
null
);
...
...
@@ -465,7 +464,7 @@ public class LinkerCallSite extends ChainedCallSite {
*
* @throws Throwable if invocation fails or throws exception/error
*/
@SuppressWarnings
(
{
"unused"
,
"resource"
}
)
@SuppressWarnings
(
"unused"
)
public
void
traceVoid
(
final
MethodHandle
mh
,
final
Object
...
args
)
throws
Throwable
{
final
PrintWriter
out
=
Context
.
getCurrentErr
();
tracePrint
(
out
,
"ENTER "
,
args
,
null
);
...
...
src/jdk/nashorn/tools/Shell.java
浏览文件 @
5546c448
...
...
@@ -392,7 +392,6 @@ public class Shell {
* @param global global scope object to use
* @return return code
*/
@SuppressWarnings
(
"resource"
)
private
static
int
readEvalPrint
(
final
Context
context
,
final
ScriptObject
global
)
{
final
String
prompt
=
bundle
.
getString
(
"shell.prompt"
);
final
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
System
.
in
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录