Chromium Code Reviews| 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 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 class SsaCodeGeneratorTask extends CompilerTask { | 7 class SsaCodeGeneratorTask extends CompilerTask { |
| 8 | 8 |
| 9 final JavaScriptBackend backend; | 9 final JavaScriptBackend backend; |
| 10 | 10 |
| 11 SsaCodeGeneratorTask(JavaScriptBackend backend) | 11 SsaCodeGeneratorTask(JavaScriptBackend backend) |
| 12 : this.backend = backend, | 12 : this.backend = backend, |
| 13 super(backend.compiler); | 13 super(backend.compiler); |
| 14 String get name => 'SSA code generator'; | 14 String get name => 'SSA code generator'; |
| 15 NativeEmitter get nativeEmitter => backend.emitter.nativeEmitter; | 15 NativeEmitter get nativeEmitter => backend.emitter.nativeEmitter; |
| 16 | 16 |
| 17 | 17 |
| 18 js.Node attachPosition(js.Node node, Element element) { | 18 js.Node attachPosition(js.Node node, Element element) { |
| 19 // TODO(sra): Attaching positions might be cleaner if the source position | 19 // TODO(sra): Attaching positions might be cleaner if the source position |
| 20 // was on a wrapping node. | 20 // was on a wrapping node. |
| 21 SourceFile sourceFile = sourceFileOfElement(element); | 21 SourceFile sourceFile = sourceFileOfElement(element); |
| 22 Node expression = element.implementation.parseNode(backend.compiler); | 22 if (element.hasIrNode(compiler)) { |
| 23 Token beginToken; | 23 IrFunction function = element.irNode(compiler); |
| 24 Token endToken; | 24 node.sourcePosition = new OffsetSourceFileLocation( |
| 25 if (expression == null) { | 25 sourceFile, function.offset, function.sourceName); |
| 26 // Synthesized node. Use the enclosing element for the location. | 26 node.endSourcePosition = new OffsetSourceFileLocation( |
| 27 beginToken = endToken = element.position(); | 27 sourceFile, function.endOffset); |
| 28 } else { | 28 } else { |
| 29 beginToken = expression.getBeginToken(); | 29 Node expression = element.implementation.parseNode(backend.compiler); |
| 30 endToken = expression.getEndToken(); | 30 Token beginToken; |
| 31 } | 31 Token endToken; |
| 32 // TODO(podivilov): find the right sourceFile here and remove offset checks | 32 if (expression == null) { |
| 33 // below. | 33 // Synthesized node. Use the enclosing element for the location. |
| 34 if (beginToken.charOffset < sourceFile.length) { | 34 beginToken = endToken = element.position(); |
| 35 node.sourcePosition = new SourceFileLocation(sourceFile, beginToken); | 35 } else { |
| 36 } | 36 beginToken = expression.getBeginToken(); |
| 37 if (endToken.charOffset < sourceFile.length) { | 37 endToken = expression.getEndToken(); |
| 38 node.endSourcePosition = new SourceFileLocation(sourceFile, endToken); | 38 } |
| 39 // TODO(podivilov): find the right sourceFile here and remove offset check s | |
|
ngeoffray
2013/11/20 14:55:27
line too long.
lukas
2013/11/21 12:20:21
Done.
| |
| 40 // below. | |
| 41 if (beginToken.charOffset < sourceFile.length) { | |
| 42 node.sourcePosition = new TokenSourceFileLocation(sourceFile, beginToken ); | |
|
ngeoffray
2013/11/20 14:55:27
ditto
lukas
2013/11/21 12:20:21
Done.
| |
| 43 } | |
| 44 if (endToken.charOffset < sourceFile.length) { | |
| 45 node.endSourcePosition = | |
| 46 new TokenSourceFileLocation(sourceFile, endToken); | |
| 47 } | |
| 39 } | 48 } |
| 40 return node; | 49 return node; |
| 41 } | 50 } |
| 42 | 51 |
| 43 SourceFile sourceFileOfElement(Element element) { | 52 SourceFile sourceFileOfElement(Element element) { |
| 44 // TODO(johnniwinther): remove the 'element.patch' hack. | 53 // TODO(johnniwinther): remove the 'element.patch' hack. |
| 45 FunctionElement functionElement = element.asFunctionElement(); | 54 FunctionElement functionElement = element.asFunctionElement(); |
| 46 if (functionElement != null && functionElement.patch != null) { | 55 if (functionElement != null && functionElement.patch != null) { |
| 47 element = functionElement.patch; | 56 element = functionElement.patch; |
| 48 } | 57 } |
| (...skipping 2532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2581 if (left.isConstantNull() || right.isConstantNull() || | 2590 if (left.isConstantNull() || right.isConstantNull() || |
| 2582 (left.isPrimitive(compiler) && | 2591 (left.isPrimitive(compiler) && |
| 2583 left.instructionType == right.instructionType)) { | 2592 left.instructionType == right.instructionType)) { |
| 2584 return '=='; | 2593 return '=='; |
| 2585 } | 2594 } |
| 2586 return null; | 2595 return null; |
| 2587 } else { | 2596 } else { |
| 2588 return '==='; | 2597 return '==='; |
| 2589 } | 2598 } |
| 2590 } | 2599 } |
| OLD | NEW |