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

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

Issue 1524843002: JS: Format if statements with no else on a single line (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: rebased Created 5 years 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.js ('k') | lib/runtime/dart/math.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/js', null, /* Imports */[ 1 dart_library.library('dart/js', null, /* Imports */[
2 "dart/_runtime", 2 "dart/_runtime",
3 'dart/core', 3 'dart/core',
4 'dart/collection', 4 'dart/collection',
5 'dart/_js_helper' 5 'dart/_js_helper'
6 ], /* Lazy imports */[ 6 ], /* Lazy imports */[
7 ], function(exports, dart, core, collection, _js_helper) { 7 ], function(exports, dart, core, collection, _js_helper) {
8 'use strict'; 8 'use strict';
9 let dartx = dart.dartx; 9 let dartx = dart.dartx;
10 const _global = dart.global; 10 const _global = dart.global;
11 dart.defineLazyProperties(exports, { 11 dart.defineLazyProperties(exports, {
12 get context() { 12 get context() {
13 return _wrapToDart(_global); 13 return _wrapToDart(_global);
14 } 14 }
15 }); 15 });
16 const _jsObject = Symbol('_jsObject'); 16 const _jsObject = Symbol('_jsObject');
17 class JsObject extends core.Object { 17 class JsObject extends core.Object {
18 _fromJs(jsObject) { 18 _fromJs(jsObject) {
19 this[_jsObject] = jsObject; 19 this[_jsObject] = jsObject;
20 dart.assert(this[_jsObject] != null); 20 dart.assert(this[_jsObject] != null);
21 } 21 }
22 static new(constructor, arguments$) { 22 static new(constructor, arguments$) {
23 if (arguments$ === void 0) 23 if (arguments$ === void 0) arguments$ = null;
24 arguments$ = null;
25 let ctor = constructor[_jsObject]; 24 let ctor = constructor[_jsObject];
26 if (arguments$ == null) { 25 if (arguments$ == null) {
27 return _wrapToDart(new ctor()); 26 return _wrapToDart(new ctor());
28 } 27 }
29 return _wrapToDart(new ctor(...arguments$)); 28 return _wrapToDart(new ctor(...arguments$));
30 } 29 }
31 static fromBrowserObject(object) { 30 static fromBrowserObject(object) {
32 if (typeof object == 'number' || typeof object == 'string' || typeof objec t == 'boolean' || object == null) { 31 if (typeof object == 'number' || typeof object == 'string' || typeof objec t == 'boolean' || object == null) {
33 dart.throw(new core.ArgumentError("object cannot be a num, string, bool, or null")); 32 dart.throw(new core.ArgumentError("object cannot be a num, string, bool, or null"));
34 } 33 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 100 }
102 toString() { 101 toString() {
103 try { 102 try {
104 return String(this[_jsObject]); 103 return String(this[_jsObject]);
105 } catch (e) { 104 } catch (e) {
106 return super.toString(); 105 return super.toString();
107 } 106 }
108 107
109 } 108 }
110 callMethod(method, args) { 109 callMethod(method, args) {
111 if (args === void 0) 110 if (args === void 0) args = null;
112 args = null;
113 if (!(typeof method == 'string') && !(typeof method == 'number')) { 111 if (!(typeof method == 'string') && !(typeof method == 'number')) {
114 dart.throw(new core.ArgumentError("method is not a String or num")); 112 dart.throw(new core.ArgumentError("method is not a String or num"));
115 } 113 }
116 if (args != null) 114 if (args != null) args = core.List.from(args[dartx.map](_convertToJS));
117 args = core.List.from(args[dartx.map](_convertToJS));
118 let fn = this[_jsObject][method]; 115 let fn = this[_jsObject][method];
119 if (!(fn instanceof Function)) { 116 if (!(fn instanceof Function)) {
120 dart.throw(new core.NoSuchMethodError(this[_jsObject], core.Symbol.new(d art.as(method, core.String)), args, dart.map())); 117 dart.throw(new core.NoSuchMethodError(this[_jsObject], core.Symbol.new(d art.as(method, core.String)), args, dart.map()));
121 } 118 }
122 return _convertToDart(fn.apply(this[_jsObject], args)); 119 return _convertToDart(fn.apply(this[_jsObject], args));
123 } 120 }
124 } 121 }
125 dart.defineNamedConstructor(JsObject, '_fromJs'); 122 dart.defineNamedConstructor(JsObject, '_fromJs');
126 dart.setSignature(JsObject, { 123 dart.setSignature(JsObject, {
127 constructors: () => ({ 124 constructors: () => ({
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 insert(index, element) { 235 insert(index, element) {
239 dart.as(element, E); 236 dart.as(element, E);
240 this[_checkInsertIndex](index); 237 this[_checkInsertIndex](index);
241 this.callMethod('splice', [index, 0, element]); 238 this.callMethod('splice', [index, 0, element]);
242 } 239 }
243 removeAt(index) { 240 removeAt(index) {
244 this[_checkIndex](index); 241 this[_checkIndex](index);
245 return dart.as(dart.dindex(this.callMethod('splice', [index, 1]), 0), E) ; 242 return dart.as(dart.dindex(this.callMethod('splice', [index, 1]), 0), E) ;
246 } 243 }
247 removeLast() { 244 removeLast() {
248 if (this.length == 0) 245 if (this.length == 0) dart.throw(new core.RangeError(-1));
249 dart.throw(new core.RangeError(-1));
250 return dart.as(this.callMethod('pop'), E); 246 return dart.as(this.callMethod('pop'), E);
251 } 247 }
252 removeRange(start, end) { 248 removeRange(start, end) {
253 JsArray$()._checkRange(start, end, this.length); 249 JsArray$()._checkRange(start, end, this.length);
254 this.callMethod('splice', [start, dart.notNull(end) - dart.notNull(start )]); 250 this.callMethod('splice', [start, dart.notNull(end) - dart.notNull(start )]);
255 } 251 }
256 setRange(start, end, iterable, skipCount) { 252 setRange(start, end, iterable, skipCount) {
257 dart.as(iterable, core.Iterable$(E)); 253 dart.as(iterable, core.Iterable$(E));
258 if (skipCount === void 0) 254 if (skipCount === void 0) skipCount = 0;
259 skipCount = 0;
260 JsArray$()._checkRange(start, end, this.length); 255 JsArray$()._checkRange(start, end, this.length);
261 let length = dart.notNull(end) - dart.notNull(start); 256 let length = dart.notNull(end) - dart.notNull(start);
262 if (length == 0) 257 if (length == 0) return;
263 return; 258 if (dart.notNull(skipCount) < 0) dart.throw(new core.ArgumentError(skipC ount));
264 if (dart.notNull(skipCount) < 0)
265 dart.throw(new core.ArgumentError(skipCount));
266 let args = [start, length]; 259 let args = [start, length];
267 args[dartx.addAll](iterable[dartx.skip](skipCount)[dartx.take](length)); 260 args[dartx.addAll](iterable[dartx.skip](skipCount)[dartx.take](length));
268 this.callMethod('splice', args); 261 this.callMethod('splice', args);
269 } 262 }
270 sort(compare) { 263 sort(compare) {
271 if (compare === void 0) 264 if (compare === void 0) compare = null;
272 compare = null;
273 dart.as(compare, dart.functionType(core.int, [E, E])); 265 dart.as(compare, dart.functionType(core.int, [E, E]));
274 this.callMethod('sort', compare == null ? [] : [compare]); 266 this.callMethod('sort', compare == null ? [] : [compare]);
275 } 267 }
276 } 268 }
277 dart.defineNamedConstructor(JsArray, 'from'); 269 dart.defineNamedConstructor(JsArray, 'from');
278 dart.defineNamedConstructor(JsArray, '_fromJs'); 270 dart.defineNamedConstructor(JsArray, '_fromJs');
279 dart.setSignature(JsArray, { 271 dart.setSignature(JsArray, {
280 constructors: () => ({ 272 constructors: () => ({
281 JsArray: [JsArray$(E), []], 273 JsArray: [JsArray$(E), []],
282 from: [JsArray$(E), [core.Iterable$(E)]], 274 from: [JsArray$(E), [core.Iterable$(E)]],
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 function _wrapDartFunction(f) { 337 function _wrapDartFunction(f) {
346 let wrapper = function() { 338 let wrapper = function() {
347 let args = Array.prototype.map.call(arguments, _convertToDart); 339 let args = Array.prototype.map.call(arguments, _convertToDart);
348 return _convertToJS(f(...args)); 340 return _convertToJS(f(...args));
349 }; 341 };
350 dart.dsetindex(_dartProxies, wrapper, f); 342 dart.dsetindex(_dartProxies, wrapper, f);
351 return wrapper; 343 return wrapper;
352 } 344 }
353 dart.fn(_wrapDartFunction); 345 dart.fn(_wrapDartFunction);
354 function _convertToDart(o, isBrowserType) { 346 function _convertToDart(o, isBrowserType) {
355 if (isBrowserType === void 0) 347 if (isBrowserType === void 0) isBrowserType = null;
356 isBrowserType = null; 348 if (isBrowserType == null) isBrowserType = _isBrowserType;
357 if (isBrowserType == null)
358 isBrowserType = _isBrowserType;
359 if (o == null || typeof o == "string" || typeof o == "number" || typeof o == "boolean" || dart.notNull(dart.dcall(isBrowserType, o))) { 349 if (o == null || typeof o == "string" || typeof o == "number" || typeof o == "boolean" || dart.notNull(dart.dcall(isBrowserType, o))) {
360 return o; 350 return o;
361 } else if (o instanceof Date) { 351 } else if (o instanceof Date) {
362 let ms = o.getTime(); 352 let ms = o.getTime();
363 return new core.DateTime.fromMillisecondsSinceEpoch(dart.asInt(ms)); 353 return new core.DateTime.fromMillisecondsSinceEpoch(dart.asInt(ms));
364 } else if (dart.is(o, _DartObject) && dart.jsobject != dart.realRuntimeType( o)) { 354 } else if (dart.is(o, _DartObject) && dart.jsobject != dart.realRuntimeType( o)) {
365 return dart.dload(o, _dartObj); 355 return dart.dload(o, _dartObj);
366 } else { 356 } else {
367 return _putIfAbsent(_dartProxies, o, _wrapToDart); 357 return _putIfAbsent(_dartProxies, o, _wrapToDart);
368 } 358 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 }); 410 });
421 let __CastType0 = __CastType0$(); 411 let __CastType0 = __CastType0$();
422 // Exports: 412 // Exports:
423 exports.JsObject = JsObject; 413 exports.JsObject = JsObject;
424 exports.JsFunction = JsFunction; 414 exports.JsFunction = JsFunction;
425 exports.JsArray$ = JsArray$; 415 exports.JsArray$ = JsArray$;
426 exports.JsArray = JsArray; 416 exports.JsArray = JsArray;
427 exports.allowInterop = allowInterop; 417 exports.allowInterop = allowInterop;
428 exports.allowInteropCaptureThis = allowInteropCaptureThis; 418 exports.allowInteropCaptureThis = allowInteropCaptureThis;
429 }); 419 });
OLDNEW
« no previous file with comments | « lib/runtime/dart/isolate.js ('k') | lib/runtime/dart/math.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698