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

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

Issue 1055923002: Don't call dinvoke on Object methods (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Refactor dynamic target logic 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 _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 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 function runtimeTypeToString(type, opts) { 957 function runtimeTypeToString(type, opts) {
958 let onTypeVariable = opts && 'onTypeVariable' in opts ? opts.onTypeVariable : null; 958 let onTypeVariable = opts && 'onTypeVariable' in opts ? opts.onTypeVariable : null;
959 if (type == null) { 959 if (type == null) {
960 return 'dynamic'; 960 return 'dynamic';
961 } else if (isJsArray(type)) { 961 } else if (isJsArray(type)) {
962 return getRuntimeTypeAsString(type, {onTypeVariable: onTypeVariable}); 962 return getRuntimeTypeAsString(type, {onTypeVariable: onTypeVariable});
963 } else if (isJsFunction(type)) { 963 } else if (isJsFunction(type)) {
964 return getConstructorName(type); 964 return getConstructorName(type);
965 } else if (typeof type == 'number') { 965 } else if (typeof type == 'number') {
966 if (onTypeVariable == null) { 966 if (onTypeVariable == null) {
967 return dart.as(dart.dinvoke(type, 'toString'), core.String); 967 return type.toString();
968 } else { 968 } else {
969 return onTypeVariable(dart.as(type, core.int)); 969 return onTypeVariable(dart.as(type, core.int));
970 } 970 }
971 } else { 971 } else {
972 return null; 972 return null;
973 } 973 }
974 } 974 }
975 // Function joinArguments: (dynamic, int, {onTypeVariable: (int) → String}) → String 975 // Function joinArguments: (dynamic, int, {onTypeVariable: (int) → String}) → String
976 function joinArguments(types, startIndex, opts) { 976 function joinArguments(types, startIndex, opts) {
977 let onTypeVariable = opts && 'onTypeVariable' in opts ? opts.onTypeVariable : null; 977 let onTypeVariable = opts && 'onTypeVariable' in opts ? opts.onTypeVariable : null;
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 if (!dart.equals(value, 0)) { 1360 if (!dart.equals(value, 0)) {
1361 return "" + value; 1361 return "" + value;
1362 } 1362 }
1363 } else if (dart.equals(true, value)) { 1363 } else if (dart.equals(true, value)) {
1364 return 'true'; 1364 return 'true';
1365 } else if (dart.equals(false, value)) { 1365 } else if (dart.equals(false, value)) {
1366 return 'false'; 1366 return 'false';
1367 } else if (value == null) { 1367 } else if (value == null) {
1368 return 'null'; 1368 return 'null';
1369 } 1369 }
1370 let res = dart.dinvoke(value, 'toString'); 1370 let res = value.toString();
1371 if (!(typeof res == 'string')) 1371 if (!(typeof res == 'string'))
1372 throw new core.ArgumentError(value); 1372 throw new core.ArgumentError(value);
1373 return dart.as(res, core.String); 1373 return res;
1374 } 1374 }
1375 // Function createInvocationMirror: (String, dynamic, dynamic, dynamic, dynami c) → dynamic 1375 // Function createInvocationMirror: (String, dynamic, dynamic, dynamic, dynami c) → dynamic
1376 function createInvocationMirror(name, internalName, kind, arguments$, argument Names) { 1376 function createInvocationMirror(name, internalName, kind, arguments$, argument Names) {
1377 return new JSInvocationMirror(name, dart.as(internalName, core.String), dart .as(kind, core.int), dart.as(arguments$, core.List), dart.as(argumentNames, core .List)); 1377 return new JSInvocationMirror(name, dart.as(internalName, core.String), dart .as(kind, core.int), dart.as(arguments$, core.List), dart.as(argumentNames, core .List));
1378 } 1378 }
1379 // Function createUnmangledInvocationMirror: (Symbol, dynamic, dynamic, dynami c, dynamic) → dynamic 1379 // Function createUnmangledInvocationMirror: (Symbol, dynamic, dynamic, dynami c, dynamic) → dynamic
1380 function createUnmangledInvocationMirror(symbol, internalName, kind, arguments $, argumentNames) { 1380 function createUnmangledInvocationMirror(symbol, internalName, kind, arguments $, argumentNames) {
1381 return new JSInvocationMirror(symbol, dart.as(internalName, core.String), da rt.as(kind, core.int), dart.as(arguments$, core.List), dart.as(argumentNames, co re.List)); 1381 return new JSInvocationMirror(symbol, dart.as(internalName, core.String), da rt.as(kind, core.int), dart.as(arguments$, core.List), dart.as(argumentNames, co re.List));
1382 } 1382 }
1383 // Function throwInvalidReflectionError: (String) → void 1383 // Function throwInvalidReflectionError: (String) → void
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
2189 if ("defineProperty" in Object) { 2189 if ("defineProperty" in Object) {
2190 Object.defineProperty(wrapper, "message", {get: _foreign_helper.DART_CLOSU RE_TO_JS(toStringWrapper)}); 2190 Object.defineProperty(wrapper, "message", {get: _foreign_helper.DART_CLOSU RE_TO_JS(toStringWrapper)});
2191 wrapper.name = ""; 2191 wrapper.name = "";
2192 } else { 2192 } else {
2193 wrapper.toString = _foreign_helper.DART_CLOSURE_TO_JS(toStringWrapper); 2193 wrapper.toString = _foreign_helper.DART_CLOSURE_TO_JS(toStringWrapper);
2194 } 2194 }
2195 return wrapper; 2195 return wrapper;
2196 } 2196 }
2197 // Function toStringWrapper: () → dynamic 2197 // Function toStringWrapper: () → dynamic
2198 function toStringWrapper() { 2198 function toStringWrapper() {
2199 return dart.dinvoke(this.dartException, 'toString'); 2199 return this.dartException.toString();
2200 } 2200 }
2201 // Function throwExpression: (dynamic) → dynamic 2201 // Function throwExpression: (dynamic) → dynamic
2202 function throwExpression(ex) { 2202 function throwExpression(ex) {
2203 throw wrapException(ex); 2203 throw wrapException(ex);
2204 } 2204 }
2205 // Function makeLiteralListConst: (dynamic) → dynamic 2205 // Function makeLiteralListConst: (dynamic) → dynamic
2206 function makeLiteralListConst(list) { 2206 function makeLiteralListConst(list) {
2207 list.immutable$list = true; 2207 list.immutable$list = true;
2208 list.fixed$length = true; 2208 list.fixed$length = true;
2209 return list; 2209 return list;
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
2516 if (typeof this[_exception] === "object") { 2516 if (typeof this[_exception] === "object") {
2517 trace = dart.as(this[_exception].stack, core.String); 2517 trace = dart.as(this[_exception].stack, core.String);
2518 } 2518 }
2519 return this[_trace] = trace == null ? '' : trace; 2519 return this[_trace] = trace == null ? '' : trace;
2520 } 2520 }
2521 } 2521 }
2522 _StackTrace[dart.implements] = () => [core.StackTrace]; 2522 _StackTrace[dart.implements] = () => [core.StackTrace];
2523 // Function objectHashCode: (dynamic) → int 2523 // Function objectHashCode: (dynamic) → int
2524 function objectHashCode(object) { 2524 function objectHashCode(object) {
2525 if (dart.notNull(object == null) || typeof object != 'object') { 2525 if (dart.notNull(object == null) || typeof object != 'object') {
2526 return dart.as(dart.dload(object, 'hashCode'), core.int); 2526 return object.hashCode;
2527 } else { 2527 } else {
2528 return Primitives.objectHashCode(object); 2528 return Primitives.objectHashCode(object);
2529 } 2529 }
2530 } 2530 }
2531 // Function fillLiteralMap: (dynamic, Map<dynamic, dynamic>) → dynamic 2531 // Function fillLiteralMap: (dynamic, Map<dynamic, dynamic>) → dynamic
2532 function fillLiteralMap(keyValuePairs, result) { 2532 function fillLiteralMap(keyValuePairs, result) {
2533 let index = 0; 2533 let index = 0;
2534 let length = getLength(keyValuePairs); 2534 let length = getLength(keyValuePairs);
2535 while (dart.notNull(index) < dart.notNull(length)) { 2535 while (dart.notNull(index) < dart.notNull(length)) {
2536 let key = getIndex(keyValuePairs, ((x$) => index = dart.notNull(x$) + 1, x $)(index)); 2536 let key = getIndex(keyValuePairs, ((x$) => index = dart.notNull(x$) + 1, x $)(index));
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
2838 return true; 2838 return true;
2839 if (!dart.is(other, BoundClosure)) 2839 if (!dart.is(other, BoundClosure))
2840 return false; 2840 return false;
2841 return this[_self] === dart.dload(other, '_self') && this[_target] === dar t.dload(other, '_target') && this[_receiver] === dart.dload(other, '_receiver'); 2841 return this[_self] === dart.dload(other, '_self') && this[_target] === dar t.dload(other, '_target') && this[_receiver] === dart.dload(other, '_receiver');
2842 } 2842 }
2843 get hashCode() { 2843 get hashCode() {
2844 let receiverHashCode = null; 2844 let receiverHashCode = null;
2845 if (this[_receiver] == null) { 2845 if (this[_receiver] == null) {
2846 receiverHashCode = Primitives.objectHashCode(this[_self]); 2846 receiverHashCode = Primitives.objectHashCode(this[_self]);
2847 } else if (typeof this[_receiver] != 'object') { 2847 } else if (typeof this[_receiver] != 'object') {
2848 receiverHashCode = dart.as(dart.dload(this[_receiver], 'hashCode'), core .int); 2848 receiverHashCode = this[_receiver].hashCode;
2849 } else { 2849 } else {
2850 receiverHashCode = Primitives.objectHashCode(this[_receiver]); 2850 receiverHashCode = Primitives.objectHashCode(this[_receiver]);
2851 } 2851 }
2852 return dart.notNull(receiverHashCode) ^ dart.notNull(Primitives.objectHash Code(this[_target])); 2852 return dart.notNull(receiverHashCode) ^ dart.notNull(Primitives.objectHash Code(this[_target]));
2853 } 2853 }
2854 static selfOf(closure) { 2854 static selfOf(closure) {
2855 return closure[_self]; 2855 return closure[_self];
2856 } 2856 }
2857 static targetOf(closure) { 2857 static targetOf(closure) {
2858 return closure[_target]; 2858 return closure[_target];
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after
4003 exports.jsonEncodeNative = jsonEncodeNative; 4003 exports.jsonEncodeNative = jsonEncodeNative;
4004 exports.getIsolateAffinityTag = getIsolateAffinityTag; 4004 exports.getIsolateAffinityTag = getIsolateAffinityTag;
4005 exports.LoadLibraryFunctionType = LoadLibraryFunctionType; 4005 exports.LoadLibraryFunctionType = LoadLibraryFunctionType;
4006 exports.DeferredLoadCallback = DeferredLoadCallback; 4006 exports.DeferredLoadCallback = DeferredLoadCallback;
4007 exports.loadDeferredLibrary = loadDeferredLibrary; 4007 exports.loadDeferredLibrary = loadDeferredLibrary;
4008 exports.MainError = MainError; 4008 exports.MainError = MainError;
4009 exports.missingMain = missingMain; 4009 exports.missingMain = missingMain;
4010 exports.badMain = badMain; 4010 exports.badMain = badMain;
4011 exports.mainHasTooManyParameters = mainHasTooManyParameters; 4011 exports.mainHasTooManyParameters = mainHasTooManyParameters;
4012 })(_js_helper || (_js_helper = {})); 4012 })(_js_helper || (_js_helper = {}));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698