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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 | 209 |
210 static void MarkInvisibleFunctions() { | 210 static void MarkInvisibleFunctions() { |
211 #define MARK_FUNCTION(lib, class_name, function_name) \ | 211 #define MARK_FUNCTION(lib, class_name, function_name) \ |
212 MarkFunctionAsInvisible(Library::Handle(Library::lib()), \ | 212 MarkFunctionAsInvisible(Library::Handle(Library::lib()), \ |
213 #class_name, #function_name); \ | 213 #class_name, #function_name); \ |
214 | 214 |
215 INVISIBLE_LIST(MARK_FUNCTION) | 215 INVISIBLE_LIST(MARK_FUNCTION) |
216 #undef MARK_FUNCTION | 216 #undef MARK_FUNCTION |
217 } | 217 } |
218 | 218 |
| 219 |
219 // Takes a vm internal name and makes it suitable for external user. | 220 // Takes a vm internal name and makes it suitable for external user. |
220 // | 221 // |
221 // Examples: | 222 // Examples: |
222 // | 223 // |
223 // Internal getter and setter prefixes are changed: | 224 // Internal getter and setter prefixes are changed: |
224 // | 225 // |
225 // get:foo -> foo | 226 // get:foo -> foo |
226 // set:foo -> foo= | 227 // set:foo -> foo= |
227 // | 228 // |
228 // Private name mangling is removed, possibly multiple times: | 229 // Private name mangling is removed, possibly multiple times: |
229 // | 230 // |
230 // _ReceivePortImpl@6be832b -> _ReceivePortImpl | 231 // _ReceivePortImpl@6be832b -> _ReceivePortImpl |
231 // _ReceivePortImpl@6be832b._internal@6be832b -> _ReceivePortImpl._internal | 232 // _ReceivePortImpl@6be832b._internal@6be832b -> _ReceivePortImpl._internal |
232 // _C@0x2b4ab9cc&_E@0x2b4ab9cc&_F@0x2b4ab9cc -> _C&_E&_F | 233 // _C@0x2b4ab9cc&_E@0x2b4ab9cc&_F@0x2b4ab9cc -> _C&_E&_F |
233 // | 234 // |
234 // The trailing . on the default constructor name is dropped: | 235 // The trailing . on the default constructor name is dropped: |
235 // | 236 // |
236 // List. -> List | 237 // List. -> List |
237 // | 238 // |
238 // And so forth: | 239 // And so forth: |
239 // | 240 // |
240 // get:foo@6be832b -> foo | 241 // get:foo@6be832b -> foo |
241 // _MyClass@6b3832b. -> _MyClass | 242 // _MyClass@6b3832b. -> _MyClass |
242 // _MyClass@6b3832b.named -> _MyClass.named | 243 // _MyClass@6b3832b.named -> _MyClass.named |
243 // | 244 // |
244 static RawString* IdentifierPrettyName(const String& name) { | 245 RawString* String::IdentifierPrettyName(const String& name) { |
245 if (name.Equals(Symbols::TopLevel())) { | 246 if (name.Equals(Symbols::TopLevel())) { |
246 // Name of invisible top-level class. | 247 // Name of invisible top-level class. |
247 return Symbols::Empty().raw(); | 248 return Symbols::Empty().raw(); |
248 } | 249 } |
249 | 250 |
250 // First remove all private name mangling. | 251 // First remove all private name mangling. |
251 String& unmangled_name = String::Handle(Symbols::Empty().raw()); | 252 String& unmangled_name = String::Handle(Symbols::Empty().raw()); |
252 String& segment = String::Handle(); | 253 String& segment = String::Handle(); |
253 intptr_t start_pos = 0; | 254 intptr_t start_pos = 0; |
254 for (intptr_t i = 0; i < name.Length(); i++) { | 255 for (intptr_t i = 0; i < name.Length(); i++) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 | 309 |
309 if (is_setter) { | 310 if (is_setter) { |
310 // Setters need to end with '='. | 311 // Setters need to end with '='. |
311 return String::Concat(result, Symbols::Equals()); | 312 return String::Concat(result, Symbols::Equals()); |
312 } | 313 } |
313 | 314 |
314 return result.raw(); | 315 return result.raw(); |
315 } | 316 } |
316 | 317 |
317 | 318 |
| 319 RawString* String::IdentifierPrettyNameRetainPrivate(const String& name) { |
| 320 intptr_t len = name.Length(); |
| 321 intptr_t start = 0; |
| 322 intptr_t at_pos = -1; // Position of '@' in the name, if any. |
| 323 bool is_setter = false; |
| 324 |
| 325 for (intptr_t i = start; i < len; i++) { |
| 326 if (name.CharAt(i) == ':') { |
| 327 ASSERT(start == 0); // Only one : is possible in getters or setters. |
| 328 if (name.CharAt(0) == 's') { |
| 329 is_setter = true; |
| 330 } |
| 331 start = i + 1; |
| 332 } else if (name.CharAt(i) == '@') { |
| 333 ASSERT(at_pos == -1); // Only one @ is supported. |
| 334 at_pos = i; |
| 335 } |
| 336 } |
| 337 |
| 338 if (start == 0) { |
| 339 // This unmangled_name is fine as it is. |
| 340 return name.raw(); |
| 341 } |
| 342 |
| 343 String& result = |
| 344 String::Handle(String::SubString(name, start, (len - start))); |
| 345 |
| 346 if (is_setter) { |
| 347 // Setters need to end with '='. |
| 348 if (at_pos == -1) { |
| 349 return String::Concat(result, Symbols::Equals()); |
| 350 } else { |
| 351 const String& pre_at = |
| 352 String::Handle(String::SubString(result, 0, at_pos - 4)); |
| 353 const String& post_at = |
| 354 String::Handle(String::SubString(name, at_pos, len - at_pos)); |
| 355 result = String::Concat(pre_at, Symbols::Equals()); |
| 356 result = String::Concat(result, post_at); |
| 357 } |
| 358 } |
| 359 |
| 360 return result.raw(); |
| 361 } |
| 362 |
| 363 |
318 template<typename type> | 364 template<typename type> |
319 static bool IsSpecialCharacter(type value) { | 365 static bool IsSpecialCharacter(type value) { |
320 return ((value == '"') || | 366 return ((value == '"') || |
321 (value == '\n') || | 367 (value == '\n') || |
322 (value == '\f') || | 368 (value == '\f') || |
323 (value == '\b') || | 369 (value == '\b') || |
324 (value == '\t') || | 370 (value == '\t') || |
325 (value == '\v') || | 371 (value == '\v') || |
326 (value == '\r') || | 372 (value == '\r') || |
327 (value == '\\') || | 373 (value == '\\') || |
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1484 return Symbols::Float32x4List().raw(); | 1530 return Symbols::Float32x4List().raw(); |
1485 case kTypedDataFloat32ArrayCid: | 1531 case kTypedDataFloat32ArrayCid: |
1486 case kExternalTypedDataFloat32ArrayCid: | 1532 case kExternalTypedDataFloat32ArrayCid: |
1487 return Symbols::Float32List().raw(); | 1533 return Symbols::Float32List().raw(); |
1488 case kTypedDataFloat64ArrayCid: | 1534 case kTypedDataFloat64ArrayCid: |
1489 case kExternalTypedDataFloat64ArrayCid: | 1535 case kExternalTypedDataFloat64ArrayCid: |
1490 return Symbols::Float64List().raw(); | 1536 return Symbols::Float64List().raw(); |
1491 default: | 1537 default: |
1492 if (!IsSignatureClass()) { | 1538 if (!IsSignatureClass()) { |
1493 const String& name = String::Handle(Name()); | 1539 const String& name = String::Handle(Name()); |
1494 return IdentifierPrettyName(name); | 1540 return String::IdentifierPrettyName(name); |
1495 } else { | 1541 } else { |
1496 return Name(); | 1542 return Name(); |
1497 } | 1543 } |
1498 } | 1544 } |
1499 UNREACHABLE(); | 1545 UNREACHABLE(); |
1500 } | 1546 } |
1501 | 1547 |
1502 | 1548 |
1503 RawType* Class::SignatureType() const { | 1549 RawType* Class::SignatureType() const { |
1504 ASSERT(IsSignatureClass()); | 1550 ASSERT(IsSignatureClass()); |
(...skipping 3685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5190 } | 5236 } |
5191 | 5237 |
5192 | 5238 |
5193 bool Function::HasOptimizedCode() const { | 5239 bool Function::HasOptimizedCode() const { |
5194 return HasCode() && Code::Handle(raw_ptr()->code_).is_optimized(); | 5240 return HasCode() && Code::Handle(raw_ptr()->code_).is_optimized(); |
5195 } | 5241 } |
5196 | 5242 |
5197 | 5243 |
5198 RawString* Function::UserVisibleName() const { | 5244 RawString* Function::UserVisibleName() const { |
5199 const String& str = String::Handle(name()); | 5245 const String& str = String::Handle(name()); |
5200 return IdentifierPrettyName(str); | 5246 return String::IdentifierPrettyName(str); |
5201 } | 5247 } |
5202 | 5248 |
5203 | 5249 |
5204 RawString* Function::QualifiedUserVisibleName() const { | 5250 RawString* Function::QualifiedUserVisibleName() const { |
5205 String& tmp = String::Handle(); | 5251 String& tmp = String::Handle(); |
5206 const Class& cls = Class::Handle(Owner()); | 5252 const Class& cls = Class::Handle(Owner()); |
5207 | 5253 |
5208 if (IsClosureFunction()) { | 5254 if (IsClosureFunction()) { |
5209 if (IsLocalFunction() && !IsImplicitClosureFunction()) { | 5255 if (IsLocalFunction() && !IsImplicitClosureFunction()) { |
5210 const Function& parent = Function::Handle(parent_function()); | 5256 const Function& parent = Function::Handle(parent_function()); |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5607 clone.set_dependent_code(Object::null_array()); | 5653 clone.set_dependent_code(Object::null_array()); |
5608 if (!clone.is_static()) { | 5654 if (!clone.is_static()) { |
5609 clone.SetOffset(0); | 5655 clone.SetOffset(0); |
5610 } | 5656 } |
5611 return clone.raw(); | 5657 return clone.raw(); |
5612 } | 5658 } |
5613 | 5659 |
5614 | 5660 |
5615 RawString* Field::UserVisibleName() const { | 5661 RawString* Field::UserVisibleName() const { |
5616 const String& str = String::Handle(name()); | 5662 const String& str = String::Handle(name()); |
5617 return IdentifierPrettyName(str); | 5663 return String::IdentifierPrettyName(str); |
5618 } | 5664 } |
5619 | 5665 |
5620 | 5666 |
5621 intptr_t Field::guarded_list_length() const { | 5667 intptr_t Field::guarded_list_length() const { |
5622 return Smi::Value(raw_ptr()->guarded_list_length_); | 5668 return Smi::Value(raw_ptr()->guarded_list_length_); |
5623 } | 5669 } |
5624 | 5670 |
5625 | 5671 |
5626 void Field::set_guarded_list_length(intptr_t list_length) const { | 5672 void Field::set_guarded_list_length(intptr_t list_length) const { |
5627 raw_ptr()->guarded_list_length_ = Smi::New(list_length); | 5673 raw_ptr()->guarded_list_length_ = Smi::New(list_length); |
(...skipping 9794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15422 return "_MirrorReference"; | 15468 return "_MirrorReference"; |
15423 } | 15469 } |
15424 | 15470 |
15425 | 15471 |
15426 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 15472 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
15427 JSONObject jsobj(stream); | 15473 JSONObject jsobj(stream); |
15428 } | 15474 } |
15429 | 15475 |
15430 | 15476 |
15431 } // namespace dart | 15477 } // namespace dart |
OLD | NEW |