Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: test/cctest/test-parsing.cc

Issue 2610823003: PreParsing inner funcs: declare arrow function parameters. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/parsing/preparser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 8546 matching lines...) Expand 10 before | Expand all | Expand 10 after
8557 // Context allocating because we need to: 8557 // Context allocating because we need to:
8558 {"function inner() { my_var; }", true}, 8558 {"function inner() { my_var; }", true},
8559 {"function inner() { eval(\"foo\"); }", true}, 8559 {"function inner() { eval(\"foo\"); }", true},
8560 {"function inner() { function inner2() { my_var; } }", true}, 8560 {"function inner() { function inner2() { my_var; } }", true},
8561 {"function inner() { function inner2() { eval(\"foo\"); } }", true}, 8561 {"function inner() { function inner2() { eval(\"foo\"); } }", true},
8562 {"function inner() { var {my_var : a} = {my_var}; }", true}, 8562 {"function inner() { var {my_var : a} = {my_var}; }", true},
8563 {"function inner() { let {my_var : a} = {my_var}; }", true}, 8563 {"function inner() { let {my_var : a} = {my_var}; }", true},
8564 {"function inner() { const {my_var : a} = {my_var}; }", true}, 8564 {"function inner() { const {my_var : a} = {my_var}; }", true},
8565 {"function inner(a = my_var) { }", true}, 8565 {"function inner(a = my_var) { }", true},
8566 {"function inner() { function inner2(a = my_var) { } }", true}, 8566 {"function inner() { function inner2(a = my_var) { } }", true},
8567 {"function inner() { (a = my_var) => { } }", true},
8567 {"function inner({a} = {a: my_var}) { }", true}, 8568 {"function inner({a} = {a: my_var}) { }", true},
8568 {"function inner() { function inner2({a} = {a: my_var}) { } }", true}, 8569 {"function inner() { function inner2({a} = {a: my_var}) { } }", true},
8570 {"function inner() { ({a} = {a: my_var}) => { } }", true},
8569 {"function inner([a] = [my_var]) { }", true}, 8571 {"function inner([a] = [my_var]) { }", true},
8570 {"function inner() { function inner2([a] = [my_var]) { } }", true}, 8572 {"function inner() { function inner2([a] = [my_var]) { } }", true},
8573 {"function inner() { ([a] = [my_var]) => { } }", true},
8571 // No pessimistic context allocation: 8574 // No pessimistic context allocation:
8572 {"function inner() { var my_var; my_var; }", false}, 8575 {"function inner() { var my_var; my_var; }", false},
8573 {"function inner() { var my_var; }", false}, 8576 {"function inner() { var my_var; }", false},
8574 {"function inner() { let my_var; my_var; }", false}, 8577 {"function inner() { let my_var; my_var; }", false},
8575 {"function inner() { let my_var; }", false}, 8578 {"function inner() { let my_var; }", false},
8576 {"function inner() { const my_var = 0; my_var; }", false}, 8579 {"function inner() { const my_var = 0; my_var; }", false},
8577 {"function inner() { const my_var = 0; }", false}, 8580 {"function inner() { const my_var = 0; }", false},
8578 {"function inner() { var [a, my_var] = [1, 2]; my_var; }", false}, 8581 {"function inner() { var [a, my_var] = [1, 2]; my_var; }", false},
8579 {"function inner() { let [a, my_var] = [1, 2]; my_var; }", false}, 8582 {"function inner() { let [a, my_var] = [1, 2]; my_var; }", false},
8580 {"function inner() { const [a, my_var] = [1, 2]; my_var; }", false}, 8583 {"function inner() { const [a, my_var] = [1, 2]; my_var; }", false},
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
8641 {"({x: my_var}) => my_var;", false}, 8644 {"({x: my_var}) => my_var;", false},
8642 {"({x: my_var}) => { }", false}, 8645 {"({x: my_var}) => { }", false},
8643 {"({x: my_var} = {x: 0}) => my_var;", false}, 8646 {"({x: my_var} = {x: 0}) => my_var;", false},
8644 {"({x: my_var} = {x: 0}) => { }", false}, 8647 {"({x: my_var} = {x: 0}) => { }", false},
8645 {"({my_var}) => my_var;", false}, 8648 {"({my_var}) => my_var;", false},
8646 {"({my_var}) => { }", false}, 8649 {"({my_var}) => { }", false},
8647 {"({my_var} = {my_var: 5}) => my_var;", false}, 8650 {"({my_var} = {my_var: 5}) => my_var;", false},
8648 {"({my_var} = {my_var: 5}) => { }", false}, 8651 {"({my_var} = {my_var: 5}) => { }", false},
8649 {"function inner() { try { } catch (my_var) { } }", false}, 8652 {"function inner() { try { } catch (my_var) { } }", false},
8650 {"function inner() { class my_var {}; }", false}, 8653 {"function inner() { class my_var {}; }", false},
8654 {"function inner() { my_var => my_var; }", false},
adamk 2017/01/04 19:28:47 How does this one work?
8655 {"function inner() { my_var => { }}", false},
8656 {"function inner() { (my_var = 5) => my_var; }", false},
8657 {"function inner() { (my_var = 5) => { }}", false},
8658 {"function inner() { (...my_var) => my_var;}", false},
8659 {"function inner() { (...my_var) => { }}", false},
8660 {"function inner() { ([a, my_var, b]) => my_var;}", false},
8661 {"function inner() { ([a, my_var, b]) => { }}", false},
8662 {"function inner() { ([a, my_var, b] = [1, 2, 3]) => my_var;}", false},
8663 {"function inner() { ([a, my_var, b] = [1, 2, 3]) => { }}", false},
8664 {"function inner() { ({x: my_var}) => my_var;}", false},
8665 {"function inner() { ({x: my_var}) => { }}", false},
8666 {"function inner() { ({x: my_var} = {x: 0}) => my_var;}", false},
8667 {"function inner() { ({x: my_var} = {x: 0}) => { }}", false},
8668 {"function inner() { ({my_var}) => my_var;}", false},
adamk 2017/01/04 19:28:47 And this one?
8669 {"function inner() { ({my_var}) => { }}", false},
8670 {"function inner() { ({my_var} = {my_var: 5}) => my_var;}", false},
8671 {"function inner() { ({my_var} = {my_var: 5}) => { }}", false},
8651 // In the following cases we still context allocate pessimistically: 8672 // In the following cases we still context allocate pessimistically:
8652 {"function inner() { function my_var() {} my_var; }", true}, 8673 {"function inner() { function my_var() {} my_var; }", true},
8653 {"function inner() { if (true) { function my_var() {} } my_var; }", 8674 {"function inner() { if (true) { function my_var() {} } my_var; }",
8654 true}, 8675 true},
8655 {"function inner() { try { } catch (my_var) { my_var; } }", true}, 8676 {"function inner() { try { } catch (my_var) { my_var; } }", true},
8656 {"function inner() { for (my_var of {}) { my_var; } }", true}, 8677 {"function inner() { for (my_var of {}) { my_var; } }", true},
8657 {"function inner() { for (my_var of {}) { } }", true}, 8678 {"function inner() { for (my_var of {}) { } }", true},
8658 {"function inner() { for (my_var in []) { my_var; } }", true}, 8679 {"function inner() { for (my_var in []) { my_var; } }", true},
8659 {"function inner() { for (my_var in []) { } }", true}, 8680 {"function inner() { for (my_var in []) { } }", true},
8660 {"function inner() { my_var => my_var; }", true},
8661 {"function inner() { my_var => { }}", true},
8662 {"function inner() { (my_var = 5) => my_var; }", true},
8663 {"function inner() { (my_var = 5) => { }}", true},
8664 {"function inner() { (...my_var) => my_var;}", true},
8665 {"function inner() { (...my_var) => { }}", true},
8666 {"function inner() { ([a, my_var, b]) => my_var;}", true},
8667 {"function inner() { ([a, my_var, b]) => { }}", true},
8668 {"function inner() { ([a, my_var, b] = [1, 2, 3]) => my_var;}", true},
8669 {"function inner() { ([a, my_var, b] = [1, 2, 3]) => { }}", true},
8670 {"function inner() { ({x: my_var}) => my_var;}", true},
8671 {"function inner() { ({x: my_var}) => { }}", true},
8672 {"function inner() { ({x: my_var} = {x: 0}) => my_var;}", true},
8673 {"function inner() { ({x: my_var} = {x: 0}) => { }}", true},
8674 {"function inner() { ({my_var}) => my_var;}", true},
8675 {"function inner() { ({my_var}) => { }}", true},
8676 {"function inner() { ({my_var} = {my_var: 5}) => my_var;}", true},
8677 {"function inner() { ({my_var} = {my_var: 5}) => { }}", true},
8678 {"function inner() { class my_var {}; my_var }", true}, 8681 {"function inner() { class my_var {}; my_var }", true},
8679 }; 8682 };
8680 8683
8681 for (unsigned i = 0; i < arraysize(inners); ++i) { 8684 for (unsigned i = 0; i < arraysize(inners); ++i) {
8682 const char* inner = inners[i].source; 8685 const char* inner = inners[i].source;
8683 int inner_len = Utf8LengthHelper(inner); 8686 int inner_len = Utf8LengthHelper(inner);
8684 int len = prefix_len + inner_len + suffix_len; 8687 int len = prefix_len + inner_len + suffix_len;
8685 i::ScopedVector<char> program(len + 1); 8688 i::ScopedVector<char> program(len + 1);
8686 i::SNPrintF(program, "%s%s%s", prefix, inner, suffix); 8689 i::SNPrintF(program, "%s%s%s", prefix, inner, suffix);
8687 i::Handle<i::String> source = 8690 i::Handle<i::String> source =
(...skipping 13 matching lines...) Expand all
8701 DCHECK_NOT_NULL(scope); 8704 DCHECK_NOT_NULL(scope);
8702 DCHECK_NULL(scope->sibling()); 8705 DCHECK_NULL(scope->sibling());
8703 DCHECK(scope->is_function_scope()); 8706 DCHECK(scope->is_function_scope());
8704 const i::AstRawString* var_name = 8707 const i::AstRawString* var_name =
8705 info.ast_value_factory()->GetOneByteString("my_var"); 8708 info.ast_value_factory()->GetOneByteString("my_var");
8706 i::Variable* var = scope->Lookup(var_name); 8709 i::Variable* var = scope->Lookup(var_name);
8707 CHECK_EQ(inners[i].ctxt_allocate, 8710 CHECK_EQ(inners[i].ctxt_allocate,
8708 i::ScopeTestHelper::MustAllocateInContext(var)); 8711 i::ScopeTestHelper::MustAllocateInContext(var));
8709 } 8712 }
8710 } 8713 }
OLDNEW
« no previous file with comments | « src/parsing/preparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698