OLD | NEW |
1 dart_library.library('dart/_runtime', null, /* Imports */[ | 1 dart_library.library('dart/_runtime', null, /* Imports */[ |
2 ], /* Lazy imports */[ | 2 ], /* Lazy imports */[ |
3 'dart/core', | 3 'dart/core', |
4 'dart/_interceptors', | 4 'dart/_interceptors', |
5 'dart/_js_helper', | 5 'dart/_js_helper', |
6 'dart/async', | 6 'dart/async', |
7 'dart/collection' | 7 'dart/collection' |
8 ], function(exports, core, _interceptors, _js_helper, async, collection) { | 8 ], function(exports, core, _interceptors, _js_helper, async, collection) { |
9 'use strict'; | 9 'use strict'; |
10 function mixin(base, ...mixins) { | 10 function mixin(base, ...mixins) { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 }); | 123 }); |
124 } | 124 } |
125 function _setConstructorSignature(f, sigF) { | 125 function _setConstructorSignature(f, sigF) { |
126 return defineMemoizedGetter(f, _constructorSig, sigF); | 126 return defineMemoizedGetter(f, _constructorSig, sigF); |
127 } | 127 } |
128 function _setStaticSignature(f, sigF) { | 128 function _setStaticSignature(f, sigF) { |
129 return defineMemoizedGetter(f, _staticSig, sigF); | 129 return defineMemoizedGetter(f, _staticSig, sigF); |
130 } | 130 } |
131 function _setStaticTypes(f, names) { | 131 function _setStaticTypes(f, names) { |
132 for (let name of names) { | 132 for (let name of names) { |
| 133 if (!f[name]) continue; |
133 tagMemoized(f[name], function() { | 134 tagMemoized(f[name], function() { |
134 let parts = f[_staticSig][name]; | 135 let parts = f[_staticSig][name]; |
135 return definiteFunctionType.apply(null, parts); | 136 return definiteFunctionType.apply(null, parts); |
136 }); | 137 }); |
137 } | 138 } |
138 } | 139 } |
139 function setSignature(f, signature) { | 140 function setSignature(f, signature) { |
140 let constructors = 'constructors' in signature ? signature.constructors : ()
=> ({}); | 141 let constructors = 'constructors' in signature ? signature.constructors : ()
=> ({}); |
141 let methods = 'methods' in signature ? signature.methods : () => ({}); | 142 let methods = 'methods' in signature ? signature.methods : () => ({}); |
142 let statics = 'statics' in signature ? signature.statics : () => ({}); | 143 let statics = 'statics' in signature ? signature.statics : () => ({}); |
143 let names = 'names' in signature ? signature.names : []; | 144 let names = 'names' in signature ? signature.names : []; |
144 _setConstructorSignature(f, constructors); | 145 _setConstructorSignature(f, constructors); |
145 _setMethodSignature(f, methods); | 146 _setMethodSignature(f, methods); |
146 _setStaticSignature(f, statics); | 147 _setStaticSignature(f, statics); |
147 _setStaticTypes(f, names); | 148 _setStaticTypes(f, names); |
148 tagMemoized(f, () => core.Type); | 149 tagMemoized(f, () => core.Type); |
149 } | 150 } |
150 function hasMethod(obj, name) { | 151 function hasMethod(obj, name) { |
151 return getMethodType(obj, name) !== void 0; | 152 return getMethodType(obj, name) !== void 0; |
152 } | 153 } |
153 function virtualField(subclass, fieldName) { | 154 function virtualField(subclass, fieldName) { |
154 let prop = getOwnPropertyDescriptor(subclass.prototype, fieldName); | 155 let prop = getOwnPropertyDescriptor(subclass.prototype, fieldName); |
155 if (prop) return; | 156 if (prop) return; |
156 let symbol = Symbol(subclass.name + '.' + fieldName); | 157 let symbol = Symbol(subclass.name + '.' + fieldName.toString()); |
157 defineProperty(subclass.prototype, fieldName, { | 158 defineProperty(subclass.prototype, fieldName, { |
158 get: function() { | 159 get: function() { |
159 return this[symbol]; | 160 return this[symbol]; |
160 }, | 161 }, |
161 set: function(x) { | 162 set: function(x) { |
162 this[symbol] = x; | 163 this[symbol] = x; |
163 } | 164 } |
164 }); | 165 }); |
165 } | 166 } |
166 function defineNamedConstructor(clazz, name) { | 167 function defineNamedConstructor(clazz, name) { |
167 let proto = clazz.prototype; | 168 let proto = clazz.prototype; |
168 let initMethod = proto[name]; | 169 let initMethod = proto[name]; |
169 let ctor = function() { | 170 let ctor = function() { |
170 return initMethod.apply(this, arguments); | 171 return initMethod.apply(this, arguments); |
171 }; | 172 }; |
172 ctor.prototype = proto; | 173 ctor.prototype = proto; |
173 defineProperty(clazz, name, {value: ctor, configurable: true}); | 174 defineProperty(clazz, name, {value: ctor, configurable: true}); |
174 } | 175 } |
175 const _extensionType = Symbol("extensionType"); | 176 const _extensionType = Symbol("extensionType"); |
176 function getExtensionType(obj) { | 177 function getExtensionType(obj) { |
177 return obj[_extensionType]; | 178 return obj[_extensionType]; |
178 } | 179 } |
179 const dartx = {}; | 180 const dartx = {}; |
180 function getExtensionSymbol(name) { | 181 function getExtensionSymbol(name) { |
181 let sym = dartx[name]; | 182 let sym = dartx[name]; |
182 if (!sym) dartx[name] = sym = Symbol('dartx.' + name); | 183 if (!sym) dartx[name] = sym = Symbol('dartx.' + name.toString()); |
183 return sym; | 184 return sym; |
184 } | 185 } |
185 function defineExtensionNames(names) { | 186 function defineExtensionNames(names) { |
186 return names.forEach(getExtensionSymbol); | 187 return names.forEach(getExtensionSymbol); |
187 } | 188 } |
188 function _installProperties(jsProto, extProto) { | 189 function _installProperties(jsProto, extProto) { |
189 if (extProto !== core.Object.prototype && extProto !== jsProto) { | 190 if (extProto !== core.Object.prototype && extProto !== jsProto) { |
190 _installProperties(jsProto, extProto.__proto__); | 191 _installProperties(jsProto, extProto.__proto__); |
191 } | 192 } |
192 copyTheseProperties(jsProto, extProto, getOwnPropertySymbols(extProto)); | 193 copyTheseProperties(jsProto, extProto, getOwnPropertySymbols(extProto)); |
193 } | 194 } |
194 function registerExtension(jsType, dartExtType) { | 195 function registerExtension(jsType, dartExtType) { |
| 196 if (!jsType) return; |
195 let extProto = dartExtType.prototype; | 197 let extProto = dartExtType.prototype; |
196 let jsProto = jsType.prototype; | 198 let jsProto = jsType.prototype; |
197 assert_(jsProto[_extensionType] === void 0); | |
198 jsProto[_extensionType] = dartExtType; | 199 jsProto[_extensionType] = dartExtType; |
199 _installProperties(jsProto, extProto); | 200 _installProperties(jsProto, extProto); |
200 let originalSigFn = getOwnPropertyDescriptor(dartExtType, _methodSig).get; | 201 let originalSigFn = getOwnPropertyDescriptor(dartExtType, _methodSig).get; |
201 assert_(originalSigFn); | 202 assert_(originalSigFn); |
202 defineMemoizedGetter(jsType, _methodSig, originalSigFn); | 203 defineMemoizedGetter(jsType, _methodSig, originalSigFn); |
203 } | 204 } |
204 function defineExtensionMembers(type, methodNames) { | 205 function defineExtensionMembers(type, methodNames) { |
205 let proto = type.prototype; | 206 let proto = type.prototype; |
206 for (let name of methodNames) { | 207 for (let name of methodNames) { |
207 let method = getOwnPropertyDescriptor(proto, name); | 208 let method = getOwnPropertyDescriptor(proto, name); |
| 209 if (!method) continue; |
208 defineProperty(proto, getExtensionSymbol(name), method); | 210 defineProperty(proto, getExtensionSymbol(name), method); |
209 } | 211 } |
210 let originalSigFn = getOwnPropertyDescriptor(type, _methodSig).get; | 212 let originalSigFn = getOwnPropertyDescriptor(type, _methodSig).get; |
211 defineMemoizedGetter(type, _methodSig, function() { | 213 defineMemoizedGetter(type, _methodSig, function() { |
212 let sig = originalSigFn(); | 214 let sig = originalSigFn(); |
213 for (let name of methodNames) { | 215 for (let name of methodNames) { |
214 sig[getExtensionSymbol(name)] = sig[name]; | 216 sig[getExtensionSymbol(name)] = sig[name]; |
215 } | 217 } |
216 return sig; | 218 return sig; |
217 }); | 219 }); |
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1315 exports.copyProperties = copyProperties; | 1317 exports.copyProperties = copyProperties; |
1316 exports.export = export_; | 1318 exports.export = export_; |
1317 exports.defineLazyClass = defineLazyClass; | 1319 exports.defineLazyClass = defineLazyClass; |
1318 exports.defineLazyProperties = defineLazyProperties; | 1320 exports.defineLazyProperties = defineLazyProperties; |
1319 exports.defineLazyClassGeneric = defineLazyClassGeneric; | 1321 exports.defineLazyClassGeneric = defineLazyClassGeneric; |
1320 exports.as = as_; | 1322 exports.as = as_; |
1321 exports.is = is_; | 1323 exports.is = is_; |
1322 exports.global = global_; | 1324 exports.global = global_; |
1323 exports.JsSymbol = JsSymbol; | 1325 exports.JsSymbol = JsSymbol; |
1324 }); | 1326 }); |
OLD | NEW |