| 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 class SsaCodeGeneratorTask extends CompilerTask { | 5 class SsaCodeGeneratorTask extends CompilerTask { |
| 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); | 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); |
| 7 String get name() => 'SSA code generator'; | 7 String get name() => 'SSA code generator'; |
| 8 | 8 |
| 9 | 9 |
| 10 String buildJavaScriptFunction(FunctionElement element, | 10 String buildJavaScriptFunction(FunctionElement element, |
| (...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1286 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); | 1286 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); |
| 1287 buffer.add('.'); | 1287 buffer.add('.'); |
| 1288 buffer.add(name); | 1288 buffer.add(name); |
| 1289 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); | 1289 beginExpression(JSPrecedence.MEMBER_PRECEDENCE); |
| 1290 } else { | 1290 } else { |
| 1291 buffer.add(JsNames.getValid(node.element.name.slowToString())); | 1291 buffer.add(JsNames.getValid(node.element.name.slowToString())); |
| 1292 } | 1292 } |
| 1293 } | 1293 } |
| 1294 | 1294 |
| 1295 visitFieldSet(HFieldSet node) { | 1295 visitFieldSet(HFieldSet node) { |
| 1296 // This method may introduce variable declarations in the JS code. | |
| 1297 // If we are generating an expression, those variable declarations | |
| 1298 // must be delayed until later. | |
| 1299 bool delayDeclaration = false; | |
| 1300 String name; | 1296 String name; |
| 1301 if (node.receiver !== null) { | 1297 if (node.receiver !== null) { |
| 1302 name = | 1298 name = |
| 1303 compiler.namer.instanceFieldName(currentLibrary, node.element.name); | 1299 compiler.namer.instanceFieldName(currentLibrary, node.element.name); |
| 1304 beginExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); | 1300 beginExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); |
| 1305 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); | 1301 use(node.receiver, JSPrecedence.MEMBER_PRECEDENCE); |
| 1306 buffer.add('.'); | 1302 buffer.add('.'); |
| 1307 buffer.add(name); | 1303 buffer.add(name); |
| 1308 } else { | 1304 } else { |
| 1309 // TODO(ngeoffray): Remove the 'var' once we don't globally box | 1305 // TODO(ngeoffray): Remove the 'var' once we don't globally box |
| 1310 // variables used in a try/catch. | 1306 // variables used in a try/catch. |
| 1311 name = JsNames.getValid(node.element.name.slowToString()); | 1307 name = JsNames.getValid(node.element.name.slowToString()); |
| 1312 declareVariable(name); | 1308 declareVariable(name); |
| 1313 } | 1309 } |
| 1314 if (delayDeclaration) delayedVarDecl = delayedVarDecl.prepend(name); | |
| 1315 buffer.add(' = '); | 1310 buffer.add(' = '); |
| 1316 use(node.value, JSPrecedence.ASSIGNMENT_PRECEDENCE); | 1311 use(node.value, JSPrecedence.ASSIGNMENT_PRECEDENCE); |
| 1317 if (node.receiver !== null) { | 1312 if (node.receiver !== null) { |
| 1318 endExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); | 1313 endExpression(JSPrecedence.ASSIGNMENT_PRECEDENCE); |
| 1319 } | 1314 } |
| 1320 } | 1315 } |
| 1321 | 1316 |
| 1322 visitForeign(HForeign node) { | 1317 visitForeign(HForeign node) { |
| 1323 String code = node.code.slowToString(); | 1318 String code = node.code.slowToString(); |
| 1324 List<HInstruction> inputs = node.inputs; | 1319 List<HInstruction> inputs = node.inputs; |
| (...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2246 startBailoutSwitch(); | 2241 startBailoutSwitch(); |
| 2247 } | 2242 } |
| 2248 } | 2243 } |
| 2249 | 2244 |
| 2250 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { | 2245 void endLabeledBlock(HLabeledBlockInformation labeledBlockInfo) { |
| 2251 if (labeledBlockInfo.body.start.hasGuards()) { | 2246 if (labeledBlockInfo.body.start.hasGuards()) { |
| 2252 endBailoutSwitch(); | 2247 endBailoutSwitch(); |
| 2253 } | 2248 } |
| 2254 } | 2249 } |
| 2255 } | 2250 } |
| OLD | NEW |