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

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

Issue 1050723002: partially implement instance of checks and some codegen fixes (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/_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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 return jsPropertyAccess(this[_jsObject], dart.as(key, core.String)); 92 return jsPropertyAccess(this[_jsObject], dart.as(key, core.String));
93 } 93 }
94 forEach(f) { 94 forEach(f) {
95 let keys = this[_keys]; 95 let keys = this[_keys];
96 for (let i = 0; i['<'](dart.dload(keys, 'length')); i = dart.notNull(i) + 1) { 96 for (let i = 0; i['<'](dart.dload(keys, 'length')); i = dart.notNull(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(this); 102 return new (_ConstantMapKeyIterable$(K))(this);
103 } 103 }
104 get values() { 104 get values() {
105 return new _internal.MappedIterable(this[_keys], dart.closureWrap(((key) => this[_fetch](key)).bind(this), "(K) → V")); 105 return new (_internal.MappedIterable$(K, V))(this[_keys], dart.closureWr ap(((key) => this[_fetch](key)).bind(this), "(K) → V"));
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$(dart.dynamic, dart.dynamic); 112 let ConstantStringMap = ConstantStringMap$(dart.dynamic, dart.dynamic);
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 let _jsData = Symbol('_jsData'); 152 let _jsData = Symbol('_jsData');
153 let _getMap = Symbol('_getMap'); 153 let _getMap = Symbol('_getMap');
154 let GeneralConstantMap$ = dart.generic(function(K, V) { 154 let GeneralConstantMap$ = dart.generic(function(K, V) {
155 class GeneralConstantMap extends ConstantMap$(K, V) { 155 class GeneralConstantMap extends ConstantMap$(K, V) {
156 GeneralConstantMap(jsData) { 156 GeneralConstantMap(jsData) {
157 this[_jsData] = jsData; 157 this[_jsData] = jsData;
158 super[_$](); 158 super[_$]();
159 } 159 }
160 [_getMap]() { 160 [_getMap]() {
161 if (!this.$map) { 161 if (!this.$map) {
162 let backingMap = new collection.LinkedHashMap(); 162 let backingMap = new (collection.LinkedHashMap$(K, V))();
163 this.$map = fillLiteralMap(this[_jsData], backingMap); 163 this.$map = fillLiteralMap(this[_jsData], backingMap);
164 } 164 }
165 return this.$map; 165 return this.$map;
166 } 166 }
167 containsValue(needle) { 167 containsValue(needle) {
168 return this[_getMap]().containsValue(needle); 168 return this[_getMap]().containsValue(needle);
169 } 169 }
170 containsKey(key) { 170 containsKey(key) {
171 return this[_getMap]().containsKey(key); 171 return this[_getMap]().containsKey(key);
172 } 172 }
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 get groupCount() { 681 get groupCount() {
682 return 0; 682 return 0;
683 } 683 }
684 group(group_) { 684 group(group_) {
685 if (group_ != 0) { 685 if (group_ != 0) {
686 throw new core.RangeError.value(group_); 686 throw new core.RangeError.value(group_);
687 } 687 }
688 return this.pattern; 688 return this.pattern;
689 } 689 }
690 groups(groups_) { 690 groups(groups_) {
691 let result = new core.List(); 691 let result = new (core.List$(core.String))();
692 for (let g of groups_) { 692 for (let g of groups_) {
693 result.add(this.group(g)); 693 result.add(this.group(g));
694 } 694 }
695 return result; 695 return result;
696 } 696 }
697 } 697 }
698 StringMatch[dart.implements] = () => [core.Match]; 698 StringMatch[dart.implements] = () => [core.Match];
699 // Function allMatchesInStringUnchecked: (String, String, int) → List<Match> 699 // Function allMatchesInStringUnchecked: (String, String, int) → List<Match>
700 function allMatchesInStringUnchecked(needle, haystack, startIndex) { 700 function allMatchesInStringUnchecked(needle, haystack, startIndex) {
701 let result = new core.List(); 701 let result = new (core.List$(core.Match))();
702 let length = haystack.length; 702 let length = haystack.length;
703 let patternLength = needle.length; 703 let patternLength = needle.length;
704 while (true) { 704 while (true) {
705 let position = haystack.indexOf(needle, startIndex); 705 let position = haystack.indexOf(needle, startIndex);
706 if (position == -1) { 706 if (position == -1) {
707 break; 707 break;
708 } 708 }
709 result.add(new StringMatch(position, haystack, needle)); 709 result.add(new StringMatch(position, haystack, needle));
710 let endIndex = dart.notNull(position) + dart.notNull(patternLength); 710 let endIndex = dart.notNull(position) + dart.notNull(patternLength);
711 if (endIndex == length) { 711 if (endIndex == length) {
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 } 1450 }
1451 return dart.as(makeLiteralListConst(list), core.List); 1451 return dart.as(makeLiteralListConst(list), core.List);
1452 } 1452 }
1453 get namedArguments() { 1453 get namedArguments() {
1454 if (this.isAccessor) 1454 if (this.isAccessor)
1455 return dart.map(); 1455 return dart.map();
1456 let namedArgumentCount = this[_namedArgumentNames].length; 1456 let namedArgumentCount = this[_namedArgumentNames].length;
1457 let namedArgumentsStartIndex = dart.notNull(this[_arguments].length) - dar t.notNull(namedArgumentCount); 1457 let namedArgumentsStartIndex = dart.notNull(this[_arguments].length) - dar t.notNull(namedArgumentCount);
1458 if (namedArgumentCount == 0) 1458 if (namedArgumentCount == 0)
1459 return dart.map(); 1459 return dart.map();
1460 let map = new core.Map(); 1460 let map = new (core.Map$(core.Symbol, dynamic))();
1461 for (let i = 0; dart.notNull(i) < dart.notNull(namedArgumentCount); i = da rt.notNull(i) + 1) { 1461 for (let i = 0; dart.notNull(i) < dart.notNull(namedArgumentCount); i = da rt.notNull(i) + 1) {
1462 map.set(new _internal.Symbol.unvalidated(dart.as(this[_namedArgumentName s].get(i), core.String)), this[_arguments].get(dart.notNull(namedArgumentsStartI ndex) + dart.notNull(i))); 1462 map.set(new _internal.Symbol.unvalidated(dart.as(this[_namedArgumentName s].get(i), core.String)), this[_arguments].get(dart.notNull(namedArgumentsStartI ndex) + dart.notNull(i)));
1463 } 1463 }
1464 return map; 1464 return map;
1465 } 1465 }
1466 [_getCachedInvocation](object) { 1466 [_getCachedInvocation](object) {
1467 let interceptor = _interceptors.getInterceptor(object); 1467 let interceptor = _interceptors.getInterceptor(object);
1468 let receiver = object; 1468 let receiver = object;
1469 let name = this[_internalName]; 1469 let name = this[_internalName];
1470 let arguments$ = this[_arguments]; 1470 let arguments$ = this[_arguments];
(...skipping 1757 matching lines...) Expand 10 before | Expand all | Expand 10 after
3228 if (!(typeof condition == 'boolean')) { 3228 if (!(typeof condition == 'boolean')) {
3229 throw new TypeErrorImplementation(condition, 'bool'); 3229 throw new TypeErrorImplementation(condition, 'bool');
3230 } 3230 }
3231 } 3231 }
3232 if (!dart.equals(true, condition)) 3232 if (!dart.equals(true, condition))
3233 throw new core.AssertionError(); 3233 throw new core.AssertionError();
3234 } 3234 }
3235 // Function throwNoSuchMethod: (dynamic, dynamic, dynamic, dynamic) → void 3235 // Function throwNoSuchMethod: (dynamic, dynamic, dynamic, dynamic) → void
3236 function throwNoSuchMethod(obj, name, arguments$, expectedArgumentNames) { 3236 function throwNoSuchMethod(obj, name, arguments$, expectedArgumentNames) {
3237 let memberName = new _internal.Symbol.unvalidated(dart.as(name, core.String) ); 3237 let memberName = new _internal.Symbol.unvalidated(dart.as(name, core.String) );
3238 throw new core.NoSuchMethodError(obj, memberName, dart.as(arguments$, core.L ist), new core.Map(), dart.as(expectedArgumentNames, core.List)); 3238 throw new core.NoSuchMethodError(obj, memberName, dart.as(arguments$, core.L ist), new (core.Map$(core.Symbol, dynamic))(), dart.as(expectedArgumentNames, co re.List));
3239 } 3239 }
3240 // Function throwCyclicInit: (String) → void 3240 // Function throwCyclicInit: (String) → void
3241 function throwCyclicInit(staticName) { 3241 function throwCyclicInit(staticName) {
3242 throw new core.CyclicInitializationError(`Cyclic initialization for static $ {staticName}`); 3242 throw new core.CyclicInitializationError(`Cyclic initialization for static $ {staticName}`);
3243 } 3243 }
3244 class RuntimeError extends core.Error { 3244 class RuntimeError extends core.Error {
3245 RuntimeError(message) { 3245 RuntimeError(message) {
3246 this.message = message; 3246 this.message = message;
3247 super.Error(); 3247 super.Error();
3248 } 3248 }
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
3652 } 3652 }
3653 // Function _loadLibraryWrapper: (String) → () → Future<Null> 3653 // Function _loadLibraryWrapper: (String) → () → Future<Null>
3654 function _loadLibraryWrapper(loadId) { 3654 function _loadLibraryWrapper(loadId) {
3655 return () => loadDeferredLibrary(loadId); 3655 return () => loadDeferredLibrary(loadId);
3656 } 3656 }
3657 dart.defineLazyProperties(exports, { 3657 dart.defineLazyProperties(exports, {
3658 get _loadingLibraries() { 3658 get _loadingLibraries() {
3659 return dart.map(); 3659 return dart.map();
3660 }, 3660 },
3661 get _loadedLibraries() { 3661 get _loadedLibraries() {
3662 return new core.Set(); 3662 return new (core.Set$(core.String))();
3663 } 3663 }
3664 }); 3664 });
3665 exports.deferredLoadHook = null; 3665 exports.deferredLoadHook = null;
3666 // Function loadDeferredLibrary: (String) → Future<Null> 3666 // Function loadDeferredLibrary: (String) → Future<Null>
3667 function loadDeferredLibrary(loadId) { 3667 function loadDeferredLibrary(loadId) {
3668 let urisMap = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names.DEFE RRED_LIBRARY_URIS); 3668 let urisMap = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names.DEFE RRED_LIBRARY_URIS);
3669 let uris = dart.as(urisMap[loadId], core.List$(core.String)); 3669 let uris = dart.as(urisMap[loadId], core.List$(core.String));
3670 let hashesMap = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names.DE FERRED_LIBRARY_HASHES); 3670 let hashesMap = _foreign_helper.JS_EMBEDDED_GLOBAL('', _js_embedded_names.DE FERRED_LIBRARY_HASHES);
3671 let hashes = dart.as(hashesMap[loadId], core.List$(core.String)); 3671 let hashes = dart.as(hashesMap[loadId], core.List$(core.String));
3672 if (uris == null) 3672 if (uris == null)
(...skipping 17 matching lines...) Expand all
3690 // Function _loadHunk: (String) → Future<Null> 3690 // Function _loadHunk: (String) → Future<Null>
3691 function _loadHunk(hunkName) { 3691 function _loadHunk(hunkName) {
3692 let future = exports._loadingLibraries.get(hunkName); 3692 let future = exports._loadingLibraries.get(hunkName);
3693 if (future != null) { 3693 if (future != null) {
3694 return dart.as(future.then(dart.closureWrap((_) => null, "(Null) → dynamic ")), async.Future$(core.Null)); 3694 return dart.as(future.then(dart.closureWrap((_) => null, "(Null) → dynamic ")), async.Future$(core.Null));
3695 } 3695 }
3696 let uri = _isolate_helper.IsolateNatives.thisScript; 3696 let uri = _isolate_helper.IsolateNatives.thisScript;
3697 let index = uri.lastIndexOf('/'); 3697 let index = uri.lastIndexOf('/');
3698 uri = `${uri.substring(0, dart.notNull(index) + 1)}${hunkName}`; 3698 uri = `${uri.substring(0, dart.notNull(index) + 1)}${hunkName}`;
3699 if (dart.notNull(Primitives.isJsshell) || dart.notNull(Primitives.isD8)) { 3699 if (dart.notNull(Primitives.isJsshell) || dart.notNull(Primitives.isD8)) {
3700 return exports._loadingLibraries.set(hunkName, new async.Future(() => { 3700 return exports._loadingLibraries.set(hunkName, new (async.Future$(core.Nul l))(() => {
3701 try { 3701 try {
3702 new Function(`load("${uri}")`)(); 3702 new Function(`load("${uri}")`)();
3703 } catch (error) { 3703 } catch (error) {
3704 let stackTrace = dart.stackTrace(error); 3704 let stackTrace = dart.stackTrace(error);
3705 throw new async.DeferredLoadException(`Loading ${uri} failed.`); 3705 throw new async.DeferredLoadException(`Loading ${uri} failed.`);
3706 } 3706 }
3707 3707
3708 return null; 3708 return null;
3709 })); 3709 }));
3710 } else if (_isolate_helper.isWorker()) { 3710 } else if (_isolate_helper.isWorker()) {
3711 return exports._loadingLibraries.set(hunkName, new async.Future(() => { 3711 return exports._loadingLibraries.set(hunkName, new (async.Future$(core.Nul l))(() => {
3712 let completer = new async.Completer(); 3712 let completer = new (async.Completer$(core.Null))();
3713 _isolate_helper.enterJsAsync(); 3713 _isolate_helper.enterJsAsync();
3714 let leavingFuture = dart.as(completer.future.whenComplete(() => { 3714 let leavingFuture = dart.as(completer.future.whenComplete(() => {
3715 _isolate_helper.leaveJsAsync(); 3715 _isolate_helper.leaveJsAsync();
3716 }), async.Future$(core.Null)); 3716 }), async.Future$(core.Null));
3717 let index = uri.lastIndexOf('/'); 3717 let index = uri.lastIndexOf('/');
3718 uri = `${uri.substring(0, dart.notNull(index) + 1)}${hunkName}`; 3718 uri = `${uri.substring(0, dart.notNull(index) + 1)}${hunkName}`;
3719 let xhr = new XMLHttpRequest(); 3719 let xhr = new XMLHttpRequest();
3720 xhr.open("GET", uri); 3720 xhr.open("GET", uri);
3721 xhr.addEventListener("load", convertDartClosureToJS((event) => { 3721 xhr.addEventListener("load", convertDartClosureToJS((event) => {
3722 if (xhr.status != 200) { 3722 if (xhr.status != 200) {
(...skipping 13 matching lines...) Expand all
3736 }, 1), false); 3736 }, 1), false);
3737 let fail = convertDartClosureToJS((event) => { 3737 let fail = convertDartClosureToJS((event) => {
3738 new async.DeferredLoadException(`Loading ${uri} failed.`); 3738 new async.DeferredLoadException(`Loading ${uri} failed.`);
3739 }, 1); 3739 }, 1);
3740 xhr.addEventListener("error", fail, false); 3740 xhr.addEventListener("error", fail, false);
3741 xhr.addEventListener("abort", fail, false); 3741 xhr.addEventListener("abort", fail, false);
3742 xhr.send(); 3742 xhr.send();
3743 return leavingFuture; 3743 return leavingFuture;
3744 })); 3744 }));
3745 } 3745 }
3746 return exports._loadingLibraries.set(hunkName, new async.Future(() => { 3746 return exports._loadingLibraries.set(hunkName, new (async.Future$(core.Null) )(() => {
3747 let completer = new async.Completer(); 3747 let completer = new (async.Completer$(core.Null))();
3748 let script = document.createElement("script"); 3748 let script = document.createElement("script");
3749 script.type = "text/javascript"; 3749 script.type = "text/javascript";
3750 script.src = uri; 3750 script.src = uri;
3751 script.addEventListener("load", convertDartClosureToJS((event) => { 3751 script.addEventListener("load", convertDartClosureToJS((event) => {
3752 completer.complete(null); 3752 completer.complete(null);
3753 }, 1), false); 3753 }, 1), false);
3754 script.addEventListener("error", convertDartClosureToJS((event) => { 3754 script.addEventListener("error", convertDartClosureToJS((event) => {
3755 completer.completeError(new async.DeferredLoadException(`Loading ${uri} failed.`)); 3755 completer.completeError(new async.DeferredLoadException(`Loading ${uri} failed.`));
3756 }, 1), false); 3756 }, 1), false);
3757 document.body.appendChild(script); 3757 document.body.appendChild(script);
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
4002 exports.UnimplementedNoSuchMethodError = UnimplementedNoSuchMethodError; 4002 exports.UnimplementedNoSuchMethodError = UnimplementedNoSuchMethodError;
4003 exports.random64 = random64; 4003 exports.random64 = random64;
4004 exports.jsonEncodeNative = jsonEncodeNative; 4004 exports.jsonEncodeNative = jsonEncodeNative;
4005 exports.getIsolateAffinityTag = getIsolateAffinityTag; 4005 exports.getIsolateAffinityTag = getIsolateAffinityTag;
4006 exports.loadDeferredLibrary = loadDeferredLibrary; 4006 exports.loadDeferredLibrary = loadDeferredLibrary;
4007 exports.MainError = MainError; 4007 exports.MainError = MainError;
4008 exports.missingMain = missingMain; 4008 exports.missingMain = missingMain;
4009 exports.badMain = badMain; 4009 exports.badMain = badMain;
4010 exports.mainHasTooManyParameters = mainHasTooManyParameters; 4010 exports.mainHasTooManyParameters = mainHasTooManyParameters;
4011 })(_js_helper || (_js_helper = {})); 4011 })(_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