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

Side by Side Diff: pkg/compiler/lib/src/resolution/members.dart

Issue 819183005: Wrap standalone invariant() calls in assert(). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 months 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 | « pkg/compiler/lib/src/dart_types.dart ('k') | no next file » | 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 part of resolution; 5 part of resolution;
6 6
7 abstract class TreeElements { 7 abstract class TreeElements {
8 AnalyzableElement get analyzedElement; 8 AnalyzableElement get analyzedElement;
9 Iterable<Node> get superUses; 9 Iterable<Node> get superUses;
10 10
(...skipping 2033 matching lines...) Expand 10 before | Expand all | Expand 10 after
2044 compiler.reportError( 2044 compiler.reportError(
2045 node, MessageKind.ASYNC_KEYWORD_AS_IDENTIFIER, 2045 node, MessageKind.ASYNC_KEYWORD_AS_IDENTIFIER,
2046 {'keyword': element.name, 2046 {'keyword': element.name,
2047 'modifier': currentAsyncMarker}); 2047 'modifier': currentAsyncMarker});
2048 } 2048 }
2049 } 2049 }
2050 } 2050 }
2051 2051
2052 /// Register [node] as the definition of [element]. 2052 /// Register [node] as the definition of [element].
2053 void defineLocalVariable(Node node, LocalVariableElement element) { 2053 void defineLocalVariable(Node node, LocalVariableElement element) {
2054 invariant(node, element != null); 2054 if (element == null) {
2055 throw compiler.internalError(node, 'element is null');
2056 }
2055 checkLocalDefinitionName(node, element); 2057 checkLocalDefinitionName(node, element);
2056 registry.defineElement(node, element); 2058 registry.defineElement(node, element);
2057 } 2059 }
2058 2060
2059 void reportDuplicateDefinition(String name, 2061 void reportDuplicateDefinition(String name,
2060 Spannable definition, 2062 Spannable definition,
2061 Spannable existing) { 2063 Spannable existing) {
2062 compiler.reportError(definition, 2064 compiler.reportError(definition,
2063 MessageKind.DUPLICATE_DEFINITION, {'name': name}); 2065 MessageKind.DUPLICATE_DEFINITION, {'name': name});
2064 compiler.reportInfo(existing, 2066 compiler.reportInfo(existing,
(...skipping 2102 matching lines...) Expand 10 before | Expand all | Expand 10 after
4167 */ 4169 */
4168 class ClassResolverVisitor extends TypeDefinitionVisitor { 4170 class ClassResolverVisitor extends TypeDefinitionVisitor {
4169 BaseClassElementX get element => enclosingElement; 4171 BaseClassElementX get element => enclosingElement;
4170 4172
4171 ClassResolverVisitor(Compiler compiler, 4173 ClassResolverVisitor(Compiler compiler,
4172 ClassElement classElement, 4174 ClassElement classElement,
4173 ResolutionRegistry registry) 4175 ResolutionRegistry registry)
4174 : super(compiler, classElement, registry); 4176 : super(compiler, classElement, registry);
4175 4177
4176 DartType visitClassNode(ClassNode node) { 4178 DartType visitClassNode(ClassNode node) {
4177 invariant(node, element != null); 4179 if (element == null) {
4178 invariant(element, element.resolutionState == STATE_STARTED, 4180 throw compiler.internalError(node, 'element is null');
4179 message: () => 'cyclic resolution of class $element'); 4181 }
4182 if (element.resolutionState != STATE_STARTED) {
4183 throw compiler.internalError(element,
4184 'cyclic resolution of class $element');
4185 }
4180 4186
4181 InterfaceType type = element.computeType(compiler); 4187 InterfaceType type = element.computeType(compiler);
4182 scope = new TypeDeclarationScope(scope, element); 4188 scope = new TypeDeclarationScope(scope, element);
4183 // TODO(ahe): It is not safe to call resolveTypeVariableBounds yet. 4189 // TODO(ahe): It is not safe to call resolveTypeVariableBounds yet.
4184 // As a side-effect, this may get us back here trying to 4190 // As a side-effect, this may get us back here trying to
4185 // resolve this class again. 4191 // resolve this class again.
4186 resolveTypeVariableBounds(node.typeParameters); 4192 resolveTypeVariableBounds(node.typeParameters);
4187 4193
4188 // Setup the supertype for the element (if there is a cycle in the 4194 // Setup the supertype for the element (if there is a cycle in the
4189 // class hierarchy, it has already been set to Object). 4195 // class hierarchy, it has already been set to Object).
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
4254 } 4260 }
4255 return element.computeType(compiler); 4261 return element.computeType(compiler);
4256 } 4262 }
4257 4263
4258 @override 4264 @override
4259 DartType visitEnum(Enum node) { 4265 DartType visitEnum(Enum node) {
4260 if (!compiler.enableEnums) { 4266 if (!compiler.enableEnums) {
4261 compiler.reportError(node, MessageKind.EXPERIMENTAL_ENUMS); 4267 compiler.reportError(node, MessageKind.EXPERIMENTAL_ENUMS);
4262 } 4268 }
4263 4269
4264 invariant(node, element != null); 4270 if (element == null) {
4265 invariant(element, element.resolutionState == STATE_STARTED, 4271 throw compiler.internalError(node, 'element is null');
4266 message: () => 'cyclic resolution of class $element'); 4272 }
4273 if (element.resolutionState != STATE_STARTED) {
4274 throw compiler.internalError(element,
4275 'cyclic resolution of class $element');
4276 }
4267 4277
4268 InterfaceType enumType = element.computeType(compiler); 4278 InterfaceType enumType = element.computeType(compiler);
4269 element.supertype = compiler.objectClass.computeType(compiler); 4279 element.supertype = compiler.objectClass.computeType(compiler);
4270 element.interfaces = const Link<DartType>(); 4280 element.interfaces = const Link<DartType>();
4271 calculateAllSupertypes(element); 4281 calculateAllSupertypes(element);
4272 4282
4273 if (node.names.nodes.isEmpty) { 4283 if (node.names.nodes.isEmpty) {
4274 compiler.reportError(node, 4284 compiler.reportError(node,
4275 MessageKind.EMPTY_ENUM_DECLARATION, 4285 MessageKind.EMPTY_ENUM_DECLARATION,
4276 {'enumName': element.name}); 4286 {'enumName': element.name});
(...skipping 17 matching lines...) Expand all
4294 compiler.reportError(mixinNode, MessageKind.CANNOT_MIXIN_MALFORMED, 4304 compiler.reportError(mixinNode, MessageKind.CANNOT_MIXIN_MALFORMED,
4295 {'className': element.name, 'malformedType': mixinType}); 4305 {'className': element.name, 'malformedType': mixinType});
4296 } else if (mixinType.isEnumType) { 4306 } else if (mixinType.isEnumType) {
4297 compiler.reportError(mixinNode, MessageKind.CANNOT_MIXIN_ENUM, 4307 compiler.reportError(mixinNode, MessageKind.CANNOT_MIXIN_ENUM,
4298 {'className': element.name, 'enumType': mixinType}); 4308 {'className': element.name, 'enumType': mixinType});
4299 } 4309 }
4300 return mixinType; 4310 return mixinType;
4301 } 4311 }
4302 4312
4303 DartType visitNamedMixinApplication(NamedMixinApplication node) { 4313 DartType visitNamedMixinApplication(NamedMixinApplication node) {
4304 invariant(node, element != null); 4314 if (element == null) {
4305 invariant(element, element.resolutionState == STATE_STARTED, 4315 throw compiler.internalError(node, 'element is null');
4306 message: () => 'cyclic resolution of class $element'); 4316 }
4317 if (element.resolutionState != STATE_STARTED) {
4318 throw compiler.internalError(element,
4319 'cyclic resolution of class $element');
4320 }
4307 4321
4308 if (identical(node.classKeyword.stringValue, 'typedef')) { 4322 if (identical(node.classKeyword.stringValue, 'typedef')) {
4309 // TODO(aprelev@gmail.com): Remove this deprecation diagnostic 4323 // TODO(aprelev@gmail.com): Remove this deprecation diagnostic
4310 // together with corresponding TODO in parser.dart. 4324 // together with corresponding TODO in parser.dart.
4311 compiler.reportWarning(node.classKeyword, 4325 compiler.reportWarning(node.classKeyword,
4312 MessageKind.DEPRECATED_TYPEDEF_MIXIN_SYNTAX); 4326 MessageKind.DEPRECATED_TYPEDEF_MIXIN_SYNTAX);
4313 } 4327 }
4314 4328
4315 InterfaceType type = element.computeType(compiler); 4329 InterfaceType type = element.computeType(compiler);
4316 scope = new TypeDeclarationScope(scope, element); 4330 scope = new TypeDeclarationScope(scope, element);
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
5015 } 5029 }
5016 5030
5017 /// The result for the resolution of the `assert` method. 5031 /// The result for the resolution of the `assert` method.
5018 class AssertResult implements ResolutionResult { 5032 class AssertResult implements ResolutionResult {
5019 const AssertResult(); 5033 const AssertResult();
5020 5034
5021 Element get element => null; 5035 Element get element => null;
5022 5036
5023 String toString() => 'AssertResult()'; 5037 String toString() => 'AssertResult()';
5024 } 5038 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/dart_types.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698