OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/ast-loop-assignment-analyzer.h" | 5 #include "src/compiler/ast-loop-assignment-analyzer.h" |
6 #include "src/parser.h" | 6 #include "src/parser.h" |
7 #include "src/rewriter.h" | 7 #include "src/rewriter.h" |
8 #include "src/scopes.h" | 8 #include "src/scopes.h" |
9 #include "test/cctest/cctest.h" | 9 #include "test/cctest/cctest.h" |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 : function(Handle<JSFunction>::null()), result(NULL) { | 22 : function(Handle<JSFunction>::null()), result(NULL) { |
23 ScopedVector<char> program(kBufferSize); | 23 ScopedVector<char> program(kBufferSize); |
24 SNPrintF(program, "function f(a,b,c) { %s; } f;", body); | 24 SNPrintF(program, "function f(a,b,c) { %s; } f;", body); |
25 v8::Local<v8::Value> v = CompileRun(program.start()); | 25 v8::Local<v8::Value> v = CompileRun(program.start()); |
26 Handle<Object> obj = v8::Utils::OpenHandle(*v); | 26 Handle<Object> obj = v8::Utils::OpenHandle(*v); |
27 function = Handle<JSFunction>::cast(obj); | 27 function = Handle<JSFunction>::cast(obj); |
28 } | 28 } |
29 | 29 |
30 void CheckLoopAssignedCount(int expected, const char* var_name) { | 30 void CheckLoopAssignedCount(int expected, const char* var_name) { |
31 // TODO(titzer): don't scope analyze every single time. | 31 // TODO(titzer): don't scope analyze every single time. |
32 ParseInfo parse_info(main_zone()); | 32 ParseInfo parse_info(main_zone(), function); |
33 parse_info.InitializeFromJSFunction(function); | |
34 CompilationInfo info(&parse_info); | 33 CompilationInfo info(&parse_info); |
35 | 34 |
36 CHECK(Parser::ParseStatic(&parse_info)); | 35 CHECK(Parser::ParseStatic(&parse_info)); |
37 CHECK(Rewriter::Rewrite(&parse_info)); | 36 CHECK(Rewriter::Rewrite(&parse_info)); |
38 CHECK(Scope::Analyze(&parse_info)); | 37 CHECK(Scope::Analyze(&parse_info)); |
39 | 38 |
40 Scope* scope = info.function()->scope(); | 39 Scope* scope = info.function()->scope(); |
41 AstValueFactory* factory = parse_info.ast_value_factory(); | 40 AstValueFactory* factory = parse_info.ast_value_factory(); |
42 CHECK(scope); | 41 CHECK(scope); |
43 | 42 |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 " while (1) z++;" | 286 " while (1) z++;" |
288 " }" | 287 " }" |
289 "}" | 288 "}" |
290 "w;"); | 289 "w;"); |
291 | 290 |
292 f.CheckLoopAssignedCount(1, "x"); | 291 f.CheckLoopAssignedCount(1, "x"); |
293 f.CheckLoopAssignedCount(3, "y"); | 292 f.CheckLoopAssignedCount(3, "y"); |
294 f.CheckLoopAssignedCount(5, "z"); | 293 f.CheckLoopAssignedCount(5, "z"); |
295 f.CheckLoopAssignedCount(0, "w"); | 294 f.CheckLoopAssignedCount(0, "w"); |
296 } | 295 } |
OLD | NEW |