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

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

Issue 1096583002: Reifier hookup (Closed) Base URL: git@github.com:dart-lang/dart-dev-compiler.git@master
Patch Set: Address comments Created 5 years, 8 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 var convert; 1 var convert;
2 (function(exports) { 2 (function(exports) {
3 'use strict'; 3 'use strict';
4 let ASCII = new AsciiCodec(); 4 let ASCII = new AsciiCodec();
5 let _ASCII_MASK = 127; 5 let _ASCII_MASK = 127;
6 let _allowInvalid = Symbol('_allowInvalid'); 6 let _allowInvalid = Symbol('_allowInvalid');
7 let _nameToEncoding = Symbol('_nameToEncoding'); 7 let _nameToEncoding = Symbol('_nameToEncoding');
8 let Codec$ = dart.generic(function(S, T) { 8 let Codec$ = dart.generic(function(S, T) {
9 class Codec extends core.Object { 9 class Codec extends core.Object {
10 Codec() { 10 Codec() {
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 if (reviver == null) 655 if (reviver == null)
656 return this.decoder.convert(source); 656 return this.decoder.convert(source);
657 return new JsonDecoder(reviver).convert(source); 657 return new JsonDecoder(reviver).convert(source);
658 } 658 }
659 encode(value, opts) { 659 encode(value, opts) {
660 let toEncodable = opts && 'toEncodable' in opts ? opts.toEncodable : null; 660 let toEncodable = opts && 'toEncodable' in opts ? opts.toEncodable : null;
661 if (toEncodable == null) 661 if (toEncodable == null)
662 toEncodable = this[_toEncodable$]; 662 toEncodable = this[_toEncodable$];
663 if (toEncodable == null) 663 if (toEncodable == null)
664 return this.encoder.convert(value); 664 return this.encoder.convert(value);
665 return new JsonEncoder(dart.as(toEncodable, dart.functionType(core.Object, [core.Object]))).convert(value); 665 return new JsonEncoder(dart.as(toEncodable, __CastType0)).convert(value);
666 } 666 }
667 get encoder() { 667 get encoder() {
668 if (this[_toEncodable$] == null) 668 if (this[_toEncodable$] == null)
669 return new JsonEncoder(); 669 return new JsonEncoder();
670 return new JsonEncoder(dart.as(this[_toEncodable$], dart.functionType(core .Object, [core.Object]))); 670 return new JsonEncoder(dart.as(this[_toEncodable$], dart.functionType(core .Object, [core.Object])));
671 } 671 }
672 get decoder() { 672 get decoder() {
673 if (this[_reviver] == null) 673 if (this[_reviver] == null)
674 return new JsonDecoder(); 674 return new JsonDecoder();
675 return new JsonDecoder(this[_reviver]); 675 return new JsonDecoder(this[_reviver]);
(...skipping 10 matching lines...) Expand all
686 super.Converter(); 686 super.Converter();
687 } 687 }
688 withIndent(indent, toEncodable) { 688 withIndent(indent, toEncodable) {
689 if (toEncodable === void 0) 689 if (toEncodable === void 0)
690 toEncodable = null; 690 toEncodable = null;
691 this.indent = indent; 691 this.indent = indent;
692 this[_toEncodable$] = toEncodable; 692 this[_toEncodable$] = toEncodable;
693 super.Converter(); 693 super.Converter();
694 } 694 }
695 convert(object) { 695 convert(object) {
696 return _JsonStringStringifier.stringify(object, dart.as(this[_toEncodable$ ], dart.functionType(dart.dynamic, [dart.dynamic])), this.indent); 696 return _JsonStringStringifier.stringify(object, dart.as(this[_toEncodable$ ], __CastType2), this.indent);
697 } 697 }
698 startChunkedConversion(sink) { 698 startChunkedConversion(sink) {
699 if (!dart.is(sink, StringConversionSink)) { 699 if (!dart.is(sink, StringConversionSink)) {
700 sink = new StringConversionSink.from(sink); 700 sink = new StringConversionSink.from(sink);
701 } else if (dart.is(sink, _Utf8EncoderSink)) { 701 } else if (dart.is(sink, _Utf8EncoderSink)) {
702 return new _JsonUtf8EncoderSink(sink[_sink], this[_toEncodable$], JsonUt f8Encoder[_utf8Encode](this.indent), JsonUtf8Encoder.DEFAULT_BUFFER_SIZE); 702 return new _JsonUtf8EncoderSink(sink[_sink], this[_toEncodable$], JsonUt f8Encoder[_utf8Encode](this.indent), JsonUtf8Encoder.DEFAULT_BUFFER_SIZE);
703 } 703 }
704 return new _JsonEncoderSink(dart.as(sink, StringConversionSink), this[_toE ncodable$], this.indent); 704 return new _JsonEncoderSink(dart.as(sink, StringConversionSink), this[_toE ncodable$], this.indent);
705 } 705 }
706 bind(stream) { 706 bind(stream) {
707 return dart.as(super.bind(stream), async.Stream$(core.String)); 707 return dart.as(super.bind(stream), async.Stream$(core.String));
708 } 708 }
709 fuse(other) { 709 fuse(other) {
710 if (dart.is(other, Utf8Encoder)) { 710 if (dart.is(other, Utf8Encoder)) {
711 return new JsonUtf8Encoder(this.indent, dart.as(this[_toEncodable$], dar t.functionType(dart.dynamic, [core.Object]))); 711 return new JsonUtf8Encoder(this.indent, dart.as(this[_toEncodable$], __C astType4));
712 } 712 }
713 return super.fuse(other); 713 return super.fuse(other);
714 } 714 }
715 } 715 }
716 dart.defineNamedConstructor(JsonEncoder, 'withIndent'); 716 dart.defineNamedConstructor(JsonEncoder, 'withIndent');
717 let _indent = Symbol('_indent'); 717 let _indent = Symbol('_indent');
718 let _bufferSize = Symbol('_bufferSize'); 718 let _bufferSize = Symbol('_bufferSize');
719 class JsonUtf8Encoder extends Converter$(core.Object, core.List$(core.int)) { 719 class JsonUtf8Encoder extends Converter$(core.Object, core.List$(core.int)) {
720 JsonUtf8Encoder(indent, toEncodable, bufferSize) { 720 JsonUtf8Encoder(indent, toEncodable, bufferSize) {
721 if (indent === void 0) 721 if (indent === void 0)
(...skipping 15 matching lines...) Expand all
737 checkAscii: { 737 checkAscii: {
738 for (let i = 0; dart.notNull(i) < dart.notNull(string.length); i = dart. notNull(i) + 1) { 738 for (let i = 0; dart.notNull(i) < dart.notNull(string.length); i = dart. notNull(i) + 1) {
739 if (dart.notNull(string.codeUnitAt(i)) >= 128) 739 if (dart.notNull(string.codeUnitAt(i)) >= 128)
740 break checkAscii; 740 break checkAscii;
741 } 741 }
742 return string.codeUnits; 742 return string.codeUnits;
743 } 743 }
744 return UTF8.encode(string); 744 return UTF8.encode(string);
745 } 745 }
746 convert(object) { 746 convert(object) {
747 let bytes = dart.as(new core.List.from([]), core.List$(core.List$(core.int ))); 747 let bytes = new core.List$(core.List$(core.int)).from([]);
748 // Function addChunk: (Uint8List, int, int) → void 748 // Function addChunk: (Uint8List, int, int) → void
749 function addChunk(chunk, start, end) { 749 function addChunk(chunk, start, end) {
750 if (dart.notNull(start) > 0 || dart.notNull(end) < dart.notNull(chunk[co re.$length])) { 750 if (dart.notNull(start) > 0 || dart.notNull(end) < dart.notNull(chunk[co re.$length])) {
751 let length = dart.notNull(end) - dart.notNull(start); 751 let length = dart.notNull(end) - dart.notNull(start);
752 chunk = new typed_data.Uint8List.view(chunk.buffer, dart.notNull(chunk .offsetInBytes) + dart.notNull(start), length); 752 chunk = new typed_data.Uint8List.view(chunk.buffer, dart.notNull(chunk .offsetInBytes) + dart.notNull(start), length);
753 } 753 }
754 bytes[core.$add](chunk); 754 bytes[core.$add](chunk);
755 } 755 }
756 _JsonUtf8Stringifier.stringify(object, this[_indent], dart.as(this[_toEnco dable$], dart.functionType(dart.dynamic, [core.Object])), this[_bufferSize], add Chunk); 756 _JsonUtf8Stringifier.stringify(object, this[_indent], dart.as(this[_toEnco dable$], dart.functionType(dart.dynamic, [core.Object])), this[_bufferSize], add Chunk);
757 if (bytes[core.$length] == 1) 757 if (bytes[core.$length] == 1)
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 for (let i = 1; dart.notNull(i) < dart.notNull(list[core.$length]); i = dart.notNull(i) + 1) { 1014 for (let i = 1; dart.notNull(i) < dart.notNull(list[core.$length]); i = dart.notNull(i) + 1) {
1015 this.writeString(','); 1015 this.writeString(',');
1016 this.writeObject(list[core.$get](i)); 1016 this.writeObject(list[core.$get](i));
1017 } 1017 }
1018 } 1018 }
1019 this.writeString(']'); 1019 this.writeString(']');
1020 } 1020 }
1021 writeMap(map) { 1021 writeMap(map) {
1022 this.writeString('{'); 1022 this.writeString('{');
1023 let separator = '"'; 1023 let separator = '"';
1024 map.forEach(dart.as(((key, value) => { 1024 map.forEach(((key, value) => {
1025 this.writeString(separator); 1025 this.writeString(separator);
1026 separator = ',"'; 1026 separator = ',"';
1027 this.writeStringContent(key); 1027 this.writeStringContent(key);
1028 this.writeString('":'); 1028 this.writeString('":');
1029 this.writeObject(value); 1029 this.writeObject(value);
1030 }).bind(this), dart.functionType(dart.void, [core.String, core.Object]))); 1030 }).bind(this));
1031 this.writeString('}'); 1031 this.writeString('}');
1032 } 1032 }
1033 } 1033 }
1034 _JsonStringifier.BACKSPACE = 8; 1034 _JsonStringifier.BACKSPACE = 8;
1035 _JsonStringifier.TAB = 9; 1035 _JsonStringifier.TAB = 9;
1036 _JsonStringifier.NEWLINE = 10; 1036 _JsonStringifier.NEWLINE = 10;
1037 _JsonStringifier.CARRIAGE_RETURN = 13; 1037 _JsonStringifier.CARRIAGE_RETURN = 13;
1038 _JsonStringifier.FORM_FEED = 12; 1038 _JsonStringifier.FORM_FEED = 12;
1039 _JsonStringifier.QUOTE = 34; 1039 _JsonStringifier.QUOTE = 34;
1040 _JsonStringifier.CHAR_0 = 48; 1040 _JsonStringifier.CHAR_0 = 48;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 this.buffer[core.$setRange](this.index, end, indent); 1259 this.buffer[core.$setRange](this.index, end, indent);
1260 this.index = end; 1260 this.index = end;
1261 } else { 1261 } else {
1262 for (let i = 0; dart.notNull(i) < dart.notNull(indentLength); i = dart .notNull(i) + 1) { 1262 for (let i = 0; dart.notNull(i) < dart.notNull(indentLength); i = dart .notNull(i) + 1) {
1263 this.writeByte(indent[core.$get](i)); 1263 this.writeByte(indent[core.$get](i));
1264 } 1264 }
1265 } 1265 }
1266 } 1266 }
1267 } 1267 }
1268 } 1268 }
1269 let __CastType0 = dart.typedef('__CastType0', () => dart.functionType(core.Obj ect, [core.Object]));
1270 let __CastType2 = dart.typedef('__CastType2', () => dart.functionType(dart.dyn amic, [dart.dynamic]));
1271 let __CastType4 = dart.typedef('__CastType4', () => dart.functionType(dart.dyn amic, [core.Object]));
1269 let LATIN1 = new Latin1Codec(); 1272 let LATIN1 = new Latin1Codec();
1270 let _LATIN1_MASK = 255; 1273 let _LATIN1_MASK = 255;
1271 class Latin1Codec extends Encoding { 1274 class Latin1Codec extends Encoding {
1272 Latin1Codec(opts) { 1275 Latin1Codec(opts) {
1273 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : fa lse; 1276 let allowInvalid = opts && 'allowInvalid' in opts ? opts.allowInvalid : fa lse;
1274 this[_allowInvalid] = allowInvalid; 1277 this[_allowInvalid] = allowInvalid;
1275 super.Encoding(); 1278 super.Encoding();
1276 } 1279 }
1277 get name() { 1280 get name() {
1278 return "iso-8859-1"; 1281 return "iso-8859-1";
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 _Latin1AllowInvalidDecoderSink(sink) { 1356 _Latin1AllowInvalidDecoderSink(sink) {
1354 super._Latin1DecoderSink(sink); 1357 super._Latin1DecoderSink(sink);
1355 } 1358 }
1356 addSlice(source, start, end, isLast) { 1359 addSlice(source, start, end, isLast) {
1357 core.RangeError.checkValidRange(start, end, source[core.$length]); 1360 core.RangeError.checkValidRange(start, end, source[core.$length]);
1358 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) { 1361 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) {
1359 let char = source[core.$get](i); 1362 let char = source[core.$get](i);
1360 if (dart.notNull(char) > dart.notNull(_LATIN1_MASK) || dart.notNull(char ) < 0) { 1363 if (dart.notNull(char) > dart.notNull(_LATIN1_MASK) || dart.notNull(char ) < 0) {
1361 if (dart.notNull(i) > dart.notNull(start)) 1364 if (dart.notNull(i) > dart.notNull(start))
1362 this[_addSliceToSink](source, start, i, false); 1365 this[_addSliceToSink](source, start, i, false);
1363 this[_addSliceToSink](dart.as(/* Unimplemented const */new core.List.f rom([65533]), core.List$(core.int)), 0, 1, false); 1366 this[_addSliceToSink](/* Unimplemented const */new core.List$(core.int ).from([65533]), 0, 1, false);
1364 start = dart.notNull(i) + 1; 1367 start = dart.notNull(i) + 1;
1365 } 1368 }
1366 } 1369 }
1367 if (dart.notNull(start) < dart.notNull(end)) { 1370 if (dart.notNull(start) < dart.notNull(end)) {
1368 this[_addSliceToSink](source, start, end, isLast); 1371 this[_addSliceToSink](source, start, end, isLast);
1369 } 1372 }
1370 if (isLast) { 1373 if (isLast) {
1371 this.close(); 1374 this.close();
1372 } 1375 }
1373 } 1376 }
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
2434 exports.LineSplitter = LineSplitter; 2437 exports.LineSplitter = LineSplitter;
2435 exports.StringConversionSink = StringConversionSink; 2438 exports.StringConversionSink = StringConversionSink;
2436 exports.ClosableStringSink = ClosableStringSink; 2439 exports.ClosableStringSink = ClosableStringSink;
2437 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN E; 2440 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN E;
2438 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE; 2441 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE;
2439 exports.UTF8 = UTF8; 2442 exports.UTF8 = UTF8;
2440 exports.Utf8Codec = Utf8Codec; 2443 exports.Utf8Codec = Utf8Codec;
2441 exports.Utf8Encoder = Utf8Encoder; 2444 exports.Utf8Encoder = Utf8Encoder;
2442 exports.Utf8Decoder = Utf8Decoder; 2445 exports.Utf8Decoder = Utf8Decoder;
2443 })(convert || (convert = {})); 2446 })(convert || (convert = {}));
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