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

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

Issue 1142293002: Use dart.tearoff helper at tearoff sites (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Use dart.bind instead of dart.tearoff Created 5 years, 7 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 = dart.defineLibrary(convert, {}); 1 var convert = dart.defineLibrary(convert, {});
2 var core = dart.import(core); 2 var core = dart.import(core);
3 var async = dart.import(async); 3 var async = dart.import(async);
4 var typed_data = dart.import(typed_data); 4 var typed_data = dart.import(typed_data);
5 var _internal = dart.import(_internal); 5 var _internal = dart.import(_internal);
6 var collection = dart.import(collection); 6 var collection = dart.import(collection);
7 (function(exports, core, async, typed_data, _internal, collection) { 7 (function(exports, core, async, typed_data, _internal, collection) {
8 'use strict'; 8 'use strict';
9 let Codec$ = dart.generic(function(S, T) { 9 let Codec$ = dart.generic(function(S, T) {
10 class Codec extends core.Object { 10 class Codec extends core.Object {
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 super.ChunkedConversionSink(); 991 super.ChunkedConversionSink();
992 } 992 }
993 [_addChunk](chunk, start, end) { 993 [_addChunk](chunk, start, end) {
994 this[_sink].addSlice(chunk, start, end, false); 994 this[_sink].addSlice(chunk, start, end, false);
995 } 995 }
996 add(object) { 996 add(object) {
997 if (this[_isDone]) { 997 if (this[_isDone]) {
998 throw new core.StateError("Only one call to add allowed"); 998 throw new core.StateError("Only one call to add allowed");
999 } 999 }
1000 this[_isDone] = true; 1000 this[_isDone] = true;
1001 _JsonUtf8Stringifier.stringify(object, this[_indent], dart.as(this[_toEnco dable$], dart.functionType(dart.dynamic, [core.Object])), this[_bufferSize], thi s[_addChunk].bind(this)); 1001 _JsonUtf8Stringifier.stringify(object, this[_indent], dart.as(this[_toEnco dable$], dart.functionType(dart.dynamic, [core.Object])), this[_bufferSize], dar t.bind(this, _addChunk));
1002 this[_sink].close(); 1002 this[_sink].close();
1003 } 1003 }
1004 close() { 1004 close() {
1005 if (!dart.notNull(this[_isDone])) { 1005 if (!dart.notNull(this[_isDone])) {
1006 this[_isDone] = true; 1006 this[_isDone] = true;
1007 this[_sink].close(); 1007 this[_sink].close();
1008 } 1008 }
1009 } 1009 }
1010 } 1010 }
1011 dart.setSignature(_JsonUtf8EncoderSink, { 1011 dart.setSignature(_JsonUtf8EncoderSink, {
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 } 1632 }
1633 dart.setSignature(_Latin1AllowInvalidDecoderSink, { 1633 dart.setSignature(_Latin1AllowInvalidDecoderSink, {
1634 methods: () => ({addSlice: dart.functionType(dart.void, [core.List$(core.int ), core.int, core.int, core.bool])}) 1634 methods: () => ({addSlice: dart.functionType(dart.void, [core.List$(core.int ), core.int, core.int, core.bool])})
1635 }); 1635 });
1636 class LineSplitter extends Converter$(core.String, core.List$(core.String)) { 1636 class LineSplitter extends Converter$(core.String, core.List$(core.String)) {
1637 LineSplitter() { 1637 LineSplitter() {
1638 super.Converter(); 1638 super.Converter();
1639 } 1639 }
1640 convert(data) { 1640 convert(data) {
1641 let lines = new (core.List$(core.String))(); 1641 let lines = new (core.List$(core.String))();
1642 _LineSplitterSink._addSlice(data, 0, data.length, true, lines[core.$add].b ind(lines)); 1642 _LineSplitterSink._addSlice(data, 0, data.length, true, dart.bind(lines, c ore.$add));
1643 return lines; 1643 return lines;
1644 } 1644 }
1645 startChunkedConversion(sink) { 1645 startChunkedConversion(sink) {
1646 if (!dart.is(sink, StringConversionSink)) { 1646 if (!dart.is(sink, StringConversionSink)) {
1647 sink = new StringConversionSink.from(dart.as(sink, core.Sink$(core.Strin g))); 1647 sink = new StringConversionSink.from(dart.as(sink, core.Sink$(core.Strin g)));
1648 } 1648 }
1649 return new _LineSplitterSink(dart.as(sink, StringConversionSink)); 1649 return new _LineSplitterSink(dart.as(sink, StringConversionSink));
1650 } 1650 }
1651 } 1651 }
1652 dart.setSignature(LineSplitter, { 1652 dart.setSignature(LineSplitter, {
1653 methods: () => ({ 1653 methods: () => ({
1654 convert: dart.functionType(core.List$(core.String), [core.String]), 1654 convert: dart.functionType(core.List$(core.String), [core.String]),
1655 startChunkedConversion: dart.functionType(StringConversionSink, [core.Sink ]) 1655 startChunkedConversion: dart.functionType(StringConversionSink, [core.Sink ])
1656 }) 1656 })
1657 }); 1657 });
1658 let _carry = Symbol('_carry'); 1658 let _carry = Symbol('_carry');
1659 class _LineSplitterSink extends StringConversionSinkBase { 1659 class _LineSplitterSink extends StringConversionSinkBase {
1660 _LineSplitterSink(sink) { 1660 _LineSplitterSink(sink) {
1661 this[_sink] = sink; 1661 this[_sink] = sink;
1662 this[_carry] = null; 1662 this[_carry] = null;
1663 } 1663 }
1664 addSlice(chunk, start, end, isLast) { 1664 addSlice(chunk, start, end, isLast) {
1665 if (this[_carry] != null) { 1665 if (this[_carry] != null) {
1666 chunk = dart.notNull(this[_carry]) + dart.notNull(chunk.substring(start, end)); 1666 chunk = dart.notNull(this[_carry]) + dart.notNull(chunk.substring(start, end));
1667 start = 0; 1667 start = 0;
1668 end = chunk.length; 1668 end = chunk.length;
1669 this[_carry] = null; 1669 this[_carry] = null;
1670 } 1670 }
1671 this[_carry] = _LineSplitterSink._addSlice(chunk, start, end, isLast, this [_sink].add.bind(this[_sink])); 1671 this[_carry] = _LineSplitterSink._addSlice(chunk, start, end, isLast, dart .bind(this[_sink], 'add'));
1672 if (isLast) 1672 if (isLast)
1673 this[_sink].close(); 1673 this[_sink].close();
1674 } 1674 }
1675 close() { 1675 close() {
1676 this.addSlice('', 0, 0, true); 1676 this.addSlice('', 0, 0, true);
1677 } 1677 }
1678 static _addSlice(chunk, start, end, isLast, adder) { 1678 static _addSlice(chunk, start, end, isLast, adder) {
1679 let pos = start; 1679 let pos = start;
1680 while (dart.notNull(pos) < dart.notNull(end)) { 1680 while (dart.notNull(pos) < dart.notNull(end)) {
1681 let skip = 0; 1681 let skip = 0;
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 if (isLast) 1865 if (isLast)
1866 this.close(); 1866 this.close();
1867 } 1867 }
1868 add(str) { 1868 add(str) {
1869 return this[_stringSink].write(str); 1869 return this[_stringSink].write(str);
1870 } 1870 }
1871 asUtf8Sink(allowMalformed) { 1871 asUtf8Sink(allowMalformed) {
1872 return new _Utf8StringSinkAdapter(this, this[_stringSink], allowMalformed) ; 1872 return new _Utf8StringSinkAdapter(this, this[_stringSink], allowMalformed) ;
1873 } 1873 }
1874 asStringSink() { 1874 asStringSink() {
1875 return new ClosableStringSink.fromStringSink(this[_stringSink], this.close .bind(this)); 1875 return new ClosableStringSink.fromStringSink(this[_stringSink], dart.bind( this, 'close'));
1876 } 1876 }
1877 } 1877 }
1878 dart.setSignature(_StringSinkConversionSink, { 1878 dart.setSignature(_StringSinkConversionSink, {
1879 methods: () => ({ 1879 methods: () => ({
1880 close: dart.functionType(dart.void, []), 1880 close: dart.functionType(dart.void, []),
1881 addSlice: dart.functionType(dart.void, [core.String, core.int, core.int, c ore.bool]), 1881 addSlice: dart.functionType(dart.void, [core.String, core.int, core.int, c ore.bool]),
1882 add: dart.functionType(dart.void, [core.String]), 1882 add: dart.functionType(dart.void, [core.String]),
1883 asUtf8Sink: dart.functionType(ByteConversionSink, [core.bool]), 1883 asUtf8Sink: dart.functionType(ByteConversionSink, [core.bool]),
1884 asStringSink: dart.functionType(ClosableStringSink, []) 1884 asStringSink: dart.functionType(ClosableStringSink, [])
1885 }) 1885 })
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
2824 exports.LineSplitter = LineSplitter; 2824 exports.LineSplitter = LineSplitter;
2825 exports.StringConversionSink = StringConversionSink; 2825 exports.StringConversionSink = StringConversionSink;
2826 exports.ClosableStringSink = ClosableStringSink; 2826 exports.ClosableStringSink = ClosableStringSink;
2827 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN E; 2827 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN E;
2828 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE; 2828 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE;
2829 exports.Utf8Codec = Utf8Codec; 2829 exports.Utf8Codec = Utf8Codec;
2830 exports.UTF8 = UTF8; 2830 exports.UTF8 = UTF8;
2831 exports.Utf8Encoder = Utf8Encoder; 2831 exports.Utf8Encoder = Utf8Encoder;
2832 exports.Utf8Decoder = Utf8Decoder; 2832 exports.Utf8Decoder = Utf8Decoder;
2833 })(convert, core, async, typed_data, _internal, collection); 2833 })(convert, core, async, typed_data, _internal, collection);
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