Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dart2js.semantics_visitor; | 5 part of dart2js.semantics_visitor; |
| 6 | 6 |
| 7 enum SendStructureKind { | 7 enum SendStructureKind { |
| 8 GET, | 8 GET, |
| 9 SET, | 9 SET, |
| 10 INVOKE, | 10 INVOKE, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 assert(invariant(node, getter != null, message: | 99 assert(invariant(node, getter != null, message: |
| 100 "Compound static access without element.")); | 100 "Compound static access without element.")); |
| 101 return handleCompoundErroneousSetterAccess(node, element, getter); | 101 return handleCompoundErroneousSetterAccess(node, element, getter); |
| 102 } | 102 } |
| 103 if (element.isErroneous) { | 103 if (element.isErroneous) { |
| 104 if (isCompound) { | 104 if (isCompound) { |
| 105 return handleCompoundErroneousSetterAccess(node, element, getter); | 105 return handleCompoundErroneousSetterAccess(node, element, getter); |
| 106 } | 106 } |
| 107 return new StaticAccess.unresolved(element); | 107 return new StaticAccess.unresolved(element); |
| 108 } else if (element.isParameter) { | 108 } else if (element.isParameter) { |
| 109 return new StaticAccess.parameter(element); | 109 if (element.isFinal) { |
| 110 return new StaticAccess.finalParameter(element); | |
| 111 } else { | |
| 112 return new StaticAccess.parameter(element); | |
| 113 } | |
| 110 } else if (element.isLocal) { | 114 } else if (element.isLocal) { |
| 111 if (element.isFunction) { | 115 if (element.isFunction) { |
| 112 return new StaticAccess.localFunction(element); | 116 return new StaticAccess.localFunction(element); |
| 117 } else if (element.isFinal || element.isConst) { | |
| 118 return new StaticAccess.finalLocalVariable(element); | |
| 113 } else { | 119 } else { |
| 114 return new StaticAccess.localVariable(element); | 120 return new StaticAccess.localVariable(element); |
| 115 } | 121 } |
| 116 } else if (element.isStatic) { | 122 } else if (element.isStatic) { |
| 117 if (element.isField) { | 123 if (element.isField) { |
| 118 if (element.isFinal || element.isConst) { | 124 if (element.isFinal || element.isConst) { |
| 119 // TODO(johnniwinther): Handle const field separately. | 125 // TODO(johnniwinther): Handle const field separately. |
| 120 return new StaticAccess.finalStaticField(element); | 126 return new StaticAccess.finalStaticField(element); |
| 121 } | 127 } |
| 122 return new StaticAccess.staticField(element); | 128 return new StaticAccess.staticField(element); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 417 selector); | 423 selector); |
| 418 } | 424 } |
| 419 } | 425 } |
| 420 | 426 |
| 421 AccessSemantics computeAccessSemantics(Send node, | 427 AccessSemantics computeAccessSemantics(Send node, |
| 422 {bool isSet: false, | 428 {bool isSet: false, |
| 423 bool isInvoke: false, | 429 bool isInvoke: false, |
| 424 bool isCompound: false}) { | 430 bool isCompound: false}) { |
| 425 Element element = elements[node]; | 431 Element element = elements[node]; |
| 426 Element getter = isCompound ? elements[node.selector] : null; | 432 Element getter = isCompound ? elements[node.selector] : null; |
| 433 //print('$node,element=$element,getter=$getter'); | |
|
karlklose
2015/05/22 12:14:19
Remove debug code.
| |
| 427 if (elements.isTypeLiteral(node)) { | 434 if (elements.isTypeLiteral(node)) { |
| 428 DartType dartType = elements.getTypeLiteralType(node); | 435 DartType dartType = elements.getTypeLiteralType(node); |
| 429 // TODO(johnniwinther): Handle deferred constants. There are runtime | 436 // TODO(johnniwinther): Handle deferred constants. There are runtime |
| 430 // but not compile-time constants and should have their own | 437 // but not compile-time constants and should have their own |
| 431 // [DeferredConstantExpression] class. | 438 // [DeferredConstantExpression] class. |
| 432 ConstantExpression constant = elements.getConstant( | 439 ConstantExpression constant = elements.getConstant( |
| 433 isInvoke || isSet || isCompound ? node.selector : node); | 440 isInvoke || isSet || isCompound ? node.selector : node); |
| 434 switch (dartType.kind) { | 441 switch (dartType.kind) { |
| 435 case TypeKind.INTERFACE: | 442 case TypeKind.INTERFACE: |
| 436 return new ConstantAccess.classTypeLiteral(constant); | 443 return new ConstantAccess.classTypeLiteral(constant); |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 931 return internalError(node, "Unexpected variable $element."); | 938 return internalError(node, "Unexpected variable $element."); |
| 932 } | 939 } |
| 933 if (element.isConst) { | 940 if (element.isConst) { |
| 934 ConstantExpression constant = elements.getConstant(element.initializer); | 941 ConstantExpression constant = elements.getConstant(element.initializer); |
| 935 return new ConstantVariableStructure(kind, node, element, constant); | 942 return new ConstantVariableStructure(kind, node, element, constant); |
| 936 } else { | 943 } else { |
| 937 return new NonConstantVariableStructure(kind, node, element); | 944 return new NonConstantVariableStructure(kind, node, element); |
| 938 } | 945 } |
| 939 } | 946 } |
| 940 } | 947 } |
| OLD | NEW |