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

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

Issue 1145283002: Use short array syntax in method signatures (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 7 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/math.js ('k') | lib/src/codegen/js_codegen.dart » ('j') | 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 var dart, _js_helper, _js_primitives; 5 var dart, _js_helper, _js_primitives;
6 (function (dart) { 6 (function (dart) {
7 'use strict'; 7 'use strict';
8 8
9 // TODO(vsm): This is referenced (as init.globalState) from 9 // TODO(vsm): This is referenced (as init.globalState) from
10 // isolate_helper.dart. Where should it go? 10 // isolate_helper.dart. Where should it go?
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 function _getFunctionType(f) { 995 function _getFunctionType(f) {
996 return f[_runtimeType]; 996 return f[_runtimeType];
997 } 997 }
998 998
999 /// Get the type of a method using the stored signature 999 /// Get the type of a method using the stored signature
1000 function _getMethodType(obj, name) { 1000 function _getMethodType(obj, name) {
1001 if (obj === void 0) return void 0; 1001 if (obj === void 0) return void 0;
1002 if (obj == null) return void 0; 1002 if (obj == null) return void 0;
1003 let sigObj = obj.__proto__.constructor[_methodSig]; 1003 let sigObj = obj.__proto__.constructor[_methodSig];
1004 if (sigObj === void 0) return void 0; 1004 if (sigObj === void 0) return void 0;
1005 let sig = sigObj[name]; 1005 let parts = sigObj[name];
1006 if (parts === void 0) return void 0;
1007 let sig = functionType.apply(functionType, parts);
Jennifer Messerly 2015/05/20 19:47:34 first arg here could be null right, since there is
vsm 2015/05/20 22:29:35 Yes, the first arg to apply is the 'this' pointer.
Leaf 2015/05/20 22:52:07 Done.
1006 return sig; 1008 return sig;
1007 } 1009 }
1008 1010
1009 /// Given an object and a method name, tear off the method. 1011 /// Given an object and a method name, tear off the method.
1010 /// Sets the runtime type of the torn off method appropriately, 1012 /// Sets the runtime type of the torn off method appropriately,
1011 /// and also binds the object. 1013 /// and also binds the object.
1012 /// TODO(leafp): Consider caching the tearoff on the object? 1014 /// TODO(leafp): Consider caching the tearoff on the object?
1013 function bind(obj, name) { 1015 function bind(obj, name) {
1014 let f = obj[name].bind(obj); 1016 let f = obj[name].bind(obj);
1015 let sig = _getMethodType(obj, name) 1017 let sig = _getMethodType(obj, name)
(...skipping 13 matching lines...) Expand all
1029 } 1031 }
1030 1032
1031 // Set up the static signature field on the constructor 1033 // Set up the static signature field on the constructor
1032 function _setStaticSignature(f, sigF) { 1034 function _setStaticSignature(f, sigF) {
1033 defineMemoizedGetter(f, _staticSig, sigF); 1035 defineMemoizedGetter(f, _staticSig, sigF);
1034 } 1036 }
1035 1037
1036 // Set the lazily computed runtime type field on static methods 1038 // Set the lazily computed runtime type field on static methods
1037 function _setStaticTypes(f, names) { 1039 function _setStaticTypes(f, names) {
1038 for (let name of names) { 1040 for (let name of names) {
1039 function getT() { return f[_staticSig][name];}; 1041 function getT() { let parts = f[_staticSig][name];
1042 return functionType.apply(functionType, parts)
Jennifer Messerly 2015/05/20 19:47:34 indent here is a little off
Leaf 2015/05/20 22:52:07 Done.
1043 };
1040 defineProperty(f[name], _runtimeType, {get : getT}); 1044 defineProperty(f[name], _runtimeType, {get : getT});
1041 } 1045 }
1042 } 1046 }
1043 1047
1044 /// Set up the type signature of a class (constructor object) 1048 /// Set up the type signature of a class (constructor object)
1045 /// f is a constructor object 1049 /// f is a constructor object
1046 /// signature is an object containing optional properties as follows: 1050 /// signature is an object containing optional properties as follows:
1047 /// methods: A function returning an object mapping method names 1051 /// methods: A function returning an object mapping method names
1048 /// to method types. The function is evaluated lazily and cached. 1052 /// to method types. The function is evaluated lazily and cached.
1049 /// statics: A function returning an object mapping static method 1053 /// statics: A function returning an object mapping static method
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 Number.prototype['>'] = function(arg) { return this.valueOf() > arg; }; 1274 Number.prototype['>'] = function(arg) { return this.valueOf() > arg; };
1271 Number.prototype['+'] = function(arg) { return this.valueOf() + arg; }; 1275 Number.prototype['+'] = function(arg) { return this.valueOf() + arg; };
1272 1276
1273 // TODO(vsm): DOM facades? 1277 // TODO(vsm): DOM facades?
1274 // See: https://github.com/dart-lang/dev_compiler/issues/173 1278 // See: https://github.com/dart-lang/dev_compiler/issues/173
1275 NodeList.prototype.get = function(i) { return this[i]; }; 1279 NodeList.prototype.get = function(i) { return this[i]; };
1276 NamedNodeMap.prototype.get = function(i) { return this[i]; }; 1280 NamedNodeMap.prototype.get = function(i) { return this[i]; };
1277 DOMTokenList.prototype.get = function(i) { return this[i]; }; 1281 DOMTokenList.prototype.get = function(i) { return this[i]; };
1278 1282
1279 })(dart || (dart = {})); 1283 })(dart || (dart = {}));
OLDNEW
« no previous file with comments | « lib/runtime/dart/math.js ('k') | lib/src/codegen/js_codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698