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

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

Issue 10928160: Limit the maximum number of formal parameters (32K fixed and 32K optional) (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 "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 21 matching lines...) Expand all
32 function = Function::New( 32 function = Function::New(
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 kNumOptionalPositionalParameters = 3;
43 const bool kAreOptionalPositional = true; 43 const int kNumOptionalNamedParameters = 0;
44 function.SetNumberOfParameters(kNumFixedParameters, 44 function.set_num_fixed_parameters(kNumFixedParameters);
45 kNumOptionalParameters, 45 function.SetNumOptionalParameters(kNumOptionalPositionalParameters,
46 kAreOptionalPositional); 46 kNumOptionalNamedParameters);
47 functions.SetAt(1, function); 47 functions.SetAt(1, function);
48 48
49 function_name = Symbols::New("baz"); 49 function_name = Symbols::New("baz");
50 function = Function::New( 50 function = Function::New(
51 function_name, RawFunction::kRegularFunction, 51 function_name, RawFunction::kRegularFunction,
52 false, false, false, false, cls, 0); 52 false, false, false, false, cls, 0);
53 functions.SetAt(2, function); 53 functions.SetAt(2, function);
54 54
55 function_name = Symbols::New("Foo"); 55 function_name = Symbols::New("Foo");
56 function = Function::New( 56 function = Function::New(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 function_name = String::New("foo"); 92 function_name = String::New("foo");
93 function = cls.LookupDynamicFunction(function_name); 93 function = cls.LookupDynamicFunction(function_name);
94 EXPECT(!function.IsNull()); 94 EXPECT(!function.IsNull());
95 EXPECT_EQ(0, function.num_fixed_parameters()); 95 EXPECT_EQ(0, function.num_fixed_parameters());
96 EXPECT(!function.HasOptionalParameters()); 96 EXPECT(!function.HasOptionalParameters());
97 97
98 function_name = String::New("bar"); 98 function_name = String::New("bar");
99 function = cls.LookupDynamicFunction(function_name); 99 function = cls.LookupDynamicFunction(function_name);
100 EXPECT(!function.IsNull()); 100 EXPECT(!function.IsNull());
101 EXPECT_EQ(kNumFixedParameters, function.num_fixed_parameters()); 101 EXPECT_EQ(kNumFixedParameters, function.num_fixed_parameters());
102 EXPECT_EQ(kNumOptionalParameters, 102 EXPECT_EQ(kNumOptionalPositionalParameters, function.NumOptionalParameters());
103 function.num_optional_positional_parameters() +
104 function.num_optional_named_parameters());
105 103
106 const Array& interfaces = Array::Handle(Array::New(2)); 104 const Array& interfaces = Array::Handle(Array::New(2));
107 Class& interface = Class::Handle(); 105 Class& interface = Class::Handle();
108 String& interface_name = String::Handle(); 106 String& interface_name = String::Handle();
109 interface_name = Symbols::New("Harley"); 107 interface_name = Symbols::New("Harley");
110 interface = Class::New(interface_name, script, Scanner::kDummyTokenIndex); 108 interface = Class::New(interface_name, script, Scanner::kDummyTokenIndex);
111 interfaces.SetAt(0, Type::Handle(Type::NewNonParameterizedType(interface))); 109 interfaces.SetAt(0, Type::Handle(Type::NewNonParameterizedType(interface)));
112 interface_name = Symbols::New("Norton"); 110 interface_name = Symbols::New("Norton");
113 interface = Class::New(interface_name, script, Scanner::kDummyTokenIndex); 111 interface = Class::New(interface_name, script, Scanner::kDummyTokenIndex);
114 interfaces.SetAt(1, Type::Handle(Type::NewNonParameterizedType(interface))); 112 interfaces.SetAt(1, Type::Handle(Type::NewNonParameterizedType(interface)));
(...skipping 2993 matching lines...) Expand 10 before | Expand all | Expand 10 after
3108 isolate->heap()->CollectAllGarbage(); 3106 isolate->heap()->CollectAllGarbage();
3109 EXPECT(weak1.key() == Object::null()); 3107 EXPECT(weak1.key() == Object::null());
3110 EXPECT(weak1.value() == Object::null()); 3108 EXPECT(weak1.value() == Object::null());
3111 EXPECT(weak2.key() == Object::null()); 3109 EXPECT(weak2.key() == Object::null());
3112 EXPECT(weak2.value() == Object::null()); 3110 EXPECT(weak2.value() == Object::null());
3113 } 3111 }
3114 3112
3115 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 3113 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
3116 3114
3117 } // namespace dart 3115 } // namespace dart
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/object.cc ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698