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/assembler.h" | 6 #include "vm/assembler.h" |
7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
9 #include "vm/object.h" | 9 #include "vm/object.h" |
10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 function_name, RawFunction::kRegularFunction, | 33 function_name, RawFunction::kRegularFunction, |
34 false, false, false, false, cls, 0); | 34 false, false, false, false, cls, 0); |
35 functions.SetAt(0, function); | 35 functions.SetAt(0, function); |
36 function_name = Symbols::New("bar"); | 36 function_name = Symbols::New("bar"); |
37 function = Function::New( | 37 function = Function::New( |
38 function_name, RawFunction::kRegularFunction, | 38 function_name, RawFunction::kRegularFunction, |
39 false, false, false, false, cls, 0); | 39 false, false, false, false, cls, 0); |
40 | 40 |
41 const int kNumFixedParameters = 2; | 41 const int kNumFixedParameters = 2; |
42 const int kNumOptionalParameters = 3; | 42 const int kNumOptionalParameters = 3; |
43 function.set_num_fixed_parameters(kNumFixedParameters); | 43 const bool kAreOptionalPositional = true; |
44 function.set_num_optional_parameters(kNumOptionalParameters); | 44 function.SetNumberOfParameters(kNumFixedParameters, |
| 45 kNumOptionalParameters, |
| 46 kAreOptionalPositional); |
45 functions.SetAt(1, function); | 47 functions.SetAt(1, function); |
46 | 48 |
47 function_name = Symbols::New("baz"); | 49 function_name = Symbols::New("baz"); |
48 function = Function::New( | 50 function = Function::New( |
49 function_name, RawFunction::kRegularFunction, | 51 function_name, RawFunction::kRegularFunction, |
50 false, false, false, false, cls, 0); | 52 false, false, false, false, cls, 0); |
51 functions.SetAt(2, function); | 53 functions.SetAt(2, function); |
52 | 54 |
53 function_name = Symbols::New("Foo"); | 55 function_name = Symbols::New("Foo"); |
54 function = Function::New( | 56 function = Function::New( |
(...skipping 29 matching lines...) Expand all Loading... |
84 EXPECT(function_name.Equals(String::Handle(function.name()))); | 86 EXPECT(function_name.Equals(String::Handle(function.name()))); |
85 EXPECT_EQ(cls.raw(), function.Owner()); | 87 EXPECT_EQ(cls.raw(), function.Owner()); |
86 EXPECT(!function.is_static()); | 88 EXPECT(!function.is_static()); |
87 function = cls.LookupStaticFunction(function_name); | 89 function = cls.LookupStaticFunction(function_name); |
88 EXPECT(function.IsNull()); | 90 EXPECT(function.IsNull()); |
89 | 91 |
90 function_name = String::New("foo"); | 92 function_name = String::New("foo"); |
91 function = cls.LookupDynamicFunction(function_name); | 93 function = cls.LookupDynamicFunction(function_name); |
92 EXPECT(!function.IsNull()); | 94 EXPECT(!function.IsNull()); |
93 EXPECT_EQ(0, function.num_fixed_parameters()); | 95 EXPECT_EQ(0, function.num_fixed_parameters()); |
94 EXPECT_EQ(0, function.num_optional_parameters()); | 96 EXPECT(!function.HasOptionalParameters()); |
95 | 97 |
96 function_name = String::New("bar"); | 98 function_name = String::New("bar"); |
97 function = cls.LookupDynamicFunction(function_name); | 99 function = cls.LookupDynamicFunction(function_name); |
98 EXPECT(!function.IsNull()); | 100 EXPECT(!function.IsNull()); |
99 EXPECT_EQ(kNumFixedParameters, function.num_fixed_parameters()); | 101 EXPECT_EQ(kNumFixedParameters, function.num_fixed_parameters()); |
100 EXPECT_EQ(kNumOptionalParameters, function.num_optional_parameters()); | 102 EXPECT_EQ(kNumOptionalParameters, |
| 103 function.num_optional_positional_parameters() + |
| 104 function.num_optional_named_parameters()); |
101 | 105 |
102 const Array& interfaces = Array::Handle(Array::New(2)); | 106 const Array& interfaces = Array::Handle(Array::New(2)); |
103 Class& interface = Class::Handle(); | 107 Class& interface = Class::Handle(); |
104 String& interface_name = String::Handle(); | 108 String& interface_name = String::Handle(); |
105 interface_name = Symbols::New("Harley"); | 109 interface_name = Symbols::New("Harley"); |
106 interface = Class::New(interface_name, script, Scanner::kDummyTokenIndex); | 110 interface = Class::New(interface_name, script, Scanner::kDummyTokenIndex); |
107 interfaces.SetAt(0, Type::Handle(Type::NewNonParameterizedType(interface))); | 111 interfaces.SetAt(0, Type::Handle(Type::NewNonParameterizedType(interface))); |
108 interface_name = Symbols::New("Norton"); | 112 interface_name = Symbols::New("Norton"); |
109 interface = Class::New(interface_name, script, Scanner::kDummyTokenIndex); | 113 interface = Class::New(interface_name, script, Scanner::kDummyTokenIndex); |
110 interfaces.SetAt(1, Type::Handle(Type::NewNonParameterizedType(interface))); | 114 interfaces.SetAt(1, Type::Handle(Type::NewNonParameterizedType(interface))); |
(...skipping 2993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3104 isolate->heap()->CollectAllGarbage(); | 3108 isolate->heap()->CollectAllGarbage(); |
3105 EXPECT(weak1.key() == Object::null()); | 3109 EXPECT(weak1.key() == Object::null()); |
3106 EXPECT(weak1.value() == Object::null()); | 3110 EXPECT(weak1.value() == Object::null()); |
3107 EXPECT(weak2.key() == Object::null()); | 3111 EXPECT(weak2.key() == Object::null()); |
3108 EXPECT(weak2.value() == Object::null()); | 3112 EXPECT(weak2.value() == Object::null()); |
3109 } | 3113 } |
3110 | 3114 |
3111 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 3115 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
3112 | 3116 |
3113 } // namespace dart | 3117 } // namespace dart |
OLD | NEW |