Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_nashorn
提交
860d4b92
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,发现更多精彩内容 >>
提交
860d4b92
编写于
11月 01, 2013
作者:
S
sundar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8027700: function redeclaration checks missing for declaration binding instantiation
Reviewed-by: jlaskey, lagergren
上级
ab9e5f18
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
111 addition
and
16 deletion
+111
-16
src/jdk/nashorn/internal/codegen/Attr.java
src/jdk/nashorn/internal/codegen/Attr.java
+1
-0
src/jdk/nashorn/internal/codegen/MapCreator.java
src/jdk/nashorn/internal/codegen/MapCreator.java
+4
-0
src/jdk/nashorn/internal/ir/Symbol.java
src/jdk/nashorn/internal/ir/Symbol.java
+20
-0
src/jdk/nashorn/internal/runtime/Property.java
src/jdk/nashorn/internal/runtime/Property.java
+21
-10
src/jdk/nashorn/internal/runtime/ScriptObject.java
src/jdk/nashorn/internal/runtime/ScriptObject.java
+11
-2
test/script/basic/JDK-8015355.js
test/script/basic/JDK-8015355.js
+0
-4
test/script/basic/JDK-8027700.js
test/script/basic/JDK-8027700.js
+54
-0
未找到文件。
src/jdk/nashorn/internal/codegen/Attr.java
浏览文件 @
860d4b92
...
...
@@ -271,6 +271,7 @@ final class Attr extends NodeOperatorVisitor<LexicalContext> {
functionNode
.
addDeclaredSymbol
(
symbol
);
if
(
varNode
.
isFunctionDeclaration
())
{
newType
(
symbol
,
FunctionNode
.
FUNCTION_TYPE
);
symbol
.
setIsFunctionDeclaration
();
}
return
varNode
.
setName
((
IdentNode
)
ident
.
setSymbol
(
lc
,
symbol
));
}
...
...
src/jdk/nashorn/internal/codegen/MapCreator.java
浏览文件 @
860d4b92
...
...
@@ -134,6 +134,10 @@ public class MapCreator {
flags
|=
Property
.
CAN_BE_UNDEFINED
;
}
if
(
symbol
.
isFunctionDeclaration
())
{
flags
|=
Property
.
IS_FUNCTION_DECLARATION
;
}
return
flags
;
}
...
...
src/jdk/nashorn/internal/ir/Symbol.java
浏览文件 @
860d4b92
...
...
@@ -75,6 +75,8 @@ public final class Symbol implements Comparable<Symbol> {
public
static
final
int
IS_SPECIALIZED_PARAM
=
1
<<
13
;
/** Is this symbol a shared temporary? */
public
static
final
int
IS_SHARED
=
1
<<
14
;
/** Is this a function declaration? */
public
static
final
int
IS_FUNCTION_DECLARATION
=
1
<<
15
;
/** Null or name identifying symbol. */
private
final
String
name
;
...
...
@@ -359,6 +361,14 @@ public final class Symbol implements Comparable<Symbol> {
return
(
flags
&
IS_SHARED
)
==
IS_SHARED
;
}
/**
* Check if this symbol is a function declaration
* @return true if a function declaration
*/
public
boolean
isFunctionDeclaration
()
{
return
(
flags
&
IS_FUNCTION_DECLARATION
)
==
IS_FUNCTION_DECLARATION
;
}
/**
* Creates an unshared copy of a symbol. The symbol must be currently shared.
* @param newName the name for the new symbol.
...
...
@@ -395,6 +405,16 @@ public final class Symbol implements Comparable<Symbol> {
}
/**
* Mark this symbol as a function declaration.
*/
public
void
setIsFunctionDeclaration
()
{
if
(!
isFunctionDeclaration
())
{
trace
(
"SET IS FUNCTION DECLARATION"
);
flags
|=
IS_FUNCTION_DECLARATION
;
}
}
/**
* Check if this symbol is a variable
* @return true if variable
...
...
src/jdk/nashorn/internal/runtime/Property.java
浏览文件 @
860d4b92
...
...
@@ -56,33 +56,36 @@ public abstract class Property {
public
static
final
int
WRITABLE_ENUMERABLE_CONFIGURABLE
=
0b0000_0000_0000
;
/** ECMA 8.6.1 - Is this property not writable? */
public
static
final
int
NOT_WRITABLE
=
0b0000_0000_0001
;
public
static
final
int
NOT_WRITABLE
=
1
<<
0
;
/** ECMA 8.6.1 - Is this property not enumerable? */
public
static
final
int
NOT_ENUMERABLE
=
0b0000_0000_0010
;
public
static
final
int
NOT_ENUMERABLE
=
1
<<
1
;
/** ECMA 8.6.1 - Is this property not configurable? */
public
static
final
int
NOT_CONFIGURABLE
=
0b0000_0000_0100
;
public
static
final
int
NOT_CONFIGURABLE
=
1
<<
2
;
private
static
final
int
MODIFY_MASK
=
0b0000_0000_1111
;
private
static
final
int
MODIFY_MASK
=
(
NOT_WRITABLE
|
NOT_ENUMERABLE
|
NOT_CONFIGURABLE
)
;
/** Is this a spill property? See {@link AccessorProperty} */
public
static
final
int
IS_SPILL
=
0b0000_0001_0000
;
public
static
final
int
IS_SPILL
=
1
<<
3
;
/** Is this a function parameter? */
public
static
final
int
IS_PARAMETER
=
0b0000_0010_0000
;
public
static
final
int
IS_PARAMETER
=
1
<<
4
;
/** Is parameter accessed thru arguments? */
public
static
final
int
HAS_ARGUMENTS
=
0b0000_0100_0000
;
public
static
final
int
HAS_ARGUMENTS
=
1
<<
5
;
/** Is this property always represented as an Object? See {@link ObjectClassGenerator} and dual fields flag. */
public
static
final
int
IS_ALWAYS_OBJECT
=
0b0000_1000_0000
;
public
static
final
int
IS_ALWAYS_OBJECT
=
1
<<
6
;
/** Can this property be primitive? */
public
static
final
int
CAN_BE_PRIMITIVE
=
0b0001_0000_0000
;
public
static
final
int
CAN_BE_PRIMITIVE
=
1
<<
7
;
/** Can this property be undefined? */
public
static
final
int
CAN_BE_UNDEFINED
=
0b0010_0000_0000
;
public
static
final
int
CAN_BE_UNDEFINED
=
1
<<
8
;
/* Is this a function declaration property ? */
public
static
final
int
IS_FUNCTION_DECLARATION
=
1
<<
9
;
/** Property key. */
private
final
String
key
;
...
...
@@ -522,4 +525,12 @@ public abstract class Property {
public
boolean
canBeUndefined
()
{
return
(
flags
&
CAN_BE_UNDEFINED
)
==
CAN_BE_UNDEFINED
;
}
/**
* Check whether this property represents a function declaration.
* @return whether this property is a function declaration or not.
*/
public
boolean
isFunctionDeclaration
()
{
return
(
flags
&
IS_FUNCTION_DECLARATION
)
==
IS_FUNCTION_DECLARATION
;
}
}
src/jdk/nashorn/internal/runtime/ScriptObject.java
浏览文件 @
860d4b92
...
...
@@ -226,14 +226,23 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr
for
(
final
Property
property
:
properties
)
{
final
String
key
=
property
.
getKey
();
if
(
newMap
.
findProperty
(
key
)
==
null
)
{
final
Property
oldProp
=
newMap
.
findProperty
(
key
);
if
(
oldProp
==
null
)
{
if
(
property
instanceof
UserAccessorProperty
)
{
final
UserAccessorProperty
prop
=
this
.
newUserAccessors
(
key
,
property
.
getFlags
(),
property
.
getGetterFunction
(
source
),
property
.
getSetterFunction
(
source
));
newMap
=
newMap
.
addProperty
(
prop
);
}
else
{
newMap
=
newMap
.
addPropertyBind
((
AccessorProperty
)
property
,
source
);
}
}
else
{
// See ECMA section 10.5 Declaration Binding Instantiation
// step 5 processing each function declaration.
if
(
property
.
isFunctionDeclaration
()
&&
!
oldProp
.
isConfigurable
())
{
if
(
oldProp
instanceof
UserAccessorProperty
||
!(
oldProp
.
isWritable
()
&&
oldProp
.
isEnumerable
()))
{
throw
typeError
(
"cant.redefine.property"
,
key
,
ScriptRuntime
.
safeToString
(
this
));
}
}
}
}
...
...
test/script/basic/JDK-8015355.js
浏览文件 @
860d4b92
...
...
@@ -28,10 +28,6 @@
* @run
*/
function
fail
(
msg
)
{
print
(
msg
);
}
function
check
(
callback
)
{
try
{
callback
();
...
...
test/script/basic/JDK-8027700.js
0 → 100644
浏览文件 @
860d4b92
/*
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* JDK-8027700: function redeclaration checks missing for declaration binding instantiation
*
* @test
* @run
*/
Object
.
defineProperty
(
this
,
"
x
"
,
{
value
:
0
,
writable
:
true
,
enumerable
:
false
})
try
{
eval
(
"
function x() {}
"
);
fail
(
"
should have thrown TypeError
"
);
}
catch
(
e
)
{
if
(
!
(
e
instanceof
TypeError
))
{
fail
(
"
TypeError expected but got
"
+
e
);
}
}
Object
.
defineProperty
(
this
,
"
foo
"
,
{
value
:
0
})
try
{
eval
(
"
function foo() {}
"
);
fail
(
"
should have thrown TypeError
"
);
}
catch
(
e
)
{
if
(
!
(
e
instanceof
TypeError
))
{
fail
(
"
TypeError expected but got
"
+
e
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录