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

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

Issue 1680263002: Support for dart:typed_data (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Address comments, rebase Created 4 years, 10 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/html.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 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 for (let i = 0; i < dart.notNull(string[dartx.length]); i++) { 910 for (let i = 0; i < dart.notNull(string[dartx.length]); i++) {
911 if (dart.notNull(string[dartx.codeUnitAt](i)) >= 128) break checkAscii ; 911 if (dart.notNull(string[dartx.codeUnitAt](i)) >= 128) break checkAscii ;
912 } 912 }
913 return string[dartx.codeUnits]; 913 return string[dartx.codeUnits];
914 } 914 }
915 return UTF8.encode(string); 915 return UTF8.encode(string);
916 } 916 }
917 convert(object) { 917 convert(object) {
918 let bytes = dart.list([], core.List$(core.int)); 918 let bytes = dart.list([], core.List$(core.int));
919 function addChunk(chunk, start, end) { 919 function addChunk(chunk, start, end) {
920 if (dart.notNull(start) > 0 || dart.notNull(end) < dart.notNull(chunk.le ngth)) { 920 if (dart.notNull(start) > 0 || dart.notNull(end) < dart.notNull(chunk[da rtx.length])) {
921 let length = dart.notNull(end) - dart.notNull(start); 921 let length = dart.notNull(end) - dart.notNull(start);
922 chunk = typed_data.Uint8List.view(chunk.buffer, dart.notNull(chunk.off setInBytes) + dart.notNull(start), length); 922 chunk = typed_data.Uint8List.view(chunk[dartx.buffer], dart.notNull(ch unk[dartx.offsetInBytes]) + dart.notNull(start), length);
923 } 923 }
924 bytes[dartx.add](chunk); 924 bytes[dartx.add](chunk);
925 } 925 }
926 dart.fn(addChunk, dart.void, [typed_data.Uint8List, core.int, core.int]); 926 dart.fn(addChunk, dart.void, [typed_data.Uint8List, core.int, core.int]);
927 _JsonUtf8Stringifier.stringify(object, this[_indent], dart.as(this[_toEnco dable$], dart.functionType(dart.dynamic, [core.Object])), this[_bufferSize], add Chunk); 927 _JsonUtf8Stringifier.stringify(object, this[_indent], dart.as(this[_toEnco dable$], dart.functionType(dart.dynamic, [core.Object])), this[_bufferSize], add Chunk);
928 if (bytes[dartx.length] == 1) return bytes[dartx.get](0); 928 if (bytes[dartx.length] == 1) return bytes[dartx.get](0);
929 let length = 0; 929 let length = 0;
930 for (let i = 0; i < dart.notNull(bytes[dartx.length]); i++) { 930 for (let i = 0; i < dart.notNull(bytes[dartx.length]); i++) {
931 length = dart.notNull(length) + dart.notNull(bytes[dartx.get](i)[dartx.l ength]); 931 length = dart.notNull(length) + dart.notNull(bytes[dartx.get](i)[dartx.l ength]);
932 } 932 }
933 let result = typed_data.Uint8List.new(length); 933 let result = typed_data.Uint8List.new(length);
934 for (let i = 0, offset = 0; i < dart.notNull(bytes[dartx.length]); i++) { 934 for (let i = 0, offset = 0; i < dart.notNull(bytes[dartx.length]); i++) {
935 let byteList = bytes[dartx.get](i); 935 let byteList = bytes[dartx.get](i);
936 let end = offset + dart.notNull(byteList[dartx.length]); 936 let end = offset + dart.notNull(byteList[dartx.length]);
937 result.setRange(offset, end, byteList); 937 result[dartx.setRange](offset, end, byteList);
938 offset = end; 938 offset = end;
939 } 939 }
940 return result; 940 return result;
941 } 941 }
942 startChunkedConversion(sink) { 942 startChunkedConversion(sink) {
943 let byteSink = null; 943 let byteSink = null;
944 if (dart.is(sink, ByteConversionSink)) { 944 if (dart.is(sink, ByteConversionSink)) {
945 byteSink = sink; 945 byteSink = sink;
946 } else { 946 } else {
947 byteSink = ByteConversionSink.from(sink); 947 byteSink = ByteConversionSink.from(sink);
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 } 1452 }
1453 writeFourByteCharCode(charCode) { 1453 writeFourByteCharCode(charCode) {
1454 dart.assert(dart.notNull(charCode) <= 1114111); 1454 dart.assert(dart.notNull(charCode) <= 1114111);
1455 this.writeByte(240 | dart.notNull(charCode) >> 18); 1455 this.writeByte(240 | dart.notNull(charCode) >> 18);
1456 this.writeByte(128 | dart.notNull(charCode) >> 12 & 63); 1456 this.writeByte(128 | dart.notNull(charCode) >> 12 & 63);
1457 this.writeByte(128 | dart.notNull(charCode) >> 6 & 63); 1457 this.writeByte(128 | dart.notNull(charCode) >> 6 & 63);
1458 this.writeByte(128 | dart.notNull(charCode) & 63); 1458 this.writeByte(128 | dart.notNull(charCode) & 63);
1459 } 1459 }
1460 writeByte(byte) { 1460 writeByte(byte) {
1461 dart.assert(dart.notNull(byte) <= 255); 1461 dart.assert(dart.notNull(byte) <= 255);
1462 if (this.index == this.buffer.length) { 1462 if (this.index == this.buffer[dartx.length]) {
1463 dart.dcall(this.addChunk, this.buffer, 0, this.index); 1463 dart.dcall(this.addChunk, this.buffer, 0, this.index);
1464 this.buffer = typed_data.Uint8List.new(this.bufferSize); 1464 this.buffer = typed_data.Uint8List.new(this.bufferSize);
1465 this.index = 0; 1465 this.index = 0;
1466 } 1466 }
1467 this.buffer.set((() => { 1467 this.buffer[dartx.set]((() => {
1468 let x = this.index; 1468 let x = this.index;
1469 this.index = dart.notNull(x) + 1; 1469 this.index = dart.notNull(x) + 1;
1470 return x; 1470 return x;
1471 })(), byte); 1471 })(), byte);
1472 } 1472 }
1473 } 1473 }
1474 dart.setSignature(_JsonUtf8Stringifier, { 1474 dart.setSignature(_JsonUtf8Stringifier, {
1475 constructors: () => ({_JsonUtf8Stringifier: [_JsonUtf8Stringifier, [dart.dyn amic, core.int, core.Function]]}), 1475 constructors: () => ({_JsonUtf8Stringifier: [_JsonUtf8Stringifier, [dart.dyn amic, core.int, core.Function]]}),
1476 methods: () => ({ 1476 methods: () => ({
1477 flush: [dart.void, []], 1477 flush: [dart.void, []],
(...skipping 21 matching lines...) Expand all
1499 let char = indent[dartx.get](0); 1499 let char = indent[dartx.get](0);
1500 while (dart.notNull(count) > 0) { 1500 while (dart.notNull(count) > 0) {
1501 this.writeByte(char); 1501 this.writeByte(char);
1502 count = dart.notNull(count) - 1; 1502 count = dart.notNull(count) - 1;
1503 } 1503 }
1504 return; 1504 return;
1505 } 1505 }
1506 while (dart.notNull(count) > 0) { 1506 while (dart.notNull(count) > 0) {
1507 count = dart.notNull(count) - 1; 1507 count = dart.notNull(count) - 1;
1508 let end = dart.notNull(this.index) + dart.notNull(indentLength); 1508 let end = dart.notNull(this.index) + dart.notNull(indentLength);
1509 if (end <= dart.notNull(this.buffer.length)) { 1509 if (end <= dart.notNull(this.buffer[dartx.length])) {
1510 this.buffer.setRange(this.index, end, indent); 1510 this.buffer[dartx.setRange](this.index, end, indent);
1511 this.index = end; 1511 this.index = end;
1512 } else { 1512 } else {
1513 for (let i = 0; i < dart.notNull(indentLength); i++) { 1513 for (let i = 0; i < dart.notNull(indentLength); i++) {
1514 this.writeByte(indent[dartx.get](i)); 1514 this.writeByte(indent[dartx.get](i));
1515 } 1515 }
1516 } 1516 }
1517 } 1517 }
1518 } 1518 }
1519 } 1519 }
1520 dart.setSignature(_JsonUtf8StringifierPretty, { 1520 dart.setSignature(_JsonUtf8StringifierPretty, {
(...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after
2812 exports.LineSplitter = LineSplitter; 2812 exports.LineSplitter = LineSplitter;
2813 exports.StringConversionSink = StringConversionSink; 2813 exports.StringConversionSink = StringConversionSink;
2814 exports.ClosableStringSink = ClosableStringSink; 2814 exports.ClosableStringSink = ClosableStringSink;
2815 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN E; 2815 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN E;
2816 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE; 2816 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE;
2817 exports.Utf8Codec = Utf8Codec; 2817 exports.Utf8Codec = Utf8Codec;
2818 exports.UTF8 = UTF8; 2818 exports.UTF8 = UTF8;
2819 exports.Utf8Encoder = Utf8Encoder; 2819 exports.Utf8Encoder = Utf8Encoder;
2820 exports.Utf8Decoder = Utf8Decoder; 2820 exports.Utf8Decoder = Utf8Decoder;
2821 }); 2821 });
OLDNEW
« no previous file with comments | « lib/runtime/dart/collection.js ('k') | lib/runtime/dart/html.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698