Code coverage report for sc/lang/compiler/codegen/binop-expr.js

Statements: 100% (16 / 16)      Branches: 100% (6 / 6)      Functions: 100% (4 / 4)      Lines: 100% (16 / 16)      Ignored: none     

All files » sc/lang/compiler/codegen/ » binop-expr.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 401     1   1   1 8   8 1     7     1 1             1 7         7 1   7   7      
(function(sc) {
  "use strict";
 
  require("./codegen");
 
  var CodeGen = sc.lang.compiler.CodeGen;
 
  CodeGen.addGenerateMethod("BinaryExpression", function(node) {
    var operator = node.operator;
 
    if (operator === "===" || operator === "!==") {
      return generateEqualityOperator(this, node);
    }
 
    return generateBinaryExpression(this, node);
  });
 
  function generateEqualityOperator(that, node) {
    return [
      "$.Boolean(",
      that.generate(node.left), node.operator, that.generate(node.right),
      ")"
    ];
  }
 
  function generateBinaryExpression(that, node) {
    var result = [
      that.generate(node.left),
      ".$('" + node.operator + "',[", that.generate(node.right)
    ];
 
    if (node.adverb) {
      result.push(",", that.generate(node.adverb));
    }
    result.push("])");
 
    return result;
  }
})(sc);