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

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

Issue 1076883003: Initial support for runtime function types and type checking (Closed) Base URL: https://github.com/dart-lang/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() {
11 } 11 }
12 encode(input) { 12 encode(input) {
13 return this.encoder.convert(input); 13 return this.encoder.convert(input);
14 } 14 }
15 decode(encoded) { 15 decode(encoded) {
16 return this.decoder.convert(encoded); 16 return this.decoder.convert(encoded);
17 } 17 }
18 fuse(other) { 18 fuse(other) {
19 return new (_FusedCodec$(S, T, dynamic))(this, other); 19 return new (_FusedCodec$(S, T, dart.dynamic))(this, other);
20 } 20 }
21 get inverted() { 21 get inverted() {
22 return new (_InvertedCodec$(T, S))(this); 22 return new (_InvertedCodec$(T, S))(this);
23 } 23 }
24 } 24 }
25 return Codec; 25 return Codec;
26 }); 26 });
27 let Codec = Codec$(); 27 let Codec = Codec$();
28 class Encoding extends Codec$(core.String, core.List$(core.int)) { 28 class Encoding extends Codec$(core.String, core.List$(core.int)) {
29 Encoding() { 29 Encoding() {
30 super.Codec(); 30 super.Codec();
31 } 31 }
32 decodeStream(byteStream) { 32 decodeStream(byteStream) {
33 return dart.as(byteStream.transform(dart.as(this.decoder, async.StreamTran sformer$(core.List$(core.int), dynamic))).fold(new core.StringBuffer(), (buffer, string) => dart.dinvoke(buffer, 'write', string), buffer).then((buffer) => buff er.toString()), async.Future$(core.String)); 33 return dart.as(byteStream.transform(dart.as(this.decoder, async.StreamTran sformer$(core.List$(core.int), dart.dynamic))).fold(new core.StringBuffer(), (bu ffer, string) => dart.dinvoke(buffer, 'write', string), buffer).then((buffer) => buffer.toString()), async.Future$(core.String));
34 } 34 }
35 static getByName(name) { 35 static getByName(name) {
36 if (name == null) 36 if (name == null)
37 return null; 37 return null;
38 name = name.toLowerCase(); 38 name = name.toLowerCase();
39 return Encoding[_nameToEncoding].get(name); 39 return Encoding[_nameToEncoding].get(name);
40 } 40 }
41 } 41 }
42 dart.defineLazyProperties(Encoding, { 42 dart.defineLazyProperties(Encoding, {
43 get _nameToEncoding() { 43 get _nameToEncoding() {
(...skipping 26 matching lines...) Expand all
70 get decoder() { 70 get decoder() {
71 return this[_allowInvalid] ? new AsciiDecoder({allowInvalid: true}) : new AsciiDecoder({allowInvalid: false}); 71 return this[_allowInvalid] ? new AsciiDecoder({allowInvalid: true}) : new AsciiDecoder({allowInvalid: false});
72 } 72 }
73 } 73 }
74 let _subsetMask = Symbol('_subsetMask'); 74 let _subsetMask = Symbol('_subsetMask');
75 let Converter$ = dart.generic(function(S, T) { 75 let Converter$ = dart.generic(function(S, T) {
76 class Converter extends core.Object { 76 class Converter extends core.Object {
77 Converter() { 77 Converter() {
78 } 78 }
79 fuse(other) { 79 fuse(other) {
80 return new (_FusedConverter$(S, T, dynamic))(this, other); 80 return new (_FusedConverter$(S, T, dart.dynamic))(this, other);
81 } 81 }
82 startChunkedConversion(sink) { 82 startChunkedConversion(sink) {
83 throw new core.UnsupportedError(`This converter does not support chunked conversions: ${this}`); 83 throw new core.UnsupportedError(`This converter does not support chunked conversions: ${this}`);
84 } 84 }
85 bind(source) { 85 bind(source) {
86 return new async.Stream.eventTransformed(source, ((sink) => new _Convert erStreamEventSink(this, sink)).bind(this)); 86 return new async.Stream.eventTransformed(source, ((sink) => new _Convert erStreamEventSink(this, sink)).bind(this));
87 } 87 }
88 } 88 }
89 Converter[dart.implements] = () => [async.StreamTransformer]; 89 Converter[dart.implements] = () => [async.StreamTransformer];
90 return Converter; 90 return Converter;
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 v = dart.notNull(v) >> 16; 365 v = dart.notNull(v) >> 16;
366 v = dart.notNull(v) + 1; 366 v = dart.notNull(v) + 1;
367 return v; 367 return v;
368 } 368 }
369 close() { 369 close() {
370 this[_callback](this[_buffer][core.$sublist](0, this[_bufferIndex])); 370 this[_callback](this[_buffer][core.$sublist](0, this[_bufferIndex]));
371 } 371 }
372 } 372 }
373 _ByteCallbackSink._INITIAL_BUFFER_SIZE = 1024; 373 _ByteCallbackSink._INITIAL_BUFFER_SIZE = 1024;
374 let _ChunkedConversionCallback$ = dart.generic(function(T) { 374 let _ChunkedConversionCallback$ = dart.generic(function(T) {
375 class _ChunkedConversionCallback extends core.Function {} 375 let _ChunkedConversionCallback = dart.typedef('_ChunkedConversionCallback', () => dart.functionType(dart.void, [T]));
376 return _ChunkedConversionCallback; 376 return _ChunkedConversionCallback;
377 }); 377 });
378 let _ChunkedConversionCallback = _ChunkedConversionCallback$(); 378 let _ChunkedConversionCallback = _ChunkedConversionCallback$();
379 let _accumulated = Symbol('_accumulated'); 379 let _accumulated = Symbol('_accumulated');
380 let _SimpleCallbackSink$ = dart.generic(function(T) { 380 let _SimpleCallbackSink$ = dart.generic(function(T) {
381 class _SimpleCallbackSink extends ChunkedConversionSink$(T) { 381 class _SimpleCallbackSink extends ChunkedConversionSink$(T) {
382 _SimpleCallbackSink(callback$) { 382 _SimpleCallbackSink(callback$) {
383 this[_accumulated] = new core.List$(T).from([]); 383 this[_accumulated] = new core.List$(T).from([]);
384 this[_callback] = callback$; 384 this[_callback] = callback$;
385 super.ChunkedConversionSink(); 385 super.ChunkedConversionSink();
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 } 623 }
624 class JsonCyclicError extends JsonUnsupportedObjectError { 624 class JsonCyclicError extends JsonUnsupportedObjectError {
625 JsonCyclicError(object) { 625 JsonCyclicError(object) {
626 super.JsonUnsupportedObjectError(object); 626 super.JsonUnsupportedObjectError(object);
627 } 627 }
628 toString() { 628 toString() {
629 return "Cyclic error in JSON stringify"; 629 return "Cyclic error in JSON stringify";
630 } 630 }
631 } 631 }
632 let JSON = new JsonCodec(); 632 let JSON = new JsonCodec();
633 class _Reviver extends core.Function {} 633 let _Reviver = dart.typedef('_Reviver', () => dart.functionType(dart.dynamic, [dart.dynamic, dart.dynamic]));
634 class _ToEncodable extends core.Function {} 634 let _ToEncodable = dart.typedef('_ToEncodable', () => dart.functionType(dart.d ynamic, [dart.dynamic]));
635 let _reviver = Symbol('_reviver'); 635 let _reviver = Symbol('_reviver');
636 let _toEncodable$ = Symbol('_toEncodable'); 636 let _toEncodable$ = Symbol('_toEncodable');
637 class JsonCodec extends Codec$(core.Object, core.String) { 637 class JsonCodec extends Codec$(core.Object, core.String) {
638 JsonCodec(opts) { 638 JsonCodec(opts) {
639 let reviver = opts && 'reviver' in opts ? opts.reviver : null; 639 let reviver = opts && 'reviver' in opts ? opts.reviver : null;
640 let toEncodable = opts && 'toEncodable' in opts ? opts.toEncodable : null; 640 let toEncodable = opts && 'toEncodable' in opts ? opts.toEncodable : null;
641 this[_reviver] = reviver; 641 this[_reviver] = reviver;
642 this[_toEncodable$] = toEncodable; 642 this[_toEncodable$] = toEncodable;
643 super.Codec(); 643 super.Codec();
644 } 644 }
645 withReviver(reviver) { 645 withReviver(reviver) {
646 this.JsonCodec({reviver: reviver}); 646 this.JsonCodec({reviver: reviver});
647 } 647 }
648 decode(source, opts) { 648 decode(source, opts) {
649 let reviver = opts && 'reviver' in opts ? opts.reviver : null; 649 let reviver = opts && 'reviver' in opts ? opts.reviver : null;
650 if (reviver == null) 650 if (reviver == null)
651 reviver = this[_reviver]; 651 reviver = this[_reviver];
652 if (reviver == null) 652 if (reviver == null)
653 return this.decoder.convert(source); 653 return this.decoder.convert(source);
654 return new JsonDecoder(reviver).convert(source); 654 return new JsonDecoder(reviver).convert(source);
655 } 655 }
656 encode(value, opts) { 656 encode(value, opts) {
657 let toEncodable = opts && 'toEncodable' in opts ? opts.toEncodable : null; 657 let toEncodable = opts && 'toEncodable' in opts ? opts.toEncodable : null;
658 if (toEncodable == null) 658 if (toEncodable == null)
659 toEncodable = this[_toEncodable$]; 659 toEncodable = this[_toEncodable$];
660 if (toEncodable == null) 660 if (toEncodable == null)
661 return this.encoder.convert(value); 661 return this.encoder.convert(value);
662 return new JsonEncoder(dart.as(toEncodable, dart.throw_("Unimplemented typ e (Object) → Object"))).convert(value); 662 return new JsonEncoder(dart.as(toEncodable, dart.functionType(core.Object, [core.Object]))).convert(value);
663 } 663 }
664 get encoder() { 664 get encoder() {
665 if (this[_toEncodable$] == null) 665 if (this[_toEncodable$] == null)
666 return new JsonEncoder(); 666 return new JsonEncoder();
667 return new JsonEncoder(dart.as(this[_toEncodable$], dart.throw_("Unimpleme nted type (Object) → Object"))); 667 return new JsonEncoder(dart.as(this[_toEncodable$], dart.functionType(core .Object, [core.Object])));
668 } 668 }
669 get decoder() { 669 get decoder() {
670 if (this[_reviver] == null) 670 if (this[_reviver] == null)
671 return new JsonDecoder(); 671 return new JsonDecoder();
672 return new JsonDecoder(this[_reviver]); 672 return new JsonDecoder(this[_reviver]);
673 } 673 }
674 } 674 }
675 dart.defineNamedConstructor(JsonCodec, 'withReviver'); 675 dart.defineNamedConstructor(JsonCodec, 'withReviver');
676 let _utf8Encode = Symbol('_utf8Encode'); 676 let _utf8Encode = Symbol('_utf8Encode');
677 class JsonEncoder extends Converter$(core.Object, core.String) { 677 class JsonEncoder extends Converter$(core.Object, core.String) {
678 JsonEncoder(toEncodable) { 678 JsonEncoder(toEncodable) {
679 if (toEncodable === void 0) 679 if (toEncodable === void 0)
680 toEncodable = null; 680 toEncodable = null;
681 this.indent = null; 681 this.indent = null;
682 this[_toEncodable$] = toEncodable; 682 this[_toEncodable$] = toEncodable;
683 super.Converter(); 683 super.Converter();
684 } 684 }
685 withIndent(indent, toEncodable) { 685 withIndent(indent, toEncodable) {
686 if (toEncodable === void 0) 686 if (toEncodable === void 0)
687 toEncodable = null; 687 toEncodable = null;
688 this.indent = indent; 688 this.indent = indent;
689 this[_toEncodable$] = toEncodable; 689 this[_toEncodable$] = toEncodable;
690 super.Converter(); 690 super.Converter();
691 } 691 }
692 convert(object) { 692 convert(object) {
693 return _JsonStringStringifier.stringify(object, dart.as(this[_toEncodable$ ], dart.throw_("Unimplemented type (dynamic) → dynamic")), this.indent); 693 return _JsonStringStringifier.stringify(object, dart.as(this[_toEncodable$ ], dart.functionType(dart.dynamic, [dart.dynamic])), this.indent);
694 } 694 }
695 startChunkedConversion(sink) { 695 startChunkedConversion(sink) {
696 if (!dart.is(sink, StringConversionSink)) { 696 if (!dart.is(sink, StringConversionSink)) {
697 sink = new StringConversionSink.from(sink); 697 sink = new StringConversionSink.from(sink);
698 } else if (dart.is(sink, _Utf8EncoderSink)) { 698 } else if (dart.is(sink, _Utf8EncoderSink)) {
699 return new _JsonUtf8EncoderSink(sink[_sink], this[_toEncodable$], JsonUt f8Encoder[_utf8Encode](this.indent), JsonUtf8Encoder.DEFAULT_BUFFER_SIZE); 699 return new _JsonUtf8EncoderSink(sink[_sink], this[_toEncodable$], JsonUt f8Encoder[_utf8Encode](this.indent), JsonUtf8Encoder.DEFAULT_BUFFER_SIZE);
700 } 700 }
701 return new _JsonEncoderSink(dart.as(sink, StringConversionSink), this[_toE ncodable$], this.indent); 701 return new _JsonEncoderSink(dart.as(sink, StringConversionSink), this[_toE ncodable$], this.indent);
702 } 702 }
703 bind(stream) { 703 bind(stream) {
704 return dart.as(super.bind(stream), async.Stream$(core.String)); 704 return dart.as(super.bind(stream), async.Stream$(core.String));
705 } 705 }
706 fuse(other) { 706 fuse(other) {
707 if (dart.is(other, Utf8Encoder)) { 707 if (dart.is(other, Utf8Encoder)) {
708 return new JsonUtf8Encoder(this.indent, dart.as(this[_toEncodable$], dar t.throw_("Unimplemented type (Object) → dynamic"))); 708 return new JsonUtf8Encoder(this.indent, dart.as(this[_toEncodable$], dar t.functionType(dart.dynamic, [core.Object])));
709 } 709 }
710 return super.fuse(other); 710 return super.fuse(other);
711 } 711 }
712 } 712 }
713 dart.defineNamedConstructor(JsonEncoder, 'withIndent'); 713 dart.defineNamedConstructor(JsonEncoder, 'withIndent');
714 let _indent = Symbol('_indent'); 714 let _indent = Symbol('_indent');
715 let _bufferSize = Symbol('_bufferSize'); 715 let _bufferSize = Symbol('_bufferSize');
716 class JsonUtf8Encoder extends Converter$(core.Object, core.List$(core.int)) { 716 class JsonUtf8Encoder extends Converter$(core.Object, core.List$(core.int)) {
717 JsonUtf8Encoder(indent, toEncodable, bufferSize) { 717 JsonUtf8Encoder(indent, toEncodable, bufferSize) {
718 if (indent === void 0) 718 if (indent === void 0)
(...skipping 24 matching lines...) Expand all
743 convert(object) { 743 convert(object) {
744 let bytes = dart.as(new core.List.from([]), core.List$(core.List$(core.int ))); 744 let bytes = dart.as(new core.List.from([]), core.List$(core.List$(core.int )));
745 // Function addChunk: (Uint8List, int, int) → void 745 // Function addChunk: (Uint8List, int, int) → void
746 function addChunk(chunk, start, end) { 746 function addChunk(chunk, start, end) {
747 if (dart.notNull(start) > 0 || dart.notNull(end) < dart.notNull(chunk[co re.$length])) { 747 if (dart.notNull(start) > 0 || dart.notNull(end) < dart.notNull(chunk[co re.$length])) {
748 let length = dart.notNull(end) - dart.notNull(start); 748 let length = dart.notNull(end) - dart.notNull(start);
749 chunk = new typed_data.Uint8List.view(chunk.buffer, dart.notNull(chunk .offsetInBytes) + dart.notNull(start), length); 749 chunk = new typed_data.Uint8List.view(chunk.buffer, dart.notNull(chunk .offsetInBytes) + dart.notNull(start), length);
750 } 750 }
751 bytes[core.$add](chunk); 751 bytes[core.$add](chunk);
752 } 752 }
753 _JsonUtf8Stringifier.stringify(object, this[_indent], dart.as(this[_toEnco dable$], dart.throw_("Unimplemented type (Object) → dynamic")), this[_bufferSize ], addChunk); 753 _JsonUtf8Stringifier.stringify(object, this[_indent], dart.as(this[_toEnco dable$], dart.functionType(dart.dynamic, [core.Object])), this[_bufferSize], add Chunk);
754 if (bytes[core.$length] == 1) 754 if (bytes[core.$length] == 1)
755 return bytes[core.$get](0); 755 return bytes[core.$get](0);
756 let length = 0; 756 let length = 0;
757 for (let i = 0; dart.notNull(i) < dart.notNull(bytes[core.$length]); i = d art.notNull(i) + 1) { 757 for (let i = 0; dart.notNull(i) < dart.notNull(bytes[core.$length]); i = d art.notNull(i) + 1) {
758 length = bytes[core.$get](i)[core.$length]; 758 length = bytes[core.$get](i)[core.$length];
759 } 759 }
760 let result = new typed_data.Uint8List(length); 760 let result = new typed_data.Uint8List(length);
761 for (let i = 0, offset = 0; dart.notNull(i) < dart.notNull(bytes[core.$len gth]); i = dart.notNull(i) + 1) { 761 for (let i = 0, offset = 0; dart.notNull(i) < dart.notNull(bytes[core.$len gth]); i = dart.notNull(i) + 1) {
762 let byteList = bytes[core.$get](i); 762 let byteList = bytes[core.$get](i);
763 let end = dart.notNull(offset) + dart.notNull(byteList[core.$length]); 763 let end = dart.notNull(offset) + dart.notNull(byteList[core.$length]);
(...skipping 27 matching lines...) Expand all
791 this[_indent] = indent$; 791 this[_indent] = indent$;
792 this[_isDone] = false; 792 this[_isDone] = false;
793 super.ChunkedConversionSink(); 793 super.ChunkedConversionSink();
794 } 794 }
795 add(o) { 795 add(o) {
796 if (this[_isDone]) { 796 if (this[_isDone]) {
797 throw new core.StateError("Only one call to add allowed"); 797 throw new core.StateError("Only one call to add allowed");
798 } 798 }
799 this[_isDone] = true; 799 this[_isDone] = true;
800 let stringSink = this[_sink].asStringSink(); 800 let stringSink = this[_sink].asStringSink();
801 _JsonStringStringifier.printOn(o, stringSink, dart.as(this[_toEncodable$], dart.throw_("Unimplemented type (dynamic) → dynamic")), this[_indent]); 801 _JsonStringStringifier.printOn(o, stringSink, dart.as(this[_toEncodable$], dart.functionType(dart.dynamic, [dart.dynamic])), this[_indent]);
802 stringSink.close(); 802 stringSink.close();
803 } 803 }
804 close() {} 804 close() {}
805 } 805 }
806 let _addChunk = Symbol('_addChunk'); 806 let _addChunk = Symbol('_addChunk');
807 class _JsonUtf8EncoderSink extends ChunkedConversionSink$(core.Object) { 807 class _JsonUtf8EncoderSink extends ChunkedConversionSink$(core.Object) {
808 _JsonUtf8EncoderSink(sink$, toEncodable$, indent$, bufferSize$) { 808 _JsonUtf8EncoderSink(sink$, toEncodable$, indent$, bufferSize$) {
809 this[_sink] = sink$; 809 this[_sink] = sink$;
810 this[_toEncodable$] = toEncodable$; 810 this[_toEncodable$] = toEncodable$;
811 this[_indent] = indent$; 811 this[_indent] = indent$;
812 this[_bufferSize] = bufferSize$; 812 this[_bufferSize] = bufferSize$;
813 this[_isDone] = false; 813 this[_isDone] = false;
814 super.ChunkedConversionSink(); 814 super.ChunkedConversionSink();
815 } 815 }
816 [_addChunk](chunk, start, end) { 816 [_addChunk](chunk, start, end) {
817 this[_sink].addSlice(chunk, start, end, false); 817 this[_sink].addSlice(chunk, start, end, false);
818 } 818 }
819 add(object) { 819 add(object) {
820 if (this[_isDone]) { 820 if (this[_isDone]) {
821 throw new core.StateError("Only one call to add allowed"); 821 throw new core.StateError("Only one call to add allowed");
822 } 822 }
823 this[_isDone] = true; 823 this[_isDone] = true;
824 _JsonUtf8Stringifier.stringify(object, this[_indent], dart.as(this[_toEnco dable$], dart.throw_("Unimplemented type (Object) → dynamic")), this[_bufferSize ], this[_addChunk]); 824 _JsonUtf8Stringifier.stringify(object, this[_indent], dart.as(this[_toEnco dable$], dart.functionType(dart.dynamic, [core.Object])), this[_bufferSize], thi s[_addChunk]);
825 this[_sink].close(); 825 this[_sink].close();
826 } 826 }
827 close() { 827 close() {
828 if (!dart.notNull(this[_isDone])) { 828 if (!dart.notNull(this[_isDone])) {
829 this[_isDone] = true; 829 this[_isDone] = true;
830 this[_sink].close(); 830 this[_sink].close();
831 } 831 }
832 } 832 }
833 } 833 }
834 class JsonDecoder extends Converter$(core.String, core.Object) { 834 class JsonDecoder extends Converter$(core.String, core.Object) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 } 1017 }
1018 writeMap(map) { 1018 writeMap(map) {
1019 this.writeString('{'); 1019 this.writeString('{');
1020 let separator = '"'; 1020 let separator = '"';
1021 map.forEach(dart.as(((key, value) => { 1021 map.forEach(dart.as(((key, value) => {
1022 this.writeString(separator); 1022 this.writeString(separator);
1023 separator = ',"'; 1023 separator = ',"';
1024 this.writeStringContent(key); 1024 this.writeStringContent(key);
1025 this.writeString('":'); 1025 this.writeString('":');
1026 this.writeObject(value); 1026 this.writeObject(value);
1027 }).bind(this), dart.throw_("Unimplemented type (String, Object) → void"))) ; 1027 }).bind(this), dart.functionType(dart.void, [core.String, core.Object])));
1028 this.writeString('}'); 1028 this.writeString('}');
1029 } 1029 }
1030 } 1030 }
1031 _JsonStringifier.BACKSPACE = 8; 1031 _JsonStringifier.BACKSPACE = 8;
1032 _JsonStringifier.TAB = 9; 1032 _JsonStringifier.TAB = 9;
1033 _JsonStringifier.NEWLINE = 10; 1033 _JsonStringifier.NEWLINE = 10;
1034 _JsonStringifier.CARRIAGE_RETURN = 13; 1034 _JsonStringifier.CARRIAGE_RETURN = 13;
1035 _JsonStringifier.FORM_FEED = 12; 1035 _JsonStringifier.FORM_FEED = 12;
1036 _JsonStringifier.QUOTE = 34; 1036 _JsonStringifier.QUOTE = 34;
1037 _JsonStringifier.CHAR_0 = 48; 1037 _JsonStringifier.CHAR_0 = 48;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 this[_indentLevel] = dart.notNull(this[_indentLevel]) - 1; 1088 this[_indentLevel] = dart.notNull(this[_indentLevel]) - 1;
1089 this.writeIndentation(this[_indentLevel]); 1089 this.writeIndentation(this[_indentLevel]);
1090 this.writeString('}'); 1090 this.writeString('}');
1091 } 1091 }
1092 } 1092 }
1093 } 1093 }
1094 _JsonPrettyPrintMixin[dart.implements] = () => [_JsonStringifier]; 1094 _JsonPrettyPrintMixin[dart.implements] = () => [_JsonStringifier];
1095 class _JsonStringStringifier extends _JsonStringifier { 1095 class _JsonStringStringifier extends _JsonStringifier {
1096 _JsonStringStringifier(sink$, _toEncodable) { 1096 _JsonStringStringifier(sink$, _toEncodable) {
1097 this[_sink] = sink$; 1097 this[_sink] = sink$;
1098 super._JsonStringifier(dart.as(_toEncodable, dart.throw_("Unimplemented ty pe (Object) → Object"))); 1098 super._JsonStringifier(dart.as(_toEncodable, dart.functionType(core.Object , [core.Object])));
1099 } 1099 }
1100 static stringify(object, toEncodable, indent) { 1100 static stringify(object, toEncodable, indent) {
1101 let output = new core.StringBuffer(); 1101 let output = new core.StringBuffer();
1102 _JsonStringStringifier.printOn(object, output, toEncodable, indent); 1102 _JsonStringStringifier.printOn(object, output, toEncodable, indent);
1103 return output.toString(); 1103 return output.toString();
1104 } 1104 }
1105 static printOn(object, output, toEncodable, indent) { 1105 static printOn(object, output, toEncodable, indent) {
1106 let stringifier = null; 1106 let stringifier = null;
1107 if (indent == null) { 1107 if (indent == null) {
1108 stringifier = new _JsonStringStringifier(output, toEncodable); 1108 stringifier = new _JsonStringStringifier(output, toEncodable);
(...skipping 24 matching lines...) Expand all
1133 for (let i = 0; dart.notNull(i) < dart.notNull(count); i = dart.notNull(i) + 1) 1133 for (let i = 0; dart.notNull(i) < dart.notNull(count); i = dart.notNull(i) + 1)
1134 this.writeString(this[_indent]); 1134 this.writeString(this[_indent]);
1135 } 1135 }
1136 } 1136 }
1137 class _JsonUtf8Stringifier extends _JsonStringifier { 1137 class _JsonUtf8Stringifier extends _JsonStringifier {
1138 _JsonUtf8Stringifier(toEncodable, bufferSize, addChunk) { 1138 _JsonUtf8Stringifier(toEncodable, bufferSize, addChunk) {
1139 this.addChunk = addChunk; 1139 this.addChunk = addChunk;
1140 this.bufferSize = bufferSize; 1140 this.bufferSize = bufferSize;
1141 this.buffer = new typed_data.Uint8List(bufferSize); 1141 this.buffer = new typed_data.Uint8List(bufferSize);
1142 this.index = 0; 1142 this.index = 0;
1143 super._JsonStringifier(dart.as(toEncodable, dart.throw_("Unimplemented typ e (Object) → Object"))); 1143 super._JsonStringifier(dart.as(toEncodable, dart.functionType(core.Object, [core.Object])));
1144 } 1144 }
1145 static stringify(object, indent, toEncodableFunction, bufferSize, addChunk) { 1145 static stringify(object, indent, toEncodableFunction, bufferSize, addChunk) {
1146 let stringifier = null; 1146 let stringifier = null;
1147 if (indent != null) { 1147 if (indent != null) {
1148 stringifier = new _JsonUtf8StringifierPretty(toEncodableFunction, indent , bufferSize, addChunk); 1148 stringifier = new _JsonUtf8StringifierPretty(toEncodableFunction, indent , bufferSize, addChunk);
1149 } else { 1149 } else {
1150 stringifier = new _JsonUtf8Stringifier(toEncodableFunction, bufferSize, addChunk); 1150 stringifier = new _JsonUtf8Stringifier(toEncodableFunction, bufferSize, addChunk);
1151 } 1151 }
1152 stringifier.writeObject(object); 1152 stringifier.writeObject(object);
1153 stringifier.flush(); 1153 stringifier.flush();
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 } 1458 }
1459 dart.defineNamedConstructor(StringConversionSink, 'withCallback'); 1459 dart.defineNamedConstructor(StringConversionSink, 'withCallback');
1460 dart.defineNamedConstructor(StringConversionSink, 'from'); 1460 dart.defineNamedConstructor(StringConversionSink, 'from');
1461 dart.defineNamedConstructor(StringConversionSink, 'fromStringSink'); 1461 dart.defineNamedConstructor(StringConversionSink, 'fromStringSink');
1462 class ClosableStringSink extends core.StringSink { 1462 class ClosableStringSink extends core.StringSink {
1463 fromStringSink(sink, onClose) { 1463 fromStringSink(sink, onClose) {
1464 return new _ClosableStringSink(sink, onClose); 1464 return new _ClosableStringSink(sink, onClose);
1465 } 1465 }
1466 } 1466 }
1467 dart.defineNamedConstructor(ClosableStringSink, 'fromStringSink'); 1467 dart.defineNamedConstructor(ClosableStringSink, 'fromStringSink');
1468 class _StringSinkCloseCallback extends core.Function {} 1468 let _StringSinkCloseCallback = dart.typedef('_StringSinkCloseCallback', () => dart.functionType(dart.void, []));
1469 class _ClosableStringSink extends core.Object { 1469 class _ClosableStringSink extends core.Object {
1470 _ClosableStringSink(sink$, callback$) { 1470 _ClosableStringSink(sink$, callback$) {
1471 this[_sink] = sink$; 1471 this[_sink] = sink$;
1472 this[_callback] = callback$; 1472 this[_callback] = callback$;
1473 } 1473 }
1474 close() { 1474 close() {
1475 return this[_callback](); 1475 return this[_callback]();
1476 } 1476 }
1477 writeCharCode(charCode) { 1477 writeCharCode(charCode) {
1478 return this[_sink].writeCharCode(charCode); 1478 return this[_sink].writeCharCode(charCode);
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
2369 exports.LineSplitter = LineSplitter; 2369 exports.LineSplitter = LineSplitter;
2370 exports.StringConversionSink = StringConversionSink; 2370 exports.StringConversionSink = StringConversionSink;
2371 exports.ClosableStringSink = ClosableStringSink; 2371 exports.ClosableStringSink = ClosableStringSink;
2372 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN E; 2372 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN E;
2373 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE; 2373 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE;
2374 exports.UTF8 = UTF8; 2374 exports.UTF8 = UTF8;
2375 exports.Utf8Codec = Utf8Codec; 2375 exports.Utf8Codec = Utf8Codec;
2376 exports.Utf8Encoder = Utf8Encoder; 2376 exports.Utf8Encoder = Utf8Encoder;
2377 exports.Utf8Decoder = Utf8Decoder; 2377 exports.Utf8Decoder = Utf8Decoder;
2378 })(convert || (convert = {})); 2378 })(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