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

Side by Side Diff: runtime/vm/code_generator_test.cc

Issue 1955453002: - Use a map to lookup libraries by URL. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix precompiler handling. Created 4 years, 7 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/globals.h" 8 #include "vm/globals.h"
9 #include "vm/ast.h" 9 #include "vm/ast.h"
10 #include "vm/assembler.h" 10 #include "vm/assembler.h"
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 SequenceNode* node_seq = test->node_sequence(); 206 SequenceNode* node_seq = test->node_sequence();
207 LiteralNode* a = 207 LiteralNode* a =
208 new LiteralNode(kPos, Double::ZoneHandle(Double::New(12.0, Heap::kOld))); 208 new LiteralNode(kPos, Double::ZoneHandle(Double::New(12.0, Heap::kOld)));
209 UnaryOpNode* neg_node = new UnaryOpNode(kPos, Token::kNEGATE, a); 209 UnaryOpNode* neg_node = new UnaryOpNode(kPos, Token::kNEGATE, a);
210 node_seq->Add(new ReturnNode(kPos, neg_node)); 210 node_seq->Add(new ReturnNode(kPos, neg_node));
211 } 211 }
212 CODEGEN_TEST_RUN(DoubleUnaryOpCodegen, Double::New(-12.0)) 212 CODEGEN_TEST_RUN(DoubleUnaryOpCodegen, Double::New(-12.0))
213 213
214 214
215 static Library& MakeTestLibrary(const char* url) { 215 static Library& MakeTestLibrary(const char* url) {
216 const String& lib_url = String::ZoneHandle(Symbols::New(Thread::Current(), 216 Thread* thread = Thread::Current();
217 url)); 217 Zone* zone = thread->zone();
218 Library& lib = Library::ZoneHandle(Library::New(lib_url)); 218
219 lib.Register(); 219 const String& lib_url = String::ZoneHandle(zone, Symbols::New(thread, url));
220 Library& core_lib = Library::Handle(Library::CoreLibrary()); 220 Library& lib = Library::ZoneHandle(zone, Library::New(lib_url));
221 lib.Register(thread);
222 Library& core_lib = Library::Handle(zone, Library::CoreLibrary());
221 ASSERT(!core_lib.IsNull()); 223 ASSERT(!core_lib.IsNull());
222 const Namespace& core_ns = Namespace::Handle( 224 const Namespace& core_ns = Namespace::Handle(zone,
223 Namespace::New(core_lib, Array::Handle(), Array::Handle())); 225 Namespace::New(core_lib, Array::Handle(zone), Array::Handle(zone)));
224 lib.AddImport(core_ns); 226 lib.AddImport(core_ns);
225 return lib; 227 return lib;
226 } 228 }
227 229
228 230
229 static RawClass* LookupClass(const Library& lib, const char* name) { 231 static RawClass* LookupClass(const Library& lib, const char* name) {
230 const String& cls_name = String::ZoneHandle(Symbols::New(Thread::Current(), 232 const String& cls_name = String::ZoneHandle(Symbols::New(Thread::Current(),
231 name)); 233 name));
232 return lib.LookupClass(cls_name); 234 return lib.LookupClass(cls_name);
233 } 235 }
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 Library& app_lib = Library::Handle(); 365 Library& app_lib = Library::Handle();
364 app_lib ^= libs.At(num_libs - 1); 366 app_lib ^= libs.At(num_libs - 1);
365 ASSERT(!app_lib.IsNull()); 367 ASSERT(!app_lib.IsNull());
366 const Class& cls = Class::Handle( 368 const Class& cls = Class::Handle(
367 app_lib.LookupClass(String::Handle(Symbols::New(Thread::Current(), 369 app_lib.LookupClass(String::Handle(Symbols::New(Thread::Current(),
368 "A")))); 370 "A"))));
369 EXPECT_EQ(cls.raw(), result.clazz()); 371 EXPECT_EQ(cls.raw(), result.clazz());
370 } 372 }
371 373
372 } // namespace dart 374 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698