Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 /** | 5 /** |
| 6 * Represents a meta-value for code generation. | 6 * Represents a meta-value for code generation. |
| 7 */ | 7 */ |
| 8 class Value { | 8 class Value { |
| 9 /** The [Type] of the [Value]. */ | 9 /** The [Type] of the [Value]. */ |
| 10 Type type; | 10 Type type; |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 * Generates a run time type assertion for the given value. This works like | 330 * Generates a run time type assertion for the given value. This works like |
| 331 * [instanceOf], but it allows null since Dart types are nullable. | 331 * [instanceOf], but it allows null since Dart types are nullable. |
| 332 * Also it will throw a TypeError if it gets the wrong type. | 332 * Also it will throw a TypeError if it gets the wrong type. |
| 333 */ | 333 */ |
| 334 Value _typeAssert(MethodGenerator context, Type toType, Node node) { | 334 Value _typeAssert(MethodGenerator context, Type toType, Node node) { |
| 335 if (toType is ParameterType) { | 335 if (toType is ParameterType) { |
| 336 ParameterType p = toType; | 336 ParameterType p = toType; |
| 337 toType = p.extendsType; | 337 toType = p.extendsType; |
| 338 } | 338 } |
| 339 | 339 |
| 340 // TODO(jmesserly): fix checking of function types. | 340 // TODO(jmesserly): fix checking of function types, and DOM objects |
| 341 // For now, don't generate a broken check. | 341 // For now, don't generate a broken check. |
| 342 if (toType.getCallMethod() != null) { | 342 // (For DOM types to work right, we need to lazily patch the "is$DOMWindow" |
| 343 // check methods, by catching it on Object.prototype like VarMember does) | |
|
jimhug
2011/11/22 18:20:14
Niggling worry - does this change conflict with St
| |
| 344 if (toType.getCallMethod() != null || toType.library == world.dom) { | |
| 343 return this; | 345 return this; |
| 344 } | 346 } |
| 345 | 347 |
| 346 if (toType.isObject || toType.isVar) { | 348 if (toType.isObject || toType.isVar) { |
| 347 world.internalError('We thought ${type.name} is not a subtype of ${toType. name}?'); | 349 world.internalError('We thought ${type.name} is not a subtype of ${toType. name}?'); |
| 348 } | 350 } |
| 349 | 351 |
| 350 // TODO(jmesserly): better assert for integers? | 352 // TODO(jmesserly): better assert for integers? |
| 351 if (toType.isNum) toType = world.numType; | 353 if (toType.isNum) toType = world.numType; |
| 352 | 354 |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 724 // Then look for members in my library. | 726 // Then look for members in my library. |
| 725 member = home.library.lookup(name, span); | 727 member = home.library.lookup(name, span); |
| 726 if (member != null) { | 728 if (member != null) { |
| 727 return member; | 729 return member; |
| 728 } | 730 } |
| 729 | 731 |
| 730 _ensureCode(); | 732 _ensureCode(); |
| 731 return null; | 733 return null; |
| 732 } | 734 } |
| 733 } | 735 } |
| OLD | NEW |