2011-10-05 05:20:07 +00:00
|
|
|
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
|
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "vm/dart_entry.h"
|
|
|
|
|
|
|
|
#include "vm/code_generator.h"
|
|
|
|
#include "vm/compiler.h"
|
|
|
|
#include "vm/object_store.h"
|
|
|
|
#include "vm/resolver.h"
|
|
|
|
#include "vm/stub_code.h"
|
2012-07-24 00:01:50 +00:00
|
|
|
#include "vm/symbols.h"
|
2011-10-05 05:20:07 +00:00
|
|
|
|
|
|
|
namespace dart {
|
|
|
|
|
2012-02-02 19:05:06 +00:00
|
|
|
RawObject* DartEntry::InvokeDynamic(
|
2011-10-05 05:20:07 +00:00
|
|
|
const Instance& receiver,
|
|
|
|
const Function& function,
|
2011-10-06 22:40:45 +00:00
|
|
|
const GrowableArray<const Object*>& arguments,
|
|
|
|
const Array& optional_arguments_names) {
|
2011-10-05 05:20:07 +00:00
|
|
|
// Get the entrypoint corresponding to the function specified, this
|
|
|
|
// will result in a compilation of the function if it is not already
|
|
|
|
// compiled.
|
|
|
|
if (!function.HasCode()) {
|
2012-02-02 19:05:06 +00:00
|
|
|
const Error& error = Error::Handle(Compiler::CompileFunction(function));
|
|
|
|
if (!error.IsNull()) {
|
|
|
|
return error.raw();
|
|
|
|
}
|
2011-10-05 05:20:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set up arguments to include the receiver as the first argument.
|
2011-10-06 22:40:45 +00:00
|
|
|
const int num_arguments = arguments.length() + 1;
|
|
|
|
GrowableArray<const Object*> args(num_arguments);
|
2011-10-05 05:20:07 +00:00
|
|
|
const Object& arg0 = Object::ZoneHandle(receiver.raw());
|
|
|
|
args.Add(&arg0);
|
2011-10-06 22:40:45 +00:00
|
|
|
for (int i = 1; i < num_arguments; i++) {
|
|
|
|
args.Add(arguments[i - 1]);
|
2011-10-05 05:20:07 +00:00
|
|
|
}
|
|
|
|
// Now Call the invoke stub which will invoke the dart function.
|
|
|
|
invokestub entrypoint = reinterpret_cast<invokestub>(
|
|
|
|
StubCode::InvokeDartCodeEntryPoint());
|
|
|
|
const Context& context =
|
|
|
|
Context::ZoneHandle(Isolate::Current()->object_store()->empty_context());
|
|
|
|
ASSERT(context.isolate() == Isolate::Current());
|
2012-02-28 01:31:44 +00:00
|
|
|
const Code& code = Code::Handle(function.CurrentCode());
|
|
|
|
ASSERT(!code.IsNull());
|
2012-12-05 12:05:57 +00:00
|
|
|
const Array& arg_descriptor =
|
|
|
|
Array::Handle(ArgumentsDescriptor::New(num_arguments,
|
|
|
|
optional_arguments_names));
|
|
|
|
return entrypoint(code.EntryPoint(), arg_descriptor, args.data(), context);
|
2011-10-05 05:20:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-02 19:05:06 +00:00
|
|
|
RawObject* DartEntry::InvokeStatic(
|
2011-10-06 22:40:45 +00:00
|
|
|
const Function& function,
|
|
|
|
const GrowableArray<const Object*>& arguments,
|
|
|
|
const Array& optional_arguments_names) {
|
2011-10-05 05:20:07 +00:00
|
|
|
// Get the entrypoint corresponding to the function specified, this
|
|
|
|
// will result in a compilation of the function if it is not already
|
|
|
|
// compiled.
|
|
|
|
ASSERT(!function.IsNull());
|
|
|
|
if (!function.HasCode()) {
|
2012-02-02 19:05:06 +00:00
|
|
|
const Error& error = Error::Handle(Compiler::CompileFunction(function));
|
|
|
|
if (!error.IsNull()) {
|
|
|
|
return error.raw();
|
|
|
|
}
|
2011-10-05 05:20:07 +00:00
|
|
|
}
|
|
|
|
// Now Call the invoke stub which will invoke the dart function.
|
|
|
|
invokestub entrypoint = reinterpret_cast<invokestub>(
|
|
|
|
StubCode::InvokeDartCodeEntryPoint());
|
|
|
|
const Context& context =
|
|
|
|
Context::ZoneHandle(Isolate::Current()->object_store()->empty_context());
|
|
|
|
ASSERT(context.isolate() == Isolate::Current());
|
2012-02-28 01:31:44 +00:00
|
|
|
const Code& code = Code::Handle(function.CurrentCode());
|
|
|
|
ASSERT(!code.IsNull());
|
2012-12-05 12:05:57 +00:00
|
|
|
const Array& arg_descriptor =
|
|
|
|
Array::Handle(ArgumentsDescriptor::New(arguments.length(),
|
|
|
|
optional_arguments_names));
|
|
|
|
return entrypoint(code.EntryPoint(), arg_descriptor, arguments.data(),
|
|
|
|
context);
|
2011-10-05 05:20:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-02 19:05:06 +00:00
|
|
|
RawObject* DartEntry::InvokeClosure(
|
2012-10-11 20:34:08 +00:00
|
|
|
const Instance& closure,
|
2011-10-06 22:40:45 +00:00
|
|
|
const GrowableArray<const Object*>& arguments,
|
|
|
|
const Array& optional_arguments_names) {
|
2011-10-05 05:20:07 +00:00
|
|
|
// Get the entrypoint corresponding to the closure specified, this
|
|
|
|
// will result in a compilation of the closure if it is not already
|
|
|
|
// compiled.
|
|
|
|
ASSERT(Class::Handle(closure.clazz()).signature_function() != Object::null());
|
2012-10-11 20:34:08 +00:00
|
|
|
const Function& function = Function::Handle(Closure::function(closure));
|
|
|
|
const Context& context = Context::Handle(Closure::context(closure));
|
2011-10-05 05:20:07 +00:00
|
|
|
ASSERT(!function.IsNull());
|
|
|
|
if (!function.HasCode()) {
|
2012-02-02 19:05:06 +00:00
|
|
|
const Error& error = Error::Handle(Compiler::CompileFunction(function));
|
|
|
|
if (!error.IsNull()) {
|
|
|
|
return error.raw();
|
|
|
|
}
|
2011-10-05 05:20:07 +00:00
|
|
|
}
|
2012-11-08 18:28:07 +00:00
|
|
|
// Set up arguments to include the closure as the first argument.
|
|
|
|
const int num_arguments = arguments.length() + 1;
|
|
|
|
GrowableArray<const Object*> args(num_arguments);
|
|
|
|
const Object& arg0 = Object::ZoneHandle(closure.raw());
|
|
|
|
args.Add(&arg0);
|
|
|
|
for (int i = 1; i < num_arguments; i++) {
|
|
|
|
args.Add(arguments[i - 1]);
|
|
|
|
}
|
2011-10-05 05:20:07 +00:00
|
|
|
// Now Call the invoke stub which will invoke the closure.
|
|
|
|
invokestub entrypoint = reinterpret_cast<invokestub>(
|
|
|
|
StubCode::InvokeDartCodeEntryPoint());
|
|
|
|
ASSERT(context.isolate() == Isolate::Current());
|
2012-02-28 01:31:44 +00:00
|
|
|
const Code& code = Code::Handle(function.CurrentCode());
|
|
|
|
ASSERT(!code.IsNull());
|
2012-12-05 12:05:57 +00:00
|
|
|
const Array& arg_descriptor =
|
|
|
|
Array::Handle(ArgumentsDescriptor::New(num_arguments,
|
|
|
|
optional_arguments_names));
|
|
|
|
return entrypoint(code.EntryPoint(), arg_descriptor, args.data(), context);
|
2011-10-05 05:20:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-05 19:50:50 +00:00
|
|
|
ArgumentsDescriptor::ArgumentsDescriptor(const Array& array)
|
|
|
|
: array_(array) {
|
2012-12-05 12:05:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
intptr_t ArgumentsDescriptor::Count() const {
|
|
|
|
return Smi::CheckedHandle(array_.At(kCountIndex)).Value();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
intptr_t ArgumentsDescriptor::PositionalCount() const {
|
|
|
|
return Smi::CheckedHandle(array_.At(kPositionalCountIndex)).Value();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-07 17:59:53 +00:00
|
|
|
bool ArgumentsDescriptor::MatchesNameAt(intptr_t index,
|
|
|
|
const String& other) const {
|
|
|
|
const intptr_t offset = kFirstNamedEntryIndex +
|
|
|
|
(index * kNamedEntrySize) +
|
|
|
|
kNameOffset;
|
|
|
|
return array_.At(offset) == other.raw();
|
2012-12-05 12:05:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
intptr_t ArgumentsDescriptor::count_offset() {
|
|
|
|
return Array::data_offset() + (kCountIndex * kWordSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
intptr_t ArgumentsDescriptor::positional_count_offset() {
|
|
|
|
return Array::data_offset() + (kPositionalCountIndex * kWordSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
intptr_t ArgumentsDescriptor::first_named_entry_offset() {
|
|
|
|
return Array::data_offset() + (kFirstNamedEntryIndex * kWordSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RawArray* ArgumentsDescriptor::New(intptr_t num_arguments,
|
|
|
|
const Array& optional_arguments_names) {
|
2012-06-26 17:43:44 +00:00
|
|
|
const intptr_t num_named_args =
|
|
|
|
optional_arguments_names.IsNull() ? 0 : optional_arguments_names.Length();
|
|
|
|
const intptr_t num_pos_args = num_arguments - num_named_args;
|
|
|
|
|
2012-12-05 12:05:57 +00:00
|
|
|
// Build the arguments descriptor array, which consists of the total
|
|
|
|
// argument count; the positional argument count; a sequence of (name,
|
|
|
|
// position) pairs, sorted by name, for each named optional argument; and
|
|
|
|
// a terminating null to simplify iterating in generated code.
|
|
|
|
const intptr_t descriptor_len = LengthFor(num_named_args);
|
|
|
|
Array& descriptor = Array::Handle(Array::New(descriptor_len, Heap::kOld));
|
2012-06-26 17:43:44 +00:00
|
|
|
|
|
|
|
// Set total number of passed arguments.
|
2012-12-05 12:05:57 +00:00
|
|
|
descriptor.SetAt(kCountIndex, Smi::Handle(Smi::New(num_arguments)));
|
2012-06-26 17:43:44 +00:00
|
|
|
// Set number of positional arguments.
|
2012-12-05 12:05:57 +00:00
|
|
|
descriptor.SetAt(kPositionalCountIndex, Smi::Handle(Smi::New(num_pos_args)));
|
|
|
|
// Set alphabetically sorted entries for named arguments.
|
2012-06-26 17:43:44 +00:00
|
|
|
String& name = String::Handle();
|
|
|
|
Smi& pos = Smi::Handle();
|
2012-12-05 12:05:57 +00:00
|
|
|
for (intptr_t i = 0; i < num_named_args; i++) {
|
2012-06-26 17:43:44 +00:00
|
|
|
name ^= optional_arguments_names.At(i);
|
|
|
|
pos = Smi::New(num_pos_args + i);
|
2012-12-05 12:05:57 +00:00
|
|
|
intptr_t insert_index = kFirstNamedEntryIndex + (kNamedEntrySize * i);
|
2012-06-26 17:43:44 +00:00
|
|
|
// Shift already inserted pairs with "larger" names.
|
2012-12-05 12:05:57 +00:00
|
|
|
String& previous_name = String::Handle();
|
|
|
|
Smi& previous_pos = Smi::Handle();
|
|
|
|
while (insert_index > kFirstNamedEntryIndex) {
|
|
|
|
intptr_t previous_index = insert_index - kNamedEntrySize;
|
|
|
|
previous_name ^= descriptor.At(previous_index + kNameOffset);
|
|
|
|
intptr_t result = name.CompareTo(previous_name);
|
2012-06-26 17:43:44 +00:00
|
|
|
ASSERT(result != 0); // Duplicate argument names checked in parser.
|
|
|
|
if (result > 0) break;
|
2012-12-05 12:05:57 +00:00
|
|
|
previous_pos ^= descriptor.At(previous_index + kPositionOffset);
|
|
|
|
descriptor.SetAt(insert_index + kNameOffset, previous_name);
|
|
|
|
descriptor.SetAt(insert_index + kPositionOffset, previous_pos);
|
|
|
|
insert_index = previous_index;
|
2012-06-26 17:43:44 +00:00
|
|
|
}
|
|
|
|
// Insert pair in descriptor array.
|
2012-12-05 12:05:57 +00:00
|
|
|
descriptor.SetAt(insert_index + kNameOffset, name);
|
|
|
|
descriptor.SetAt(insert_index + kPositionOffset, pos);
|
2012-06-26 17:43:44 +00:00
|
|
|
}
|
|
|
|
// Set terminating null.
|
|
|
|
descriptor.SetAt(descriptor_len - 1, Object::Handle());
|
|
|
|
|
|
|
|
// Share the immutable descriptor when possible by canonicalizing it.
|
|
|
|
descriptor.MakeImmutable();
|
|
|
|
descriptor ^= descriptor.Canonicalize();
|
2012-12-05 12:05:57 +00:00
|
|
|
return descriptor.raw();
|
2012-06-26 17:43:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-02 19:05:06 +00:00
|
|
|
RawObject* DartLibraryCalls::ExceptionCreate(
|
2012-03-13 22:05:08 +00:00
|
|
|
const Library& lib,
|
2011-10-05 05:20:07 +00:00
|
|
|
const String& class_name,
|
|
|
|
const GrowableArray<const Object*>& arguments) {
|
2012-10-24 06:17:21 +00:00
|
|
|
const Class& cls = Class::Handle(lib.LookupClassAllowPrivate(class_name));
|
2011-10-05 05:20:07 +00:00
|
|
|
ASSERT(!cls.IsNull());
|
|
|
|
// For now, we only support a non-parameterized or raw type.
|
|
|
|
const Instance& exception_object = Instance::Handle(Instance::New(cls));
|
2011-11-02 17:19:15 +00:00
|
|
|
GrowableArray<const Object*> constructor_arguments(arguments.length() + 2);
|
2011-10-05 05:20:07 +00:00
|
|
|
constructor_arguments.Add(&exception_object);
|
2011-11-02 17:19:15 +00:00
|
|
|
constructor_arguments.Add(&Smi::Handle(Smi::New(Function::kCtorPhaseAll)));
|
2011-10-05 05:20:07 +00:00
|
|
|
constructor_arguments.AddArray(arguments);
|
|
|
|
|
2012-12-10 18:24:34 +00:00
|
|
|
String& constructor_name = String::Handle(
|
|
|
|
String::Concat(class_name, Symbols::DotHandle()));
|
2011-10-05 05:20:07 +00:00
|
|
|
Function& constructor =
|
|
|
|
Function::Handle(cls.LookupConstructor(constructor_name));
|
|
|
|
ASSERT(!constructor.IsNull());
|
2011-10-06 22:40:45 +00:00
|
|
|
const Array& kNoArgumentNames = Array::Handle();
|
2012-02-02 19:05:06 +00:00
|
|
|
const Object& retval = Object::Handle(
|
|
|
|
DartEntry::InvokeStatic(constructor, constructor_arguments,
|
|
|
|
kNoArgumentNames));
|
|
|
|
ASSERT(retval.IsNull() || retval.IsError());
|
|
|
|
if (retval.IsError()) {
|
|
|
|
return retval.raw();
|
|
|
|
}
|
2011-10-05 05:20:07 +00:00
|
|
|
return exception_object.raw();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-02 19:05:06 +00:00
|
|
|
RawObject* DartLibraryCalls::ToString(const Instance& receiver) {
|
2011-10-05 05:20:07 +00:00
|
|
|
const String& function_name =
|
2012-07-24 00:01:50 +00:00
|
|
|
String::Handle(Symbols::New("toString"));
|
2011-10-05 05:20:07 +00:00
|
|
|
GrowableArray<const Object*> arguments;
|
|
|
|
const int kNumArguments = 1; // Receiver.
|
|
|
|
const int kNumNamedArguments = 0; // None.
|
2011-10-06 22:40:45 +00:00
|
|
|
const Array& kNoArgumentNames = Array::Handle();
|
2011-10-05 05:20:07 +00:00
|
|
|
const Function& function = Function::Handle(
|
|
|
|
Resolver::ResolveDynamic(receiver,
|
|
|
|
function_name,
|
|
|
|
kNumArguments,
|
|
|
|
kNumNamedArguments));
|
|
|
|
ASSERT(!function.IsNull());
|
2012-02-02 19:05:06 +00:00
|
|
|
const Object& result = Object::Handle(
|
2011-10-06 22:40:45 +00:00
|
|
|
DartEntry::InvokeDynamic(receiver,
|
|
|
|
function,
|
|
|
|
arguments,
|
|
|
|
kNoArgumentNames));
|
2012-02-02 19:05:06 +00:00
|
|
|
ASSERT(result.IsInstance() || result.IsError());
|
2011-10-05 05:20:07 +00:00
|
|
|
return result.raw();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-02 19:05:06 +00:00
|
|
|
RawObject* DartLibraryCalls::Equals(const Instance& left,
|
|
|
|
const Instance& right) {
|
2012-10-22 23:23:57 +00:00
|
|
|
const String& function_name = String::Handle(Symbols::EqualOperator());
|
2011-10-05 05:20:07 +00:00
|
|
|
GrowableArray<const Object*> arguments;
|
|
|
|
arguments.Add(&right);
|
|
|
|
const int kNumArguments = 2;
|
|
|
|
const int kNumNamedArguments = 0;
|
2011-10-06 22:40:45 +00:00
|
|
|
const Array& kNoArgumentNames = Array::Handle();
|
2011-10-05 05:20:07 +00:00
|
|
|
const Function& function = Function::Handle(
|
|
|
|
Resolver::ResolveDynamic(left,
|
|
|
|
function_name,
|
|
|
|
kNumArguments,
|
|
|
|
kNumNamedArguments));
|
|
|
|
ASSERT(!function.IsNull());
|
2012-02-02 19:05:06 +00:00
|
|
|
const Object& result = Object::Handle(
|
2011-10-06 22:40:45 +00:00
|
|
|
DartEntry::InvokeDynamic(left, function, arguments, kNoArgumentNames));
|
2012-02-02 19:05:06 +00:00
|
|
|
ASSERT(result.IsInstance() || result.IsError());
|
2011-10-05 05:20:07 +00:00
|
|
|
return result.raw();
|
|
|
|
}
|
|
|
|
|
2011-12-14 18:27:58 +00:00
|
|
|
|
|
|
|
RawObject* DartLibraryCalls::HandleMessage(Dart_Port dest_port_id,
|
|
|
|
Dart_Port reply_port_id,
|
|
|
|
const Instance& message) {
|
2012-02-27 22:50:44 +00:00
|
|
|
Library& isolate_lib = Library::Handle(Library::IsolateLibrary());
|
|
|
|
ASSERT(!isolate_lib.IsNull());
|
2012-03-07 21:15:58 +00:00
|
|
|
const String& public_class_name =
|
2012-07-24 00:01:50 +00:00
|
|
|
String::Handle(Symbols::New("_ReceivePortImpl"));
|
2011-12-14 18:27:58 +00:00
|
|
|
const String& class_name =
|
2012-03-07 21:15:58 +00:00
|
|
|
String::Handle(isolate_lib.PrivateName(public_class_name));
|
2011-12-14 18:27:58 +00:00
|
|
|
const String& function_name =
|
2012-07-24 00:01:50 +00:00
|
|
|
String::Handle(Symbols::New("_handleMessage"));
|
2011-12-14 18:27:58 +00:00
|
|
|
const int kNumArguments = 3;
|
|
|
|
const Array& kNoArgumentNames = Array::Handle();
|
|
|
|
const Function& function = Function::Handle(
|
2012-02-27 22:50:44 +00:00
|
|
|
Resolver::ResolveStatic(isolate_lib,
|
2011-12-14 18:27:58 +00:00
|
|
|
class_name,
|
|
|
|
function_name,
|
|
|
|
kNumArguments,
|
|
|
|
kNoArgumentNames,
|
|
|
|
Resolver::kIsQualified));
|
|
|
|
GrowableArray<const Object*> arguments(kNumArguments);
|
|
|
|
arguments.Add(&Integer::Handle(Integer::New(dest_port_id)));
|
|
|
|
arguments.Add(&Integer::Handle(Integer::New(reply_port_id)));
|
|
|
|
arguments.Add(&message);
|
|
|
|
const Object& result = Object::Handle(
|
|
|
|
DartEntry::InvokeStatic(function, arguments, kNoArgumentNames));
|
2012-02-02 19:05:06 +00:00
|
|
|
ASSERT(result.IsNull() || result.IsError());
|
2011-12-14 18:27:58 +00:00
|
|
|
return result.raw();
|
|
|
|
}
|
|
|
|
|
2012-03-12 23:51:03 +00:00
|
|
|
|
|
|
|
RawObject* DartLibraryCalls::NewSendPort(intptr_t port_id) {
|
|
|
|
Library& isolate_lib = Library::Handle(Library::IsolateLibrary());
|
|
|
|
ASSERT(!isolate_lib.IsNull());
|
|
|
|
const String& public_class_name =
|
|
|
|
String::Handle(String::New("_SendPortImpl"));
|
|
|
|
const String& class_name =
|
|
|
|
String::Handle(isolate_lib.PrivateName(public_class_name));
|
2012-07-24 00:01:50 +00:00
|
|
|
const String& function_name = String::Handle(Symbols::New("_create"));
|
2012-03-12 23:51:03 +00:00
|
|
|
const int kNumArguments = 1;
|
|
|
|
const Array& kNoArgumentNames = Array::Handle();
|
|
|
|
const Function& function = Function::Handle(
|
|
|
|
Resolver::ResolveStatic(isolate_lib,
|
|
|
|
class_name,
|
|
|
|
function_name,
|
|
|
|
kNumArguments,
|
|
|
|
kNoArgumentNames,
|
|
|
|
Resolver::kIsQualified));
|
|
|
|
GrowableArray<const Object*> arguments(kNumArguments);
|
|
|
|
arguments.Add(&Integer::Handle(Integer::New(port_id)));
|
|
|
|
return DartEntry::InvokeStatic(function, arguments, kNoArgumentNames);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RawObject* DartLibraryCalls::MapSetAt(const Instance& map,
|
|
|
|
const Instance& key,
|
|
|
|
const Instance& value) {
|
2012-12-01 00:34:19 +00:00
|
|
|
String& name = String::Handle(Symbols::AssignIndexToken());
|
2012-03-12 23:51:03 +00:00
|
|
|
const Function& function = Function::Handle(
|
|
|
|
Resolver::ResolveDynamic(map, name, 3, 0));
|
|
|
|
ASSERT(!function.IsNull());
|
|
|
|
GrowableArray<const Object*> args(2);
|
|
|
|
args.Add(&key);
|
|
|
|
args.Add(&value);
|
|
|
|
const Array& kNoArgumentNames = Array::Handle();
|
|
|
|
const Object& result = Object::Handle(
|
|
|
|
DartEntry::InvokeDynamic(map, function, args, kNoArgumentNames));
|
|
|
|
return result.raw();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RawObject* DartLibraryCalls::PortGetId(const Instance& port) {
|
2012-07-24 00:01:50 +00:00
|
|
|
const String& field_name = String::Handle(Symbols::New("_id"));
|
2012-03-12 23:51:03 +00:00
|
|
|
const Class& cls = Class::Handle(port.clazz());
|
|
|
|
const String& func_name = String::Handle(Field::GetterName(field_name));
|
|
|
|
const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name));
|
|
|
|
ASSERT(!func.IsNull());
|
|
|
|
GrowableArray<const Object*> arguments;
|
|
|
|
const Array& kNoArgumentNames = Array::Handle();
|
|
|
|
return DartEntry::InvokeDynamic(port, func, arguments, kNoArgumentNames);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-05 05:20:07 +00:00
|
|
|
} // namespace dart
|