OLD | NEW |
---|---|
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/object.h" | 5 #include "vm/object.h" |
6 | 6 |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 #include "vm/assert.h" | 8 #include "vm/assert.h" |
9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
(...skipping 2699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2710 } | 2710 } |
2711 } | 2711 } |
2712 if (!found_param_name) { | 2712 if (!found_param_name) { |
2713 return false; | 2713 return false; |
2714 } | 2714 } |
2715 } | 2715 } |
2716 return true; | 2716 return true; |
2717 } | 2717 } |
2718 | 2718 |
2719 | 2719 |
2720 bool Function::IsImplicitClosureFunction() const { | |
2721 if (kind() != RawFunction::kClosureFunction) { | |
2722 return false; | |
2723 } | |
siva
2011/10/11 21:00:46
if (!IsClosureFunction()) {
return false;
}
ins
regis
2011/10/11 23:40:19
Done.
| |
2724 const Function& parent = Function::Handle(parent_function()); | |
2725 return parent.raw_ptr()->implicit_closure_function_ == raw(); | |
2726 } | |
2727 | |
2728 | |
2720 RawFunction* Function::New() { | 2729 RawFunction* Function::New() { |
2721 const Class& function_class = Class::Handle(Object::function_class()); | 2730 const Class& function_class = Class::Handle(Object::function_class()); |
2722 RawObject* raw = Object::Allocate(function_class, | 2731 RawObject* raw = Object::Allocate(function_class, |
2723 Function::InstanceSize(), | 2732 Function::InstanceSize(), |
2724 Heap::kOld); | 2733 Heap::kOld); |
2725 return reinterpret_cast<RawFunction*>(raw); | 2734 return reinterpret_cast<RawFunction*>(raw); |
2726 } | 2735 } |
2727 | 2736 |
2728 | 2737 |
2729 RawFunction* Function::New(const String& name, | 2738 RawFunction* Function::New(const String& name, |
(...skipping 20 matching lines...) Expand all Loading... | |
2750 | 2759 |
2751 RawFunction* Function::NewClosureFunction(const String& name, | 2760 RawFunction* Function::NewClosureFunction(const String& name, |
2752 const Function& parent, | 2761 const Function& parent, |
2753 intptr_t token_index) { | 2762 intptr_t token_index) { |
2754 ASSERT(!parent.IsNull()); | 2763 ASSERT(!parent.IsNull()); |
2755 const Class& parent_class = Class::Handle(parent.owner()); | 2764 const Class& parent_class = Class::Handle(parent.owner()); |
2756 ASSERT(!parent_class.IsNull()); | 2765 ASSERT(!parent_class.IsNull()); |
2757 const Function& result = Function::Handle( | 2766 const Function& result = Function::Handle( |
2758 Function::New(name, | 2767 Function::New(name, |
2759 RawFunction::kClosureFunction, | 2768 RawFunction::kClosureFunction, |
2760 /* is_static = */ true, | 2769 /* is_static = */ parent.is_static(), |
2761 /* is_const = */ false, | 2770 /* is_const = */ false, |
2762 token_index)); | 2771 token_index)); |
2763 result.set_parent_function(parent); | 2772 result.set_parent_function(parent); |
2764 result.set_owner(parent_class); | 2773 result.set_owner(parent_class); |
2765 return result.raw(); | 2774 return result.raw(); |
2766 } | 2775 } |
2767 | 2776 |
2768 | 2777 |
2769 RawFunction* Function::ImplicitClosureFunction() const { | 2778 RawFunction* Function::ImplicitClosureFunction() const { |
2770 // Return the existing implicit closure function if any. | 2779 // Return the existing implicit closure function if any. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2823 signature_class = Class::NewSignatureClass(signature, | 2832 signature_class = Class::NewSignatureClass(signature, |
2824 closure_function, | 2833 closure_function, |
2825 script, | 2834 script, |
2826 token_index()); | 2835 token_index()); |
2827 library.AddClass(signature_class); | 2836 library.AddClass(signature_class); |
2828 } | 2837 } |
2829 ASSERT(!Function::Handle(signature_class.signature_function()).IsNull()); | 2838 ASSERT(!Function::Handle(signature_class.signature_function()).IsNull()); |
2830 ASSERT(Class::Handle(closure_function.signature_class()).IsNull()); | 2839 ASSERT(Class::Handle(closure_function.signature_class()).IsNull()); |
2831 closure_function.set_signature_class(signature_class); | 2840 closure_function.set_signature_class(signature_class); |
2832 set_implicit_closure_function(closure_function); | 2841 set_implicit_closure_function(closure_function); |
2842 ASSERT(closure_function.IsImplicitClosureFunction()); | |
2833 return closure_function.raw(); | 2843 return closure_function.raw(); |
2834 } | 2844 } |
2835 | 2845 |
2836 | 2846 |
2837 template<typename T> | 2847 template<typename T> |
2838 static RawArray* NewArray(const GrowableArray<T*>& objs) { | 2848 static RawArray* NewArray(const GrowableArray<T*>& objs) { |
2839 Array& a = Array::Handle(Array::New(objs.length(), Heap::kOld)); | 2849 Array& a = Array::Handle(Array::New(objs.length(), Heap::kOld)); |
2840 for (int i = 0; i < objs.length(); i++) { | 2850 for (int i = 0; i < objs.length(); i++) { |
2841 a.SetAt(i, *objs[i]); | 2851 a.SetAt(i, *objs[i]); |
2842 } | 2852 } |
(...skipping 3441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6284 const String& str = String::Handle(pattern()); | 6294 const String& str = String::Handle(pattern()); |
6285 const char* format = "JSRegExp: pattern=%s flags=%s"; | 6295 const char* format = "JSRegExp: pattern=%s flags=%s"; |
6286 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); | 6296 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); |
6287 char* chars = reinterpret_cast<char*>( | 6297 char* chars = reinterpret_cast<char*>( |
6288 Isolate::Current()->current_zone()->Allocate(len + 1)); | 6298 Isolate::Current()->current_zone()->Allocate(len + 1)); |
6289 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); | 6299 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); |
6290 return chars; | 6300 return chars; |
6291 } | 6301 } |
6292 | 6302 |
6293 } // namespace dart | 6303 } // namespace dart |
OLD | NEW |