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

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

Issue 1752193002: Add a few more known non-null cases (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 9 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', 2 'dart/_runtime',
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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 } 253 }
254 return core.String.fromCharCodes(bytes, start, end); 254 return core.String.fromCharCodes(bytes, start, end);
255 } 255 }
256 [_convertInvalid](bytes, start, end) { 256 [_convertInvalid](bytes, start, end) {
257 let buffer = new core.StringBuffer(); 257 let buffer = new core.StringBuffer();
258 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) { 258 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) {
259 let value = bytes[dartx.get](i); 259 let value = bytes[dartx.get](i);
260 if ((dart.notNull(value) & ~dart.notNull(this[_subsetMask])) != 0) value = 65533; 260 if ((dart.notNull(value) & ~dart.notNull(this[_subsetMask])) != 0) value = 65533;
261 buffer.writeCharCode(value); 261 buffer.writeCharCode(value);
262 } 262 }
263 return dart.toString(buffer); 263 return buffer.toString();
264 } 264 }
265 bind(stream) { 265 bind(stream) {
266 return super.bind(stream); 266 return super.bind(stream);
267 } 267 }
268 } 268 }
269 dart.setSignature(_UnicodeSubsetDecoder, { 269 dart.setSignature(_UnicodeSubsetDecoder, {
270 constructors: () => ({_UnicodeSubsetDecoder: [_UnicodeSubsetDecoder, [core.b ool, core.int]]}), 270 constructors: () => ({_UnicodeSubsetDecoder: [_UnicodeSubsetDecoder, [core.b ool, core.int]]}),
271 methods: () => ({ 271 methods: () => ({
272 convert: [core.String, [core.List$(core.int)], [core.int, core.int]], 272 convert: [core.String, [core.List$(core.int)], [core.int, core.int]],
273 [_convertInvalid]: [core.String, [core.List$(core.int), core.int, core.int ]], 273 [_convertInvalid]: [core.String, [core.List$(core.int), core.int, core.int ]],
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 } 1139 }
1140 } 1140 }
1141 if (offset == 0) { 1141 if (offset == 0) {
1142 this.writeString(s); 1142 this.writeString(s);
1143 } else if (offset < dart.notNull(length)) { 1143 } else if (offset < dart.notNull(length)) {
1144 this.writeStringSlice(s, offset, length); 1144 this.writeStringSlice(s, offset, length);
1145 } 1145 }
1146 } 1146 }
1147 [_checkCycle](object) { 1147 [_checkCycle](object) {
1148 for (let i = 0; i < dart.notNull(this[_seen][dartx.length]); i++) { 1148 for (let i = 0; i < dart.notNull(this[_seen][dartx.length]); i++) {
1149 if (dart.notNull(core.identical(object, this[_seen][dartx.get](i)))) { 1149 if (core.identical(object, this[_seen][dartx.get](i))) {
1150 dart.throw(new JsonCyclicError(object)); 1150 dart.throw(new JsonCyclicError(object));
1151 } 1151 }
1152 } 1152 }
1153 this[_seen][dartx.add](object); 1153 this[_seen][dartx.add](object);
1154 } 1154 }
1155 [_removeSeen](object) { 1155 [_removeSeen](object) {
1156 dart.assert(!dart.notNull(this[_seen][dartx.isEmpty])); 1156 dart.assert(!dart.notNull(this[_seen][dartx.isEmpty]));
1157 dart.assert(core.identical(this[_seen][dartx.last], object)); 1157 dart.assert(core.identical(this[_seen][dartx.last], object));
1158 this[_seen][dartx.removeLast](); 1158 this[_seen][dartx.removeLast]();
1159 } 1159 }
1160 writeObject(object) { 1160 writeObject(object) {
1161 if (dart.notNull(this.writeJsonValue(object))) return; 1161 if (dart.notNull(this.writeJsonValue(object))) return;
1162 this[_checkCycle](object); 1162 this[_checkCycle](object);
1163 try { 1163 try {
1164 let customJson = dart.dcall(this[_toEncodable$], object); 1164 let customJson = dart.dcall(this[_toEncodable$], object);
1165 if (!dart.notNull(this.writeJsonValue(customJson))) { 1165 if (!dart.notNull(this.writeJsonValue(customJson))) {
1166 dart.throw(new JsonUnsupportedObjectError(object)); 1166 dart.throw(new JsonUnsupportedObjectError(object));
1167 } 1167 }
1168 this[_removeSeen](object); 1168 this[_removeSeen](object);
1169 } catch (e) { 1169 } catch (e) {
1170 dart.throw(new JsonUnsupportedObjectError(object, {cause: e})); 1170 dart.throw(new JsonUnsupportedObjectError(object, {cause: e}));
1171 } 1171 }
1172 1172
1173 } 1173 }
1174 writeJsonValue(object) { 1174 writeJsonValue(object) {
1175 if (typeof object == 'number') { 1175 if (typeof object == 'number') {
1176 if (!dart.notNull(object[dartx.isFinite])) return false; 1176 if (!dart.notNull(object[dartx.isFinite])) return false;
1177 this.writeNumber(object); 1177 this.writeNumber(object);
1178 return true; 1178 return true;
1179 } else if (dart.notNull(core.identical(object, true))) { 1179 } else if (core.identical(object, true)) {
1180 this.writeString('true'); 1180 this.writeString('true');
1181 return true; 1181 return true;
1182 } else if (dart.notNull(core.identical(object, false))) { 1182 } else if (core.identical(object, false)) {
1183 this.writeString('false'); 1183 this.writeString('false');
1184 return true; 1184 return true;
1185 } else if (object == null) { 1185 } else if (object == null) {
1186 this.writeString('null'); 1186 this.writeString('null');
1187 return true; 1187 return true;
1188 } else if (typeof object == 'string') { 1188 } else if (typeof object == 'string') {
1189 this.writeString('"'); 1189 this.writeString('"');
1190 this.writeStringContent(object); 1190 this.writeStringContent(object);
1191 this.writeString('"'); 1191 this.writeString('"');
1192 return true; 1192 return true;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 }) 1313 })
1314 }); 1314 });
1315 class _JsonStringStringifier extends _JsonStringifier { 1315 class _JsonStringStringifier extends _JsonStringifier {
1316 _JsonStringStringifier(sink, _toEncodable) { 1316 _JsonStringStringifier(sink, _toEncodable) {
1317 this[_sink] = sink; 1317 this[_sink] = sink;
1318 super._JsonStringifier(dart.as(_toEncodable, dart.functionType(core.Object , [core.Object]))); 1318 super._JsonStringifier(dart.as(_toEncodable, dart.functionType(core.Object , [core.Object])));
1319 } 1319 }
1320 static stringify(object, toEncodable, indent) { 1320 static stringify(object, toEncodable, indent) {
1321 let output = new core.StringBuffer(); 1321 let output = new core.StringBuffer();
1322 _JsonStringStringifier.printOn(object, output, toEncodable, indent); 1322 _JsonStringStringifier.printOn(object, output, toEncodable, indent);
1323 return dart.toString(output); 1323 return output.toString();
1324 } 1324 }
1325 static printOn(object, output, toEncodable, indent) { 1325 static printOn(object, output, toEncodable, indent) {
1326 let stringifier = null; 1326 let stringifier = null;
1327 if (indent == null) { 1327 if (indent == null) {
1328 stringifier = new _JsonStringStringifier(output, toEncodable); 1328 stringifier = new _JsonStringStringifier(output, toEncodable);
1329 } else { 1329 } else {
1330 stringifier = new _JsonStringStringifierPretty(output, toEncodable, inde nt); 1330 stringifier = new _JsonStringStringifierPretty(output, toEncodable, inde nt);
1331 } 1331 }
1332 dart.dsend(stringifier, 'writeObject', object); 1332 dart.dsend(stringifier, 'writeObject', object);
1333 } 1333 }
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
2277 convert(codeUnits, start, end) { 2277 convert(codeUnits, start, end) {
2278 if (start === void 0) start = 0; 2278 if (start === void 0) start = 0;
2279 if (end === void 0) end = null; 2279 if (end === void 0) end = null;
2280 let length = codeUnits[dartx.length]; 2280 let length = codeUnits[dartx.length];
2281 core.RangeError.checkValidRange(start, end, length); 2281 core.RangeError.checkValidRange(start, end, length);
2282 if (end == null) end = length; 2282 if (end == null) end = length;
2283 let buffer = new core.StringBuffer(); 2283 let buffer = new core.StringBuffer();
2284 let decoder = new _Utf8Decoder(buffer, this[_allowMalformed]); 2284 let decoder = new _Utf8Decoder(buffer, this[_allowMalformed]);
2285 decoder.convert(codeUnits, start, end); 2285 decoder.convert(codeUnits, start, end);
2286 decoder.close(); 2286 decoder.close();
2287 return dart.toString(buffer); 2287 return buffer.toString();
2288 } 2288 }
2289 startChunkedConversion(sink) { 2289 startChunkedConversion(sink) {
2290 let stringSink = null; 2290 let stringSink = null;
2291 if (dart.is(sink, StringConversionSink)) { 2291 if (dart.is(sink, StringConversionSink)) {
2292 stringSink = sink; 2292 stringSink = sink;
2293 } else { 2293 } else {
2294 stringSink = StringConversionSink.from(sink); 2294 stringSink = StringConversionSink.from(sink);
2295 } 2295 }
2296 return stringSink.asUtf8Sink(this[_allowMalformed]); 2296 return stringSink.asUtf8Sink(this[_allowMalformed]);
2297 } 2297 }
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
2578 if (dart.notNull(this[_isUpgraded])) return this[_upgradedMap][dartx.value s]; 2578 if (dart.notNull(this[_isUpgraded])) return this[_upgradedMap][dartx.value s];
2579 return _internal.MappedIterable.new(this[_computeKeys](), dart.fn(each => this.get(each))); 2579 return _internal.MappedIterable.new(this[_computeKeys](), dart.fn(each => this.get(each)));
2580 } 2580 }
2581 set(key, value) { 2581 set(key, value) {
2582 if (dart.notNull(this[_isUpgraded])) { 2582 if (dart.notNull(this[_isUpgraded])) {
2583 this[_upgradedMap][dartx.set](key, value); 2583 this[_upgradedMap][dartx.set](key, value);
2584 } else if (dart.notNull(this.containsKey(key))) { 2584 } else if (dart.notNull(this.containsKey(key))) {
2585 let processed = this[_processed]; 2585 let processed = this[_processed];
2586 _JsonMap._setProperty(processed, dart.as(key, core.String), value); 2586 _JsonMap._setProperty(processed, dart.as(key, core.String), value);
2587 let original = this[_original]; 2587 let original = this[_original];
2588 if (!dart.notNull(core.identical(original, processed))) { 2588 if (!core.identical(original, processed)) {
2589 _JsonMap._setProperty(original, dart.as(key, core.String), null); 2589 _JsonMap._setProperty(original, dart.as(key, core.String), null);
2590 } 2590 }
2591 } else { 2591 } else {
2592 this[_upgrade]()[dartx.set](key, value); 2592 this[_upgrade]()[dartx.set](key, value);
2593 } 2593 }
2594 return value; 2594 return value;
2595 } 2595 }
2596 addAll(other) { 2596 addAll(other) {
2597 other[dartx.forEach](dart.fn((key, value) => { 2597 other[dartx.forEach](dart.fn((key, value) => {
2598 this.set(key, value); 2598 this.set(key, value);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2637 if (dart.notNull(this[_isUpgraded])) return this[_upgradedMap][dartx.forEa ch](f); 2637 if (dart.notNull(this[_isUpgraded])) return this[_upgradedMap][dartx.forEa ch](f);
2638 let keys = this[_computeKeys](); 2638 let keys = this[_computeKeys]();
2639 for (let i = 0; i < dart.notNull(keys[dartx.length]); i++) { 2639 for (let i = 0; i < dart.notNull(keys[dartx.length]); i++) {
2640 let key = keys[dartx.get](i); 2640 let key = keys[dartx.get](i);
2641 let value = _JsonMap._getProperty(this[_processed], key); 2641 let value = _JsonMap._getProperty(this[_processed], key);
2642 if (dart.notNull(_JsonMap._isUnprocessed(value))) { 2642 if (dart.notNull(_JsonMap._isUnprocessed(value))) {
2643 value = _convertJsonToDartLazy(_JsonMap._getProperty(this[_original], key)); 2643 value = _convertJsonToDartLazy(_JsonMap._getProperty(this[_original], key));
2644 _JsonMap._setProperty(this[_processed], key, value); 2644 _JsonMap._setProperty(this[_processed], key, value);
2645 } 2645 }
2646 dart.dcall(f, key, value); 2646 dart.dcall(f, key, value);
2647 if (!dart.notNull(core.identical(keys, this[_data]))) { 2647 if (!core.identical(keys, this[_data])) {
2648 dart.throw(new core.ConcurrentModificationError(this)); 2648 dart.throw(new core.ConcurrentModificationError(this));
2649 } 2649 }
2650 } 2650 }
2651 } 2651 }
2652 toString() { 2652 toString() {
2653 return collection.Maps.mapToString(this); 2653 return collection.Maps.mapToString(this);
2654 } 2654 }
2655 get [_isUpgraded]() { 2655 get [_isUpgraded]() {
2656 return this[_processed] == null; 2656 return this[_processed] == null;
2657 } 2657 }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
2828 exports.LineSplitter = LineSplitter; 2828 exports.LineSplitter = LineSplitter;
2829 exports.StringConversionSink = StringConversionSink; 2829 exports.StringConversionSink = StringConversionSink;
2830 exports.ClosableStringSink = ClosableStringSink; 2830 exports.ClosableStringSink = ClosableStringSink;
2831 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN E; 2831 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN E;
2832 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE; 2832 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE;
2833 exports.Utf8Codec = Utf8Codec; 2833 exports.Utf8Codec = Utf8Codec;
2834 exports.UTF8 = UTF8; 2834 exports.UTF8 = UTF8;
2835 exports.Utf8Encoder = Utf8Encoder; 2835 exports.Utf8Encoder = Utf8Encoder;
2836 exports.Utf8Decoder = Utf8Decoder; 2836 exports.Utf8Decoder = Utf8Decoder;
2837 }); 2837 });
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