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/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
(...skipping 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1429 Field& field = Field::Handle(); | 1429 Field& field = Field::Handle(); |
1430 for (intptr_t i = 0; i < field_array.Length(); ++i) { | 1430 for (intptr_t i = 0; i < field_array.Length(); ++i) { |
1431 field ^= field_array.At(i); | 1431 field ^= field_array.At(i); |
1432 if (!field.is_static()) { | 1432 if (!field.is_static()) { |
1433 return true; | 1433 return true; |
1434 } | 1434 } |
1435 } | 1435 } |
1436 return false; | 1436 return false; |
1437 } | 1437 } |
1438 | 1438 |
| 1439 |
1439 void Class::SetFunctions(const Array& value) const { | 1440 void Class::SetFunctions(const Array& value) const { |
1440 ASSERT(!value.IsNull()); | 1441 ASSERT(!value.IsNull()); |
1441 #if defined(DEBUG) | 1442 #if defined(DEBUG) |
1442 // Verify that all the functions in the array have this class as owner. | 1443 // Verify that all the functions in the array have this class as owner. |
1443 Function& func = Function::Handle(); | 1444 Function& func = Function::Handle(); |
1444 intptr_t len = value.Length(); | 1445 intptr_t len = value.Length(); |
1445 for (intptr_t i = 0; i < len; i++) { | 1446 for (intptr_t i = 0; i < len; i++) { |
1446 func ^= value.At(i); | 1447 func ^= value.At(i); |
1447 ASSERT(func.Owner() == raw()); | 1448 ASSERT(func.Owner() == raw()); |
1448 } | 1449 } |
1449 #endif | 1450 #endif |
1450 StorePointer(&raw_ptr()->functions_, value.raw()); | 1451 StorePointer(&raw_ptr()->functions_, value.raw()); |
1451 } | 1452 } |
1452 | 1453 |
1453 | 1454 |
| 1455 void Class::AddFunction(const Function& function) const { |
| 1456 const Array& arr = Array::Handle(functions()); |
| 1457 const Array& new_arr = Array::Handle(Array::Grow(arr, arr.Length() + 1)); |
| 1458 new_arr.SetAt(arr.Length(), function); |
| 1459 SetFunctions(new_arr); |
| 1460 } |
| 1461 |
| 1462 |
1454 void Class::AddClosureFunction(const Function& function) const { | 1463 void Class::AddClosureFunction(const Function& function) const { |
1455 GrowableObjectArray& closures = | 1464 GrowableObjectArray& closures = |
1456 GrowableObjectArray::Handle(raw_ptr()->closure_functions_); | 1465 GrowableObjectArray::Handle(raw_ptr()->closure_functions_); |
1457 if (closures.IsNull()) { | 1466 if (closures.IsNull()) { |
1458 closures = GrowableObjectArray::New(4); | 1467 closures = GrowableObjectArray::New(4); |
1459 StorePointer(&raw_ptr()->closure_functions_, closures.raw()); | 1468 StorePointer(&raw_ptr()->closure_functions_, closures.raw()); |
1460 } | 1469 } |
1461 ASSERT(function.IsNonImplicitClosureFunction()); | 1470 ASSERT(function.IsNonImplicitClosureFunction()); |
1462 closures.Add(function); | 1471 closures.Add(function); |
1463 } | 1472 } |
(...skipping 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3213 if (IsClosureFunction()) { | 3222 if (IsClosureFunction()) { |
3214 const Object& obj = Object::Handle(raw_ptr()->data_); | 3223 const Object& obj = Object::Handle(raw_ptr()->data_); |
3215 ASSERT(!obj.IsNull()); | 3224 ASSERT(!obj.IsNull()); |
3216 ClosureData::Cast(obj).set_closure_allocation_stub(value); | 3225 ClosureData::Cast(obj).set_closure_allocation_stub(value); |
3217 return; | 3226 return; |
3218 } | 3227 } |
3219 UNREACHABLE(); | 3228 UNREACHABLE(); |
3220 } | 3229 } |
3221 | 3230 |
3222 | 3231 |
| 3232 RawFunction* Function::extracted_method_closure() const { |
| 3233 ASSERT(kind() == RawFunction::kMethodExtractor); |
| 3234 const Object& obj = Object::Handle(raw_ptr()->data_); |
| 3235 ASSERT(obj.IsFunction()); |
| 3236 return Function::Cast(obj).raw(); |
| 3237 } |
| 3238 |
| 3239 |
| 3240 void Function::set_extracted_method_closure(const Function& value) const { |
| 3241 ASSERT(kind() == RawFunction::kMethodExtractor); |
| 3242 ASSERT(raw_ptr()->data_ == Object::null()); |
| 3243 set_data(value); |
| 3244 } |
| 3245 |
| 3246 |
3223 RawFunction* Function::parent_function() const { | 3247 RawFunction* Function::parent_function() const { |
3224 if (IsClosureFunction()) { | 3248 if (IsClosureFunction()) { |
3225 const Object& obj = Object::Handle(raw_ptr()->data_); | 3249 const Object& obj = Object::Handle(raw_ptr()->data_); |
3226 ASSERT(!obj.IsNull()); | 3250 ASSERT(!obj.IsNull()); |
3227 return ClosureData::Cast(obj).parent_function(); | 3251 return ClosureData::Cast(obj).parent_function(); |
3228 } | 3252 } |
3229 return Function::null(); | 3253 return Function::null(); |
3230 } | 3254 } |
3231 | 3255 |
3232 | 3256 |
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4302 break; | 4326 break; |
4303 case RawFunction::kImplicitGetter: | 4327 case RawFunction::kImplicitGetter: |
4304 kind_str = " getter"; | 4328 kind_str = " getter"; |
4305 break; | 4329 break; |
4306 case RawFunction::kImplicitSetter: | 4330 case RawFunction::kImplicitSetter: |
4307 kind_str = " setter"; | 4331 kind_str = " setter"; |
4308 break; | 4332 break; |
4309 case RawFunction::kConstImplicitGetter: | 4333 case RawFunction::kConstImplicitGetter: |
4310 kind_str = " const-getter"; | 4334 kind_str = " const-getter"; |
4311 break; | 4335 break; |
| 4336 case RawFunction::kMethodExtractor: |
| 4337 kind_str = " method-extractor"; |
| 4338 break; |
4312 default: | 4339 default: |
4313 UNREACHABLE(); | 4340 UNREACHABLE(); |
4314 } | 4341 } |
4315 const char* kFormat = "Function '%s':%s%s%s%s."; | 4342 const char* kFormat = "Function '%s':%s%s%s%s."; |
4316 const char* function_name = String::Handle(name()).ToCString(); | 4343 const char* function_name = String::Handle(name()).ToCString(); |
4317 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, | 4344 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, |
4318 static_str, abstract_str, kind_str, const_str) + 1; | 4345 static_str, abstract_str, kind_str, const_str) + 1; |
4319 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 4346 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
4320 OS::SNPrint(chars, len, kFormat, function_name, | 4347 OS::SNPrint(chars, len, kFormat, function_name, |
4321 static_str, abstract_str, kind_str, const_str); | 4348 static_str, abstract_str, kind_str, const_str); |
(...skipping 8174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12496 } | 12523 } |
12497 return result.raw(); | 12524 return result.raw(); |
12498 } | 12525 } |
12499 | 12526 |
12500 | 12527 |
12501 const char* WeakProperty::ToCString() const { | 12528 const char* WeakProperty::ToCString() const { |
12502 return "_WeakProperty"; | 12529 return "_WeakProperty"; |
12503 } | 12530 } |
12504 | 12531 |
12505 } // namespace dart | 12532 } // namespace dart |
OLD | NEW |