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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 206 |
207 static void MarkInvisibleFunctions() { | 207 static void MarkInvisibleFunctions() { |
208 #define MARK_FUNCTION(lib, class_name, function_name) \ | 208 #define MARK_FUNCTION(lib, class_name, function_name) \ |
209 MarkFunctionAsInvisible(Library::Handle(Library::lib()), \ | 209 MarkFunctionAsInvisible(Library::Handle(Library::lib()), \ |
210 #class_name, #function_name); \ | 210 #class_name, #function_name); \ |
211 | 211 |
212 INVISIBLE_LIST(MARK_FUNCTION) | 212 INVISIBLE_LIST(MARK_FUNCTION) |
213 #undef MARK_FUNCTION | 213 #undef MARK_FUNCTION |
214 } | 214 } |
215 | 215 |
| 216 |
216 // Takes a vm internal name and makes it suitable for external user. | 217 // Takes a vm internal name and makes it suitable for external user. |
217 // | 218 // |
218 // Examples: | 219 // Examples: |
219 // | 220 // |
220 // Internal getter and setter prefixes are changed: | 221 // Internal getter and setter prefixes are changed: |
221 // | 222 // |
222 // get:foo -> foo | 223 // get:foo -> foo |
223 // set:foo -> foo= | 224 // set:foo -> foo= |
224 // | 225 // |
225 // Private name mangling is removed, possibly multiple times: | 226 // Private name mangling is removed, possibly multiple times: |
226 // | 227 // |
227 // _ReceivePortImpl@6be832b -> _ReceivePortImpl | 228 // _ReceivePortImpl@6be832b -> _ReceivePortImpl |
228 // _ReceivePortImpl@6be832b._internal@6be832b -> _ReceivePortImpl._internal | 229 // _ReceivePortImpl@6be832b._internal@6be832b -> _ReceivePortImpl._internal |
229 // _C@0x2b4ab9cc&_E@0x2b4ab9cc&_F@0x2b4ab9cc -> _C&_E&_F | 230 // _C@0x2b4ab9cc&_E@0x2b4ab9cc&_F@0x2b4ab9cc -> _C&_E&_F |
230 // | 231 // |
231 // The trailing . on the default constructor name is dropped: | 232 // The trailing . on the default constructor name is dropped: |
232 // | 233 // |
233 // List. -> List | 234 // List. -> List |
234 // | 235 // |
235 // And so forth: | 236 // And so forth: |
236 // | 237 // |
237 // get:foo@6be832b -> foo | 238 // get:foo@6be832b -> foo |
238 // _MyClass@6b3832b. -> _MyClass | 239 // _MyClass@6b3832b. -> _MyClass |
239 // _MyClass@6b3832b.named -> _MyClass.named | 240 // _MyClass@6b3832b.named -> _MyClass.named |
240 // | 241 // |
241 static RawString* IdentifierPrettyName(const String& name) { | 242 RawString* String::IdentifierPrettyName(const String& name) { |
242 if (name.Equals(Symbols::TopLevel())) { | 243 if (name.Equals(Symbols::TopLevel())) { |
243 // Name of invisible top-level class. | 244 // Name of invisible top-level class. |
244 return Symbols::Empty().raw(); | 245 return Symbols::Empty().raw(); |
245 } | 246 } |
246 | 247 |
247 // First remove all private name mangling. | 248 // First remove all private name mangling. |
248 String& unmangled_name = String::Handle(Symbols::Empty().raw()); | 249 String& unmangled_name = String::Handle(Symbols::Empty().raw()); |
249 String& segment = String::Handle(); | 250 String& segment = String::Handle(); |
250 intptr_t start_pos = 0; | 251 intptr_t start_pos = 0; |
251 for (intptr_t i = 0; i < name.Length(); i++) { | 252 for (intptr_t i = 0; i < name.Length(); i++) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 | 306 |
306 if (is_setter) { | 307 if (is_setter) { |
307 // Setters need to end with '='. | 308 // Setters need to end with '='. |
308 return String::Concat(result, Symbols::Equals()); | 309 return String::Concat(result, Symbols::Equals()); |
309 } | 310 } |
310 | 311 |
311 return result.raw(); | 312 return result.raw(); |
312 } | 313 } |
313 | 314 |
314 | 315 |
| 316 RawString* String::IdentifierPrettyNameRetainPrivate(const String& name) { |
| 317 intptr_t len = name.Length(); |
| 318 intptr_t start = 0; |
| 319 intptr_t at_pos = -1; // Position of '@' in the name, if any. |
| 320 bool is_setter = false; |
| 321 |
| 322 for (intptr_t i = start; i < len; i++) { |
| 323 if (name.CharAt(i) == ':') { |
| 324 ASSERT(start == 0); // Only one : is possible in getters or setters. |
| 325 if (name.CharAt(0) == 's') { |
| 326 is_setter = true; |
| 327 } |
| 328 start = i + 1; |
| 329 } else if (name.CharAt(i) == '@') { |
| 330 ASSERT(at_pos == -1); // Only one @ is supported. |
| 331 at_pos = i; |
| 332 } |
| 333 } |
| 334 |
| 335 if (start == 0) { |
| 336 // This unmangled_name is fine as it is. |
| 337 return name.raw(); |
| 338 } |
| 339 |
| 340 String& result = |
| 341 String::Handle(String::SubString(name, start, (len - start))); |
| 342 |
| 343 if (is_setter) { |
| 344 // Setters need to end with '='. |
| 345 if (at_pos == -1) { |
| 346 return String::Concat(result, Symbols::Equals()); |
| 347 } else { |
| 348 const String& pre_at = |
| 349 String::Handle(String::SubString(result, 0, at_pos - 4)); |
| 350 const String& post_at = |
| 351 String::Handle(String::SubString(name, at_pos, len - at_pos)); |
| 352 result = String::Concat(pre_at, Symbols::Equals()); |
| 353 result = String::Concat(result, post_at); |
| 354 } |
| 355 } |
| 356 |
| 357 return result.raw(); |
| 358 } |
| 359 |
| 360 |
315 template<typename type> | 361 template<typename type> |
316 static bool IsSpecialCharacter(type value) { | 362 static bool IsSpecialCharacter(type value) { |
317 return ((value == '"') || | 363 return ((value == '"') || |
318 (value == '\n') || | 364 (value == '\n') || |
319 (value == '\f') || | 365 (value == '\f') || |
320 (value == '\b') || | 366 (value == '\b') || |
321 (value == '\t') || | 367 (value == '\t') || |
322 (value == '\v') || | 368 (value == '\v') || |
323 (value == '\r') || | 369 (value == '\r') || |
324 (value == '\\') || | 370 (value == '\\') || |
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1481 return Symbols::Float32x4List().raw(); | 1527 return Symbols::Float32x4List().raw(); |
1482 case kTypedDataFloat32ArrayCid: | 1528 case kTypedDataFloat32ArrayCid: |
1483 case kExternalTypedDataFloat32ArrayCid: | 1529 case kExternalTypedDataFloat32ArrayCid: |
1484 return Symbols::Float32List().raw(); | 1530 return Symbols::Float32List().raw(); |
1485 case kTypedDataFloat64ArrayCid: | 1531 case kTypedDataFloat64ArrayCid: |
1486 case kExternalTypedDataFloat64ArrayCid: | 1532 case kExternalTypedDataFloat64ArrayCid: |
1487 return Symbols::Float64List().raw(); | 1533 return Symbols::Float64List().raw(); |
1488 default: | 1534 default: |
1489 if (!IsSignatureClass()) { | 1535 if (!IsSignatureClass()) { |
1490 const String& name = String::Handle(Name()); | 1536 const String& name = String::Handle(Name()); |
1491 return IdentifierPrettyName(name); | 1537 return String::IdentifierPrettyName(name); |
1492 } else { | 1538 } else { |
1493 return Name(); | 1539 return Name(); |
1494 } | 1540 } |
1495 } | 1541 } |
1496 UNREACHABLE(); | 1542 UNREACHABLE(); |
1497 } | 1543 } |
1498 | 1544 |
1499 | 1545 |
1500 RawType* Class::SignatureType() const { | 1546 RawType* Class::SignatureType() const { |
1501 ASSERT(IsSignatureClass()); | 1547 ASSERT(IsSignatureClass()); |
(...skipping 3580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5082 } | 5128 } |
5083 | 5129 |
5084 | 5130 |
5085 bool Function::HasOptimizedCode() const { | 5131 bool Function::HasOptimizedCode() const { |
5086 return HasCode() && Code::Handle(raw_ptr()->code_).is_optimized(); | 5132 return HasCode() && Code::Handle(raw_ptr()->code_).is_optimized(); |
5087 } | 5133 } |
5088 | 5134 |
5089 | 5135 |
5090 RawString* Function::UserVisibleName() const { | 5136 RawString* Function::UserVisibleName() const { |
5091 const String& str = String::Handle(name()); | 5137 const String& str = String::Handle(name()); |
5092 return IdentifierPrettyName(str); | 5138 return String::IdentifierPrettyName(str); |
5093 } | 5139 } |
5094 | 5140 |
5095 | 5141 |
5096 RawString* Function::QualifiedUserVisibleName() const { | 5142 RawString* Function::QualifiedUserVisibleName() const { |
5097 String& tmp = String::Handle(); | 5143 String& tmp = String::Handle(); |
5098 const Class& cls = Class::Handle(Owner()); | 5144 const Class& cls = Class::Handle(Owner()); |
5099 | 5145 |
5100 if (IsClosureFunction()) { | 5146 if (IsClosureFunction()) { |
5101 if (IsLocalFunction() && !IsImplicitClosureFunction()) { | 5147 if (IsLocalFunction() && !IsImplicitClosureFunction()) { |
5102 const Function& parent = Function::Handle(parent_function()); | 5148 const Function& parent = Function::Handle(parent_function()); |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5499 clone.set_dependent_code(Object::null_array()); | 5545 clone.set_dependent_code(Object::null_array()); |
5500 if (!clone.is_static()) { | 5546 if (!clone.is_static()) { |
5501 clone.SetOffset(0); | 5547 clone.SetOffset(0); |
5502 } | 5548 } |
5503 return clone.raw(); | 5549 return clone.raw(); |
5504 } | 5550 } |
5505 | 5551 |
5506 | 5552 |
5507 RawString* Field::UserVisibleName() const { | 5553 RawString* Field::UserVisibleName() const { |
5508 const String& str = String::Handle(name()); | 5554 const String& str = String::Handle(name()); |
5509 return IdentifierPrettyName(str); | 5555 return String::IdentifierPrettyName(str); |
5510 } | 5556 } |
5511 | 5557 |
5512 | 5558 |
5513 intptr_t Field::guarded_list_length() const { | 5559 intptr_t Field::guarded_list_length() const { |
5514 return Smi::Value(raw_ptr()->guarded_list_length_); | 5560 return Smi::Value(raw_ptr()->guarded_list_length_); |
5515 } | 5561 } |
5516 | 5562 |
5517 | 5563 |
5518 void Field::set_guarded_list_length(intptr_t list_length) const { | 5564 void Field::set_guarded_list_length(intptr_t list_length) const { |
5519 raw_ptr()->guarded_list_length_ = Smi::New(list_length); | 5565 raw_ptr()->guarded_list_length_ = Smi::New(list_length); |
(...skipping 9796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15316 return "_MirrorReference"; | 15362 return "_MirrorReference"; |
15317 } | 15363 } |
15318 | 15364 |
15319 | 15365 |
15320 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 15366 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
15321 JSONObject jsobj(stream); | 15367 JSONObject jsobj(stream); |
15322 } | 15368 } |
15323 | 15369 |
15324 | 15370 |
15325 } // namespace dart | 15371 } // namespace dart |
OLD | NEW |