How to use the traceur/src/codegeneration/ParseTreeFactory.createCallExpression function in traceur

To help you get started, we’ve selected a few traceur examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github angular / angular / tools / transpiler / src / codegeneration / StrictEqualityTransformer.js View on Github external
transformBinaryExpression(tree) {
    tree.left = this.transformAny(tree.left);
    tree.right = this.transformAny(tree.right);

    if (tree.operator.type === EQUAL_EQUAL_EQUAL) {
      // `a === b` -> `identical(a, b)`
      return createCallExpression(createIdentifierExpression('identical'),
                                  createArgumentList([tree.left, tree.right]));
    }

    if (tree.operator.type === NOT_EQUAL_EQUAL) {
      // `a !== b` -> `!identical(a, b)`
      // TODO(vojta): do this in a cleaner way.
      return createCallExpression(createIdentifierExpression('!identical'),
                                  createArgumentList([tree.left, tree.right]));
    }

    return tree;
  }
}
github angular / angular / tools / transpiler / src / dart_class_transformer.js View on Github external
transformBinaryExpression(tree) {
    tree.left = this.transformAny(tree.left);
    tree.right = this.transformAny(tree.right);
    if (tree.operator.type === 'instanceof') {
      // a instanceof b -> a is b
      // TODO(vojta): do this in a cleaner way.
      tree.operator.type = 'is';
      return tree;
    } else if (tree.operator.type === EQUAL_EQUAL_EQUAL) {
      // a === b -> identical(a, b)
      return createCallExpression(createIdentifierExpression('identical'), createArgumentList([tree.left, tree.right]));
    } else if (tree.operator.type === NOT_EQUAL_EQUAL) {
      // a !== b -> !identical(a, b)
      // TODO(vojta): do this in a cleaner way.
      return createCallExpression(createIdentifierExpression('!identical'), createArgumentList([tree.left, tree.right]));
    } else {
      return tree;
    }
  };