| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library dart2js.ir_builder; | 5 library dart2js.ir_builder; |
| 6 | 6 |
| 7 import 'ir_nodes.dart' as ir; | 7 import 'ir_nodes.dart' as ir; |
| 8 import '../elements/elements.dart'; | 8 import '../elements/elements.dart'; |
| 9 import '../dart2jslib.dart'; | 9 import '../dart2jslib.dart'; |
| 10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
| (...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1255 assert(node.receiver != null); | 1255 assert(node.receiver != null); |
| 1256 assert(node.arguments.isEmpty); | 1256 assert(node.arguments.isEmpty); |
| 1257 return buildNegation(visit(node.receiver)); | 1257 return buildNegation(visit(node.receiver)); |
| 1258 } | 1258 } |
| 1259 if (op.source == "!=") { | 1259 if (op.source == "!=") { |
| 1260 assert(node.receiver != null); | 1260 assert(node.receiver != null); |
| 1261 assert(!node.arguments.isEmpty); | 1261 assert(!node.arguments.isEmpty); |
| 1262 assert(node.arguments.tail.isEmpty); | 1262 assert(node.arguments.tail.isEmpty); |
| 1263 return buildNegation(visitDynamicSend(node)); | 1263 return buildNegation(visitDynamicSend(node)); |
| 1264 } | 1264 } |
| 1265 if (op.source == "is") { | 1265 if (op.source == "is" || op.source == "as") { |
| 1266 DartType type = elements.getType(node.typeAnnotationFromIsCheckOrCast); | 1266 DartType type = elements.getType(node.typeAnnotationFromIsCheckOrCast); |
| 1267 ir.Primitive receiver = visit(node.receiver); | 1267 ir.Primitive receiver = visit(node.receiver); |
| 1268 ir.IsCheck isCheck = new ir.IsCheck(receiver, type); | 1268 ir.Primitive check = continueWithExpression( |
| 1269 add(new ir.LetPrim(isCheck)); | 1269 (k) => new ir.TypeOperator(op.source, receiver, type, k)); |
| 1270 return node.isIsNotCheck ? buildNegation(isCheck) : isCheck; | 1270 return node.isIsNotCheck ? buildNegation(check) : check; |
| 1271 } | 1271 } |
| 1272 if (op.source == "as") { | |
| 1273 DartType type = elements.getType(node.typeAnnotationFromIsCheckOrCast); | |
| 1274 ir.Primitive receiver = visit(node.receiver); | |
| 1275 return continueWithExpression( | |
| 1276 (k) => new ir.AsCast(receiver, type, k)); | |
| 1277 } | |
| 1278 compiler.internalError(node, "Unknown operator '${op.source}'"); | |
| 1279 } | 1272 } |
| 1280 | 1273 |
| 1281 // Build(StaticSend(f, arguments), C) = C[C'[InvokeStatic(f, xs)]] | 1274 // Build(StaticSend(f, arguments), C) = C[C'[InvokeStatic(f, xs)]] |
| 1282 // where (C', xs) = arguments.fold(Build, C) | 1275 // where (C', xs) = arguments.fold(Build, C) |
| 1283 ir.Primitive visitStaticSend(ast.Send node) { | 1276 ir.Primitive visitStaticSend(ast.Send node) { |
| 1284 assert(isOpen); | 1277 assert(isOpen); |
| 1285 Element element = elements[node]; | 1278 Element element = elements[node]; |
| 1286 assert(!element.isConstructor); | 1279 assert(!element.isConstructor); |
| 1287 // TODO(lry): support foreign functions. | 1280 // TODO(lry): support foreign functions. |
| 1288 if (element.isForeign(compiler)) return giveup(node, 'StaticSend: foreign'); | 1281 if (element.isForeign(compiler)) return giveup(node, 'StaticSend: foreign'); |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1716 } | 1709 } |
| 1717 | 1710 |
| 1718 visitFunctionExpression(ast.FunctionExpression node) { | 1711 visitFunctionExpression(ast.FunctionExpression node) { |
| 1719 FunctionElement oldFunction = currentFunction; | 1712 FunctionElement oldFunction = currentFunction; |
| 1720 currentFunction = elements[node]; | 1713 currentFunction = elements[node]; |
| 1721 visit(node.body); | 1714 visit(node.body); |
| 1722 currentFunction = oldFunction; | 1715 currentFunction = oldFunction; |
| 1723 } | 1716 } |
| 1724 | 1717 |
| 1725 } | 1718 } |
| OLD | NEW |