Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "vm/globals.h" | 6 #include "vm/globals.h" |
| 7 #include "vm/ast.h" | 7 #include "vm/ast.h" |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/code_generator.h" | 10 #include "vm/code_generator.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 function.set_num_fixed_parameters(num_fixed_params); | 215 function.set_num_fixed_parameters(num_fixed_params); |
| 216 function.SetNumOptionalParameters(num_opt_params, true); | 216 function.SetNumOptionalParameters(num_opt_params, true); |
| 217 const String& native_name = | 217 const String& native_name = |
| 218 String::ZoneHandle(Symbols::New("TestSmiSub")); | 218 String::ZoneHandle(Symbols::New("TestSmiSub")); |
| 219 NativeFunction native_function = | 219 NativeFunction native_function = |
| 220 reinterpret_cast<NativeFunction>(TestSmiSub); | 220 reinterpret_cast<NativeFunction>(TestSmiSub); |
| 221 node_seq->Add(new ReturnNode(kPos, | 221 node_seq->Add(new ReturnNode(kPos, |
| 222 new NativeBodyNode(kPos, | 222 new NativeBodyNode(kPos, |
| 223 function, | 223 function, |
| 224 native_name, | 224 native_name, |
| 225 native_function))); | 225 native_function, |
| 226 false))); | |
|
srdjan
2013/08/06 17:06:28
Comment what 'false' means. (also on cases below)
siva
2013/08/06 19:04:26
Done.
| |
| 226 } | 227 } |
| 227 | 228 |
| 228 | 229 |
| 229 // Tested Dart code: | 230 // Tested Dart code: |
| 230 // return dec(5); | 231 // return dec(5); |
| 231 CODEGEN_TEST2_GENERATE(StaticDecCallCodegen, function, test) { | 232 CODEGEN_TEST2_GENERATE(StaticDecCallCodegen, function, test) { |
| 232 SequenceNode* node_seq = test->node_sequence(); | 233 SequenceNode* node_seq = test->node_sequence(); |
| 233 ArgumentListNode* arguments = new ArgumentListNode(kPos); | 234 ArgumentListNode* arguments = new ArgumentListNode(kPos); |
| 234 arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(5)))); | 235 arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(5)))); |
| 235 node_seq->Add(new ReturnNode(kPos, | 236 node_seq->Add(new ReturnNode(kPos, |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 395 function.SetParameterTypeAt(i, param_type); | 396 function.SetParameterTypeAt(i, param_type); |
| 396 } | 397 } |
| 397 const String& native_name = | 398 const String& native_name = |
| 398 String::ZoneHandle(Symbols::New("TestSmiSum")); | 399 String::ZoneHandle(Symbols::New("TestSmiSum")); |
| 399 NativeFunction native_function = | 400 NativeFunction native_function = |
| 400 reinterpret_cast<NativeFunction>(TestSmiSum); | 401 reinterpret_cast<NativeFunction>(TestSmiSum); |
| 401 node_seq->Add(new ReturnNode(kPos, | 402 node_seq->Add(new ReturnNode(kPos, |
| 402 new NativeBodyNode(kPos, | 403 new NativeBodyNode(kPos, |
| 403 function, | 404 function, |
| 404 native_name, | 405 native_name, |
| 405 native_function))); | 406 native_function, |
| 407 false))); | |
| 406 } | 408 } |
| 407 | 409 |
| 408 | 410 |
| 409 // Tested Dart code, calling function sum declared above: | 411 // Tested Dart code, calling function sum declared above: |
| 410 // return sum(1, 3); | 412 // return sum(1, 3); |
| 411 // Optional arguments are not passed and hence are set to their default values. | 413 // Optional arguments are not passed and hence are set to their default values. |
| 412 CODEGEN_TEST2_GENERATE(StaticSumCallNoOptCodegen, function, test) { | 414 CODEGEN_TEST2_GENERATE(StaticSumCallNoOptCodegen, function, test) { |
| 413 SequenceNode* node_seq = test->node_sequence(); | 415 SequenceNode* node_seq = test->node_sequence(); |
| 414 ArgumentListNode* arguments = new ArgumentListNode(kPos); | 416 ArgumentListNode* arguments = new ArgumentListNode(kPos); |
| 415 arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(1)))); | 417 arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(1)))); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 482 function.SetParameterTypeAt(i, param_type); | 484 function.SetParameterTypeAt(i, param_type); |
| 483 } | 485 } |
| 484 const String& native_name = | 486 const String& native_name = |
| 485 String::ZoneHandle(Symbols::New("TestNonNullSmiSum")); | 487 String::ZoneHandle(Symbols::New("TestNonNullSmiSum")); |
| 486 NativeFunction native_function = | 488 NativeFunction native_function = |
| 487 reinterpret_cast<NativeFunction>(TestNonNullSmiSum); | 489 reinterpret_cast<NativeFunction>(TestNonNullSmiSum); |
| 488 node_seq->Add(new ReturnNode(kPos, | 490 node_seq->Add(new ReturnNode(kPos, |
| 489 new NativeBodyNode(kPos, | 491 new NativeBodyNode(kPos, |
| 490 function, | 492 function, |
| 491 native_name, | 493 native_name, |
| 492 native_function))); | 494 native_function, |
| 495 false))); | |
| 493 } | 496 } |
| 494 | 497 |
| 495 | 498 |
| 496 // Tested Dart code, calling function sum declared above: | 499 // Tested Dart code, calling function sum declared above: |
| 497 // return sum(1, null, 3); | 500 // return sum(1, null, 3); |
| 498 CODEGEN_TEST2_GENERATE(StaticNonNullSumCallCodegen, function, test) { | 501 CODEGEN_TEST2_GENERATE(StaticNonNullSumCallCodegen, function, test) { |
| 499 SequenceNode* node_seq = test->node_sequence(); | 502 SequenceNode* node_seq = test->node_sequence(); |
| 500 ArgumentListNode* arguments = new ArgumentListNode(kPos); | 503 ArgumentListNode* arguments = new ArgumentListNode(kPos); |
| 501 arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(1)))); | 504 arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(1)))); |
| 502 arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle())); | 505 arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle())); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 553 app_lib ^= libs.At(num_libs - 1); | 556 app_lib ^= libs.At(num_libs - 1); |
| 554 ASSERT(!app_lib.IsNull()); | 557 ASSERT(!app_lib.IsNull()); |
| 555 String& ambiguity_error_msg = String::Handle(); | 558 String& ambiguity_error_msg = String::Handle(); |
| 556 const Class& cls = Class::Handle( | 559 const Class& cls = Class::Handle( |
| 557 app_lib.LookupClass(String::Handle(Symbols::New("A")), | 560 app_lib.LookupClass(String::Handle(Symbols::New("A")), |
| 558 &ambiguity_error_msg)); | 561 &ambiguity_error_msg)); |
| 559 EXPECT_EQ(cls.raw(), result.clazz()); // No ambiguity error expected. | 562 EXPECT_EQ(cls.raw(), result.clazz()); // No ambiguity error expected. |
| 560 } | 563 } |
| 561 | 564 |
| 562 } // namespace dart | 565 } // namespace dart |
| OLD | NEW |