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

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

Issue 1096583002: Reifier hookup (Closed) Base URL: git@github.com:dart-lang/dart-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/_isolate_helper.js ('k') | lib/runtime/dart/async.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 _js_helper; 1 var _js_helper;
2 (function(exports) { 2 (function(exports) {
3 'use strict'; 3 'use strict';
4 class NoSideEffects extends core.Object { 4 class NoSideEffects extends core.Object {
5 NoSideEffects() { 5 NoSideEffects() {
6 } 6 }
7 } 7 }
8 class NoThrows extends core.Object { 8 class NoThrows extends core.Object {
9 NoThrows() { 9 NoThrows() {
10 } 10 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 let keys = this[_keys]; 95 let keys = this[_keys];
96 for (let i = 0; core.int['<'](i, dart.dload(keys, 'length')); i = dart.n otNull(i) + 1) { 96 for (let i = 0; core.int['<'](i, dart.dload(keys, 'length')); i = dart.n otNull(i) + 1) {
97 let key = dart.dindex(keys, i); 97 let key = dart.dindex(keys, i);
98 f(dart.as(key, K), dart.as(this[_fetch](key), V)); 98 f(dart.as(key, K), dart.as(this[_fetch](key), V));
99 } 99 }
100 } 100 }
101 get keys() { 101 get keys() {
102 return new (_ConstantMapKeyIterable$(K))(this); 102 return new (_ConstantMapKeyIterable$(K))(this);
103 } 103 }
104 get values() { 104 get values() {
105 return new (_internal.MappedIterable$(K, V))(this[_keys], dart.as((key = > this[_fetch](key)).bind(this), dart.functionType(V, [K]))); 105 return new (_internal.MappedIterable$(K, V))(this[_keys], (key => dart.a s(this[_fetch](key), V)).bind(this));
106 } 106 }
107 } 107 }
108 ConstantStringMap[dart.implements] = () => [_internal.EfficientLength]; 108 ConstantStringMap[dart.implements] = () => [_internal.EfficientLength];
109 dart.defineNamedConstructor(ConstantStringMap, _); 109 dart.defineNamedConstructor(ConstantStringMap, _);
110 return ConstantStringMap; 110 return ConstantStringMap;
111 }); 111 });
112 let ConstantStringMap = ConstantStringMap$(); 112 let ConstantStringMap = ConstantStringMap$();
113 let _protoValue = Symbol('_protoValue'); 113 let _protoValue = Symbol('_protoValue');
114 let ConstantProtoMap$ = dart.generic(function(K, V) { 114 let ConstantProtoMap$ = dart.generic(function(K, V) {
115 class ConstantProtoMap extends ConstantStringMap$(K, V) { 115 class ConstantProtoMap extends ConstantStringMap$(K, V) {
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 group(index) { 599 group(index) {
600 return this[_match][core.$get](index); 600 return this[_match][core.$get](index);
601 } 601 }
602 get(index) { 602 get(index) {
603 return this.group(index); 603 return this.group(index);
604 } 604 }
605 get groupCount() { 605 get groupCount() {
606 return dart.notNull(this[_match][core.$length]) - 1; 606 return dart.notNull(this[_match][core.$length]) - 1;
607 } 607 }
608 groups(groups) { 608 groups(groups) {
609 let out = dart.as(new core.List.from([]), core.List$(core.String)); 609 let out = new core.List$(core.String).from([]);
610 for (let i of groups) { 610 for (let i of groups) {
611 out[core.$add](this.group(i)); 611 out[core.$add](this.group(i));
612 } 612 }
613 return out; 613 return out;
614 } 614 }
615 } 615 }
616 _MatchImplementation[dart.implements] = () => [core.Match]; 616 _MatchImplementation[dart.implements] = () => [core.Match];
617 let _re = Symbol('_re'); 617 let _re = Symbol('_re');
618 let _string = Symbol('_string'); 618 let _string = Symbol('_string');
619 let _start = Symbol('_start'); 619 let _start = Symbol('_start');
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1733 hash = Math.random() * 0x3fffffff | 0; 1733 hash = Math.random() * 0x3fffffff | 0;
1734 object.$identityHash = hash; 1734 object.$identityHash = hash;
1735 } 1735 }
1736 return hash; 1736 return hash;
1737 } 1737 }
1738 static [_throwFormatException](string) { 1738 static [_throwFormatException](string) {
1739 throw new core.FormatException(string); 1739 throw new core.FormatException(string);
1740 } 1740 }
1741 static parseInt(source, radix, handleError) { 1741 static parseInt(source, radix, handleError) {
1742 if (handleError == null) 1742 if (handleError == null)
1743 handleError = dart.as(Primitives[_throwFormatException], dart.functionTy pe(core.int, [core.String])); 1743 handleError = dart.as(Primitives[_throwFormatException], __CastType0);
1744 checkString(source); 1744 checkString(source);
1745 let match = /^\s*[+-]?((0x[a-f0-9]+)|(\d+)|([a-z0-9]+))\s*$/i.exec(source) ; 1745 let match = /^\s*[+-]?((0x[a-f0-9]+)|(\d+)|([a-z0-9]+))\s*$/i.exec(source) ;
1746 let digitsIndex = 1; 1746 let digitsIndex = 1;
1747 let hexIndex = 2; 1747 let hexIndex = 2;
1748 let decimalIndex = 3; 1748 let decimalIndex = 3;
1749 let nonDecimalHexIndex = 4; 1749 let nonDecimalHexIndex = 4;
1750 if (radix == null) { 1750 if (radix == null) {
1751 radix = 10; 1751 radix = 10;
1752 if (match != null) { 1752 if (match != null) {
1753 if (dart.dindex(match, hexIndex) != null) { 1753 if (dart.dindex(match, hexIndex) != null) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1785 } 1785 }
1786 } 1786 }
1787 } 1787 }
1788 if (match == null) 1788 if (match == null)
1789 return handleError(source); 1789 return handleError(source);
1790 return parseInt(source, radix); 1790 return parseInt(source, radix);
1791 } 1791 }
1792 static parseDouble(source, handleError) { 1792 static parseDouble(source, handleError) {
1793 checkString(source); 1793 checkString(source);
1794 if (handleError == null) 1794 if (handleError == null)
1795 handleError = dart.as(Primitives[_throwFormatException], dart.functionTy pe(core.double, [core.String])); 1795 handleError = dart.as(Primitives[_throwFormatException], __CastType2);
1796 if (!/^\s*[+-]?(?:Infinity|NaN|(?:\.\d+|\d+(?:\.\d*)?)(?:[eE][+-]?\d+)?)\s *$/.test(source)) { 1796 if (!/^\s*[+-]?(?:Infinity|NaN|(?:\.\d+|\d+(?:\.\d*)?)(?:[eE][+-]?\d+)?)\s *$/.test(source)) {
1797 return handleError(source); 1797 return handleError(source);
1798 } 1798 }
1799 let result = parseFloat(source); 1799 let result = parseFloat(source);
1800 if (result.isNaN) { 1800 if (result.isNaN) {
1801 let trimmed = source.trim(); 1801 let trimmed = source.trim();
1802 if (trimmed == 'NaN' || trimmed == '+NaN' || trimmed == '-NaN') { 1802 if (trimmed == 'NaN' || trimmed == '+NaN' || trimmed == '-NaN') {
1803 return result; 1803 return result;
1804 } 1804 }
1805 return handleError(source); 1805 return handleError(source);
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
2272 toString: function() { 2272 toString: function() {
2273 return "$receiver$"; 2273 return "$receiver$";
2274 } 2274 }
2275 }; 2275 };
2276 } 2276 }
2277 static extractPattern(message) { 2277 static extractPattern(message) {
2278 message = message.replace(String({}), '$receiver$'); 2278 message = message.replace(String({}), '$receiver$');
2279 message = message.replace(new RegExp(ESCAPE_REGEXP, 'g'), '\\$&'); 2279 message = message.replace(new RegExp(ESCAPE_REGEXP, 'g'), '\\$&');
2280 let match = dart.as(message.match(/\\\$[a-zA-Z]+\\\$/g), core.List$(core.S tring)); 2280 let match = dart.as(message.match(/\\\$[a-zA-Z]+\\\$/g), core.List$(core.S tring));
2281 if (match == null) 2281 if (match == null)
2282 match = dart.as(new core.List.from([]), core.List$(core.String)); 2282 match = new core.List$(core.String).from([]);
2283 let arguments$ = match.indexOf('\\$arguments\\$'); 2283 let arguments$ = match.indexOf('\\$arguments\\$');
2284 let argumentsExpr = match.indexOf('\\$argumentsExpr\\$'); 2284 let argumentsExpr = match.indexOf('\\$argumentsExpr\\$');
2285 let expr = match.indexOf('\\$expr\\$'); 2285 let expr = match.indexOf('\\$expr\\$');
2286 let method = match.indexOf('\\$method\\$'); 2286 let method = match.indexOf('\\$method\\$');
2287 let receiver = match.indexOf('\\$receiver\\$'); 2287 let receiver = match.indexOf('\\$receiver\\$');
2288 let pattern = message.replace('\\$arguments\\$', '((?:x|[^x])*)').replace( '\\$argumentsExpr\\$', '((?:x|[^x])*)').replace('\\$expr\\$', '((?:x|[^x])*)').r eplace('\\$method\\$', '((?:x|[^x])*)').replace('\\$receiver\\$', '((?:x|[^x])*) '); 2288 let pattern = message.replace('\\$arguments\\$', '((?:x|[^x])*)').replace( '\\$argumentsExpr\\$', '((?:x|[^x])*)').replace('\\$expr\\$', '((?:x|[^x])*)').r eplace('\\$method\\$', '((?:x|[^x])*)').replace('\\$receiver\\$', '((?:x|[^x])*) ');
2289 return new TypeErrorDecoder(arguments$, argumentsExpr, expr, method, recei ver, pattern); 2289 return new TypeErrorDecoder(arguments$, argumentsExpr, expr, method, recei ver, pattern);
2290 } 2290 }
2291 static provokeCallErrorOn(expression) { 2291 static provokeCallErrorOn(expression) {
2292 let func = function($expr$) { 2292 let func = function($expr$) {
(...skipping 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after
3702 }); 3702 });
3703 let DeferredLoadCallback = dart.typedef('DeferredLoadCallback', () => dart.fun ctionType(dart.void, [])); 3703 let DeferredLoadCallback = dart.typedef('DeferredLoadCallback', () => dart.fun ctionType(dart.void, []));
3704 exports.deferredLoadHook = null; 3704 exports.deferredLoadHook = null;
3705 // Function loadDeferredLibrary: (String) → Future<Null> 3705 // Function loadDeferredLibrary: (String) → Future<Null>
3706 function loadDeferredLibrary(loadId) { 3706 function loadDeferredLibrary(loadId) {
3707 let urisMap = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names.DEFE RRED_LIBRARY_URIS); 3707 let urisMap = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names.DEFE RRED_LIBRARY_URIS);
3708 let uris = dart.as(urisMap[loadId], core.List$(core.String)); 3708 let uris = dart.as(urisMap[loadId], core.List$(core.String));
3709 let hashesMap = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names.DE FERRED_LIBRARY_HASHES); 3709 let hashesMap = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names.DE FERRED_LIBRARY_HASHES);
3710 let hashes = dart.as(hashesMap[loadId], core.List$(core.String)); 3710 let hashes = dart.as(hashesMap[loadId], core.List$(core.String));
3711 if (uris == null) 3711 if (uris == null)
3712 return dart.as(new async.Future.value(null), async.Future$(core.Null)); 3712 return new async.Future$(core.Null).value(null);
3713 let indices = dart.as(new core.List.generate(uris[core.$length], dart.as(i = > i, dart.functionType(dart.dynamic, [core.int]))), core.List$(core.int)); 3713 let indices = new core.List$(core.int).generate(uris[core.$length], i => dar t.as(i, core.int));
3714 let isHunkLoaded = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names .IS_HUNK_LOADED); 3714 let isHunkLoaded = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names .IS_HUNK_LOADED);
3715 let isHunkInitialized = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_ names.IS_HUNK_INITIALIZED); 3715 let isHunkInitialized = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_ names.IS_HUNK_INITIALIZED);
3716 let indicesToLoad = indices[core.$where](i => !isHunkLoaded(hashes[core.$get ](i)))[core.$toList](); 3716 let indicesToLoad = indices[core.$where](i => !isHunkLoaded(hashes[core.$get ](i)))[core.$toList]();
3717 return dart.as(async.Future.wait(dart.as(indicesToLoad[core.$map](i => _load Hunk(uris[core.$get](i))), core.Iterable$(async.Future))).then(dart.as(_ => { 3717 return dart.as(async.Future.wait(dart.as(indicesToLoad[core.$map](i => _load Hunk(uris[core.$get](i))), core.Iterable$(async.Future))).then(_ => {
3718 let indicesToInitialize = indices[core.$where](i => !isHunkInitialized(has hes[core.$get](i)))[core.$toList](); 3718 let indicesToInitialize = indices[core.$where](i => !isHunkInitialized(has hes[core.$get](i)))[core.$toList]();
3719 for (let i of indicesToInitialize) { 3719 for (let i of indicesToInitialize) {
3720 let initializer = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_na mes.INITIALIZE_LOADED_HUNK); 3720 let initializer = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_na mes.INITIALIZE_LOADED_HUNK);
3721 initializer(hashes[core.$get](i)); 3721 initializer(hashes[core.$get](i));
3722 } 3722 }
3723 let updated = exports._loadedLibraries.add(loadId); 3723 let updated = exports._loadedLibraries.add(loadId);
3724 if (dart.notNull(updated) && dart.notNull(exports.deferredLoadHook != null )) { 3724 if (dart.notNull(updated) && dart.notNull(exports.deferredLoadHook != null )) {
3725 exports.deferredLoadHook(); 3725 exports.deferredLoadHook();
3726 } 3726 }
3727 }, dart.functionType(dart.dynamic, [core.List]))), async.Future$(core.Null)) ; 3727 }), async.Future$(core.Null));
3728 } 3728 }
3729 // Function _loadHunk: (String) → Future<Null> 3729 // Function _loadHunk: (String) → Future<Null>
3730 function _loadHunk(hunkName) { 3730 function _loadHunk(hunkName) {
3731 let future = exports._loadingLibraries.get(hunkName); 3731 let future = exports._loadingLibraries.get(hunkName);
3732 if (future != null) { 3732 if (future != null) {
3733 return dart.as(future.then(dart.as(_ => null, dart.functionType(dart.dynam ic, [core.Null]))), async.Future$(core.Null)); 3733 return dart.as(future.then(_ => null), async.Future$(core.Null));
3734 } 3734 }
3735 let uri = _isolate_helper.IsolateNatives.thisScript; 3735 let uri = _isolate_helper.IsolateNatives.thisScript;
3736 let index = uri.lastIndexOf('/'); 3736 let index = uri.lastIndexOf('/');
3737 uri = `${uri.substring(0, dart.notNull(index) + 1)}${hunkName}`; 3737 uri = `${uri.substring(0, dart.notNull(index) + 1)}${hunkName}`;
3738 if (dart.notNull(Primitives.isJsshell) || dart.notNull(Primitives.isD8)) { 3738 if (dart.notNull(Primitives.isJsshell) || dart.notNull(Primitives.isD8)) {
3739 return exports._loadingLibraries.set(hunkName, new (async.Future$(core.Nul l))(() => { 3739 return exports._loadingLibraries.set(hunkName, new (async.Future$(core.Nul l))(() => {
3740 try { 3740 try {
3741 new Function(`load("${uri}")`)(); 3741 new Function(`load("${uri}")`)();
3742 } catch (error) { 3742 } catch (error) {
3743 let stackTrace = dart.stackTrace(error); 3743 let stackTrace = dart.stackTrace(error);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3812 throw new MainError("No top-level function named 'main'."); 3812 throw new MainError("No top-level function named 'main'.");
3813 } 3813 }
3814 // Function badMain: () → void 3814 // Function badMain: () → void
3815 function badMain() { 3815 function badMain() {
3816 throw new MainError("'main' is not a function."); 3816 throw new MainError("'main' is not a function.");
3817 } 3817 }
3818 // Function mainHasTooManyParameters: () → void 3818 // Function mainHasTooManyParameters: () → void
3819 function mainHasTooManyParameters() { 3819 function mainHasTooManyParameters() {
3820 throw new MainError("'main' expects too many parameters."); 3820 throw new MainError("'main' expects too many parameters.");
3821 } 3821 }
3822 let __CastType0 = dart.typedef('__CastType0', () => dart.functionType(core.int , [core.String]));
3823 let __CastType2 = dart.typedef('__CastType2', () => dart.functionType(core.dou ble, [core.String]));
3822 // Exports: 3824 // Exports:
3823 exports.NoSideEffects = NoSideEffects; 3825 exports.NoSideEffects = NoSideEffects;
3824 exports.NoThrows = NoThrows; 3826 exports.NoThrows = NoThrows;
3825 exports.NoInline = NoInline; 3827 exports.NoInline = NoInline;
3826 exports.IrRepresentation = IrRepresentation; 3828 exports.IrRepresentation = IrRepresentation;
3827 exports.Native = Native; 3829 exports.Native = Native;
3828 exports.ConstantMap$ = ConstantMap$; 3830 exports.ConstantMap$ = ConstantMap$;
3829 exports.ConstantMap = ConstantMap; 3831 exports.ConstantMap = ConstantMap;
3830 exports.ConstantStringMap$ = ConstantStringMap$; 3832 exports.ConstantStringMap$ = ConstantStringMap$;
3831 exports.ConstantStringMap = ConstantStringMap; 3833 exports.ConstantStringMap = ConstantStringMap;
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
4043 exports.jsonEncodeNative = jsonEncodeNative; 4045 exports.jsonEncodeNative = jsonEncodeNative;
4044 exports.getIsolateAffinityTag = getIsolateAffinityTag; 4046 exports.getIsolateAffinityTag = getIsolateAffinityTag;
4045 exports.LoadLibraryFunctionType = LoadLibraryFunctionType; 4047 exports.LoadLibraryFunctionType = LoadLibraryFunctionType;
4046 exports.DeferredLoadCallback = DeferredLoadCallback; 4048 exports.DeferredLoadCallback = DeferredLoadCallback;
4047 exports.loadDeferredLibrary = loadDeferredLibrary; 4049 exports.loadDeferredLibrary = loadDeferredLibrary;
4048 exports.MainError = MainError; 4050 exports.MainError = MainError;
4049 exports.missingMain = missingMain; 4051 exports.missingMain = missingMain;
4050 exports.badMain = badMain; 4052 exports.badMain = badMain;
4051 exports.mainHasTooManyParameters = mainHasTooManyParameters; 4053 exports.mainHasTooManyParameters = mainHasTooManyParameters;
4052 })(_js_helper || (_js_helper = {})); 4054 })(_js_helper || (_js_helper = {}));
OLDNEW
« no previous file with comments | « lib/runtime/dart/_isolate_helper.js ('k') | lib/runtime/dart/async.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698