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

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

Issue 1088943006: implement tear offs (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: 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 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 super.ChunkedConversionSink(); 811 super.ChunkedConversionSink();
812 } 812 }
813 [_addChunk](chunk, start, end) { 813 [_addChunk](chunk, start, end) {
814 this[_sink].addSlice(chunk, start, end, false); 814 this[_sink].addSlice(chunk, start, end, false);
815 } 815 }
816 add(object) { 816 add(object) {
817 if (this[_isDone]) { 817 if (this[_isDone]) {
818 throw new core.StateError("Only one call to add allowed"); 818 throw new core.StateError("Only one call to add allowed");
819 } 819 }
820 this[_isDone] = true; 820 this[_isDone] = true;
821 _JsonUtf8Stringifier.stringify(object, this[_indent], dart.as(this[_toEnco dable$], dart.functionType(dart.dynamic, [core.Object])), this[_bufferSize], thi s[_addChunk]); 821 _JsonUtf8Stringifier.stringify(object, this[_indent], dart.as(this[_toEnco dable$], dart.functionType(dart.dynamic, [core.Object])), this[_bufferSize], thi s[_addChunk].bind(this));
822 this[_sink].close(); 822 this[_sink].close();
823 } 823 }
824 close() { 824 close() {
825 if (!dart.notNull(this[_isDone])) { 825 if (!dart.notNull(this[_isDone])) {
826 this[_isDone] = true; 826 this[_isDone] = true;
827 this[_sink].close(); 827 this[_sink].close();
828 } 828 }
829 } 829 }
830 } 830 }
831 class JsonDecoder extends Converter$(core.String, core.Object) { 831 class JsonDecoder extends Converter$(core.String, core.Object) {
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 } 1368 }
1369 } 1369 }
1370 } 1370 }
1371 let _addSlice = Symbol('_addSlice'); 1371 let _addSlice = Symbol('_addSlice');
1372 class LineSplitter extends Converter$(core.String, core.List$(core.String)) { 1372 class LineSplitter extends Converter$(core.String, core.List$(core.String)) {
1373 LineSplitter() { 1373 LineSplitter() {
1374 super.Converter(); 1374 super.Converter();
1375 } 1375 }
1376 convert(data) { 1376 convert(data) {
1377 let lines = new (core.List$(core.String))(); 1377 let lines = new (core.List$(core.String))();
1378 _LineSplitterSink[_addSlice](data, 0, data.length, true, lines[core.$add]) ; 1378 _LineSplitterSink[_addSlice](data, 0, data.length, true, lines[core.$add]. bind(lines));
1379 return lines; 1379 return lines;
1380 } 1380 }
1381 startChunkedConversion(sink) { 1381 startChunkedConversion(sink) {
1382 if (!dart.is(sink, StringConversionSink)) { 1382 if (!dart.is(sink, StringConversionSink)) {
1383 sink = new StringConversionSink.from(sink); 1383 sink = new StringConversionSink.from(sink);
1384 } 1384 }
1385 return new _LineSplitterSink(dart.as(sink, StringConversionSink)); 1385 return new _LineSplitterSink(dart.as(sink, StringConversionSink));
1386 } 1386 }
1387 } 1387 }
1388 let _carry = Symbol('_carry'); 1388 let _carry = Symbol('_carry');
1389 let _LF = Symbol('_LF'); 1389 let _LF = Symbol('_LF');
1390 let _CR = Symbol('_CR'); 1390 let _CR = Symbol('_CR');
1391 class _LineSplitterSink extends StringConversionSinkBase { 1391 class _LineSplitterSink extends StringConversionSinkBase {
1392 _LineSplitterSink(sink) { 1392 _LineSplitterSink(sink) {
1393 this[_sink] = sink; 1393 this[_sink] = sink;
1394 this[_carry] = null; 1394 this[_carry] = null;
1395 } 1395 }
1396 addSlice(chunk, start, end, isLast) { 1396 addSlice(chunk, start, end, isLast) {
1397 if (this[_carry] != null) { 1397 if (this[_carry] != null) {
1398 chunk = dart.notNull(this[_carry]) + dart.notNull(chunk.substring(start, end)); 1398 chunk = dart.notNull(this[_carry]) + dart.notNull(chunk.substring(start, end));
1399 start = 0; 1399 start = 0;
1400 end = chunk.length; 1400 end = chunk.length;
1401 this[_carry] = null; 1401 this[_carry] = null;
1402 } 1402 }
1403 this[_carry] = _LineSplitterSink[_addSlice](chunk, start, end, isLast, thi s[_sink].add); 1403 this[_carry] = _LineSplitterSink[_addSlice](chunk, start, end, isLast, thi s[_sink].add.bind(this[_sink]));
1404 if (isLast) 1404 if (isLast)
1405 this[_sink].close(); 1405 this[_sink].close();
1406 } 1406 }
1407 close() { 1407 close() {
1408 this.addSlice('', 0, 0, true); 1408 this.addSlice('', 0, 0, true);
1409 } 1409 }
1410 static [_addSlice](chunk, start, end, isLast, adder) { 1410 static [_addSlice](chunk, start, end, isLast, adder) {
1411 let pos = start; 1411 let pos = start;
1412 while (dart.notNull(pos) < dart.notNull(end)) { 1412 while (dart.notNull(pos) < dart.notNull(end)) {
1413 let skip = 0; 1413 let skip = 0;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1569 if (isLast) 1569 if (isLast)
1570 this.close(); 1570 this.close();
1571 } 1571 }
1572 add(str) { 1572 add(str) {
1573 return this[_stringSink].write(str); 1573 return this[_stringSink].write(str);
1574 } 1574 }
1575 asUtf8Sink(allowMalformed) { 1575 asUtf8Sink(allowMalformed) {
1576 return new _Utf8StringSinkAdapter(this, this[_stringSink], allowMalformed) ; 1576 return new _Utf8StringSinkAdapter(this, this[_stringSink], allowMalformed) ;
1577 } 1577 }
1578 asStringSink() { 1578 asStringSink() {
1579 return new ClosableStringSink.fromStringSink(this[_stringSink], this.close ); 1579 return new ClosableStringSink.fromStringSink(this[_stringSink], dart.bind( this, 'close'));
Jacob 2015/04/21 20:27:56 I don't get why this case is dart.bind(this, 'clos
Jennifer Messerly 2015/04/21 21:11:06 Hmmm. The stateless checker may only work for iden
1580 } 1580 }
1581 } 1581 }
1582 class _StringCallbackSink extends _StringSinkConversionSink { 1582 class _StringCallbackSink extends _StringSinkConversionSink {
1583 _StringCallbackSink(callback) { 1583 _StringCallbackSink(callback) {
1584 this[_callback] = callback; 1584 this[_callback] = callback;
1585 super._StringSinkConversionSink(new core.StringBuffer()); 1585 super._StringSinkConversionSink(new core.StringBuffer());
1586 } 1586 }
1587 close() { 1587 close() {
1588 let buffer = dart.as(this[_stringSink], core.StringBuffer); 1588 let buffer = dart.as(this[_stringSink], core.StringBuffer);
1589 let accumulated = buffer.toString(); 1589 let accumulated = buffer.toString();
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
2427 exports.LineSplitter = LineSplitter; 2427 exports.LineSplitter = LineSplitter;
2428 exports.StringConversionSink = StringConversionSink; 2428 exports.StringConversionSink = StringConversionSink;
2429 exports.ClosableStringSink = ClosableStringSink; 2429 exports.ClosableStringSink = ClosableStringSink;
2430 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN E; 2430 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN E;
2431 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE; 2431 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE;
2432 exports.UTF8 = UTF8; 2432 exports.UTF8 = UTF8;
2433 exports.Utf8Codec = Utf8Codec; 2433 exports.Utf8Codec = Utf8Codec;
2434 exports.Utf8Encoder = Utf8Encoder; 2434 exports.Utf8Encoder = Utf8Encoder;
2435 exports.Utf8Decoder = Utf8Decoder; 2435 exports.Utf8Decoder = Utf8Decoder;
2436 })(convert || (convert = {})); 2436 })(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