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/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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 // Since this function has an optional parameter, its prologue will copy | 202 // Since this function has an optional parameter, its prologue will copy |
203 // incoming parameters to locals. | 203 // incoming parameters to locals. |
204 SequenceNode* node_seq = test->node_sequence(); | 204 SequenceNode* node_seq = test->node_sequence(); |
205 const int num_fixed_params = 1; | 205 const int num_fixed_params = 1; |
206 const int num_opt_params = 1; | 206 const int num_opt_params = 1; |
207 const int num_params = num_fixed_params + num_opt_params; | 207 const int num_params = num_fixed_params + num_opt_params; |
208 LocalScope* local_scope = node_seq->scope(); | 208 LocalScope* local_scope = node_seq->scope(); |
209 local_scope->InsertParameterAt(0, NewTestLocalVariable("a")); | 209 local_scope->InsertParameterAt(0, NewTestLocalVariable("a")); |
210 local_scope->InsertParameterAt(1, NewTestLocalVariable("b")); | 210 local_scope->InsertParameterAt(1, NewTestLocalVariable("b")); |
211 ASSERT(local_scope->num_variables() == num_params); | 211 ASSERT(local_scope->num_variables() == num_params); |
212 const Array& default_values = Array::ZoneHandle(Array::New(num_opt_params)); | 212 ZoneGrowableArray<const Instance*>* default_values = |
213 default_values.SetAt(0, Smi::ZoneHandle(Smi::New(1))); // b = 1. | 213 new ZoneGrowableArray<const Instance*>(num_opt_params); |
| 214 default_values->Add(&Smi::ZoneHandle(Smi::New(1))); // b = 1. |
214 test->set_default_parameter_values(default_values); | 215 test->set_default_parameter_values(default_values); |
215 const Function& function = test->function(); | 216 const Function& function = test->function(); |
216 function.set_is_native(true); | 217 function.set_is_native(true); |
217 function.set_num_fixed_parameters(num_fixed_params); | 218 function.set_num_fixed_parameters(num_fixed_params); |
218 function.SetNumOptionalParameters(num_opt_params, true); | 219 function.SetNumOptionalParameters(num_opt_params, true); |
219 const String& native_name = | 220 const String& native_name = |
220 String::ZoneHandle(Symbols::New("TestSmiSub")); | 221 String::ZoneHandle(Symbols::New("TestSmiSub")); |
221 NativeFunction native_function = | 222 NativeFunction native_function = |
222 reinterpret_cast<NativeFunction>(TestSmiSub); | 223 reinterpret_cast<NativeFunction>(TestSmiSub); |
223 node_seq->Add( | 224 node_seq->Add( |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 const int num_fixed_params = 2; | 377 const int num_fixed_params = 2; |
377 const int num_opt_params = 3; | 378 const int num_opt_params = 3; |
378 const int num_params = num_fixed_params + num_opt_params; | 379 const int num_params = num_fixed_params + num_opt_params; |
379 LocalScope* local_scope = node_seq->scope(); | 380 LocalScope* local_scope = node_seq->scope(); |
380 local_scope->InsertParameterAt(0, NewTestLocalVariable("a")); | 381 local_scope->InsertParameterAt(0, NewTestLocalVariable("a")); |
381 local_scope->InsertParameterAt(1, NewTestLocalVariable("b")); | 382 local_scope->InsertParameterAt(1, NewTestLocalVariable("b")); |
382 local_scope->InsertParameterAt(2, NewTestLocalVariable("c")); | 383 local_scope->InsertParameterAt(2, NewTestLocalVariable("c")); |
383 local_scope->InsertParameterAt(3, NewTestLocalVariable("d")); | 384 local_scope->InsertParameterAt(3, NewTestLocalVariable("d")); |
384 local_scope->InsertParameterAt(4, NewTestLocalVariable("e")); | 385 local_scope->InsertParameterAt(4, NewTestLocalVariable("e")); |
385 ASSERT(local_scope->num_variables() == num_params); | 386 ASSERT(local_scope->num_variables() == num_params); |
386 const Array& default_values = Array::ZoneHandle(Array::New(num_opt_params)); | 387 ZoneGrowableArray<const Instance*>* default_values = |
387 default_values.SetAt(0, Smi::ZoneHandle(Smi::New(10))); | 388 new ZoneGrowableArray<const Instance*>(num_opt_params); |
388 default_values.SetAt(1, Smi::ZoneHandle(Smi::New(21))); | 389 default_values->Add(&Smi::ZoneHandle(Smi::New(10))); |
389 default_values.SetAt(2, Smi::ZoneHandle(Smi::New(-32))); | 390 default_values->Add(&Smi::ZoneHandle(Smi::New(21))); |
| 391 default_values->Add(&Smi::ZoneHandle(Smi::New(-32))); |
390 test->set_default_parameter_values(default_values); | 392 test->set_default_parameter_values(default_values); |
391 const Function& function = test->function(); | 393 const Function& function = test->function(); |
392 function.set_is_native(true); | 394 function.set_is_native(true); |
393 function.set_num_fixed_parameters(num_fixed_params); | 395 function.set_num_fixed_parameters(num_fixed_params); |
394 function.SetNumOptionalParameters(num_opt_params, true); | 396 function.SetNumOptionalParameters(num_opt_params, true); |
395 function.set_parameter_types(Array::Handle(Array::New(num_params))); | 397 function.set_parameter_types(Array::Handle(Array::New(num_params))); |
396 function.set_parameter_names(Array::Handle(Array::New(num_params))); | 398 function.set_parameter_names(Array::Handle(Array::New(num_params))); |
397 const Type& param_type = Type::Handle(Type::DynamicType()); | 399 const Type& param_type = Type::Handle(Type::DynamicType()); |
398 for (int i = 0; i < num_params; i++) { | 400 for (int i = 0; i < num_params; i++) { |
399 function.SetParameterTypeAt(i, param_type); | 401 function.SetParameterTypeAt(i, param_type); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 intptr_t num_libs = libs.Length(); | 563 intptr_t num_libs = libs.Length(); |
562 Library& app_lib = Library::Handle(); | 564 Library& app_lib = Library::Handle(); |
563 app_lib ^= libs.At(num_libs - 1); | 565 app_lib ^= libs.At(num_libs - 1); |
564 ASSERT(!app_lib.IsNull()); | 566 ASSERT(!app_lib.IsNull()); |
565 const Class& cls = Class::Handle( | 567 const Class& cls = Class::Handle( |
566 app_lib.LookupClass(String::Handle(Symbols::New("A")))); | 568 app_lib.LookupClass(String::Handle(Symbols::New("A")))); |
567 EXPECT_EQ(cls.raw(), result.clazz()); | 569 EXPECT_EQ(cls.raw(), result.clazz()); |
568 } | 570 } |
569 | 571 |
570 } // namespace dart | 572 } // namespace dart |
OLD | NEW |