Chromium Code Reviews| 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 4836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4847 if ((literal.CharAt(i) == '\\')) { | 4847 if ((literal.CharAt(i) == '\\')) { |
| 4848 if ((next != Token::kINTERPOL_VAR) && | 4848 if ((next != Token::kINTERPOL_VAR) && |
| 4849 (next != Token::kINTERPOL_START) && | 4849 (next != Token::kINTERPOL_START) && |
| 4850 (prev != Token::kINTERPOL_VAR) && | 4850 (prev != Token::kINTERPOL_VAR) && |
| 4851 (prev != Token::kINTERPOL_END)) { | 4851 (prev != Token::kINTERPOL_END)) { |
| 4852 is_raw_string = true; | 4852 is_raw_string = true; |
| 4853 } else { | 4853 } else { |
| 4854 escape_characters = true; | 4854 escape_characters = true; |
| 4855 } | 4855 } |
| 4856 } | 4856 } |
| 4857 if ((literal.CharAt(i) == '$')) { | |
|
Ivan Posva
2013/03/18 18:12:22
$ should be a SpecialCharacter and then you would
siva
2013/03/19 17:08:31
The raw string processing was interfering with tre
| |
| 4858 escape_characters = true; | |
| 4859 } | |
| 4857 } | 4860 } |
| 4858 if ((prev != Token::kINTERPOL_VAR) && (prev != Token::kINTERPOL_END)) { | 4861 if ((prev != Token::kINTERPOL_VAR) && (prev != Token::kINTERPOL_END)) { |
| 4859 if (is_raw_string) { | 4862 if (is_raw_string) { |
| 4860 literals.Add(Symbols::LowercaseR()); | 4863 literals.Add(Symbols::LowercaseR()); |
| 4861 } | 4864 } |
| 4862 literals.Add(Symbols::DoubleQuotes()); | 4865 literals.Add(Symbols::DoubleQuotes()); |
| 4863 } | 4866 } |
| 4864 if (escape_characters) { | 4867 if (escape_characters) { |
| 4865 literal = String::EscapeSpecialCharacters(literal, is_raw_string); | 4868 literal = String::EscapeSpecialCharacters(literal, is_raw_string); |
| 4866 literals.Add(literal); | 4869 literals.Add(literal); |
| (...skipping 6609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11476 | 11479 |
| 11477 | 11480 |
| 11478 RawOneByteString* OneByteString::EscapeSpecialCharacters(const String& str, | 11481 RawOneByteString* OneByteString::EscapeSpecialCharacters(const String& str, |
| 11479 bool raw_str) { | 11482 bool raw_str) { |
| 11480 intptr_t len = str.Length(); | 11483 intptr_t len = str.Length(); |
| 11481 if (len > 0) { | 11484 if (len > 0) { |
| 11482 intptr_t num_escapes = 0; | 11485 intptr_t num_escapes = 0; |
| 11483 intptr_t index = 0; | 11486 intptr_t index = 0; |
| 11484 for (intptr_t i = 0; i < len; i++) { | 11487 for (intptr_t i = 0; i < len; i++) { |
| 11485 if (IsSpecialCharacter(*CharAddr(str, i)) || | 11488 if (IsSpecialCharacter(*CharAddr(str, i)) || |
| 11489 (!raw_str && (*CharAddr(str, i) == '$')) || | |
| 11486 (!raw_str && (*CharAddr(str, i) == '\\'))) { | 11490 (!raw_str && (*CharAddr(str, i) == '\\'))) { |
| 11487 num_escapes += 1; | 11491 num_escapes += 1; |
| 11488 } | 11492 } |
| 11489 } | 11493 } |
| 11490 const String& dststr = String::Handle( | 11494 const String& dststr = String::Handle( |
| 11491 OneByteString::New(len + num_escapes, Heap::kNew)); | 11495 OneByteString::New(len + num_escapes, Heap::kNew)); |
| 11492 for (intptr_t i = 0; i < len; i++) { | 11496 for (intptr_t i = 0; i < len; i++) { |
| 11493 if (IsSpecialCharacter(*CharAddr(str, i))) { | 11497 if (IsSpecialCharacter(*CharAddr(str, i))) { |
| 11494 *(CharAddr(dststr, index)) = '\\'; | 11498 *(CharAddr(dststr, index)) = '\\'; |
| 11495 *(CharAddr(dststr, index + 1)) = SpecialCharacter(*CharAddr(str, i)); | 11499 *(CharAddr(dststr, index + 1)) = SpecialCharacter(*CharAddr(str, i)); |
| 11496 index += 2; | 11500 index += 2; |
| 11501 } else if (!raw_str && (*CharAddr(str, i) == '$')) { | |
| 11502 *(CharAddr(dststr, index)) = '\\'; | |
| 11503 *(CharAddr(dststr, index + 1)) = '$'; | |
| 11504 index += 2; | |
| 11497 } else if (!raw_str && (*CharAddr(str, i) == '\\')) { | 11505 } else if (!raw_str && (*CharAddr(str, i) == '\\')) { |
| 11498 *(CharAddr(dststr, index)) = '\\'; | 11506 *(CharAddr(dststr, index)) = '\\'; |
| 11499 *(CharAddr(dststr, index + 1)) = '\\'; | 11507 *(CharAddr(dststr, index + 1)) = '\\'; |
| 11500 index += 2; | 11508 index += 2; |
| 11501 } else { | 11509 } else { |
| 11502 *(CharAddr(dststr, index)) = *CharAddr(str, i); | 11510 *(CharAddr(dststr, index)) = *CharAddr(str, i); |
| 11503 index += 1; | 11511 index += 1; |
| 11504 } | 11512 } |
| 11505 } | 11513 } |
| 11506 return OneByteString::raw(dststr); | 11514 return OneByteString::raw(dststr); |
| (...skipping 1894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13401 } | 13409 } |
| 13402 return result.raw(); | 13410 return result.raw(); |
| 13403 } | 13411 } |
| 13404 | 13412 |
| 13405 | 13413 |
| 13406 const char* WeakProperty::ToCString() const { | 13414 const char* WeakProperty::ToCString() const { |
| 13407 return "_WeakProperty"; | 13415 return "_WeakProperty"; |
| 13408 } | 13416 } |
| 13409 | 13417 |
| 13410 } // namespace dart | 13418 } // namespace dart |
| OLD | NEW |