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

Side by Side Diff: vm/resolver_test.cc

Issue 11613009: Changed the API in DartEntry for invoking dart code from C++ to make it more compatible with the re… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years 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/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 const int kNumArguments = 2; 101 const int kNumArguments = 2;
102 const Array& kNoArgumentNames = Array::Handle(); 102 const Array& kNoArgumentNames = Array::Handle();
103 const Function& function = Function::Handle( 103 const Function& function = Function::Handle(
104 Resolver::ResolveStatic(library, 104 Resolver::ResolveStatic(library,
105 class_name, 105 class_name,
106 static_function_name, 106 static_function_name,
107 kNumArguments, 107 kNumArguments,
108 kNoArgumentNames, 108 kNoArgumentNames,
109 kResolveType)); 109 kResolveType));
110 EXPECT(!function.IsNull()); 110 EXPECT(!function.IsNull());
111 GrowableArray<const Object*> arguments(2); 111 const Array& args = Array::Handle(Array::New(kNumArguments));
112 const String& arg0 = String::Handle(String::New("junk")); 112 const String& arg0 = String::Handle(String::New("junk"));
113 arguments.Add(&arg0); 113 args.SetAt(0, arg0);
114 const Smi& arg1 = Smi::Handle(Smi::New(kTestValue)); 114 const Smi& arg1 = Smi::Handle(Smi::New(kTestValue));
115 arguments.Add(&arg1); 115 args.SetAt(1, arg1);
116 const Smi& retval = Smi::Handle( 116 const Smi& retval = Smi::Handle(
117 reinterpret_cast<RawSmi*>( 117 reinterpret_cast<RawSmi*>(DartEntry::InvokeStatic(function, args)));
118 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames)));
119 EXPECT_EQ(kTestValue, retval.Value()); 118 EXPECT_EQ(kTestValue, retval.Value());
120 } 119 }
121 120
122 // Now try to resolve a static function with invalid argument count. 121 // Now try to resolve a static function with invalid argument count.
123 { 122 {
124 const int kNumArguments = 1; 123 const int kNumArguments = 1;
125 const Array& kNoArgumentNames = Array::Handle(); 124 const Array& kNoArgumentNames = Array::Handle();
126 const Function& bad_function = Function::Handle( 125 const Function& bad_function = Function::Handle(
127 Resolver::ResolveStatic(library, 126 Resolver::ResolveStatic(library,
128 class_name, 127 class_name,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // Now try to resolve and invoke the instance function in this class. 177 // Now try to resolve and invoke the instance function in this class.
179 { 178 {
180 const int kNumPositionalArguments = 3; 179 const int kNumPositionalArguments = 3;
181 const int kNumNamedArguments = 0; 180 const int kNumNamedArguments = 0;
182 const Function& function = Function::Handle( 181 const Function& function = Function::Handle(
183 Resolver::ResolveDynamic(receiver, 182 Resolver::ResolveDynamic(receiver,
184 function_name, 183 function_name,
185 kNumPositionalArguments, 184 kNumPositionalArguments,
186 kNumNamedArguments)); 185 kNumNamedArguments));
187 EXPECT(!function.IsNull()); 186 EXPECT(!function.IsNull());
188 GrowableArray<const Object*> arguments; 187 const Array& args = Array::Handle(Array::New(kNumPositionalArguments));
188 args.SetAt(0, receiver);
189 const String& arg0 = String::Handle(String::New("junk")); 189 const String& arg0 = String::Handle(String::New("junk"));
190 arguments.Add(&arg0); 190 args.SetAt(1, arg0);
191 const Smi& arg1 = Smi::Handle(Smi::New(kTestValue)); 191 const Smi& arg1 = Smi::Handle(Smi::New(kTestValue));
192 arguments.Add(&arg1); 192 args.SetAt(2, arg1);
193 const Array& kNoArgumentNames = Array::Handle();
194 const Smi& retval = Smi::Handle( 193 const Smi& retval = Smi::Handle(
195 reinterpret_cast<RawSmi*>(DartEntry::InvokeDynamic(receiver, 194 reinterpret_cast<RawSmi*>(DartEntry::InvokeDynamic(function, args)));
196 function,
197 arguments,
198 kNoArgumentNames)));
199 EXPECT_EQ(kTestValue, retval.Value()); 195 EXPECT_EQ(kTestValue, retval.Value());
200 } 196 }
201 197
202 // Now try to resolve an instance function with invalid argument count. 198 // Now try to resolve an instance function with invalid argument count.
203 { 199 {
204 const int kNumPositionalArguments = 1; 200 const int kNumPositionalArguments = 1;
205 const int kNumNamedArguments = 0; 201 const int kNumNamedArguments = 0;
206 const Function& bad_function = Function::Handle( 202 const Function& bad_function = Function::Handle(
207 Resolver::ResolveDynamic(receiver, 203 Resolver::ResolveDynamic(receiver,
208 function_name, 204 function_name,
(...skipping 13 matching lines...) Expand all
222 super_function_name, 218 super_function_name,
223 kNumPositionalArguments, 219 kNumPositionalArguments,
224 kNumNamedArguments)); 220 kNumNamedArguments));
225 EXPECT(!super_function.IsNull()); 221 EXPECT(!super_function.IsNull());
226 } 222 }
227 } 223 }
228 224
229 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 225 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
230 226
231 } // namespace dart 227 } // namespace dart
OLDNEW
« vm/dart_entry.h ('K') | « vm/parser.cc ('k') | vm/stub_code_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698