Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: frog/member.dart

Issue 8534001: Adds typechecking of return values (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merged Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 8
9 String name; 9 String name;
10 Type type; 10 Type type;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 // TODO(jmesserly): these only makes sense on methods, but because of 118 // TODO(jmesserly): these only makes sense on methods, but because of
119 // ConcreteMember we need to support them on Member. 119 // ConcreteMember we need to support them on Member.
120 bool get isConst() => false; 120 bool get isConst() => false;
121 bool get isFactory() => false; 121 bool get isFactory() => false;
122 122
123 bool get prefersPropertySyntax() => true; 123 bool get prefersPropertySyntax() => true;
124 bool get requiresFieldSyntax() => false; 124 bool get requiresFieldSyntax() => false;
125 125
126 bool get isNative() => false; 126 bool get isNative() => false;
127 String get constructorName() => 127 String get constructorName() {
128 world.internalError('can not be a constructor', span); 128 world.internalError('can not be a constructor', span);
129 }
129 130
130 void provideFieldSyntax() => world.internalError('can not be field', span); 131 void provideFieldSyntax() => world.internalError('can not be field', span);
131 void providePropertySyntax() => 132 void providePropertySyntax() =>
132 world.internalError('can not be property', span); 133 world.internalError('can not be property', span);
133 134
134 Definition get initDelegate() => 135 Definition get initDelegate() {
135 world.internalError('cannot have initializers', span); 136 world.internalError('cannot have initializers', span);
136 Definition set initDelegate(ctor) => 137 }
137 world.internalError('cannot have initializers', span); 138 Definition set initDelegate(ctor) {
139 world.internalError('cannot have initializers', span);
140 }
138 141
139 Definition get definition() => null; 142 Definition get definition() => null;
140 143
141 List<Parameter> get parameters() => []; 144 List<Parameter> get parameters() => [];
142 145
143 // TODO(jmesserly): isDynamic isn't a great name for this, something better? 146 // TODO(jmesserly): isDynamic isn't a great name for this, something better?
144 abstract Value _get(MethodGenerator context, Node node, Value target, 147 abstract Value _get(MethodGenerator context, Node node, Value target,
145 [bool isDynamic]); 148 [bool isDynamic]);
146 149
147 abstract Value _set(MethodGenerator context, Node node, Value target, 150 abstract Value _set(MethodGenerator context, Node node, Value target,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 world.error('field can not override anything but property', 278 world.error('field can not override anything but property',
276 span, other.span); 279 span, other.span);
277 return false; 280 return false;
278 } 281 }
279 } 282 }
280 283
281 bool get prefersPropertySyntax() => false; 284 bool get prefersPropertySyntax() => false;
282 bool get requiresFieldSyntax() => isNative; 285 bool get requiresFieldSyntax() => isNative;
283 286
284 void provideFieldSyntax() {} // Nothing to do. 287 void provideFieldSyntax() {} // Nothing to do.
285 void providePropertySyntax() => _providePropertySyntax = true; 288 void providePropertySyntax() { _providePropertySyntax = true; }
286 289
287 FieldMember(String name, Type declaringType, this.definition, this.value) 290 FieldMember(String name, Type declaringType, this.definition, this.value)
288 : super(name, declaringType), isNative = false; 291 : super(name, declaringType), isNative = false;
289 292
290 SourceSpan get span() => definition == null ? null : definition.span; 293 SourceSpan get span() => definition == null ? null : definition.span;
291 294
292 Type get returnType() => type; 295 Type get returnType() => type;
293 296
294 bool get canGet() => true; 297 bool get canGet() => true;
295 bool get canSet() => !isFinal; 298 bool get canSet() => !isFinal;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 417
415 // TODO(jimhug): What is the right span for this beast? 418 // TODO(jimhug): What is the right span for this beast?
416 SourceSpan get span() => getter != null ? getter.span : null; 419 SourceSpan get span() => getter != null ? getter.span : null;
417 420
418 bool get canGet() => getter != null; 421 bool get canGet() => getter != null;
419 bool get canSet() => setter != null; 422 bool get canSet() => setter != null;
420 423
421 bool get prefersPropertySyntax() => true; 424 bool get prefersPropertySyntax() => true;
422 bool get requiresFieldSyntax() => false; 425 bool get requiresFieldSyntax() => false;
423 426
424 void provideFieldSyntax() => _provideFieldSyntax = true; 427 void provideFieldSyntax() { _provideFieldSyntax = true; }
425 void providePropertySyntax() {}// Nothing to do. 428 void providePropertySyntax() {}// Nothing to do.
426 429
427 // TODO(jimhug): Union of getter and setters sucks! 430 // TODO(jimhug): Union of getter and setters sucks!
428 bool get isStatic() => getter == null ? setter.isStatic : getter.isStatic; 431 bool get isStatic() => getter == null ? setter.isStatic : getter.isStatic;
429 432
430 bool get isProperty() => true; 433 bool get isProperty() => true;
431 434
432 Type get returnType() { 435 Type get returnType() {
433 return getter == null ? setter.returnType : getter.returnType; 436 return getter == null ? setter.returnType : getter.returnType;
434 } 437 }
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 if (p.isOptional && p.name == name) { 710 if (p.isOptional && p.name == name) {
708 return i; 711 return i;
709 } 712 }
710 } 713 }
711 return -1; 714 return -1;
712 } 715 }
713 716
714 bool get prefersPropertySyntax() => true; 717 bool get prefersPropertySyntax() => true;
715 bool get requiresFieldSyntax() => false; 718 bool get requiresFieldSyntax() => false;
716 719
717 void provideFieldSyntax() => _provideFieldSyntax = true; 720 void provideFieldSyntax() { _provideFieldSyntax = true; }
718 void providePropertySyntax() => _providePropertySyntax = true; 721 void providePropertySyntax() { _providePropertySyntax = true; }
719 722
720 Value _set(MethodGenerator context, Node, Value target, Value value, 723 Value _set(MethodGenerator context, Node, Value target, Value value,
721 [bool isDynamic=false]) { 724 [bool isDynamic=false]) {
722 world.error('can not set method', definition.span); 725 world.error('can not set method', definition.span);
723 } 726 }
724 727
725 Value _get(MethodGenerator context, Node node, Value target, 728 Value _get(MethodGenerator context, Node node, Value target,
726 [bool isDynamic=false]) { 729 [bool isDynamic=false]) {
727 // TODO(jimhug): Would prefer to invoke! 730 // TODO(jimhug): Would prefer to invoke!
728 declaringType.genMethod(this); 731 declaringType.genMethod(this);
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 } 1574 }
1572 1575
1573 void forEach(void f(Member member)) { 1576 void forEach(void f(Member member)) {
1574 factories.forEach((_, Map constructors) { 1577 factories.forEach((_, Map constructors) {
1575 constructors.forEach((_, Member member) { 1578 constructors.forEach((_, Member member) {
1576 f(member); 1579 f(member);
1577 }); 1580 });
1578 }); 1581 });
1579 } 1582 }
1580 } 1583 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698