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

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

Issue 2616393002: PreParsing inner funcs: make scope analysis even 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
« 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 8846 matching lines...) Expand 10 before | Expand all | Expand 10 after
8857 {"function inner() { for (var {x: my_var} in {}) { } my_var; }", false}, 8857 {"function inner() { for (var {x: my_var} in {}) { } my_var; }", false},
8858 {"function inner() { for (var {x: my_var} of []) { } my_var; }", false}, 8858 {"function inner() { for (var {x: my_var} of []) { } my_var; }", false},
8859 {"function inner() { for (var {my_var} in {}) { } my_var; }", false}, 8859 {"function inner() { for (var {my_var} in {}) { } my_var; }", false},
8860 {"function inner() { for (var {my_var} of []) { } my_var; }", false}, 8860 {"function inner() { for (var {my_var} of []) { } my_var; }", false},
8861 {"function inner() { for (var {y, x: my_var} in {}) { } my_var; }", 8861 {"function inner() { for (var {y, x: my_var} in {}) { } my_var; }",
8862 false}, 8862 false},
8863 {"function inner() { for (var {y, x: my_var} of []) { } my_var; }", 8863 {"function inner() { for (var {y, x: my_var} of []) { } my_var; }",
8864 false}, 8864 false},
8865 {"function inner() { for (var {a, my_var} in {}) { } my_var; }", false}, 8865 {"function inner() { for (var {a, my_var} in {}) { } my_var; }", false},
8866 {"function inner() { for (var {a, my_var} of []) { } my_var; }", false}, 8866 {"function inner() { for (var {a, my_var} of []) { } my_var; }", false},
8867 {"function inner() { for (let my_var = 0; my_var < 1; ++my_var) { my_var "
8868 "} }",
8869 false},
8870 {"function inner() { for (var my_var = 0; my_var < 1; ++my_var) { my_var "
8871 "} }",
8872 false},
8873 {"function inner() { for (let a = 0, my_var = 0; my_var < 1; ++my_var) { "
8874 "my_var } }",
8875 false},
8876 {"function inner() { for (var a = 0, my_var = 0; my_var < 1; ++my_var) { "
8877 "my_var } }",
8878 false},
8867 {"function inner() { class my_var {}; my_var }", false}, 8879 {"function inner() { class my_var {}; my_var }", false},
8868 // In the following cases we still context allocate pessimistically: 8880 // In the following cases we still context allocate pessimistically:
8869 {"function inner() { function my_var() {} my_var; }", true}, 8881 {"function inner() { function my_var() {} my_var; }", true},
8870 {"function inner() { if (true) { function my_var() {} } my_var; }", 8882 {"function inner() { if (true) { function my_var() {} } my_var; }",
8871 true}, 8883 true},
8872 {"function inner() { for (let my_var = 0; my_var < 1; ++my_var) { my_var "
8873 "} }",
8874 true},
8875 {"function inner() { for (let a = 0, my_var = 0; my_var < 1; ++my_var) { "
8876 "my_var } }",
8877 true},
8878 }; 8884 };
8879 8885
8880 for (unsigned i = 0; i < arraysize(inners); ++i) { 8886 for (unsigned i = 0; i < arraysize(inners); ++i) {
8881 const char* inner = inners[i].source; 8887 const char* inner = inners[i].source;
8882 int inner_len = Utf8LengthHelper(inner); 8888 int inner_len = Utf8LengthHelper(inner);
8883 int len = prefix_len + inner_len + suffix_len; 8889 int len = prefix_len + inner_len + suffix_len;
8884 i::ScopedVector<char> program(len + 1); 8890 i::ScopedVector<char> program(len + 1);
8885 i::SNPrintF(program, "%s%s%s", prefix, inner, suffix); 8891 i::SNPrintF(program, "%s%s%s", prefix, inner, suffix);
8886 i::Handle<i::String> source = 8892 i::Handle<i::String> source =
8887 factory->InternalizeUtf8String(program.start()); 8893 factory->InternalizeUtf8String(program.start());
(...skipping 12 matching lines...) Expand all
8900 DCHECK_NOT_NULL(scope); 8906 DCHECK_NOT_NULL(scope);
8901 DCHECK_NULL(scope->sibling()); 8907 DCHECK_NULL(scope->sibling());
8902 DCHECK(scope->is_function_scope()); 8908 DCHECK(scope->is_function_scope());
8903 const i::AstRawString* var_name = 8909 const i::AstRawString* var_name =
8904 info.ast_value_factory()->GetOneByteString("my_var"); 8910 info.ast_value_factory()->GetOneByteString("my_var");
8905 i::Variable* var = scope->Lookup(var_name); 8911 i::Variable* var = scope->Lookup(var_name);
8906 CHECK_EQ(inners[i].ctxt_allocate, 8912 CHECK_EQ(inners[i].ctxt_allocate,
8907 i::ScopeTestHelper::MustAllocateInContext(var)); 8913 i::ScopeTestHelper::MustAllocateInContext(var));
8908 } 8914 }
8909 } 8915 }
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