Fix completion value of class declarations.
BUG=v8:6022 Change-Id: I54205cb3ecc2dd31ed62e55726f0ec5fcd202c30 Reviewed-on: https://chromium-review.googlesource.com/446349 Commit-Queue: Georg Neis <neis@chromium.org> Reviewed-by: Adam Klein <adamk@chromium.org> Cr-Commit-Position: refs/heads/master@{#43500}
This commit is contained in:
parent
fc023664bd
commit
1c578f2477
@ -8215,16 +8215,6 @@ static inline Handle<Object> MakeEntryPair(Isolate* isolate, Handle<Name> key,
|
||||
FAST_ELEMENTS, 2);
|
||||
}
|
||||
|
||||
JSIteratorResult* JSIteratorResult::cast(Object* object) {
|
||||
SLOW_DCHECK(object->IsJSObject() &&
|
||||
JSObject::cast(object)->map() ==
|
||||
JSObject::cast(object)
|
||||
->GetIsolate()
|
||||
->native_context()
|
||||
->iterator_result_map());
|
||||
return reinterpret_cast<JSIteratorResult*>(object);
|
||||
}
|
||||
|
||||
ACCESSORS(JSIteratorResult, value, Object, kValueOffset)
|
||||
ACCESSORS(JSIteratorResult, done, Object, kDoneOffset)
|
||||
|
||||
|
@ -20031,8 +20031,12 @@ MaybeHandle<Object> Module::Evaluate(Handle<Module> module) {
|
||||
ASSIGN_RETURN_ON_EXCEPTION(
|
||||
isolate, result, Execution::Call(isolate, resume, generator, 0, nullptr),
|
||||
Object);
|
||||
DCHECK(Handle<JSIteratorResult>::cast(result)->done()->BooleanValue());
|
||||
return handle(Handle<JSIteratorResult>::cast(result)->value(), isolate);
|
||||
DCHECK(static_cast<JSIteratorResult*>(JSObject::cast(*result))
|
||||
->done()
|
||||
->BooleanValue());
|
||||
return handle(
|
||||
static_cast<JSIteratorResult*>(JSObject::cast(*result))->value(),
|
||||
isolate);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -2639,9 +2639,8 @@ class JSDataPropertyDescriptor: public JSObject {
|
||||
// as specified by ES6 section 25.1.1.3 The IteratorResult Interface
|
||||
class JSIteratorResult: public JSObject {
|
||||
public:
|
||||
DECLARE_CAST(JSIteratorResult)
|
||||
|
||||
DECL_ACCESSORS(value, Object)
|
||||
|
||||
DECL_ACCESSORS(done, Object)
|
||||
|
||||
// Offsets of object fields.
|
||||
|
@ -1508,12 +1508,14 @@ Statement* Parser::DeclareClass(const AstRawString* variable_name,
|
||||
Declaration* decl =
|
||||
DeclareVariable(variable_name, LET, class_token_pos, CHECK_OK);
|
||||
decl->proxy()->var()->set_initializer_position(end_pos);
|
||||
if (names) names->Add(variable_name, zone());
|
||||
|
||||
Assignment* assignment = factory()->NewAssignment(Token::INIT, decl->proxy(),
|
||||
value, class_token_pos);
|
||||
Statement* assignment_statement =
|
||||
factory()->NewExpressionStatement(assignment, kNoSourcePosition);
|
||||
if (names) names->Add(variable_name, zone());
|
||||
return assignment_statement;
|
||||
Block* block = factory()->NewBlock(nullptr, 1, true, kNoSourcePosition);
|
||||
block->statements()->Add(
|
||||
factory()->NewExpressionStatement(assignment, kNoSourcePosition), zone());
|
||||
return block;
|
||||
}
|
||||
|
||||
Statement* Parser::DeclareNative(const AstRawString* name, int pos, bool* ok) {
|
||||
|
@ -104,14 +104,21 @@ TEST(ModuleEvaluationCompletion1) {
|
||||
LocalContext env;
|
||||
|
||||
const char* sources[] = {
|
||||
"", "var a = 1", "import '42'", "export * from '42'",
|
||||
"export {} from '42'", "export {}", "var a = 1; export {a}",
|
||||
"",
|
||||
"var a = 1",
|
||||
"import '42'",
|
||||
"export * from '42'",
|
||||
"export {} from '42'",
|
||||
"export {}",
|
||||
"var a = 1; export {a}",
|
||||
"export function foo() {}",
|
||||
// TODO(neis): v8:6022 "export class C extends null {}",
|
||||
"export let a = 1", "export default 1",
|
||||
"export default function foo() {}", "export default function () {}",
|
||||
"export class C extends null {}",
|
||||
"export let a = 1",
|
||||
"export default 1",
|
||||
"export default function foo() {}",
|
||||
"export default function () {}",
|
||||
"export default (function () {})",
|
||||
// TODO(neis): v8:6022 "export default class C extends null {}",
|
||||
"export default class C extends null {}",
|
||||
"export default (class C extends null {})",
|
||||
"for (var i = 0; i < 5; ++i) {}",
|
||||
};
|
||||
@ -134,16 +141,21 @@ TEST(ModuleEvaluationCompletion2) {
|
||||
LocalContext env;
|
||||
|
||||
const char* sources[] = {
|
||||
"'gaga'; ", "'gaga'; var a = 1", "'gaga'; import '42'",
|
||||
"'gaga'; export * from '42'", "'gaga'; export {} from '42'",
|
||||
"'gaga'; export {}", "'gaga'; var a = 1; export {a}",
|
||||
"'gaga'; ",
|
||||
"'gaga'; var a = 1",
|
||||
"'gaga'; import '42'",
|
||||
"'gaga'; export * from '42'",
|
||||
"'gaga'; export {} from '42'",
|
||||
"'gaga'; export {}",
|
||||
"'gaga'; var a = 1; export {a}",
|
||||
"'gaga'; export function foo() {}",
|
||||
// TODO(neis): v8:6022 "'gaga'; export class C extends null {}",
|
||||
"'gaga'; export let a = 1", "'gaga'; export default 1",
|
||||
"'gaga'; export class C extends null {}",
|
||||
"'gaga'; export let a = 1",
|
||||
"'gaga'; export default 1",
|
||||
"'gaga'; export default function foo() {}",
|
||||
"'gaga'; export default function () {}",
|
||||
"'gaga'; export default (function () {})",
|
||||
// TODO(neis): v8:6022 "'gaga'; export default class C extends null {}",
|
||||
"'gaga'; export default class C extends null {}",
|
||||
"'gaga'; export default (class C extends null {})",
|
||||
};
|
||||
|
||||
|
@ -628,7 +628,7 @@ function assertAccessorDescriptor(object, name) {
|
||||
(function TestConstructorCall(){
|
||||
var realmIndex = Realm.create();
|
||||
var otherTypeError = Realm.eval(realmIndex, "TypeError");
|
||||
var A = Realm.eval(realmIndex, '"use strict"; class A {}');
|
||||
var A = Realm.eval(realmIndex, '"use strict"; class A {}; A');
|
||||
var instance = new A();
|
||||
var constructor = instance.constructor;
|
||||
var otherTypeError = Realm.eval(realmIndex, 'TypeError');
|
||||
|
@ -8,6 +8,16 @@ function assertUndef(x) {
|
||||
}
|
||||
|
||||
|
||||
// ClassDeclaration
|
||||
|
||||
assertUndef(eval('class C {}'));
|
||||
assertUndef(eval('class C {m() {}}'));
|
||||
assertUndef(eval('class C extends null {}'));
|
||||
assertEquals(42, eval('42; class C {}'));
|
||||
assertEquals(42, eval('42; class C {m() {}}'));
|
||||
assertEquals(42, eval('42; class C extends null {}'));
|
||||
|
||||
|
||||
// IfStatement [13.6.7]
|
||||
|
||||
assertUndef(eval('42; if (true) ; else 0;')); // ES5: 42
|
||||
|
Loading…
Reference in New Issue
Block a user