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

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

Issue 10175011: Rework mirrors implementation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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
« no previous file with comments | « runtime/vm/dart_entry.h ('k') | runtime/vm/isolate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "vm/dart_entry.h" 5 #include "vm/dart_entry.h"
6 6
7 #include "vm/code_generator.h" 7 #include "vm/code_generator.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 #include "vm/resolver.h" 10 #include "vm/resolver.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 arguments.Add(&Integer::Handle(Integer::New(dest_port_id))); 214 arguments.Add(&Integer::Handle(Integer::New(dest_port_id)));
215 arguments.Add(&Integer::Handle(Integer::New(reply_port_id))); 215 arguments.Add(&Integer::Handle(Integer::New(reply_port_id)));
216 arguments.Add(&message); 216 arguments.Add(&message);
217 const Object& result = Object::Handle( 217 const Object& result = Object::Handle(
218 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames)); 218 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames));
219 ASSERT(result.IsNull() || result.IsError()); 219 ASSERT(result.IsNull() || result.IsError());
220 return result.raw(); 220 return result.raw();
221 } 221 }
222 222
223 223
224 RawObject* DartLibraryCalls::HandleMirrorsMessage(Dart_Port dest_port_id,
225 Dart_Port reply_port_id,
226 const Instance& message) {
227 Isolate* isolate = Isolate::Current();
228 // Create the reply port.
229 const Object& reply_port = Object::Handle(
230 DartLibraryCalls::NewSendPort(reply_port_id));
231 if (reply_port.IsError()) {
232 return reply_port.raw();
233 }
234
235 // Call _Mirrors.processCommand(message, reply_port).
236 const Library& lib =
237 Library::Handle(isolate->object_store()->mirrors_library());
238 const String& raw_class_name =
239 String::Handle(String::NewSymbol("_Mirrors"));
240 const String& private_key =
241 String::Handle(lib.private_key());
242 const String& class_name =
243 String::Handle(String::Concat(raw_class_name, private_key));
244 const String& function_name =
245 String::Handle(String::NewSymbol("processCommand"));
246 const int kNumArguments = 2;
247 const Array& kNoArgumentNames = Array::Handle();
248 const Function& function = Function::Handle(
249 Resolver::ResolveStatic(lib,
250 class_name,
251 function_name,
252 kNumArguments,
253 kNoArgumentNames,
254 Resolver::kIsQualified));
255 ASSERT(!function.IsNull());
256 GrowableArray<const Object*> arguments(kNumArguments);
257 arguments.Add(&message);
258 arguments.Add(&reply_port);
259 const Object& result = Object::Handle(
260 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames));
261 ASSERT(result.IsNull() || result.IsError());
262 return result.raw();
263 }
264
265
266 RawObject* DartLibraryCalls::NewSendPort(intptr_t port_id) { 224 RawObject* DartLibraryCalls::NewSendPort(intptr_t port_id) {
267 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); 225 Library& isolate_lib = Library::Handle(Library::IsolateLibrary());
268 ASSERT(!isolate_lib.IsNull()); 226 ASSERT(!isolate_lib.IsNull());
269 const String& public_class_name = 227 const String& public_class_name =
270 String::Handle(String::New("_SendPortImpl")); 228 String::Handle(String::New("_SendPortImpl"));
271 const String& class_name = 229 const String& class_name =
272 String::Handle(isolate_lib.PrivateName(public_class_name)); 230 String::Handle(isolate_lib.PrivateName(public_class_name));
273 const String& function_name = String::Handle(String::NewSymbol("_create")); 231 const String& function_name = String::Handle(String::NewSymbol("_create"));
274 const int kNumArguments = 1; 232 const int kNumArguments = 1;
275 const Array& kNoArgumentNames = Array::Handle(); 233 const Array& kNoArgumentNames = Array::Handle();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 const String& func_name = String::Handle(Field::GetterName(field_name)); 267 const String& func_name = String::Handle(Field::GetterName(field_name));
310 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name)); 268 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name));
311 ASSERT(!func.IsNull()); 269 ASSERT(!func.IsNull());
312 GrowableArray<const Object*> arguments; 270 GrowableArray<const Object*> arguments;
313 const Array& kNoArgumentNames = Array::Handle(); 271 const Array& kNoArgumentNames = Array::Handle();
314 return DartEntry::InvokeDynamic(port, func, arguments, kNoArgumentNames); 272 return DartEntry::InvokeDynamic(port, func, arguments, kNoArgumentNames);
315 } 273 }
316 274
317 275
318 } // namespace dart 276 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_entry.h ('k') | runtime/vm/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698