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

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

Issue 1083763003: refactor emitMemberName to be used more consistently (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
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 13 matching lines...) Expand all
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), dart.dynamic))).fold(new core.StringBuffer(), (bu ffer, 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) => ((() => {
34 dart.dinvoke(buffer, 'write', string); 34 dart.dsend(buffer, 'write', string);
35 return buffer; 35 return buffer;
36 })())).then(buffer => buffer.toString()), async.Future$(core.String)); 36 })())).then(buffer => buffer.toString()), async.Future$(core.String));
37 } 37 }
38 static getByName(name) { 38 static getByName(name) {
39 if (name == null) 39 if (name == null)
40 return null; 40 return null;
41 name = name.toLowerCase(); 41 name = name.toLowerCase();
42 return Encoding[_nameToEncoding].get(name); 42 return Encoding[_nameToEncoding].get(name);
43 } 43 }
44 } 44 }
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 this.mode = mode; 520 this.mode = mode;
521 super.Converter(); 521 super.Converter();
522 } 522 }
523 convert(text) { 523 convert(text) {
524 let val = this[_convert](text, 0, text.length); 524 let val = this[_convert](text, 0, text.length);
525 return val == null ? text : val; 525 return val == null ? text : val;
526 } 526 }
527 [_convert](text, start, end) { 527 [_convert](text, start, end) {
528 let result = null; 528 let result = null;
529 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) { 529 for (let i = start; dart.notNull(i) < dart.notNull(end); i = dart.notNull( i) + 1) {
530 let ch = text.get(i); 530 let ch = core.String.get(text, i);
531 let replace = null; 531 let replace = null;
532 switch (ch) { 532 switch (ch) {
533 case '&': 533 case '&':
534 { 534 {
535 replace = '&amp;'; 535 replace = '&amp;';
536 break; 536 break;
537 } 537 }
538 case ' ': 538 case ' ':
539 { 539 {
540 replace = '&nbsp;'; 540 replace = '&nbsp;';
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 } 863 }
864 864
865 if (reviver == null) { 865 if (reviver == null) {
866 return _convertJsonToDartLazy(parsed); 866 return _convertJsonToDartLazy(parsed);
867 } else { 867 } else {
868 return _convertJsonToDart(parsed, reviver); 868 return _convertJsonToDart(parsed, reviver);
869 } 869 }
870 } 870 }
871 // Function _defaultToEncodable: (dynamic) → Object 871 // Function _defaultToEncodable: (dynamic) → Object
872 function _defaultToEncodable(object) { 872 function _defaultToEncodable(object) {
873 return dart.dinvoke(object, 'toJson'); 873 return dart.dsend(object, 'toJson');
874 } 874 }
875 let _seen = Symbol('_seen'); 875 let _seen = Symbol('_seen');
876 let _checkCycle = Symbol('_checkCycle'); 876 let _checkCycle = Symbol('_checkCycle');
877 let _removeSeen = Symbol('_removeSeen'); 877 let _removeSeen = Symbol('_removeSeen');
878 class _JsonStringifier extends core.Object { 878 class _JsonStringifier extends core.Object {
879 _JsonStringifier(_toEncodable) { 879 _JsonStringifier(_toEncodable) {
880 this[_seen] = new core.List(); 880 this[_seen] = new core.List();
881 this[_toEncodable$] = dart.as(_toEncodable != null ? _toEncodable : _defau ltToEncodable, core.Function); 881 this[_toEncodable$] = dart.as(_toEncodable != null ? _toEncodable : _defau ltToEncodable, core.Function);
882 } 882 }
883 static hexDigit(x) { 883 static hexDigit(x) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 throw new JsonUnsupportedObjectError(object); 968 throw new JsonUnsupportedObjectError(object);
969 } 969 }
970 this[_removeSeen](object); 970 this[_removeSeen](object);
971 } catch (e) { 971 } catch (e) {
972 throw new JsonUnsupportedObjectError(object, {cause: e}); 972 throw new JsonUnsupportedObjectError(object, {cause: e});
973 } 973 }
974 974
975 } 975 }
976 writeJsonValue(object) { 976 writeJsonValue(object) {
977 if (dart.is(object, core.num)) { 977 if (dart.is(object, core.num)) {
978 if (dart.dunary('!', dart.dload(object, 'isFinite'))) 978 if (dart.dsend(dart.dload(object, 'isFinite'), '!'))
979 return false; 979 return false;
980 this.writeNumber(dart.as(object, core.num)); 980 this.writeNumber(dart.as(object, core.num));
981 return true; 981 return true;
982 } else if (core.identical(object, true)) { 982 } else if (core.identical(object, true)) {
983 this.writeString('true'); 983 this.writeString('true');
984 return true; 984 return true;
985 } else if (core.identical(object, false)) { 985 } else if (core.identical(object, false)) {
986 this.writeString('false'); 986 this.writeString('false');
987 return true; 987 return true;
988 } else if (object == null) { 988 } else if (object == null) {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 _JsonStringStringifier.printOn(object, output, toEncodable, indent); 1105 _JsonStringStringifier.printOn(object, output, toEncodable, indent);
1106 return output.toString(); 1106 return output.toString();
1107 } 1107 }
1108 static printOn(object, output, toEncodable, indent) { 1108 static printOn(object, output, toEncodable, indent) {
1109 let stringifier = null; 1109 let stringifier = null;
1110 if (indent == null) { 1110 if (indent == null) {
1111 stringifier = new _JsonStringStringifier(output, toEncodable); 1111 stringifier = new _JsonStringStringifier(output, toEncodable);
1112 } else { 1112 } else {
1113 stringifier = new _JsonStringStringifierPretty(output, toEncodable, inde nt); 1113 stringifier = new _JsonStringStringifierPretty(output, toEncodable, inde nt);
1114 } 1114 }
1115 dart.dinvoke(stringifier, 'writeObject', object); 1115 dart.dsend(stringifier, 'writeObject', object);
1116 } 1116 }
1117 writeNumber(number) { 1117 writeNumber(number) {
1118 this[_sink].write(number.toString()); 1118 this[_sink].write(number.toString());
1119 } 1119 }
1120 writeString(string) { 1120 writeString(string) {
1121 this[_sink].write(string); 1121 this[_sink].write(string);
1122 } 1122 }
1123 writeStringSlice(string, start, end) { 1123 writeStringSlice(string, start, end) {
1124 this[_sink].write(string.substring(start, end)); 1124 this[_sink].write(string.substring(start, end));
1125 } 1125 }
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
2016 let extraUnits = this[_extraUnits]; 2016 let extraUnits = this[_extraUnits];
2017 this[_value] = 0; 2017 this[_value] = 0;
2018 this[_expectedUnits] = 0; 2018 this[_expectedUnits] = 0;
2019 this[_extraUnits] = 0; 2019 this[_extraUnits] = 0;
2020 // Function scanOneByteCharacters: (dynamic, int) → int 2020 // Function scanOneByteCharacters: (dynamic, int) → int
2021 function scanOneByteCharacters(units, from) { 2021 function scanOneByteCharacters(units, from) {
2022 let to = endIndex; 2022 let to = endIndex;
2023 let mask = _ONE_BYTE_LIMIT; 2023 let mask = _ONE_BYTE_LIMIT;
2024 for (let i = from; dart.notNull(i) < dart.notNull(to); i = dart.notNull( i) + 1) { 2024 for (let i = from; dart.notNull(i) < dart.notNull(to); i = dart.notNull( i) + 1) {
2025 let unit = dart.dindex(units, i); 2025 let unit = dart.dindex(units, i);
2026 if (!dart.equals(dart.dbinary(unit, '&', mask), unit)) 2026 if (!dart.equals(dart.dsend(unit, '&', mask), unit))
2027 return dart.notNull(i) - dart.notNull(from); 2027 return dart.notNull(i) - dart.notNull(from);
2028 } 2028 }
2029 return dart.notNull(to) - dart.notNull(from); 2029 return dart.notNull(to) - dart.notNull(from);
2030 } 2030 }
2031 // Function addSingleBytes: (int, int) → void 2031 // Function addSingleBytes: (int, int) → void
2032 function addSingleBytes(from, to) { 2032 function addSingleBytes(from, to) {
2033 dart.assert(dart.notNull(from) >= dart.notNull(startIndex) && dart.notNu ll(from) <= dart.notNull(endIndex)); 2033 dart.assert(dart.notNull(from) >= dart.notNull(startIndex) && dart.notNu ll(from) <= dart.notNull(endIndex));
2034 dart.assert(dart.notNull(to) >= dart.notNull(startIndex) && dart.notNull (to) <= dart.notNull(endIndex)); 2034 dart.assert(dart.notNull(to) >= dart.notNull(startIndex) && dart.notNull (to) <= dart.notNull(endIndex));
2035 this[_stringSink].write(new core.String.fromCharCodes(codeUnits, from, t o)); 2035 this[_stringSink].write(new core.String.fromCharCodes(codeUnits, from, t o));
2036 } 2036 }
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
2273 remove(key) { 2273 remove(key) {
2274 if (!dart.notNull(this[_isUpgraded]) && !dart.notNull(this.containsKey(key ))) 2274 if (!dart.notNull(this[_isUpgraded]) && !dart.notNull(this.containsKey(key )))
2275 return null; 2275 return null;
2276 return this[_upgrade]().remove(key); 2276 return this[_upgrade]().remove(key);
2277 } 2277 }
2278 clear() { 2278 clear() {
2279 if (this[_isUpgraded]) { 2279 if (this[_isUpgraded]) {
2280 this[_upgradedMap].clear(); 2280 this[_upgradedMap].clear();
2281 } else { 2281 } else {
2282 if (this[_data] != null) { 2282 if (this[_data] != null) {
2283 dart.dinvoke(this[_data], 'clear'); 2283 dart.dsend(this[_data], 'clear');
2284 } 2284 }
2285 this[_original] = this[_processed] = null; 2285 this[_original] = this[_processed] = null;
2286 this[_data] = dart.map(); 2286 this[_data] = dart.map();
2287 } 2287 }
2288 } 2288 }
2289 forEach(f) { 2289 forEach(f) {
2290 if (this[_isUpgraded]) 2290 if (this[_isUpgraded])
2291 return this[_upgradedMap].forEach(f); 2291 return this[_upgradedMap].forEach(f);
2292 let keys = this[_computeKeys](); 2292 let keys = this[_computeKeys]();
2293 for (let i = 0; dart.notNull(i) < dart.notNull(keys[core.$length]); i = da rt.notNull(i) + 1) { 2293 for (let i = 0; dart.notNull(i) < dart.notNull(keys[core.$length]); i = da rt.notNull(i) + 1) {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2434 exports.LineSplitter = LineSplitter; 2434 exports.LineSplitter = LineSplitter;
2435 exports.StringConversionSink = StringConversionSink; 2435 exports.StringConversionSink = StringConversionSink;
2436 exports.ClosableStringSink = ClosableStringSink; 2436 exports.ClosableStringSink = ClosableStringSink;
2437 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN E; 2437 exports.UNICODE_REPLACEMENT_CHARACTER_RUNE = UNICODE_REPLACEMENT_CHARACTER_RUN E;
2438 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE; 2438 exports.UNICODE_BOM_CHARACTER_RUNE = UNICODE_BOM_CHARACTER_RUNE;
2439 exports.UTF8 = UTF8; 2439 exports.UTF8 = UTF8;
2440 exports.Utf8Codec = Utf8Codec; 2440 exports.Utf8Codec = Utf8Codec;
2441 exports.Utf8Encoder = Utf8Encoder; 2441 exports.Utf8Encoder = Utf8Encoder;
2442 exports.Utf8Decoder = Utf8Decoder; 2442 exports.Utf8Decoder = Utf8Decoder;
2443 })(convert || (convert = {})); 2443 })(convert || (convert = {}));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698