| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import "dart:typed_data"; | 5 import "dart:typed_data"; |
| 6 | 6 |
| 7 // JSON conversion. | 7 // JSON conversion. |
| 8 | 8 |
| 9 patch _parseJson(String json, reviver(var key, var value)) { | 9 patch _parseJson(String json, reviver(var key, var value)) { |
| 10 _BuildJsonListener listener; | 10 _BuildJsonListener listener; |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 // At that time, position points to the next character, and isDouble | 497 // At that time, position points to the next character, and isDouble |
| 498 // is set if the literal contains a decimal point or an exponential. | 498 // is set if the literal contains a decimal point or an exponential. |
| 499 parsing: { | 499 parsing: { |
| 500 if (char == MINUS) { | 500 if (char == MINUS) { |
| 501 intSign = -1; | 501 intSign = -1; |
| 502 position++; | 502 position++; |
| 503 if (position == length) fail(position, "Missing expected digit"); | 503 if (position == length) fail(position, "Missing expected digit"); |
| 504 char = source.codeUnitAt(position); | 504 char = source.codeUnitAt(position); |
| 505 } | 505 } |
| 506 if (char < CHAR_0 || char > CHAR_9) { | 506 if (char < CHAR_0 || char > CHAR_9) { |
| 507 if (negative) { | 507 if (intSign < 0) { |
| 508 fail(position, "Missing expected digit"); | 508 fail(position, "Missing expected digit"); |
| 509 } else { | 509 } else { |
| 510 // If it doesn't even start out as a numeral. | 510 // If it doesn't even start out as a numeral. |
| 511 fail(position, "Unexpected character"); | 511 fail(position, "Unexpected character"); |
| 512 } | 512 } |
| 513 } | 513 } |
| 514 if (char == CHAR_0) { | 514 if (char == CHAR_0) { |
| 515 position++; | 515 position++; |
| 516 if (position == length) break parsing; | 516 if (position == length) break parsing; |
| 517 char = source.codeUnitAt(position); | 517 char = source.codeUnitAt(position); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 if (message == null) message = "Unexpected character"; | 574 if (message == null) message = "Unexpected character"; |
| 575 throw new FormatException(message, source, position); | 575 throw new FormatException(message, source, position); |
| 576 } | 576 } |
| 577 } | 577 } |
| 578 | 578 |
| 579 // UTF-8 conversion. | 579 // UTF-8 conversion. |
| 580 | 580 |
| 581 patch class _Utf8Encoder { | 581 patch class _Utf8Encoder { |
| 582 /* patch */ static List<int> _createBuffer(int size) => new Uint8List(size); | 582 /* patch */ static List<int> _createBuffer(int size) => new Uint8List(size); |
| 583 } | 583 } |
| OLD | NEW |