OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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:_internal" show POWERS_OF_TEN; | 5 import "dart:_internal" show POWERS_OF_TEN; |
6 | 6 |
7 // JSON conversion. | 7 // JSON conversion. |
8 | 8 |
9 @patch | 9 @patch |
10 _parseJson(String source, reviver(key, value)) { | 10 _parseJson(String source, reviver(key, value)) { |
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 void addNumberChunk(_NumberBuffer buffer, int start, int end, int overhead) { | 1184 void addNumberChunk(_NumberBuffer buffer, int start, int end, int overhead) { |
1185 int length = end - start; | 1185 int length = end - start; |
1186 int count = buffer.length; | 1186 int count = buffer.length; |
1187 int newCount = count + length; | 1187 int newCount = count + length; |
1188 int newCapacity = newCount + overhead; | 1188 int newCapacity = newCount + overhead; |
1189 buffer.ensureCapacity(newCapacity); | 1189 buffer.ensureCapacity(newCapacity); |
1190 copyCharsToList(start, end, buffer.list, count); | 1190 copyCharsToList(start, end, buffer.list, count); |
1191 buffer.length = newCount; | 1191 buffer.length = newCount; |
1192 } | 1192 } |
1193 | 1193 |
1194 // Continues an already chunked number accross an entire chunk. | 1194 // Continues an already chunked number across an entire chunk. |
1195 int continueChunkNumber(int state, int start, _NumberBuffer buffer) { | 1195 int continueChunkNumber(int state, int start, _NumberBuffer buffer) { |
1196 int end = chunkEnd; | 1196 int end = chunkEnd; |
1197 addNumberChunk(buffer, start, end, _NumberBuffer.kDefaultOverhead); | 1197 addNumberChunk(buffer, start, end, _NumberBuffer.kDefaultOverhead); |
1198 this.buffer = buffer; | 1198 this.buffer = buffer; |
1199 this.partialState = PARTIAL_NUMERAL | state; | 1199 this.partialState = PARTIAL_NUMERAL | state; |
1200 return end; | 1200 return end; |
1201 } | 1201 } |
1202 | 1202 |
1203 int finishChunkNumber(int state, int start, int end, _NumberBuffer buffer) { | 1203 int finishChunkNumber(int state, int start, int end, _NumberBuffer buffer) { |
1204 if (state == NUM_ZERO) { | 1204 if (state == NUM_ZERO) { |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 _parser.parse(start); | 1801 _parser.parse(start); |
1802 } | 1802 } |
1803 | 1803 |
1804 void close() { | 1804 void close() { |
1805 _parser.close(); | 1805 _parser.close(); |
1806 var decoded = _parser.result; | 1806 var decoded = _parser.result; |
1807 _sink.add(decoded); | 1807 _sink.add(decoded); |
1808 _sink.close(); | 1808 _sink.close(); |
1809 } | 1809 } |
1810 } | 1810 } |
OLD | NEW |