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 String& pre_at = | |
349 String::Handle(String::SubString(result, 0, at_pos - 4)); | |
350 String& post_at = | |
351 String::Handle(String::SubString(name, at_pos, len - at_pos)); | |
siva
2013/09/30 23:47:12
const String& pre_at = .....;
const String* post_a
| |
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 3550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5052 } | 5098 } |
5053 | 5099 |
5054 | 5100 |
5055 bool Function::HasOptimizedCode() const { | 5101 bool Function::HasOptimizedCode() const { |
5056 return HasCode() && Code::Handle(raw_ptr()->code_).is_optimized(); | 5102 return HasCode() && Code::Handle(raw_ptr()->code_).is_optimized(); |
5057 } | 5103 } |
5058 | 5104 |
5059 | 5105 |
5060 RawString* Function::UserVisibleName() const { | 5106 RawString* Function::UserVisibleName() const { |
5061 const String& str = String::Handle(name()); | 5107 const String& str = String::Handle(name()); |
5062 return IdentifierPrettyName(str); | 5108 return String::IdentifierPrettyName(str); |
5063 } | 5109 } |
5064 | 5110 |
5065 | 5111 |
5066 RawString* Function::QualifiedUserVisibleName() const { | 5112 RawString* Function::QualifiedUserVisibleName() const { |
5067 String& tmp = String::Handle(); | 5113 String& tmp = String::Handle(); |
5068 const Class& cls = Class::Handle(Owner()); | 5114 const Class& cls = Class::Handle(Owner()); |
5069 | 5115 |
5070 if (IsClosureFunction()) { | 5116 if (IsClosureFunction()) { |
5071 if (IsLocalFunction() && !IsImplicitClosureFunction()) { | 5117 if (IsLocalFunction() && !IsImplicitClosureFunction()) { |
5072 const Function& parent = Function::Handle(parent_function()); | 5118 const Function& parent = Function::Handle(parent_function()); |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5469 clone.set_dependent_code(Object::null_array()); | 5515 clone.set_dependent_code(Object::null_array()); |
5470 if (!clone.is_static()) { | 5516 if (!clone.is_static()) { |
5471 clone.SetOffset(0); | 5517 clone.SetOffset(0); |
5472 } | 5518 } |
5473 return clone.raw(); | 5519 return clone.raw(); |
5474 } | 5520 } |
5475 | 5521 |
5476 | 5522 |
5477 RawString* Field::UserVisibleName() const { | 5523 RawString* Field::UserVisibleName() const { |
5478 const String& str = String::Handle(name()); | 5524 const String& str = String::Handle(name()); |
5479 return IdentifierPrettyName(str); | 5525 return String::IdentifierPrettyName(str); |
5480 } | 5526 } |
5481 | 5527 |
5482 | 5528 |
5483 intptr_t Field::guarded_list_length() const { | 5529 intptr_t Field::guarded_list_length() const { |
5484 return Smi::Value(raw_ptr()->guarded_list_length_); | 5530 return Smi::Value(raw_ptr()->guarded_list_length_); |
5485 } | 5531 } |
5486 | 5532 |
5487 | 5533 |
5488 void Field::set_guarded_list_length(intptr_t list_length) const { | 5534 void Field::set_guarded_list_length(intptr_t list_length) const { |
5489 raw_ptr()->guarded_list_length_ = Smi::New(list_length); | 5535 raw_ptr()->guarded_list_length_ = Smi::New(list_length); |
(...skipping 9690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15180 return "_MirrorReference"; | 15226 return "_MirrorReference"; |
15181 } | 15227 } |
15182 | 15228 |
15183 | 15229 |
15184 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 15230 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
15185 JSONObject jsobj(stream); | 15231 JSONObject jsobj(stream); |
15186 } | 15232 } |
15187 | 15233 |
15188 | 15234 |
15189 } // namespace dart | 15235 } // namespace dart |
OLD | NEW |