 Chromium Code Reviews
 Chromium Code Reviews Issue 1195523002:
  Handle dynamic as bottom inside of function type reps  (Closed) 
  Base URL: git@github.com:dart-lang/dev_compiler.git@master
    
  
    Issue 1195523002:
  Handle dynamic as bottom inside of function type reps  (Closed) 
  Base URL: git@github.com:dart-lang/dev_compiler.git@master| OLD | NEW | 
|---|---|
| 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 /* This library defines the operations that define and manipulate Dart | 5 /* This library defines the operations that define and manipulate Dart | 
| 6 * classes. Included in this are: | 6 * classes. Included in this are: | 
| 7 * - Generics | 7 * - Generics | 
| 8 * - Class metadata | 8 * - Class metadata | 
| 9 * - Extension methods | 9 * - Extension methods | 
| 10 */ | 10 */ | 
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 let length = typeConstructor.length; | 111 let length = typeConstructor.length; | 
| 112 if (length < 1) { | 112 if (length < 1) { | 
| 113 throwError('must have at least one generic type argument'); | 113 throwError('must have at least one generic type argument'); | 
| 114 } | 114 } | 
| 115 let resultMap = new Map(); | 115 let resultMap = new Map(); | 
| 116 function makeGenericType(/*...arguments*/) { | 116 function makeGenericType(/*...arguments*/) { | 
| 117 if (arguments.length != length && arguments.length != 0) { | 117 if (arguments.length != length && arguments.length != 0) { | 
| 118 throwError('requires ' + length + ' or 0 type arguments'); | 118 throwError('requires ' + length + ' or 0 type arguments'); | 
| 119 } | 119 } | 
| 120 let args = slice.call(arguments); | 120 let args = slice.call(arguments); | 
| 121 // TODO(leafp): This should really be core.Object for | |
| 122 // consistency, but Object is not attached to core | |
| 123 // until the entire core library has been processed, | |
| 124 // which is too late. | |
| 125 while (args.length < length) args.push(types.dynamic); | 121 while (args.length < length) args.push(types.dynamic); | 
| 126 | 122 | 
| 127 let value = resultMap; | 123 let value = resultMap; | 
| 128 for (let i = 0; i < length; i++) { | 124 for (let i = 0; i < length; i++) { | 
| 129 let arg = args[i]; | 125 let arg = args[i]; | 
| 130 if (arg == null) { | 126 if (arg == null) { | 
| 131 throwError('type arguments should not be null: ' | 127 throwError('type arguments should not be null: ' | 
| 132 + typeConstructor); | 128 + typeConstructor); | 
| 133 } | 129 } | 
| 134 let map = value; | 130 let map = value; | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 let _staticSig = Symbol("sigStatic"); | 164 let _staticSig = Symbol("sigStatic"); | 
| 169 | 165 | 
| 170 /// Get the type of a method using the stored signature | 166 /// Get the type of a method using the stored signature | 
| 171 function _getMethodType(obj, name) { | 167 function _getMethodType(obj, name) { | 
| 172 if (obj === void 0) return void 0; | 168 if (obj === void 0) return void 0; | 
| 173 if (obj == null) return void 0; | 169 if (obj == null) return void 0; | 
| 174 let sigObj = obj.__proto__.constructor[_methodSig]; | 170 let sigObj = obj.__proto__.constructor[_methodSig]; | 
| 175 if (sigObj === void 0) return void 0; | 171 if (sigObj === void 0) return void 0; | 
| 176 let parts = sigObj[name]; | 172 let parts = sigObj[name]; | 
| 177 if (parts === void 0) return void 0; | 173 if (parts === void 0) return void 0; | 
| 178 return types.functionType.apply(null, parts); | 174 return types.definiteFunctionType.apply(null, parts); | 
| 
vsm
2015/06/17 23:14:38
Should these really be definite for instance metho
 
Leaf
2015/06/17 23:44:37
I don't think this affects #129.  #129 has to do w
 | |
| 179 } | 175 } | 
| 180 | 176 | 
| 181 /// Get the type of a constructor from a class using the stored signature | 177 /// Get the type of a constructor from a class using the stored signature | 
| 182 /// If name is undefined, returns the type of the default constructor | 178 /// If name is undefined, returns the type of the default constructor | 
| 183 /// Returns undefined if the constructor is not found. | 179 /// Returns undefined if the constructor is not found. | 
| 184 function _getConstructorType(cls, name) { | 180 function _getConstructorType(cls, name) { | 
| 185 if(!name) name = cls.name; | 181 if(!name) name = cls.name; | 
| 186 if (cls === void 0) return void 0; | 182 if (cls === void 0) return void 0; | 
| 187 if (cls == null) return void 0; | 183 if (cls == null) return void 0; | 
| 188 let sigCtor = cls[_constructorSig]; | 184 let sigCtor = cls[_constructorSig]; | 
| 189 if (sigCtor === void 0) return void 0; | 185 if (sigCtor === void 0) return void 0; | 
| 190 let parts = sigCtor[name]; | 186 let parts = sigCtor[name]; | 
| 191 if (parts === void 0) return void 0; | 187 if (parts === void 0) return void 0; | 
| 192 return types.functionType.apply(null, parts); | 188 return types.definiteFunctionType.apply(null, parts); | 
| 193 } | 189 } | 
| 194 exports.classGetConstructorType = _getConstructorType; | 190 exports.classGetConstructorType = _getConstructorType; | 
| 195 | 191 | 
| 196 /// Given an object and a method name, tear off the method. | 192 /// Given an object and a method name, tear off the method. | 
| 197 /// Sets the runtime type of the torn off method appropriately, | 193 /// Sets the runtime type of the torn off method appropriately, | 
| 198 /// and also binds the object. | 194 /// and also binds the object. | 
| 199 /// TODO(leafp): Consider caching the tearoff on the object? | 195 /// TODO(leafp): Consider caching the tearoff on the object? | 
| 200 function bind(obj, name) { | 196 function bind(obj, name) { | 
| 201 let f = obj[name].bind(obj); | 197 let f = obj[name].bind(obj); | 
| 202 let sig = _getMethodType(obj, name); | 198 let sig = _getMethodType(obj, name); | 
| (...skipping 20 matching lines...) Expand all Loading... | |
| 223 // Set up the static signature field on the constructor | 219 // Set up the static signature field on the constructor | 
| 224 function _setStaticSignature(f, sigF) { | 220 function _setStaticSignature(f, sigF) { | 
| 225 defineMemoizedGetter(f, _staticSig, sigF); | 221 defineMemoizedGetter(f, _staticSig, sigF); | 
| 226 } | 222 } | 
| 227 | 223 | 
| 228 // Set the lazily computed runtime type field on static methods | 224 // Set the lazily computed runtime type field on static methods | 
| 229 function _setStaticTypes(f, names) { | 225 function _setStaticTypes(f, names) { | 
| 230 for (let name of names) { | 226 for (let name of names) { | 
| 231 rtti.tagMemoized(f[name], function() { | 227 rtti.tagMemoized(f[name], function() { | 
| 232 let parts = f[_staticSig][name]; | 228 let parts = f[_staticSig][name]; | 
| 233 return types.functionType.apply(null, parts); | 229 return types.definiteFunctionType.apply(null, parts); | 
| 234 }) | 230 }) | 
| 235 } | 231 } | 
| 236 } | 232 } | 
| 237 | 233 | 
| 238 /// Set up the type signature of a class (constructor object) | 234 /// Set up the type signature of a class (constructor object) | 
| 239 /// f is a constructor object | 235 /// f is a constructor object | 
| 240 /// signature is an object containing optional properties as follows: | 236 /// signature is an object containing optional properties as follows: | 
| 241 /// methods: A function returning an object mapping method names | 237 /// methods: A function returning an object mapping method names | 
| 242 /// to method types. The function is evaluated lazily and cached. | 238 /// to method types. The function is evaluated lazily and cached. | 
| 243 /// statics: A function returning an object mapping static method | 239 /// statics: A function returning an object mapping static method | 
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 403 } | 399 } | 
| 404 exports.list = list; | 400 exports.list = list; | 
| 405 | 401 | 
| 406 function setBaseClass(derived, base) { | 402 function setBaseClass(derived, base) { | 
| 407 // Link the extension to the type it's extending as a base class. | 403 // Link the extension to the type it's extending as a base class. | 
| 408 derived.prototype.__proto__ = base.prototype; | 404 derived.prototype.__proto__ = base.prototype; | 
| 409 } | 405 } | 
| 410 exports.setBaseClass = setBaseClass; | 406 exports.setBaseClass = setBaseClass; | 
| 411 | 407 | 
| 412 }); | 408 }); | 
| OLD | NEW |