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 Element implementation = element.implementation; |
|
ngeoffray
2013/11/22 12:21:04
In hasIrNode/irNode.
lukas
2013/11/22 16:33:03
Done.
| |
| 23 Token beginToken; | 23 if (implementation.hasIrNode(compiler)) { |
| 24 Token endToken; | 24 IrFunction function = implementation.irNode(compiler); |
| 25 if (expression == null) { | 25 node.sourcePosition = new OffsetSourceFileLocation( |
| 26 // Synthesized node. Use the enclosing element for the location. | 26 sourceFile, function.offset, function.sourceName); |
| 27 beginToken = endToken = element.position(); | 27 node.endSourcePosition = new OffsetSourceFileLocation( |
| 28 sourceFile, function.endOffset); | |
| 28 } else { | 29 } else { |
| 29 beginToken = expression.getBeginToken(); | 30 Node expression = implementation.parseNode(backend.compiler); |
| 30 endToken = expression.getEndToken(); | 31 Token beginToken; |
| 31 } | 32 Token endToken; |
| 32 // TODO(podivilov): find the right sourceFile here and remove offset checks | 33 if (expression == null) { |
| 33 // below. | 34 // Synthesized node. Use the enclosing element for the location. |
| 34 if (beginToken.charOffset < sourceFile.length) { | 35 beginToken = endToken = element.position(); |
| 35 node.sourcePosition = new SourceFileLocation(sourceFile, beginToken); | 36 } else { |
| 36 } | 37 beginToken = expression.getBeginToken(); |
| 37 if (endToken.charOffset < sourceFile.length) { | 38 endToken = expression.getEndToken(); |
| 38 node.endSourcePosition = new SourceFileLocation(sourceFile, endToken); | 39 } |
| 40 // TODO(podivilov): find the right sourceFile here and remove offset | |
| 41 // checks below. | |
| 42 if (beginToken.charOffset < sourceFile.length) { | |
| 43 node.sourcePosition = | |
| 44 new TokenSourceFileLocation(sourceFile, beginToken); | |
| 45 } | |
| 46 if (endToken.charOffset < sourceFile.length) { | |
| 47 node.endSourcePosition = | |
| 48 new TokenSourceFileLocation(sourceFile, endToken); | |
| 49 } | |
| 39 } | 50 } |
| 40 return node; | 51 return node; |
| 41 } | 52 } |
| 42 | 53 |
| 43 SourceFile sourceFileOfElement(Element element) { | 54 SourceFile sourceFileOfElement(Element element) { |
| 44 // TODO(johnniwinther): remove the 'element.patch' hack. | 55 // TODO(johnniwinther): remove the 'element.patch' hack. |
| 45 FunctionElement functionElement = element.asFunctionElement(); | 56 FunctionElement functionElement = element.asFunctionElement(); |
| 46 if (functionElement != null && functionElement.patch != null) { | 57 if (functionElement != null && functionElement.patch != null) { |
| 47 element = functionElement.patch; | 58 element = functionElement.patch; |
| 48 } | 59 } |
| (...skipping 2509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2558 if (left.isConstantNull() || right.isConstantNull() || | 2569 if (left.isConstantNull() || right.isConstantNull() || |
| 2559 (left.isPrimitive(compiler) && | 2570 (left.isPrimitive(compiler) && |
| 2560 left.instructionType == right.instructionType)) { | 2571 left.instructionType == right.instructionType)) { |
| 2561 return '=='; | 2572 return '=='; |
| 2562 } | 2573 } |
| 2563 return null; | 2574 return null; |
| 2564 } else { | 2575 } else { |
| 2565 return '==='; | 2576 return '==='; |
| 2566 } | 2577 } |
| 2567 } | 2578 } |
| OLD | NEW |