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

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

Issue 22425006: Fix equality of implicit closures in the Dart VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: new simpler approach Created 7 years, 4 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
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 "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 1829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 false, // Not const. 1840 false, // Not const.
1841 false, // Not abstract. 1841 false, // Not abstract.
1842 false, // Not external. 1842 false, // Not external.
1843 *this, 1843 *this,
1844 0)); // No token position. 1844 0)); // No token position.
1845 ArgumentsDescriptor desc(args_desc); 1845 ArgumentsDescriptor desc(args_desc);
1846 invocation.set_num_fixed_parameters(desc.PositionalCount()); 1846 invocation.set_num_fixed_parameters(desc.PositionalCount());
1847 invocation.SetNumOptionalParameters(desc.NamedCount(), 1847 invocation.SetNumOptionalParameters(desc.NamedCount(),
1848 false); // Not positional. 1848 false); // Not positional.
1849 invocation.set_parameter_types(Array::Handle(Array::New(desc.Count(), 1849 invocation.set_parameter_types(Array::Handle(Array::New(desc.Count(),
1850 Heap::kOld))); 1850 Heap::kOld)));
1851 invocation.set_parameter_names(Array::Handle(Array::New(desc.Count(), 1851 invocation.set_parameter_names(Array::Handle(Array::New(desc.Count(),
1852 Heap::kOld))); 1852 Heap::kOld)));
1853 // Receiver. 1853 // Receiver.
1854 invocation.SetParameterTypeAt(0, Type::Handle(Type::DynamicType())); 1854 invocation.SetParameterTypeAt(0, Type::Handle(Type::DynamicType()));
1855 invocation.SetParameterNameAt(0, Symbols::This()); 1855 invocation.SetParameterNameAt(0, Symbols::This());
1856 // Remaining positional parameters. 1856 // Remaining positional parameters.
1857 intptr_t i = 1; 1857 intptr_t i = 1;
1858 for (; i < desc.PositionalCount(); i++) { 1858 for (; i < desc.PositionalCount(); i++) {
1859 invocation.SetParameterTypeAt(i, Type::Handle(Type::DynamicType())); 1859 invocation.SetParameterTypeAt(i, Type::Handle(Type::DynamicType()));
1860 char name[64]; 1860 char name[64];
1861 OS::SNPrint(name, 64, ":p%"Pd, i); 1861 OS::SNPrint(name, 64, ":p%"Pd, i);
1862 invocation.SetParameterNameAt(i, String::Handle(Symbols::New(name))); 1862 invocation.SetParameterNameAt(i, String::Handle(Symbols::New(name)));
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
2075 result.set_token_pos(token_pos); 2075 result.set_token_pos(token_pos);
2076 return result.raw(); 2076 return result.raw();
2077 } 2077 }
2078 2078
2079 2079
2080 RawClass* Class::NewSignatureClass(const String& name, 2080 RawClass* Class::NewSignatureClass(const String& name,
2081 const Function& signature_function, 2081 const Function& signature_function,
2082 const Script& script, 2082 const Script& script,
2083 intptr_t token_pos) { 2083 intptr_t token_pos) {
2084 const Class& result = Class::Handle(New(name, script, token_pos)); 2084 const Class& result = Class::Handle(New(name, script, token_pos));
2085 const Type& super_type = Type::Handle(Type::ObjectType());
2086 ASSERT(!super_type.IsNull());
2087 // Instances of a signature class can only be closures. 2085 // Instances of a signature class can only be closures.
2088 result.set_instance_size(Closure::InstanceSize()); 2086 result.set_instance_size(Closure::InstanceSize());
2089 result.set_next_field_offset(Closure::InstanceSize()); 2087 result.set_next_field_offset(Closure::InstanceSize());
2090 result.set_super_type(super_type); 2088 // Signature classes extend the DartFunction class.
2089 result.set_super_type(Type::Handle(Type::Function()));
2091 result.set_is_synthesized_class(); 2090 result.set_is_synthesized_class();
2092 result.set_type_arguments_field_offset(Closure::type_arguments_offset()); 2091 result.set_type_arguments_field_offset(Closure::type_arguments_offset());
2093 // Implements interface "Function".
2094 const Type& function_type = Type::Handle(Type::Function());
2095 const Array& interfaces = Array::Handle(Array::New(1, Heap::kOld));
2096 interfaces.SetAt(0, function_type);
2097 result.set_interfaces(interfaces);
2098 if (!signature_function.IsNull()) { 2092 if (!signature_function.IsNull()) {
2099 result.PatchSignatureFunction(signature_function); 2093 result.PatchSignatureFunction(signature_function);
2100 } 2094 }
2101 return result.raw(); 2095 return result.raw();
2102 } 2096 }
2103 2097
2104 2098
2105 void Class::PatchSignatureFunction(const Function& signature_function) const { 2099 void Class::PatchSignatureFunction(const Function& signature_function) const {
2106 ASSERT(!signature_function.IsNull()); 2100 ASSERT(!signature_function.IsNull());
2107 const Class& owner_class = Class::Handle(signature_function.Owner()); 2101 const Class& owner_class = Class::Handle(signature_function.Owner());
(...skipping 12464 matching lines...) Expand 10 before | Expand all | Expand 10 after
14572 } 14566 }
14573 14567
14574 14568
14575 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 14569 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
14576 stream->OpenObject(); 14570 stream->OpenObject();
14577 stream->CloseObject(); 14571 stream->CloseObject();
14578 } 14572 }
14579 14573
14580 14574
14581 } // namespace dart 14575 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698