| 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 var dart, _js_helper; | 5 var dart, _js_helper; |
| 6 (function (dart) { | 6 (function (dart) { |
| 7 'use strict'; | 7 'use strict'; |
| 8 | 8 |
| 9 var defineProperty = Object.defineProperty; | 9 var defineProperty = Object.defineProperty; |
| 10 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; | 10 var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 function copyProperties(to, from) { | 190 function copyProperties(to, from) { |
| 191 var names = getOwnPropertyNames(from); | 191 var names = getOwnPropertyNames(from); |
| 192 for (var i = 0; i < names.length; i++) { | 192 for (var i = 0; i < names.length; i++) { |
| 193 var name = names[i]; | 193 var name = names[i]; |
| 194 defineProperty(to, name, getOwnPropertyDescriptor(from, name)); | 194 defineProperty(to, name, getOwnPropertyDescriptor(from, name)); |
| 195 } | 195 } |
| 196 return to; | 196 return to; |
| 197 } | 197 } |
| 198 dart.copyProperties = copyProperties; | 198 dart.copyProperties = copyProperties; |
| 199 | 199 |
| 200 |
| 201 /** The Symbol for storing type arguments on a specialized generic type. */ |
| 202 dart.mixins = Symbol('mixins'); |
| 203 dart.implements = Symbol('implements') |
| 204 |
| 200 /** | 205 /** |
| 201 * Returns a new type that mixes members from base and all mixins. | 206 * Returns a new type that mixes members from base and all mixins. |
| 202 * | 207 * |
| 203 * Each mixin applies in sequence, with further to the right ones overriding | 208 * Each mixin applies in sequence, with further to the right ones overriding |
| 204 * previous entries. | 209 * previous entries. |
| 205 * | 210 * |
| 206 * For each mixin, we only take its own properties, not anything from its | 211 * For each mixin, we only take its own properties, not anything from its |
| 207 * superclass (prototype). | 212 * superclass (prototype). |
| 208 */ | 213 */ |
| 209 function mixin(base/*, ...mixins*/) { | 214 function mixin(base/*, ...mixins*/) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 222 mixin.prototype[mixin.name].call(this); | 227 mixin.prototype[mixin.name].call(this); |
| 223 } | 228 } |
| 224 // Run base initializer. | 229 // Run base initializer. |
| 225 base.prototype[base.name].apply(this, arguments); | 230 base.prototype[base.name].apply(this, arguments); |
| 226 } | 231 } |
| 227 } | 232 } |
| 228 // Copy each mixin's methods, with later ones overwriting earlier entries. | 233 // Copy each mixin's methods, with later ones overwriting earlier entries. |
| 229 for (var i = 0; i < mixins.length; i++) { | 234 for (var i = 0; i < mixins.length; i++) { |
| 230 copyProperties(Mixin.prototype, mixins[i].prototype); | 235 copyProperties(Mixin.prototype, mixins[i].prototype); |
| 231 } | 236 } |
| 237 // Save mixins for reflection |
| 238 Mixin[dart.mixins] = mixins; |
| 232 return Mixin; | 239 return Mixin; |
| 233 } | 240 } |
| 234 dart.mixin = mixin; | 241 dart.mixin = mixin; |
| 235 | 242 |
| 236 /** | 243 /** |
| 237 * Creates a dart:collection LinkedHashMap. | 244 * Creates a dart:collection LinkedHashMap. |
| 238 * | 245 * |
| 239 * For a map with string keys an object literal can be used, for example | 246 * For a map with string keys an object literal can be used, for example |
| 240 * `map({'hi': 1, 'there': 2})`. | 247 * `map({'hi': 1, 'there': 2})`. |
| 241 * | 248 * |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 // of some sort, assuming we keep around `dynamic` at runtime. | 346 // of some sort, assuming we keep around `dynamic` at runtime. |
| 340 dart.dynamic = Object.create(null); | 347 dart.dynamic = Object.create(null); |
| 341 | 348 |
| 342 dart.JsSymbol = Symbol; | 349 dart.JsSymbol = Symbol; |
| 343 | 350 |
| 344 // TODO(jmesserly): hack to bootstrap the SDK | 351 // TODO(jmesserly): hack to bootstrap the SDK |
| 345 _js_helper = _js_helper || {}; | 352 _js_helper = _js_helper || {}; |
| 346 _js_helper.checkNum = notNull; | 353 _js_helper.checkNum = notNull; |
| 347 | 354 |
| 348 })(dart || (dart = {})); | 355 })(dart || (dart = {})); |
| OLD | NEW |