Index: pkg/compiler/lib/src/js_backend/codegen/codegen.dart |
diff --git a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart |
index 9a05a589e8227ad157530bf829e44da0241278ef..b752a21a540e29dae94df820edd83dc87ef1e4c7 100644 |
--- a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart |
+++ b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart |
@@ -7,6 +7,7 @@ library code_generator; |
import 'glue.dart'; |
import '../../tree_ir/tree_ir_nodes.dart' as tree_ir; |
+import '../../tree_ir/tree_ir_nodes.dart' show BuiltinOperator; |
import '../../js/js.dart' as js; |
import '../../elements/elements.dart'; |
import '../../io/source_information.dart' show SourceInformation; |
@@ -695,6 +696,43 @@ class CodeGenerator extends tree_ir.StatementVisitor |
return glue.generateTypeRepresentation(node.dartType, arguments); |
} |
+ @override |
+ js.Expression visitApplyBuiltinOperator(tree_ir.ApplyBuiltinOperator node) { |
+ List<js.Expression> args = visitExpressionList(node.arguments); |
+ switch (node.operator) { |
+ case BuiltinOperator.NumAdd: |
+ return new js.Binary('+', args[0], args[1]); |
+ case BuiltinOperator.NumSubtract: |
+ return new js.Binary('-', args[0], args[1]); |
+ case BuiltinOperator.NumMultiply: |
+ return new js.Binary('*', args[0], args[1]); |
+ case BuiltinOperator.NumAnd: |
+ return js.js('(# & #) >>> 0', <js.Expression>[args[0], args[1]]); |
+ case BuiltinOperator.NumOr: |
+ return js.js('(# | #) >>> 0', <js.Expression>[args[0], args[1]]); |
+ case BuiltinOperator.NumXor: |
+ return js.js('(# ^ #) >>> 0', <js.Expression>[args[0], args[1]]); |
+ case BuiltinOperator.NumLt: |
+ return new js.Binary('<', args[0], args[1]); |
+ case BuiltinOperator.NumLe: |
+ return new js.Binary('<=', args[0], args[1]); |
+ case BuiltinOperator.NumGt: |
+ return new js.Binary('>', args[0], args[1]); |
+ case BuiltinOperator.NumGe: |
+ return new js.Binary('>=', args[0], args[1]); |
+ case BuiltinOperator.StrictEq: |
+ return new js.Binary('===', args[0], args[1]); |
+ case BuiltinOperator.StrictNeq: |
+ return new js.Binary('!==', args[0], args[1]); |
+ case BuiltinOperator.LooseEq: |
+ return new js.Binary('==', args[0], args[1]); |
+ case BuiltinOperator.LooseNeq: |
+ return new js.Binary('!=', args[0], args[1]); |
+ case BuiltinOperator.IsFalsy: |
+ return new js.Prefix('!', args[0]); |
+ } |
+ } |
+ |
visitFunctionExpression(tree_ir.FunctionExpression node) { |
// FunctionExpressions are currently unused. |
// We might need them if we want to emit raw JS nested functions. |