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

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

Issue 2617923003: PreParsing inner funcs: make scope analysis more complete. (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
« src/parsing/preparser.h ('K') | « 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 8695 matching lines...) Expand 10 before | Expand all | Expand 10 after
8706 {"function inner() { ({my_var} = {my_var: 5}) => { }}", false}, 8706 {"function inner() { ({my_var} = {my_var: 5}) => { }}", false},
8707 {"function inner() { ({a, my_var}) => my_var;}", false}, 8707 {"function inner() { ({a, my_var}) => my_var;}", false},
8708 {"function inner() { ({a, my_var}) => { }}", false}, 8708 {"function inner() { ({a, my_var}) => { }}", false},
8709 {"function inner() { ({a, my_var} = {a: 0, my_var: 5}) => my_var;}", 8709 {"function inner() { ({a, my_var} = {a: 0, my_var: 5}) => my_var;}",
8710 false}, 8710 false},
8711 {"function inner() { ({a, my_var} = {a: 0, my_var: 5}) => { }}", false}, 8711 {"function inner() { ({a, my_var} = {a: 0, my_var: 5}) => { }}", false},
8712 {"function inner() { ({y, x: my_var}) => my_var;}", false}, 8712 {"function inner() { ({y, x: my_var}) => my_var;}", false},
8713 {"function inner() { ({y, x: my_var}) => { }}", false}, 8713 {"function inner() { ({y, x: my_var}) => { }}", false},
8714 {"function inner() { ({y, x: my_var} = {y: 0, x: 0}) => my_var;}", false}, 8714 {"function inner() { ({y, x: my_var} = {y: 0, x: 0}) => my_var;}", false},
8715 {"function inner() { ({y, x: my_var} = {y: 0, x: 0}) => { }}", false}, 8715 {"function inner() { ({y, x: my_var} = {y: 0, x: 0}) => { }}", false},
8716 {"function inner() { try { } catch (my_var) { my_var; } }", false},
8717 {"function inner() { try { } catch ([a, my_var, b]) { my_var; } }",
8718 false},
8719 {"function inner() { try { } catch ({x: my_var}) { my_var; } }", false},
8720 {"function inner() { try { } catch ({y, x: my_var}) { my_var; } }",
8721 false},
8722 {"function inner() { try { } catch ({my_var}) { my_var; } }", false},
8723 {"function inner() { for (let my_var in {}) { my_var; } }", false},
8724 {"function inner() { for (let my_var in {}) { } }", false},
8725 {"function inner() { for (let my_var of []) { my_var; } }", false},
8726 {"function inner() { for (let my_var of []) { } }", false},
8727 {"function inner() { for (let [a, my_var, b] in {}) { my_var; } }",
8728 false},
8729 {"function inner() { for (let [a, my_var, b] of []) { my_var; } }",
8730 false},
8731 {"function inner() { for (let {x: my_var} in {}) { my_var; } }", false},
8732 {"function inner() { for (let {x: my_var} of []) { my_var; } }", false},
8733 {"function inner() { for (let {my_var} in {}) { my_var; } }", false},
8734 {"function inner() { for (let {my_var} of []) { my_var; } }", false},
8735 {"function inner() { for (let {y, x: my_var} in {}) { my_var; } }",
8736 false},
8737 {"function inner() { for (let {y, x: my_var} of []) { my_var; } }",
8738 false},
8739 {"function inner() { for (let {a, my_var} in {}) { my_var; } }", false},
8740 {"function inner() { for (let {a, my_var} of []) { my_var; } }", false},
8741 {"function inner() { for (var my_var in {}) { my_var; } }", false},
8742 {"function inner() { for (var my_var in {}) { } }", false},
8743 {"function inner() { for (var my_var of []) { my_var; } }", false},
8744 {"function inner() { for (var my_var of []) { } }", false},
8745 {"function inner() { for (var [a, my_var, b] in {}) { my_var; } }",
8746 false},
8747 {"function inner() { for (var [a, my_var, b] of []) { my_var; } }",
8748 false},
8749 {"function inner() { for (var {x: my_var} in {}) { my_var; } }", false},
8750 {"function inner() { for (var {x: my_var} of []) { my_var; } }", false},
8751 {"function inner() { for (var {my_var} in {}) { my_var; } }", false},
8752 {"function inner() { for (var {my_var} of []) { my_var; } }", false},
8753 {"function inner() { for (var {y, x: my_var} in {}) { my_var; } }",
8754 false},
8755 {"function inner() { for (var {y, x: my_var} of []) { my_var; } }",
8756 false},
8757 {"function inner() { for (var {a, my_var} in {}) { my_var; } }", false},
8758 {"function inner() { for (var {a, my_var} of []) { my_var; } }", false},
8759 {"function inner() { for (var my_var in {}) { } my_var; }", false},
8760 {"function inner() { for (var my_var of []) { } my_var; }", false},
8761 {"function inner() { for (var [a, my_var, b] in {}) { } my_var; }",
8762 false},
8763 {"function inner() { for (var [a, my_var, b] of []) { } my_var; }",
8764 false},
8765 {"function inner() { for (var {x: my_var} in {}) { } my_var; }", false},
8766 {"function inner() { for (var {x: my_var} of []) { } my_var; }", false},
8767 {"function inner() { for (var {my_var} in {}) { } my_var; }", false},
8768 {"function inner() { for (var {my_var} of []) { } my_var; }", false},
8769 {"function inner() { for (var {y, x: my_var} in {}) { } my_var; }",
8770 false},
8771 {"function inner() { for (var {y, x: my_var} of []) { } my_var; }",
8772 false},
8773 {"function inner() { for (var {a, my_var} in {}) { } my_var; }", false},
8774 {"function inner() { for (var {a, my_var} of []) { } my_var; }", false},
8775 {"function inner() { class my_var {}; my_var }", false},
8716 // In the following cases we still context allocate pessimistically: 8776 // In the following cases we still context allocate pessimistically:
8717 {"function inner() { function my_var() {} my_var; }", true}, 8777 {"function inner() { function my_var() {} my_var; }", true},
8718 {"function inner() { if (true) { function my_var() {} } my_var; }", 8778 {"function inner() { if (true) { function my_var() {} } my_var; }",
8719 true}, 8779 true},
8720 {"function inner() { try { } catch (my_var) { my_var; } }", true},
8721 {"function inner() { try { } catch ([a, my_var, b]) { my_var; } }", true},
8722 {"function inner() { try { } catch ({x: my_var}) { my_var; } }", true},
8723 {"function inner() { try { } catch ({y, x: my_var}) { my_var; } }", true},
8724 {"function inner() { try { } catch ({my_var}) { my_var; } }", true},
8725 {"function inner() { for (let my_var = 0; my_var < 1; ++my_var) { my_var " 8780 {"function inner() { for (let my_var = 0; my_var < 1; ++my_var) { my_var "
8726 "} }", 8781 "} }",
8727 true}, 8782 true},
8728 {"function inner() { for (let a = 0, my_var = 0; my_var < 1; ++my_var) { " 8783 {"function inner() { for (let a = 0, my_var = 0; my_var < 1; ++my_var) { "
8729 "my_var } }", 8784 "my_var } }",
8730 true}, 8785 true},
8731 {"function inner() { for (let my_var in {}) { my_var; } }", true},
8732 {"function inner() { for (let my_var in {}) { } }", true},
8733 {"function inner() { for (let my_var of []) { my_var; } }", true},
8734 {"function inner() { for (let my_var of []) { } }", true},
8735 {"function inner() { for (let [a, my_var, b] in {}) { my_var; } }", true},
8736 {"function inner() { for (let [a, my_var, b] of []) { my_var; } }", true},
8737 {"function inner() { for (let {x: my_var} in {}) { my_var; } }", true},
8738 {"function inner() { for (let {x: my_var} of []) { my_var; } }", true},
8739 {"function inner() { for (let {my_var} in {}) { my_var; } }", true},
8740 {"function inner() { for (let {my_var} of []) { my_var; } }", true},
8741 {"function inner() { for (let {y, x: my_var} in {}) { my_var; } }", true},
8742 {"function inner() { for (let {y, x: my_var} of []) { my_var; } }", true},
8743 {"function inner() { for (let {a, my_var} in {}) { my_var; } }", true},
8744 {"function inner() { for (let {a, my_var} of []) { my_var; } }", true},
8745 {"function inner() { for (var my_var in {}) { my_var; } }", true},
8746 {"function inner() { for (var my_var in {}) { } }", true},
8747 {"function inner() { for (var my_var of []) { my_var; } }", true},
8748 {"function inner() { for (var my_var of []) { } }", true},
8749 {"function inner() { for (var [a, my_var, b] in {}) { my_var; } }", true},
8750 {"function inner() { for (var [a, my_var, b] of []) { my_var; } }", true},
8751 {"function inner() { for (var {x: my_var} in {}) { my_var; } }", true},
8752 {"function inner() { for (var {x: my_var} of []) { my_var; } }", true},
8753 {"function inner() { for (var {my_var} in {}) { my_var; } }", true},
8754 {"function inner() { for (var {my_var} of []) { my_var; } }", true},
8755 {"function inner() { for (var {y, x: my_var} in {}) { my_var; } }", true},
8756 {"function inner() { for (var {y, x: my_var} of []) { my_var; } }", true},
8757 {"function inner() { for (var {a, my_var} in {}) { my_var; } }", true},
8758 {"function inner() { for (var {a, my_var} of []) { my_var; } }", true},
8759 {"function inner() { for (var my_var in {}) { } my_var; }", true},
8760 {"function inner() { for (var my_var of []) { } my_var; }", true},
8761 {"function inner() { for (var [a, my_var, b] in {}) { } my_var; }", true},
8762 {"function inner() { for (var [a, my_var, b] of []) { } my_var; }", true},
8763 {"function inner() { for (var {x: my_var} in {}) { } my_var; }", true},
8764 {"function inner() { for (var {x: my_var} of []) { } my_var; }", true},
8765 {"function inner() { for (var {my_var} in {}) { } my_var; }", true},
8766 {"function inner() { for (var {my_var} of []) { } my_var; }", true},
8767 {"function inner() { for (var {y, x: my_var} in {}) { } my_var; }", true},
8768 {"function inner() { for (var {y, x: my_var} of []) { } my_var; }", true},
8769 {"function inner() { for (var {a, my_var} in {}) { } my_var; }", true},
8770 {"function inner() { for (var {a, my_var} of []) { } my_var; }", true},
8771 {"function inner() { class my_var {}; my_var }", true},
8772 }; 8786 };
8773 8787
8774 for (unsigned i = 0; i < arraysize(inners); ++i) { 8788 for (unsigned i = 0; i < arraysize(inners); ++i) {
8775 const char* inner = inners[i].source; 8789 const char* inner = inners[i].source;
8776 int inner_len = Utf8LengthHelper(inner); 8790 int inner_len = Utf8LengthHelper(inner);
8777 int len = prefix_len + inner_len + suffix_len; 8791 int len = prefix_len + inner_len + suffix_len;
8778 i::ScopedVector<char> program(len + 1); 8792 i::ScopedVector<char> program(len + 1);
8779 i::SNPrintF(program, "%s%s%s", prefix, inner, suffix); 8793 i::SNPrintF(program, "%s%s%s", prefix, inner, suffix);
8780 i::Handle<i::String> source = 8794 i::Handle<i::String> source =
8781 factory->InternalizeUtf8String(program.start()); 8795 factory->InternalizeUtf8String(program.start());
(...skipping 12 matching lines...) Expand all
8794 DCHECK_NOT_NULL(scope); 8808 DCHECK_NOT_NULL(scope);
8795 DCHECK_NULL(scope->sibling()); 8809 DCHECK_NULL(scope->sibling());
8796 DCHECK(scope->is_function_scope()); 8810 DCHECK(scope->is_function_scope());
8797 const i::AstRawString* var_name = 8811 const i::AstRawString* var_name =
8798 info.ast_value_factory()->GetOneByteString("my_var"); 8812 info.ast_value_factory()->GetOneByteString("my_var");
8799 i::Variable* var = scope->Lookup(var_name); 8813 i::Variable* var = scope->Lookup(var_name);
8800 CHECK_EQ(inners[i].ctxt_allocate, 8814 CHECK_EQ(inners[i].ctxt_allocate,
8801 i::ScopeTestHelper::MustAllocateInContext(var)); 8815 i::ScopeTestHelper::MustAllocateInContext(var));
8802 } 8816 }
8803 } 8817 }
OLDNEW
« src/parsing/preparser.h ('K') | « src/parsing/preparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698