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 "vm/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 6469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6480 Instance::Handle(isolate, Closure::New(*this, context, Heap::kOld)); | 6480 Instance::Handle(isolate, Closure::New(*this, context, Heap::kOld)); |
6481 const char* error_str = NULL; | 6481 const char* error_str = NULL; |
6482 closure ^= closure.CheckAndCanonicalize(&error_str); | 6482 closure ^= closure.CheckAndCanonicalize(&error_str); |
6483 ASSERT(!closure.IsNull()); | 6483 ASSERT(!closure.IsNull()); |
6484 set_implicit_static_closure(closure); | 6484 set_implicit_static_closure(closure); |
6485 } | 6485 } |
6486 return implicit_static_closure(); | 6486 return implicit_static_closure(); |
6487 } | 6487 } |
6488 | 6488 |
6489 | 6489 |
| 6490 RawInstance* Function::ImplicitInstanceClosure(const Instance& receiver) const { |
| 6491 ASSERT(IsImplicitClosureFunction()); |
| 6492 const Class& cls = Class::Handle(signature_class()); |
| 6493 const Context& context = Context::Handle(Context::New(1)); |
| 6494 context.SetAt(0, receiver); |
| 6495 const Instance& result = Instance::Handle(Closure::New(*this, context)); |
| 6496 if (cls.NumTypeArguments() > 0) { |
| 6497 const TypeArguments& type_arguments = |
| 6498 TypeArguments::Handle(receiver.GetTypeArguments()); |
| 6499 result.SetTypeArguments(type_arguments); |
| 6500 } |
| 6501 return result.raw(); |
| 6502 } |
| 6503 |
| 6504 |
6490 RawString* Function::BuildSignature(bool instantiate, | 6505 RawString* Function::BuildSignature(bool instantiate, |
6491 NameVisibility name_visibility, | 6506 NameVisibility name_visibility, |
6492 const TypeArguments& instantiator) const { | 6507 const TypeArguments& instantiator) const { |
6493 const GrowableObjectArray& pieces = | 6508 const GrowableObjectArray& pieces = |
6494 GrowableObjectArray::Handle(GrowableObjectArray::New()); | 6509 GrowableObjectArray::Handle(GrowableObjectArray::New()); |
6495 String& name = String::Handle(); | 6510 String& name = String::Handle(); |
6496 if (!instantiate && !is_static() && (name_visibility == kInternalName)) { | 6511 if (!instantiate && !is_static() && (name_visibility == kInternalName)) { |
6497 // Prefix the signature with its signature class and type parameters, if any | 6512 // Prefix the signature with its signature class and type parameters, if any |
6498 // (e.g. "Map<K, V>(K) => bool"). In case of a function type alias, the | 6513 // (e.g. "Map<K, V>(K) => bool"). In case of a function type alias, the |
6499 // signature class name is the alias name. | 6514 // signature class name is the alias name. |
(...skipping 14490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20990 return tag_label.ToCString(); | 21005 return tag_label.ToCString(); |
20991 } | 21006 } |
20992 | 21007 |
20993 | 21008 |
20994 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21009 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20995 Instance::PrintJSONImpl(stream, ref); | 21010 Instance::PrintJSONImpl(stream, ref); |
20996 } | 21011 } |
20997 | 21012 |
20998 | 21013 |
20999 } // namespace dart | 21014 } // namespace dart |
OLD | NEW |