| OLD | NEW |
| 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 dart2js.resolution.members; | 5 library dart2js.resolution.members; |
| 6 | 6 |
| 7 import 'package:front_end/src/fasta/scanner.dart' show isUserDefinableOperator; | 7 import 'package:front_end/src/fasta/scanner.dart' show isUserDefinableOperator; |
| 8 | 8 |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../common/names.dart' show Selectors; | 10 import '../common/names.dart' show Selectors; |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 | 419 |
| 420 // Create the scope where the type variables are introduced, if any. | 420 // Create the scope where the type variables are introduced, if any. |
| 421 scope = new MethodScope(scope, function); | 421 scope = new MethodScope(scope, function); |
| 422 functionSignature.typeVariables | 422 functionSignature.typeVariables |
| 423 .forEach((ResolutionDartType type) => addToScope(type.element)); | 423 .forEach((ResolutionDartType type) => addToScope(type.element)); |
| 424 | 424 |
| 425 // Create the scope for the function body, and put the parameters in scope. | 425 // Create the scope for the function body, and put the parameters in scope. |
| 426 scope = new BlockScope(scope); | 426 scope = new BlockScope(scope); |
| 427 Link<Node> parameterNodes = | 427 Link<Node> parameterNodes = |
| 428 (node.parameters == null) ? const Link<Node>() : node.parameters.nodes; | 428 (node.parameters == null) ? const Link<Node>() : node.parameters.nodes; |
| 429 functionSignature.forEachParameter((ParameterElementX element) { | 429 functionSignature.forEachParameter((_element) { |
| 430 ParameterElementX element = _element; |
| 430 // TODO(karlklose): should be a list of [FormalElement]s, but the actual | 431 // TODO(karlklose): should be a list of [FormalElement]s, but the actual |
| 431 // implementation uses [Element]. | 432 // implementation uses [Element]. |
| 432 List<Element> optionals = functionSignature.optionalParameters; | 433 List<Element> optionals = functionSignature.optionalParameters; |
| 433 if (!optionals.isEmpty && element == optionals.first) { | 434 if (!optionals.isEmpty && element == optionals.first) { |
| 434 NodeList nodes = parameterNodes.head; | 435 NodeList nodes = parameterNodes.head; |
| 435 parameterNodes = nodes.nodes; | 436 parameterNodes = nodes.nodes; |
| 436 } | 437 } |
| 437 if (element.isOptional) { | 438 if (element.isOptional) { |
| 438 if (element.initializer != null) { | 439 if (element.initializer != null) { |
| 439 ResolutionResult result = visitInConstantContext(element.initializer); | 440 ResolutionResult result = visitInConstantContext(element.initializer); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 451 if (element.isInitializingFormal) { | 452 if (element.isInitializingFormal) { |
| 452 registry.useElement(parameterNode, element); | 453 registry.useElement(parameterNode, element); |
| 453 } else { | 454 } else { |
| 454 LocalParameterElementX parameterElement = element; | 455 LocalParameterElementX parameterElement = element; |
| 455 defineLocalVariable(parameterNode, parameterElement); | 456 defineLocalVariable(parameterNode, parameterElement); |
| 456 addToScope(parameterElement); | 457 addToScope(parameterElement); |
| 457 } | 458 } |
| 458 parameterNodes = parameterNodes.tail; | 459 parameterNodes = parameterNodes.tail; |
| 459 }); | 460 }); |
| 460 addDeferredAction(enclosingElement, () { | 461 addDeferredAction(enclosingElement, () { |
| 461 functionSignature.forEachOptionalParameter((ParameterElementX parameter) { | 462 functionSignature.forEachOptionalParameter((_parameter) { |
| 463 ParameterElementX parameter = _parameter; |
| 462 parameter.constant = | 464 parameter.constant = |
| 463 resolver.constantCompiler.compileConstant(parameter); | 465 resolver.constantCompiler.compileConstant(parameter); |
| 464 }); | 466 }); |
| 465 }); | 467 }); |
| 466 registry.registerCheckedModeCheck(functionSignature.returnType); | 468 registry.registerCheckedModeCheck(functionSignature.returnType); |
| 467 functionSignature.forEachParameter((ParameterElement element) { | 469 functionSignature.forEachParameter((_element) { |
| 470 ParameterElement element = _element; |
| 468 registry.registerCheckedModeCheck(element.type); | 471 registry.registerCheckedModeCheck(element.type); |
| 469 }); | 472 }); |
| 470 } | 473 } |
| 471 | 474 |
| 472 ResolutionResult visitAssert(Assert node) { | 475 ResolutionResult visitAssert(Assert node) { |
| 473 // TODO(sra): We could completely ignore the assert in production mode if we | 476 // TODO(sra): We could completely ignore the assert in production mode if we |
| 474 // didn't need it to be resolved for type checking. | 477 // didn't need it to be resolved for type checking. |
| 475 registry.registerFeature( | 478 registry.registerFeature( |
| 476 node.hasMessage ? Feature.ASSERT_WITH_MESSAGE : Feature.ASSERT); | 479 node.hasMessage ? Feature.ASSERT_WITH_MESSAGE : Feature.ASSERT); |
| 477 visit(node.condition); | 480 visit(node.condition); |
| (...skipping 3245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3723 redirectionTarget, | 3726 redirectionTarget, |
| 3724 redirectionTarget.enclosingClass.thisType | 3727 redirectionTarget.enclosingClass.thisType |
| 3725 .subst(type.typeArguments, targetClass.typeVariables))); | 3728 .subst(type.typeArguments, targetClass.typeVariables))); |
| 3726 if (resolution.commonElements.isSymbolConstructor(constructor)) { | 3729 if (resolution.commonElements.isSymbolConstructor(constructor)) { |
| 3727 registry.registerFeature(Feature.SYMBOL_CONSTRUCTOR); | 3730 registry.registerFeature(Feature.SYMBOL_CONSTRUCTOR); |
| 3728 } | 3731 } |
| 3729 if (isValidAsConstant) { | 3732 if (isValidAsConstant) { |
| 3730 List<String> names = <String>[]; | 3733 List<String> names = <String>[]; |
| 3731 List<ConstantExpression> arguments = <ConstantExpression>[]; | 3734 List<ConstantExpression> arguments = <ConstantExpression>[]; |
| 3732 int index = 0; | 3735 int index = 0; |
| 3733 constructorSignature.forEachParameter((ParameterElement parameter) { | 3736 constructorSignature.forEachParameter((_parameter) { |
| 3737 ParameterElement parameter = _parameter; |
| 3734 if (parameter.isNamed) { | 3738 if (parameter.isNamed) { |
| 3735 String name = parameter.name; | 3739 String name = parameter.name; |
| 3736 names.add(name); | 3740 names.add(name); |
| 3737 arguments.add(new NamedArgumentReference(name)); | 3741 arguments.add(new NamedArgumentReference(name)); |
| 3738 } else { | 3742 } else { |
| 3739 arguments.add(new PositionalArgumentReference(index)); | 3743 arguments.add(new PositionalArgumentReference(index)); |
| 3740 } | 3744 } |
| 3741 index++; | 3745 index++; |
| 3742 }); | 3746 }); |
| 3743 CallStructure callStructure = | 3747 CallStructure callStructure = |
| (...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4813 } | 4817 } |
| 4814 return const NoneResult(); | 4818 return const NoneResult(); |
| 4815 } | 4819 } |
| 4816 } | 4820 } |
| 4817 | 4821 |
| 4818 /// Looks up [name] in [scope] and unwraps the result. | 4822 /// Looks up [name] in [scope] and unwraps the result. |
| 4819 Element lookupInScope( | 4823 Element lookupInScope( |
| 4820 DiagnosticReporter reporter, Node node, Scope scope, String name) { | 4824 DiagnosticReporter reporter, Node node, Scope scope, String name) { |
| 4821 return Elements.unwrap(scope.lookup(name), reporter, node); | 4825 return Elements.unwrap(scope.lookup(name), reporter, node); |
| 4822 } | 4826 } |
| OLD | NEW |