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 /** A formal parameter to a [Method]. */ | 5 /** A formal parameter to a [Method]. */ |
| 6 class Parameter { | 6 class Parameter { |
| 7 FormalNode definition; | 7 FormalNode definition; |
| 8 Member method; | 8 Member method; |
| 9 | 9 |
| 10 String name; | 10 String name; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 name = name.substring(5); | 21 name = name.substring(5); |
| 22 isInitializer = true; | 22 isInitializer = true; |
| 23 } | 23 } |
| 24 | 24 |
| 25 type = method.resolveType(definition.type, false); | 25 type = method.resolveType(definition.type, false); |
| 26 | 26 |
| 27 if (definition.value != null) { | 27 if (definition.value != null) { |
| 28 // To match VM, detect cases where value was not actually specified in | 28 // To match VM, detect cases where value was not actually specified in |
| 29 // code and don't signal errors. | 29 // code and don't signal errors. |
| 30 // TODO(jimhug): Clean up after issue #352 is resolved. | 30 // TODO(jimhug): Clean up after issue #352 is resolved. |
| 31 if (definition.value.span.start == definition.span.start) { | 31 if (definition.value.span.start == definition.span.start) { |
|
Bob Nystrom
2012/01/09 22:38:54
Should use hasDefaultValue here.
| |
| 32 return; | 32 return; |
| 33 } | 33 } |
| 34 | 34 |
| 35 if (method.name == ':call') { | 35 if (method.name == ':call') { |
| 36 // TODO(jimhug): Need simpler way to detect "true" function types vs. | 36 // TODO(jimhug): Need simpler way to detect "true" function types vs. |
| 37 // regular methods being used as function types for closures. | 37 // regular methods being used as function types for closures. |
| 38 // TODO(sigmund): Disallow non-null default values for native calls? | 38 // TODO(sigmund): Disallow non-null default values for native calls? |
| 39 if (method.definition.body == null && !method.isNative) { | 39 if (method.definition.body == null && !method.isNative) { |
| 40 world.error('default value not allowed on function type', | 40 world.error('default value not allowed on function type', |
| 41 definition.span); | 41 definition.span); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 65 | 65 |
| 66 Parameter copyWithNewType(Member newMethod, Type newType) { | 66 Parameter copyWithNewType(Member newMethod, Type newType) { |
| 67 var ret = new Parameter(definition, newMethod); | 67 var ret = new Parameter(definition, newMethod); |
| 68 ret.type = newType; | 68 ret.type = newType; |
| 69 ret.name = name; | 69 ret.name = name; |
| 70 ret.isInitializer = isInitializer; | 70 ret.isInitializer = isInitializer; |
| 71 return ret; | 71 return ret; |
| 72 } | 72 } |
| 73 | 73 |
| 74 bool get isOptional() => definition != null && definition.value != null; | 74 bool get isOptional() => definition != null && definition.value != null; |
| 75 | |
| 76 /** | |
| 77 * Gets whether this named parameter has an explicit default value or relies | |
| 78 * on the implicit `null`. | |
| 79 */ | |
| 80 bool get hasDefaultValue() => | |
| 81 definition.value.span.start != definition.span.start; | |
| 75 } | 82 } |
| 76 | 83 |
| 77 | 84 |
| 78 class Member extends Element { | 85 class Member extends Element { |
| 79 final Type declaringType; | 86 final Type declaringType; |
| 80 | 87 |
| 81 bool isGenerated; | 88 bool isGenerated; |
| 82 MethodGenerator generator; | 89 MethodGenerator generator; |
| 83 | 90 |
| 84 Member(String name, Type declaringType) | 91 Member(String name, Type declaringType) |
| (...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1581 } | 1588 } |
| 1582 | 1589 |
| 1583 void forEach(void f(Member member)) { | 1590 void forEach(void f(Member member)) { |
| 1584 factories.forEach((_, Map constructors) { | 1591 factories.forEach((_, Map constructors) { |
| 1585 constructors.forEach((_, Member member) { | 1592 constructors.forEach((_, Member member) { |
| 1586 f(member); | 1593 f(member); |
| 1587 }); | 1594 }); |
| 1588 }); | 1595 }); |
| 1589 } | 1596 } |
| 1590 } | 1597 } |
| OLD | NEW |