Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: lib/runtime/dart/convert.js

Issue 1233553005: Fixes #254 - Better stacktrace support (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: format fix Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/runtime/dart/collection.js ('k') | lib/runtime/dart/core.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 dart_library.library('dart/convert', null, /* Imports */[ 1 dart_library.library('dart/convert', null, /* Imports */[
2 "dart_runtime/dart", 2 "dart_runtime/dart",
3 'dart/core', 3 'dart/core',
4 'dart/async', 4 'dart/async',
5 'dart/typed_data', 5 'dart/typed_data',
6 'dart/_internal', 6 'dart/_internal',
7 'dart/collection' 7 'dart/collection'
8 ], /* Lazy imports */[ 8 ], /* Lazy imports */[
9 ], function(exports, dart, core, async, typed_data, _internal, collection) { 9 ], function(exports, dart, core, async, typed_data, _internal, collection) {
10 'use strict'; 10 'use strict';
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 let Converter$ = dart.generic(function(S, T) { 99 let Converter$ = dart.generic(function(S, T) {
100 class Converter extends core.Object { 100 class Converter extends core.Object {
101 Converter() { 101 Converter() {
102 } 102 }
103 fuse(other) { 103 fuse(other) {
104 dart.as(other, Converter$(T, dart.dynamic)); 104 dart.as(other, Converter$(T, dart.dynamic));
105 return new (_FusedConverter$(S, T, dart.dynamic))(this, other); 105 return new (_FusedConverter$(S, T, dart.dynamic))(this, other);
106 } 106 }
107 startChunkedConversion(sink) { 107 startChunkedConversion(sink) {
108 dart.as(sink, core.Sink$(T)); 108 dart.as(sink, core.Sink$(T));
109 throw new core.UnsupportedError(`This converter does not support chunked conversions: ${this}`); 109 dart.throw(new core.UnsupportedError(`This converter does not support ch unked conversions: ${this}`));
110 } 110 }
111 bind(source) { 111 bind(source) {
112 dart.as(source, async.Stream$(S)); 112 dart.as(source, async.Stream$(S));
113 return async.Stream$(T).eventTransformed(source, dart.fn(sink => new _Co nverterStreamEventSink(this, sink), _ConverterStreamEventSink, [async.EventSink] )); 113 return async.Stream$(T).eventTransformed(source, dart.fn(sink => new _Co nverterStreamEventSink(this, sink), _ConverterStreamEventSink, [async.EventSink] ));
114 } 114 }
115 } 115 }
116 Converter[dart.implements] = () => [async.StreamTransformer$(S, T)]; 116 Converter[dart.implements] = () => [async.StreamTransformer$(S, T)];
117 dart.setSignature(Converter, { 117 dart.setSignature(Converter, {
118 constructors: () => ({Converter: [Converter$(S, T), []]}), 118 constructors: () => ({Converter: [Converter$(S, T), []]}),
119 methods: () => ({ 119 methods: () => ({
(...skipping 18 matching lines...) Expand all
138 end = null; 138 end = null;
139 let stringLength = string[dartx.length]; 139 let stringLength = string[dartx.length];
140 core.RangeError.checkValidRange(start, end, stringLength); 140 core.RangeError.checkValidRange(start, end, stringLength);
141 if (end == null) 141 if (end == null)
142 end = stringLength; 142 end = stringLength;
143 let length = dart.notNull(end) - dart.notNull(start); 143 let length = dart.notNull(end) - dart.notNull(start);
144 let result = typed_data.Uint8List.new(length); 144 let result = typed_data.Uint8List.new(length);
145 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i ) + 1) { 145 for (let i = 0; dart.notNull(i) < dart.notNull(length); i = dart.notNull(i ) + 1) {
146 let codeUnit = string[dartx.codeUnitAt](dart.notNull(start) + dart.notNu ll(i)); 146 let codeUnit = string[dartx.codeUnitAt](dart.notNull(start) + dart.notNu ll(i));
147 if ((dart.notNull(codeUnit) & ~dart.notNull(this[_subsetMask])) != 0) { 147 if ((dart.notNull(codeUnit) & ~dart.notNull(this[_subsetMask])) != 0) {
148 throw new core.ArgumentError("String contains invalid characters."); 148 dart.throw(new core.ArgumentError("String contains invalid characters. "));
149 } 149 }
150 result[dartx.set](i, codeUnit); 150 result[dartx.set](i, codeUnit);
151 } 151 }
152 return dart.as(result, core.List$(core.int)); 152 return dart.as(result, core.List$(core.int));
153 } 153 }
154 startChunkedConversion(sink) { 154 startChunkedConversion(sink) {
155 if (!dart.is(sink, ByteConversionSink)) { 155 if (!dart.is(sink, ByteConversionSink)) {
156 sink = ByteConversionSink.from(sink); 156 sink = ByteConversionSink.from(sink);
157 } 157 }
158 return new _UnicodeSubsetEncoderSink(this[_subsetMask], dart.as(sink, Byte ConversionSink)); 158 return new _UnicodeSubsetEncoderSink(this[_subsetMask], dart.as(sink, Byte ConversionSink));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 this[_sink] = sink; 204 this[_sink] = sink;
205 } 205 }
206 close() { 206 close() {
207 this[_sink].close(); 207 this[_sink].close();
208 } 208 }
209 addSlice(source, start, end, isLast) { 209 addSlice(source, start, end, isLast) {
210 core.RangeError.checkValidRange(start, end, source[dartx.length]); 210 core.RangeError.checkValidRange(start, end, source[dartx.length]);
211 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) { 211 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) {
212 let codeUnit = source[dartx.codeUnitAt](i); 212 let codeUnit = source[dartx.codeUnitAt](i);
213 if ((dart.notNull(codeUnit) & ~dart.notNull(this[_subsetMask])) != 0) { 213 if ((dart.notNull(codeUnit) & ~dart.notNull(this[_subsetMask])) != 0) {
214 throw new core.ArgumentError(`Source contains invalid character with c ode point: ${codeUnit}.`); 214 dart.throw(new core.ArgumentError(`Source contains invalid character w ith code point: ${codeUnit}.`));
215 } 215 }
216 } 216 }
217 this[_sink].add(source[dartx.codeUnits][dartx.sublist](start, end)); 217 this[_sink].add(source[dartx.codeUnits][dartx.sublist](start, end));
218 if (dart.notNull(isLast)) { 218 if (dart.notNull(isLast)) {
219 this.close(); 219 this.close();
220 } 220 }
221 } 221 }
222 } 222 }
223 dart.setSignature(_UnicodeSubsetEncoderSink, { 223 dart.setSignature(_UnicodeSubsetEncoderSink, {
224 constructors: () => ({_UnicodeSubsetEncoderSink: [_UnicodeSubsetEncoderSink, [core.int, ByteConversionSink]]}), 224 constructors: () => ({_UnicodeSubsetEncoderSink: [_UnicodeSubsetEncoderSink, [core.int, ByteConversionSink]]}),
(...skipping 16 matching lines...) Expand all
241 end = null; 241 end = null;
242 let byteCount = bytes[dartx.length]; 242 let byteCount = bytes[dartx.length];
243 core.RangeError.checkValidRange(start, end, byteCount); 243 core.RangeError.checkValidRange(start, end, byteCount);
244 if (end == null) 244 if (end == null)
245 end = byteCount; 245 end = byteCount;
246 let length = dart.notNull(end) - dart.notNull(start); 246 let length = dart.notNull(end) - dart.notNull(start);
247 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) { 247 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) {
248 let byte = bytes[dartx.get](i); 248 let byte = bytes[dartx.get](i);
249 if ((dart.notNull(byte) & ~dart.notNull(this[_subsetMask])) != 0) { 249 if ((dart.notNull(byte) & ~dart.notNull(this[_subsetMask])) != 0) {
250 if (!dart.notNull(this[_allowInvalid])) { 250 if (!dart.notNull(this[_allowInvalid])) {
251 throw new core.FormatException(`Invalid value in input: ${byte}`); 251 dart.throw(new core.FormatException(`Invalid value in input: ${byte} `));
252 } 252 }
253 return this[_convertInvalid](bytes, start, end); 253 return this[_convertInvalid](bytes, start, end);
254 } 254 }
255 } 255 }
256 return core.String.fromCharCodes(bytes, start, end); 256 return core.String.fromCharCodes(bytes, start, end);
257 } 257 }
258 [_convertInvalid](bytes, start, end) { 258 [_convertInvalid](bytes, start, end) {
259 let buffer = new core.StringBuffer(); 259 let buffer = new core.StringBuffer();
260 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) { 260 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) {
261 let value = bytes[dartx.get](i); 261 let value = bytes[dartx.get](i);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 class _SimpleAsciiDecoderSink extends ByteConversionSinkBase { 387 class _SimpleAsciiDecoderSink extends ByteConversionSinkBase {
388 _SimpleAsciiDecoderSink(sink) { 388 _SimpleAsciiDecoderSink(sink) {
389 this[_sink] = sink; 389 this[_sink] = sink;
390 } 390 }
391 close() { 391 close() {
392 this[_sink].close(); 392 this[_sink].close();
393 } 393 }
394 add(source) { 394 add(source) {
395 for (let i = 0; dart.notNull(i) < dart.notNull(source[dartx.length]); i = dart.notNull(i) + 1) { 395 for (let i = 0; dart.notNull(i) < dart.notNull(source[dartx.length]); i = dart.notNull(i) + 1) {
396 if ((dart.notNull(source[dartx.get](i)) & ~dart.notNull(_ASCII_MASK)) != 0) { 396 if ((dart.notNull(source[dartx.get](i)) & ~dart.notNull(_ASCII_MASK)) != 0) {
397 throw new core.FormatException("Source contains non-ASCII bytes."); 397 dart.throw(new core.FormatException("Source contains non-ASCII bytes." ));
398 } 398 }
399 } 399 }
400 this[_sink].add(core.String.fromCharCodes(source)); 400 this[_sink].add(core.String.fromCharCodes(source));
401 } 401 }
402 addSlice(source, start, end, isLast) { 402 addSlice(source, start, end, isLast) {
403 let length = source[dartx.length]; 403 let length = source[dartx.length];
404 core.RangeError.checkValidRange(start, end, length); 404 core.RangeError.checkValidRange(start, end, length);
405 if (dart.notNull(start) < dart.notNull(end)) { 405 if (dart.notNull(start) < dart.notNull(end)) {
406 if (start != 0 || end != length) { 406 if (start != 0 || end != length) {
407 source = source[dartx.sublist](start, end); 407 source = source[dartx.sublist](start, end);
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 class _JsonEncoderSink extends ChunkedConversionSink$(core.Object) { 999 class _JsonEncoderSink extends ChunkedConversionSink$(core.Object) {
1000 _JsonEncoderSink(sink, toEncodable, indent) { 1000 _JsonEncoderSink(sink, toEncodable, indent) {
1001 this[_sink] = sink; 1001 this[_sink] = sink;
1002 this[_toEncodable$] = toEncodable; 1002 this[_toEncodable$] = toEncodable;
1003 this[_indent] = indent; 1003 this[_indent] = indent;
1004 this[_isDone] = false; 1004 this[_isDone] = false;
1005 super.ChunkedConversionSink(); 1005 super.ChunkedConversionSink();
1006 } 1006 }
1007 add(o) { 1007 add(o) {
1008 if (dart.notNull(this[_isDone])) { 1008 if (dart.notNull(this[_isDone])) {
1009 throw new core.StateError("Only one call to add allowed"); 1009 dart.throw(new core.StateError("Only one call to add allowed"));
1010 } 1010 }
1011 this[_isDone] = true; 1011 this[_isDone] = true;
1012 let stringSink = this[_sink].asStringSink(); 1012 let stringSink = this[_sink].asStringSink();
1013 _JsonStringStringifier.printOn(o, stringSink, dart.as(this[_toEncodable$], dart.functionType(dart.dynamic, [dart.dynamic])), this[_indent]); 1013 _JsonStringStringifier.printOn(o, stringSink, dart.as(this[_toEncodable$], dart.functionType(dart.dynamic, [dart.dynamic])), this[_indent]);
1014 stringSink.close(); 1014 stringSink.close();
1015 } 1015 }
1016 close() {} 1016 close() {}
1017 } 1017 }
1018 dart.setSignature(_JsonEncoderSink, { 1018 dart.setSignature(_JsonEncoderSink, {
1019 constructors: () => ({_JsonEncoderSink: [_JsonEncoderSink, [StringConversion Sink, core.Function, core.String]]}), 1019 constructors: () => ({_JsonEncoderSink: [_JsonEncoderSink, [StringConversion Sink, core.Function, core.String]]}),
(...skipping 10 matching lines...) Expand all
1030 this[_indent] = indent; 1030 this[_indent] = indent;
1031 this[_bufferSize] = bufferSize; 1031 this[_bufferSize] = bufferSize;
1032 this[_isDone] = false; 1032 this[_isDone] = false;
1033 super.ChunkedConversionSink(); 1033 super.ChunkedConversionSink();
1034 } 1034 }
1035 [_addChunk](chunk, start, end) { 1035 [_addChunk](chunk, start, end) {
1036 this[_sink].addSlice(chunk, start, end, false); 1036 this[_sink].addSlice(chunk, start, end, false);
1037 } 1037 }
1038 add(object) { 1038 add(object) {
1039 if (dart.notNull(this[_isDone])) { 1039 if (dart.notNull(this[_isDone])) {
1040 throw new core.StateError("Only one call to add allowed"); 1040 dart.throw(new core.StateError("Only one call to add allowed"));
1041 } 1041 }
1042 this[_isDone] = true; 1042 this[_isDone] = true;
1043 _JsonUtf8Stringifier.stringify(object, this[_indent], dart.as(this[_toEnco dable$], dart.functionType(dart.dynamic, [core.Object])), this[_bufferSize], dar t.bind(this, _addChunk)); 1043 _JsonUtf8Stringifier.stringify(object, this[_indent], dart.as(this[_toEnco dable$], dart.functionType(dart.dynamic, [core.Object])), this[_bufferSize], dar t.bind(this, _addChunk));
1044 this[_sink].close(); 1044 this[_sink].close();
1045 } 1045 }
1046 close() { 1046 close() {
1047 if (!dart.notNull(this[_isDone])) { 1047 if (!dart.notNull(this[_isDone])) {
1048 this[_isDone] = true; 1048 this[_isDone] = true;
1049 this[_sink].close(); 1049 this[_sink].close();
1050 } 1050 }
(...skipping 27 matching lines...) Expand all
1078 dart.setSignature(JsonDecoder, { 1078 dart.setSignature(JsonDecoder, {
1079 constructors: () => ({JsonDecoder: [JsonDecoder, [], [dart.functionType(dart .dynamic, [dart.dynamic, dart.dynamic])]]}), 1079 constructors: () => ({JsonDecoder: [JsonDecoder, [], [dart.functionType(dart .dynamic, [dart.dynamic, dart.dynamic])]]}),
1080 methods: () => ({ 1080 methods: () => ({
1081 convert: [dart.dynamic, [core.String]], 1081 convert: [dart.dynamic, [core.String]],
1082 startChunkedConversion: [StringConversionSink, [core.Sink$(core.Object)]], 1082 startChunkedConversion: [StringConversionSink, [core.Sink$(core.Object)]],
1083 bind: [async.Stream$(core.Object), [async.Stream$(core.String)]] 1083 bind: [async.Stream$(core.Object), [async.Stream$(core.String)]]
1084 }) 1084 })
1085 }); 1085 });
1086 function _parseJson(source, reviver) { 1086 function _parseJson(source, reviver) {
1087 if (!(typeof source == 'string')) 1087 if (!(typeof source == 'string'))
1088 throw new core.ArgumentError(source); 1088 dart.throw(new core.ArgumentError(source));
1089 let parsed = null; 1089 let parsed = null;
1090 try { 1090 try {
1091 parsed = JSON.parse(source); 1091 parsed = JSON.parse(source);
1092 } catch (e) { 1092 } catch (e) {
1093 throw new core.FormatException(String(e)); 1093 dart.throw(new core.FormatException(String(e)));
1094 } 1094 }
1095 1095
1096 if (reviver == null) { 1096 if (reviver == null) {
1097 return _convertJsonToDartLazy(parsed); 1097 return _convertJsonToDartLazy(parsed);
1098 } else { 1098 } else {
1099 return _convertJsonToDart(parsed, reviver); 1099 return _convertJsonToDart(parsed, reviver);
1100 } 1100 }
1101 } 1101 }
1102 dart.fn(_parseJson, dart.dynamic, [core.String, dart.functionType(dart.dynamic , [dart.dynamic, dart.dynamic])]); 1102 dart.fn(_parseJson, dart.dynamic, [core.String, dart.functionType(dart.dynamic , [dart.dynamic, dart.dynamic])]);
1103 function _defaultToEncodable(object) { 1103 function _defaultToEncodable(object) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 } 1173 }
1174 if (offset == 0) { 1174 if (offset == 0) {
1175 this.writeString(s); 1175 this.writeString(s);
1176 } else if (dart.notNull(offset) < dart.notNull(length)) { 1176 } else if (dart.notNull(offset) < dart.notNull(length)) {
1177 this.writeStringSlice(s, offset, length); 1177 this.writeStringSlice(s, offset, length);
1178 } 1178 }
1179 } 1179 }
1180 [_checkCycle](object) { 1180 [_checkCycle](object) {
1181 for (let i = 0; dart.notNull(i) < dart.notNull(this[_seen][dartx.length]); i = dart.notNull(i) + 1) { 1181 for (let i = 0; dart.notNull(i) < dart.notNull(this[_seen][dartx.length]); i = dart.notNull(i) + 1) {
1182 if (dart.notNull(core.identical(object, this[_seen][dartx.get](i)))) { 1182 if (dart.notNull(core.identical(object, this[_seen][dartx.get](i)))) {
1183 throw new JsonCyclicError(object); 1183 dart.throw(new JsonCyclicError(object));
1184 } 1184 }
1185 } 1185 }
1186 this[_seen][dartx.add](object); 1186 this[_seen][dartx.add](object);
1187 } 1187 }
1188 [_removeSeen](object) { 1188 [_removeSeen](object) {
1189 dart.assert(!dart.notNull(this[_seen][dartx.isEmpty])); 1189 dart.assert(!dart.notNull(this[_seen][dartx.isEmpty]));
1190 dart.assert(core.identical(this[_seen][dartx.last], object)); 1190 dart.assert(core.identical(this[_seen][dartx.last], object));
1191 this[_seen][dartx.removeLast](); 1191 this[_seen][dartx.removeLast]();
1192 } 1192 }
1193 writeObject(object) { 1193 writeObject(object) {
1194 if (dart.notNull(this.writeJsonValue(object))) 1194 if (dart.notNull(this.writeJsonValue(object)))
1195 return; 1195 return;
1196 this[_checkCycle](object); 1196 this[_checkCycle](object);
1197 try { 1197 try {
1198 let customJson = dart.dcall(this[_toEncodable$], object); 1198 let customJson = dart.dcall(this[_toEncodable$], object);
1199 if (!dart.notNull(this.writeJsonValue(customJson))) { 1199 if (!dart.notNull(this.writeJsonValue(customJson))) {
1200 throw new JsonUnsupportedObjectError(object); 1200 dart.throw(new JsonUnsupportedObjectError(object));
1201 } 1201 }
1202 this[_removeSeen](object); 1202 this[_removeSeen](object);
1203 } catch (e) { 1203 } catch (e) {
1204 throw new JsonUnsupportedObjectError(object, {cause: e}); 1204 dart.throw(new JsonUnsupportedObjectError(object, {cause: e}));
1205 } 1205 }
1206 1206
1207 } 1207 }
1208 writeJsonValue(object) { 1208 writeJsonValue(object) {
1209 if (dart.is(object, core.num)) { 1209 if (dart.is(object, core.num)) {
1210 if (!dart.notNull(dart.as(dart.dload(object, 'isFinite'), core.bool))) 1210 if (!dart.notNull(dart.as(dart.dload(object, 'isFinite'), core.bool)))
1211 return false; 1211 return false;
1212 this.writeNumber(dart.as(object, core.num)); 1212 this.writeNumber(dart.as(object, core.num));
1213 return true; 1213 return true;
1214 } else if (dart.notNull(core.identical(object, true))) { 1214 } else if (dart.notNull(core.identical(object, true))) {
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 [_addSliceToSink](source, start, end, isLast) { 1634 [_addSliceToSink](source, start, end, isLast) {
1635 this[_sink].add(core.String.fromCharCodes(source, start, end)); 1635 this[_sink].add(core.String.fromCharCodes(source, start, end));
1636 if (dart.notNull(isLast)) 1636 if (dart.notNull(isLast))
1637 this.close(); 1637 this.close();
1638 } 1638 }
1639 addSlice(source, start, end, isLast) { 1639 addSlice(source, start, end, isLast) {
1640 core.RangeError.checkValidRange(start, end, source[dartx.length]); 1640 core.RangeError.checkValidRange(start, end, source[dartx.length]);
1641 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) { 1641 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) {
1642 let char = source[dartx.get](i); 1642 let char = source[dartx.get](i);
1643 if (dart.notNull(char) > dart.notNull(_LATIN1_MASK) || dart.notNull(char ) < 0) { 1643 if (dart.notNull(char) > dart.notNull(_LATIN1_MASK) || dart.notNull(char ) < 0) {
1644 throw new core.FormatException("Source contains non-Latin-1 characters ."); 1644 dart.throw(new core.FormatException("Source contains non-Latin-1 chara cters."));
1645 } 1645 }
1646 } 1646 }
1647 if (dart.notNull(start) < dart.notNull(end)) { 1647 if (dart.notNull(start) < dart.notNull(end)) {
1648 this[_addSliceToSink](source, start, end, isLast); 1648 this[_addSliceToSink](source, start, end, isLast);
1649 } 1649 }
1650 if (dart.notNull(isLast)) { 1650 if (dart.notNull(isLast)) {
1651 this.close(); 1651 this.close();
1652 } 1652 }
1653 } 1653 }
1654 } 1654 }
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
2419 } 2419 }
2420 get hasPartialInput() { 2420 get hasPartialInput() {
2421 return dart.notNull(this[_expectedUnits]) > 0; 2421 return dart.notNull(this[_expectedUnits]) > 0;
2422 } 2422 }
2423 close() { 2423 close() {
2424 this.flush(); 2424 this.flush();
2425 } 2425 }
2426 flush() { 2426 flush() {
2427 if (dart.notNull(this.hasPartialInput)) { 2427 if (dart.notNull(this.hasPartialInput)) {
2428 if (!dart.notNull(this[_allowMalformed])) { 2428 if (!dart.notNull(this[_allowMalformed])) {
2429 throw new core.FormatException("Unfinished UTF-8 octet sequence"); 2429 dart.throw(new core.FormatException("Unfinished UTF-8 octet sequence") );
2430 } 2430 }
2431 this[_stringSink].writeCharCode(UNICODE_REPLACEMENT_CHARACTER_RUNE); 2431 this[_stringSink].writeCharCode(UNICODE_REPLACEMENT_CHARACTER_RUNE);
2432 this[_value] = 0; 2432 this[_value] = 0;
2433 this[_expectedUnits] = 0; 2433 this[_expectedUnits] = 0;
2434 this[_extraUnits] = 0; 2434 this[_extraUnits] = 0;
2435 } 2435 }
2436 } 2436 }
2437 convert(codeUnits, startIndex, endIndex) { 2437 convert(codeUnits, startIndex, endIndex) {
2438 let value = this[_value]; 2438 let value = this[_value];
2439 let expectedUnits = this[_expectedUnits]; 2439 let expectedUnits = this[_expectedUnits];
(...skipping 24 matching lines...) Expand all
2464 multibyte: 2464 multibyte:
2465 if (dart.notNull(expectedUnits) > 0) { 2465 if (dart.notNull(expectedUnits) > 0) {
2466 do { 2466 do {
2467 if (i == endIndex) { 2467 if (i == endIndex) {
2468 break loop; 2468 break loop;
2469 } 2469 }
2470 let unit = codeUnits[dartx.get](i); 2470 let unit = codeUnits[dartx.get](i);
2471 if ((dart.notNull(unit) & 192) != 128) { 2471 if ((dart.notNull(unit) & 192) != 128) {
2472 expectedUnits = 0; 2472 expectedUnits = 0;
2473 if (!dart.notNull(this[_allowMalformed])) { 2473 if (!dart.notNull(this[_allowMalformed])) {
2474 throw new core.FormatException(`Bad UTF-8 encoding 0x${unit[ dartx.toRadixString](16)}`); 2474 dart.throw(new core.FormatException(`Bad UTF-8 encoding 0x${ unit[dartx.toRadixString](16)}`));
2475 } 2475 }
2476 this[_isFirstCharacter] = false; 2476 this[_isFirstCharacter] = false;
2477 this[_stringSink].writeCharCode(UNICODE_REPLACEMENT_CHARACTER_ RUNE); 2477 this[_stringSink].writeCharCode(UNICODE_REPLACEMENT_CHARACTER_ RUNE);
2478 break multibyte; 2478 break multibyte;
2479 } else { 2479 } else {
2480 value = dart.notNull(value) << 6 | dart.notNull(unit) & 63; 2480 value = dart.notNull(value) << 6 | dart.notNull(unit) & 63;
2481 expectedUnits = dart.notNull(expectedUnits) - 1; 2481 expectedUnits = dart.notNull(expectedUnits) - 1;
2482 i = dart.notNull(i) + 1; 2482 i = dart.notNull(i) + 1;
2483 } 2483 }
2484 } while (dart.notNull(expectedUnits) > 0); 2484 } while (dart.notNull(expectedUnits) > 0);
2485 if (dart.notNull(value) <= dart.notNull(_Utf8Decoder._LIMITS[dartx .get](dart.notNull(extraUnits) - 1))) { 2485 if (dart.notNull(value) <= dart.notNull(_Utf8Decoder._LIMITS[dartx .get](dart.notNull(extraUnits) - 1))) {
2486 if (!dart.notNull(this[_allowMalformed])) { 2486 if (!dart.notNull(this[_allowMalformed])) {
2487 throw new core.FormatException(`Overlong encoding of 0x${value [dartx.toRadixString](16)}`); 2487 dart.throw(new core.FormatException(`Overlong encoding of 0x${ value[dartx.toRadixString](16)}`));
2488 } 2488 }
2489 expectedUnits = extraUnits = 0; 2489 expectedUnits = extraUnits = 0;
2490 value = UNICODE_REPLACEMENT_CHARACTER_RUNE; 2490 value = UNICODE_REPLACEMENT_CHARACTER_RUNE;
2491 } 2491 }
2492 if (dart.notNull(value) > dart.notNull(_FOUR_BYTE_LIMIT)) { 2492 if (dart.notNull(value) > dart.notNull(_FOUR_BYTE_LIMIT)) {
2493 if (!dart.notNull(this[_allowMalformed])) { 2493 if (!dart.notNull(this[_allowMalformed])) {
2494 throw new core.FormatException("Character outside valid Unicod e range: " + `0x${value[dartx.toRadixString](16)}`); 2494 dart.throw(new core.FormatException("Character outside valid U nicode range: " + `0x${value[dartx.toRadixString](16)}`));
2495 } 2495 }
2496 value = UNICODE_REPLACEMENT_CHARACTER_RUNE; 2496 value = UNICODE_REPLACEMENT_CHARACTER_RUNE;
2497 } 2497 }
2498 if (!dart.notNull(this[_isFirstCharacter]) || value != UNICODE_BOM _CHARACTER_RUNE) { 2498 if (!dart.notNull(this[_isFirstCharacter]) || value != UNICODE_BOM _CHARACTER_RUNE) {
2499 this[_stringSink].writeCharCode(value); 2499 this[_stringSink].writeCharCode(value);
2500 } 2500 }
2501 this[_isFirstCharacter] = false; 2501 this[_isFirstCharacter] = false;
2502 } 2502 }
2503 while (dart.notNull(i) < dart.notNull(endIndex)) { 2503 while (dart.notNull(i) < dart.notNull(endIndex)) {
2504 let oneBytes = scanOneByteCharacters(codeUnits, i); 2504 let oneBytes = scanOneByteCharacters(codeUnits, i);
2505 if (dart.notNull(oneBytes) > 0) { 2505 if (dart.notNull(oneBytes) > 0) {
2506 this[_isFirstCharacter] = false; 2506 this[_isFirstCharacter] = false;
2507 addSingleBytes(i, dart.notNull(i) + dart.notNull(oneBytes)); 2507 addSingleBytes(i, dart.notNull(i) + dart.notNull(oneBytes));
2508 i = dart.notNull(i) + dart.notNull(oneBytes); 2508 i = dart.notNull(i) + dart.notNull(oneBytes);
2509 if (i == endIndex) 2509 if (i == endIndex)
2510 break; 2510 break;
2511 } 2511 }
2512 let unit = codeUnits[dartx.get]((() => { 2512 let unit = codeUnits[dartx.get]((() => {
2513 let x = i; 2513 let x = i;
2514 i = dart.notNull(x) + 1; 2514 i = dart.notNull(x) + 1;
2515 return x; 2515 return x;
2516 })()); 2516 })());
2517 if (dart.notNull(unit) < 0) { 2517 if (dart.notNull(unit) < 0) {
2518 if (!dart.notNull(this[_allowMalformed])) { 2518 if (!dart.notNull(this[_allowMalformed])) {
2519 throw new core.FormatException(`Negative UTF-8 code unit: -0x${( -dart.notNull(unit))[dartx.toRadixString](16)}`); 2519 dart.throw(new core.FormatException(`Negative UTF-8 code unit: - 0x${(-dart.notNull(unit))[dartx.toRadixString](16)}`));
2520 } 2520 }
2521 this[_stringSink].writeCharCode(UNICODE_REPLACEMENT_CHARACTER_RUNE ); 2521 this[_stringSink].writeCharCode(UNICODE_REPLACEMENT_CHARACTER_RUNE );
2522 } else { 2522 } else {
2523 dart.assert(dart.notNull(unit) > dart.notNull(_ONE_BYTE_LIMIT)); 2523 dart.assert(dart.notNull(unit) > dart.notNull(_ONE_BYTE_LIMIT));
2524 if ((dart.notNull(unit) & 224) == 192) { 2524 if ((dart.notNull(unit) & 224) == 192) {
2525 value = dart.notNull(unit) & 31; 2525 value = dart.notNull(unit) & 31;
2526 expectedUnits = extraUnits = 1; 2526 expectedUnits = extraUnits = 1;
2527 continue loop; 2527 continue loop;
2528 } 2528 }
2529 if ((dart.notNull(unit) & 240) == 224) { 2529 if ((dart.notNull(unit) & 240) == 224) {
2530 value = dart.notNull(unit) & 15; 2530 value = dart.notNull(unit) & 15;
2531 expectedUnits = extraUnits = 2; 2531 expectedUnits = extraUnits = 2;
2532 continue loop; 2532 continue loop;
2533 } 2533 }
2534 if ((dart.notNull(unit) & 248) == 240 && dart.notNull(unit) < 245) { 2534 if ((dart.notNull(unit) & 248) == 240 && dart.notNull(unit) < 245) {
2535 value = dart.notNull(unit) & 7; 2535 value = dart.notNull(unit) & 7;
2536 expectedUnits = extraUnits = 3; 2536 expectedUnits = extraUnits = 3;
2537 continue loop; 2537 continue loop;
2538 } 2538 }
2539 if (!dart.notNull(this[_allowMalformed])) { 2539 if (!dart.notNull(this[_allowMalformed])) {
2540 throw new core.FormatException(`Bad UTF-8 encoding 0x${unit[dart x.toRadixString](16)}`); 2540 dart.throw(new core.FormatException(`Bad UTF-8 encoding 0x${unit [dartx.toRadixString](16)}`));
2541 } 2541 }
2542 value = UNICODE_REPLACEMENT_CHARACTER_RUNE; 2542 value = UNICODE_REPLACEMENT_CHARACTER_RUNE;
2543 expectedUnits = extraUnits = 0; 2543 expectedUnits = extraUnits = 0;
2544 this[_isFirstCharacter] = false; 2544 this[_isFirstCharacter] = false;
2545 this[_stringSink].writeCharCode(value); 2545 this[_stringSink].writeCharCode(value);
2546 } 2546 }
2547 } 2547 }
2548 break loop; 2548 break loop;
2549 } 2549 }
2550 if (dart.notNull(expectedUnits) > 0) { 2550 if (dart.notNull(expectedUnits) > 0) {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
2718 let keys = this[_computeKeys](); 2718 let keys = this[_computeKeys]();
2719 for (let i = 0; dart.notNull(i) < dart.notNull(keys[dartx.length]); i = da rt.notNull(i) + 1) { 2719 for (let i = 0; dart.notNull(i) < dart.notNull(keys[dartx.length]); i = da rt.notNull(i) + 1) {
2720 let key = keys[dartx.get](i); 2720 let key = keys[dartx.get](i);
2721 let value = _JsonMap._getProperty(this[_processed], key); 2721 let value = _JsonMap._getProperty(this[_processed], key);
2722 if (dart.notNull(_JsonMap._isUnprocessed(value))) { 2722 if (dart.notNull(_JsonMap._isUnprocessed(value))) {
2723 value = _convertJsonToDartLazy(_JsonMap._getProperty(this[_original], key)); 2723 value = _convertJsonToDartLazy(_JsonMap._getProperty(this[_original], key));
2724 _JsonMap._setProperty(this[_processed], key, value); 2724 _JsonMap._setProperty(this[_processed], key, value);
2725 } 2725 }
2726 dart.dcall(f, key, value); 2726 dart.dcall(f, key, value);
2727 if (!dart.notNull(core.identical(keys, this[_data]))) { 2727 if (!dart.notNull(core.identical(keys, this[_data]))) {
2728 throw new core.ConcurrentModificationError(this); 2728 dart.throw(new core.ConcurrentModificationError(this));
2729 } 2729 }
2730 } 2730 }
2731 } 2731 }
2732 toString() { 2732 toString() {
2733 return collection.Maps.mapToString(this); 2733 return collection.Maps.mapToString(this);
2734 } 2734 }
2735 get [_isUpgraded]() { 2735 get [_isUpgraded]() {
2736 return this[_processed] == null; 2736 return this[_processed] == null;
2737 } 2737 }
2738 get [_upgradedMap]() { 2738 get [_upgradedMap]() {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2894 exports.LineSplitter = LineSplitter; 2894 exports.LineSplitter = LineSplitter;
2895 exports.StringConversionSink = StringConversionSink; 2895 exports.StringConversionSink = StringConversionSink;
2896 exports.ClosableStringSink = ClosableStringSink; 2896 exports.ClosableStringSink = ClosableStringSink;
2897 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN E; 2897 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN E;
2898 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE; 2898 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE;
2899 exports.Utf8Codec = Utf8Codec; 2899 exports.Utf8Codec = Utf8Codec;
2900 exports.UTF8 = UTF8; 2900 exports.UTF8 = UTF8;
2901 exports.Utf8Encoder = Utf8Encoder; 2901 exports.Utf8Encoder = Utf8Encoder;
2902 exports.Utf8Decoder = Utf8Decoder; 2902 exports.Utf8Decoder = Utf8Decoder;
2903 }); 2903 });
OLDNEW
« no previous file with comments | « lib/runtime/dart/collection.js ('k') | lib/runtime/dart/core.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698