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

Side by Side Diff: sdk/lib/_internal/compiler/js_lib/js_helper.dart

Issue 1207723003: Revert "JSInvocationMirror - return unmodifiable list or map" (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 | « sdk/lib/_internal/compiler/js_lib/constant_map.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library _js_helper; 5 library _js_helper;
6 6
7 import 'dart:_async_await_error_codes' as async_error_codes; 7 import 'dart:_async_await_error_codes' as async_error_codes;
8 8
9 import 'dart:_js_embedded_names' show 9 import 'dart:_js_embedded_names' show
10 DEFERRED_LIBRARY_URIS, 10 DEFERRED_LIBRARY_URIS,
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 bool get isAccessor => _kind != METHOD; 293 bool get isAccessor => _kind != METHOD;
294 294
295 List get positionalArguments { 295 List get positionalArguments {
296 if (isGetter) return const []; 296 if (isGetter) return const [];
297 var argumentCount = _arguments.length - _namedArgumentNames.length; 297 var argumentCount = _arguments.length - _namedArgumentNames.length;
298 if (argumentCount == 0) return const []; 298 if (argumentCount == 0) return const [];
299 var list = []; 299 var list = [];
300 for (var index = 0 ; index < argumentCount ; index++) { 300 for (var index = 0 ; index < argumentCount ; index++) {
301 list.add(_arguments[index]); 301 list.add(_arguments[index]);
302 } 302 }
303 return JSArray.markUnmodifiableList(list); 303 return makeLiteralListConst(list);
304 } 304 }
305 305
306 Map<Symbol, dynamic> get namedArguments { 306 Map<Symbol, dynamic> get namedArguments {
307 if (isAccessor) return const <Symbol, dynamic>{}; 307 // TODO: Make maps const (issue 10471)
308 if (isAccessor) return <Symbol, dynamic>{};
308 int namedArgumentCount = _namedArgumentNames.length; 309 int namedArgumentCount = _namedArgumentNames.length;
309 int namedArgumentsStartIndex = _arguments.length - namedArgumentCount; 310 int namedArgumentsStartIndex = _arguments.length - namedArgumentCount;
310 if (namedArgumentCount == 0) return const <Symbol, dynamic>{}; 311 if (namedArgumentCount == 0) return <Symbol, dynamic>{};
311 var map = new Map<Symbol, dynamic>(); 312 var map = new Map<Symbol, dynamic>();
312 for (int i = 0; i < namedArgumentCount; i++) { 313 for (int i = 0; i < namedArgumentCount; i++) {
313 map[new _symbol_dev.Symbol.unvalidated(_namedArgumentNames[i])] = 314 map[new _symbol_dev.Symbol.unvalidated(_namedArgumentNames[i])] =
314 _arguments[namedArgumentsStartIndex + i]; 315 _arguments[namedArgumentsStartIndex + i];
315 } 316 }
316 return new ConstantMapView<Symbol, dynamic>(map); 317 return map;
317 } 318 }
318 319
319 _getCachedInvocation(Object object) { 320 _getCachedInvocation(Object object) {
320 var interceptor = getInterceptor(object); 321 var interceptor = getInterceptor(object);
321 var receiver = object; 322 var receiver = object;
322 var name = _internalName; 323 var name = _internalName;
323 var arguments = _arguments; 324 var arguments = _arguments;
324 var interceptedNames = JS_EMBEDDED_GLOBAL('', INTERCEPTED_NAMES); 325 var interceptedNames = JS_EMBEDDED_GLOBAL('', INTERCEPTED_NAMES);
325 bool isIntercepted = 326 bool isIntercepted =
326 JS("bool", 'Object.prototype.hasOwnProperty.call(#, #)', 327 JS("bool", 'Object.prototype.hasOwnProperty.call(#, #)',
(...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 /** 1498 /**
1498 * This wraps the exception and does the throw. It is possible to call this in 1499 * This wraps the exception and does the throw. It is possible to call this in
1499 * a JS expression context, where the throw statement is not allowed. Helpers 1500 * a JS expression context, where the throw statement is not allowed. Helpers
1500 * are never inlined, so we don't risk inlining the throw statement into an 1501 * are never inlined, so we don't risk inlining the throw statement into an
1501 * expression context. 1502 * expression context.
1502 */ 1503 */
1503 throwExpression(ex) { 1504 throwExpression(ex) {
1504 JS('void', 'throw #', wrapException(ex)); 1505 JS('void', 'throw #', wrapException(ex));
1505 } 1506 }
1506 1507
1508 makeLiteralListConst(list) {
1509 JS('bool', r'#.immutable$list = #', list, true);
1510 JS('bool', r'#.fixed$length = #', list, true);
1511 return list;
1512 }
1513
1507 throwRuntimeError(message) { 1514 throwRuntimeError(message) {
1508 throw new RuntimeError(message); 1515 throw new RuntimeError(message);
1509 } 1516 }
1510 1517
1511 throwAbstractClassInstantiationError(className) { 1518 throwAbstractClassInstantiationError(className) {
1512 throw new AbstractClassInstantiationError(className); 1519 throw new AbstractClassInstantiationError(className);
1513 } 1520 }
1514 1521
1515 // This is used in open coded for-in loops on arrays. 1522 // This is used in open coded for-in loops on arrays.
1516 // 1523 //
(...skipping 2605 matching lines...) Expand 10 before | Expand all | Expand 10 after
4122 // This is a function that will return a helper function that does the 4129 // This is a function that will return a helper function that does the
4123 // iteration of the sync*. 4130 // iteration of the sync*.
4124 // 4131 //
4125 // Each invocation should give a body with fresh state. 4132 // Each invocation should give a body with fresh state.
4126 final dynamic /* js function */ _outerHelper; 4133 final dynamic /* js function */ _outerHelper;
4127 4134
4128 SyncStarIterable(this._outerHelper); 4135 SyncStarIterable(this._outerHelper);
4129 4136
4130 Iterator get iterator => new SyncStarIterator(JS('', '#()', _outerHelper)); 4137 Iterator get iterator => new SyncStarIterator(JS('', '#()', _outerHelper));
4131 } 4138 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/js_lib/constant_map.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698