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.Fun buildJavaScriptFunction(FunctionElement element, | 18 js.Fun buildJavaScriptFunction(FunctionElement element, |
| 19 List<js.Parameter> parameters, | 19 List<js.Parameter> parameters, |
| 20 js.Block body) { | 20 js.Block body) { |
| 21 FunctionExpression expression = | |
| 22 element.implementation.parseNode(backend.compiler); | |
| 23 js.Fun result = new js.Fun(parameters, body); | 21 js.Fun result = new js.Fun(parameters, body); |
| 24 // TODO(johnniwinther): remove the 'element.patch' hack. | 22 // TODO(johnniwinther): remove the 'element.patch' hack. |
| 25 Element sourceElement = element.patch == null ? element : element.patch; | 23 Element sourceElement = element.patch == null ? element : element.patch; |
| 26 SourceFile sourceFile = sourceElement.getCompilationUnit().script.file; | 24 SourceFile sourceFile = sourceElement.getCompilationUnit().script.file; |
| 25 Node expression = | |
| 26 element.implementation.parseNode(backend.compiler); | |
| 27 if (expression == null) { | |
| 28 // Synthesized node. Use the enclosing element for the location. | |
| 29 expression = element.enclosingElement.parseNode(backend.compiler); | |
|
ahe
2013/07/18 09:59:32
I'm not sure about this. I'll suggest an alternati
ahe
2013/07/18 14:32:56
Spannable spannable = element.implementation.parse
ngeoffray
2013/07/18 15:25:14
Done.
| |
| 30 } | |
| 27 // TODO(podivilov): find the right sourceFile here and remove offset checks | 31 // TODO(podivilov): find the right sourceFile here and remove offset checks |
| 28 // below. | 32 // below. |
| 29 if (expression.getBeginToken().charOffset < sourceFile.text.length) { | 33 if (expression.getBeginToken().charOffset < sourceFile.text.length) { |
| 30 result.sourcePosition = new SourceFileLocation( | 34 result.sourcePosition = new SourceFileLocation( |
| 31 sourceFile, expression.getBeginToken()); | 35 sourceFile, expression.getBeginToken()); |
| 32 } | 36 } |
| 33 if (expression.getEndToken().charOffset < sourceFile.text.length) { | 37 if (expression.getEndToken().charOffset < sourceFile.text.length) { |
| 34 result.endSourcePosition = new SourceFileLocation( | 38 result.endSourcePosition = new SourceFileLocation( |
| 35 sourceFile, expression.getEndToken()); | 39 sourceFile, expression.getEndToken()); |
| 36 } | 40 } |
| (...skipping 2939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2976 if (leftType.canBeNull() && rightType.canBeNull()) { | 2980 if (leftType.canBeNull() && rightType.canBeNull()) { |
| 2977 if (left.isConstantNull() || right.isConstantNull() || | 2981 if (left.isConstantNull() || right.isConstantNull() || |
| 2978 (leftType.isPrimitive(compiler) && leftType == rightType)) { | 2982 (leftType.isPrimitive(compiler) && leftType == rightType)) { |
| 2979 return '=='; | 2983 return '=='; |
| 2980 } | 2984 } |
| 2981 return null; | 2985 return null; |
| 2982 } else { | 2986 } else { |
| 2983 return '==='; | 2987 return '==='; |
| 2984 } | 2988 } |
| 2985 } | 2989 } |
| OLD | NEW |