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

Side by Side Diff: dart/lib/compiler/implementation/elements/elements.dart

Issue 11348037: A method or accessor with empty body is implicitly abstract. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Changes to make unit tests pass Created 8 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
« no previous file with comments | « no previous file | dart/lib/compiler/implementation/js_backend/emitter.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library elements; 5 library elements;
6 6
7 import 'dart:uri'; 7 import 'dart:uri';
8 8
9 // TODO(ahe): Rename prefix to 'api' when VM bug is fixed. 9 // TODO(ahe): Rename prefix to 'api' when VM bug is fixed.
10 import '../../compiler.dart' as api_e; 10 import '../../compiler.dart' as api_e;
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 } 346 }
347 } 347 }
348 348
349 bool _isNative = false; 349 bool _isNative = false;
350 void setNative() { _isNative = true; } 350 void setNative() { _isNative = true; }
351 bool isNative() => _isNative; 351 bool isNative() => _isNative;
352 352
353 FunctionElement asFunctionElement() => null; 353 FunctionElement asFunctionElement() => null;
354 354
355 static bool isInvalid(Element e) => e == null || e.isErroneous(); 355 static bool isInvalid(Element e) => e == null || e.isErroneous();
356
357 bool isAbstract(Compiler compiler) => modifiers.isAbstract();
356 } 358 }
357 359
358 /** 360 /**
359 * Represents an unresolvable or duplicated element. 361 * Represents an unresolvable or duplicated element.
360 * 362 *
361 * An [ErroneousElement] is used instead of [null] to provide additional 363 * An [ErroneousElement] is used instead of [null] to provide additional
362 * information about the error that caused the element to be unresolvable 364 * information about the error that caused the element to be unresolvable
363 * or otherwise invalid. 365 * or otherwise invalid.
364 * 366 *
365 * Accessing any field or calling any method defined on [ErroneousElement] 367 * Accessing any field or calling any method defined on [ErroneousElement]
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 return computeSignature(compiler).parameterCount; 1179 return computeSignature(compiler).parameterCount;
1178 } 1180 }
1179 1181
1180 FunctionType computeType(Compiler compiler) { 1182 FunctionType computeType(Compiler compiler) {
1181 if (type != null) return type; 1183 if (type != null) return type;
1182 type = compiler.computeFunctionType(declaration, 1184 type = compiler.computeFunctionType(declaration,
1183 computeSignature(compiler)); 1185 computeSignature(compiler));
1184 return type; 1186 return type;
1185 } 1187 }
1186 1188
1187 Node parseNode(DiagnosticListener listener) { 1189 FunctionExpression parseNode(DiagnosticListener listener) {
1188 if (patch == null) { 1190 if (patch == null) {
1189 if (modifiers.isExternal()) { 1191 if (modifiers.isExternal()) {
1190 listener.cancel("Compiling external function with no implementation.", 1192 listener.cancel("Compiling external function with no implementation.",
1191 element: this); 1193 element: this);
1192 } 1194 }
1193 } 1195 }
1194 return cachedNode; 1196 return cachedNode;
1195 } 1197 }
1196 1198
1197 Token position() => cachedNode.getBeginToken(); 1199 Token position() => cachedNode.getBeginToken();
1198 1200
1199 FunctionElement asFunctionElement() => this; 1201 FunctionElement asFunctionElement() => this;
1200 1202
1201 String toString() { 1203 String toString() {
1202 if (isPatch) { 1204 if (isPatch) {
1203 return 'patch ${super.toString()}'; 1205 return 'patch ${super.toString()}';
1204 } else if (isPatched) { 1206 } else if (isPatched) {
1205 return 'origin ${super.toString()}'; 1207 return 'origin ${super.toString()}';
1206 } else { 1208 } else {
1207 return super.toString(); 1209 return super.toString();
1208 } 1210 }
1209 } 1211 }
1212
1213 bool isAbstract(Compiler compiler) {
1214 if (super.isAbstract(compiler)) return true;
1215 if (modifiers.isExternal()) return false;
1216 if (isFunction() || isAccessor()) {
1217 return !parseNode(compiler).hasBody();
1218 }
1219 return false;
1220 }
1210 } 1221 }
1211 1222
1212 class ConstructorBodyElement extends FunctionElement { 1223 class ConstructorBodyElement extends FunctionElement {
1213 FunctionElement constructor; 1224 FunctionElement constructor;
1214 1225
1215 ConstructorBodyElement(FunctionElement constructor) 1226 ConstructorBodyElement(FunctionElement constructor)
1216 : this.constructor = constructor, 1227 : this.constructor = constructor,
1217 super(constructor.name, 1228 super(constructor.name,
1218 ElementKind.GENERATIVE_CONSTRUCTOR_BODY, 1229 ElementKind.GENERATIVE_CONSTRUCTOR_BODY,
1219 Modifiers.EMPTY, 1230 Modifiers.EMPTY,
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 1956
1946 MetadataAnnotation ensureResolved(Compiler compiler) { 1957 MetadataAnnotation ensureResolved(Compiler compiler) {
1947 if (resolutionState == STATE_NOT_STARTED) { 1958 if (resolutionState == STATE_NOT_STARTED) {
1948 compiler.resolver.resolveMetadataAnnotation(this); 1959 compiler.resolver.resolveMetadataAnnotation(this);
1949 } 1960 }
1950 return this; 1961 return this;
1951 } 1962 }
1952 1963
1953 String toString() => 'MetadataAnnotation($value, $resolutionState)'; 1964 String toString() => 'MetadataAnnotation($value, $resolutionState)';
1954 } 1965 }
OLDNEW
« no previous file with comments | « no previous file | dart/lib/compiler/implementation/js_backend/emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698