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

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

Issue 22916006: Move the begin token of explicit functions to the start of the function declaration. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
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 "vm/assembler.h" 5 #include "vm/assembler.h"
6 #include "vm/bigint_operations.h" 6 #include "vm/bigint_operations.h"
7 #include "vm/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/dart_api_impl.h" 8 #include "vm/dart_api_impl.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 3196 matching lines...) Expand 10 before | Expand all | Expand 10 after
3207 3207
3208 3208
3209 static RawFunction* GetFunction(const Class& cls, const char* name) { 3209 static RawFunction* GetFunction(const Class& cls, const char* name) {
3210 const Function& result = Function::Handle(cls.LookupDynamicFunction( 3210 const Function& result = Function::Handle(cls.LookupDynamicFunction(
3211 String::Handle(String::New(name)))); 3211 String::Handle(String::New(name))));
3212 EXPECT(!result.IsNull()); 3212 EXPECT(!result.IsNull());
3213 return result.raw(); 3213 return result.raw();
3214 } 3214 }
3215 3215
3216 3216
3217 static RawFunction* GetStaticFunction(const Class& cls, const char* name) {
3218 const Function& result = Function::Handle(cls.LookupStaticFunction(
3219 String::Handle(String::New(name))));
3220 EXPECT(!result.IsNull());
3221 return result.raw();
3222 }
3223
3224
3217 static RawField* GetField(const Class& cls, const char* name) { 3225 static RawField* GetField(const Class& cls, const char* name) {
3218 const Field& field = 3226 const Field& field =
3219 Field::Handle(cls.LookupField(String::Handle(String::New(name)))); 3227 Field::Handle(cls.LookupField(String::Handle(String::New(name))));
3220 EXPECT(!field.IsNull()); 3228 EXPECT(!field.IsNull());
3221 return field.raw(); 3229 return field.raw();
3222 } 3230 }
3223 3231
3224 3232
3225 static RawClass* GetClass(const Library& lib, const char* name) { 3233 static RawClass* GetClass(const Library& lib, const char* name) {
3226 String& ambiguity_error_msg = String::Handle(); 3234 String& ambiguity_error_msg = String::Handle();
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
3318 field = lib.LookupLocalField(String::Handle(Symbols::New("gVar"))); 3326 field = lib.LookupLocalField(String::Handle(Symbols::New("gVar")));
3319 EXPECT(!field.IsNull()); 3327 EXPECT(!field.IsNull());
3320 res = lib.GetMetadata(field); 3328 res = lib.GetMetadata(field);
3321 PrintMetadata("gVar", res); 3329 PrintMetadata("gVar", res);
3322 } 3330 }
3323 3331
3324 3332
3325 TEST_CASE(FunctionSourceFingerprint) { 3333 TEST_CASE(FunctionSourceFingerprint) {
3326 const char* kScriptChars = 3334 const char* kScriptChars =
3327 "class A {\n" 3335 "class A {\n"
3328 " void test1(int a) {\n" 3336 " static void test1(int a) {\n"
hausner 2013/08/13 15:40:11 Why did you change the functions to static? Is it
Michael Lippautz (Google) 2013/08/13 18:07:34 Yes, it's because the fingerprint's intial value i
3329 " return a > 1 ? a + 1 : a;\n" 3337 " return a > 1 ? a + 1 : a;\n"
3330 " }\n" 3338 " }\n"
3331 " void test2(int a) {\n" 3339 " static void test2(a) {\n"
3332 " return a > 1 ? a + 1 : a;\n" 3340 " return a > 1 ? a + 1 : a;\n"
3333 " }\n" 3341 " }\n"
3334 " void test3(a) {\n" 3342 " static void test3(b) {\n"
3335 " return a > 1 ? a + 1 : a;\n"
3336 " }\n"
3337 " void test4(b) {\n"
3338 " return b > 1 ? b + 1 : b;\n" 3343 " return b > 1 ? b + 1 : b;\n"
3339 " }\n" 3344 " }\n"
3340 " void test5(b) {\n" 3345 " static void test4(b) {\n"
3341 " return b > 1 ? b - 1 : b;\n" 3346 " return b > 1 ? b - 1 : b;\n"
3342 " }\n" 3347 " }\n"
3343 " void test6(b) {\n" 3348 " static void test5(b) {\n"
3344 " return b > 1 ? b - 2 : b;\n" 3349 " return b > 1 ? b - 2 : b;\n"
3345 " }\n" 3350 " }\n"
3346 " void test7(b) {\n" 3351 "}\n"
3352 "class B {\n"
3353 " static void /* Different declaration style. */\n"
3354 " test1(int a) {\n"
3355 " /* Returns a + 1 for a > 1, a otherwise. */\n"
3356 " return a > 1 ?\n"
3357 " a + 1 :\n"
3358 " a;\n"
3359 " }\n"
3360 " static void test5(b) {\n"
3347 " return b > 1 ?\n" 3361 " return b > 1 ?\n"
3348 " b - 2 : b;\n" 3362 " b - 2 : b;\n"
3349 " }\n" 3363 " }\n"
3350 "}"; 3364 "}";
3351 TestCase::LoadTestScript(kScriptChars, NULL); 3365 TestCase::LoadTestScript(kScriptChars, NULL);
3352 EXPECT(ClassFinalizer::FinalizePendingClasses()); 3366 EXPECT(ClassFinalizer::FinalizePendingClasses());
3353 const String& name = String::Handle(String::New(TestCase::url())); 3367 const String& name = String::Handle(String::New(TestCase::url()));
3354 const Library& lib = Library::Handle(Library::LookupLibrary(name)); 3368 const Library& lib = Library::Handle(Library::LookupLibrary(name));
3355 EXPECT(!lib.IsNull()); 3369 EXPECT(!lib.IsNull());
3356 3370
3357 const Class& class_a = Class::Handle( 3371 const Class& class_a = Class::Handle(
3358 lib.LookupClass(String::Handle(Symbols::New("A")), NULL)); 3372 lib.LookupClass(String::Handle(Symbols::New("A")), NULL));
3359 const Function& test1 = Function::Handle(GetFunction(class_a, "test1")); 3373 const Class& class_b = Class::Handle(
3360 const Function& test2 = Function::Handle(GetFunction(class_a, "test2")); 3374 lib.LookupClass(String::Handle(Symbols::New("B")), NULL));
3361 const Function& test3 = Function::Handle(GetFunction(class_a, "test3")); 3375 const Function& a_test1 = Function::Handle(GetStaticFunction(
hausner 2013/08/13 15:40:11 Nit: could you reformat this as const Function& a
Michael Lippautz (Google) 2013/08/13 18:07:34 Done.
3362 const Function& test4 = Function::Handle(GetFunction(class_a, "test4")); 3376 class_a, "test1"));
3363 const Function& test5 = Function::Handle(GetFunction(class_a, "test5")); 3377 const Function& b_test1 = Function::Handle(GetStaticFunction(
3364 const Function& test6 = Function::Handle(GetFunction(class_a, "test6")); 3378 class_b, "test1"));
3365 const Function& test7 = Function::Handle(GetFunction(class_a, "test7")); 3379 const Function& a_test2 = Function::Handle(GetStaticFunction(
3366 EXPECT_EQ(test1.SourceFingerprint(), test2.SourceFingerprint()); 3380 class_a, "test2"));
3367 EXPECT_NE(test1.SourceFingerprint(), test3.SourceFingerprint()); 3381 const Function& a_test3 = Function::Handle(GetStaticFunction(
3368 EXPECT_NE(test3.SourceFingerprint(), test4.SourceFingerprint()); 3382 class_a, "test3"));
3369 EXPECT_NE(test4.SourceFingerprint(), test5.SourceFingerprint()); 3383 const Function& a_test4 = Function::Handle(GetStaticFunction(
3370 EXPECT_NE(test5.SourceFingerprint(), test6.SourceFingerprint()); 3384 class_a, "test4"));
3371 EXPECT_EQ(test6.SourceFingerprint(), test7.SourceFingerprint()); 3385 const Function& a_test5 = Function::Handle(GetStaticFunction(
3386 class_a, "test5"));
3387 const Function& b_test5 = Function::Handle(GetStaticFunction(
3388 class_b, "test5"));
3389
3390 EXPECT_EQ(a_test1.SourceFingerprint(), b_test1.SourceFingerprint());
3391 EXPECT_NE(a_test1.SourceFingerprint(), a_test2.SourceFingerprint());
3392 EXPECT_NE(a_test2.SourceFingerprint(), a_test3.SourceFingerprint());
3393 EXPECT_NE(a_test3.SourceFingerprint(), a_test4.SourceFingerprint());
3394 EXPECT_NE(a_test4.SourceFingerprint(), a_test5.SourceFingerprint());
3395 EXPECT_EQ(a_test5.SourceFingerprint(), b_test5.SourceFingerprint());
3372 } 3396 }
3373 3397
3374 } // namespace dart 3398 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier.h ('k') | runtime/vm/parser.h » ('j') | runtime/vm/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698