How to use the lua-types.binaryExpression function in lua-types

To help you get started, we’ve selected a few lua-types 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 ark120202 / babel-lua / packages / babel-plugin-lua-generator / src / transformers / expressions.js View on Github external
export function UpdateExpression(node, parent) {
  if (!bt.isExpressionStatement(parent)) {
    // FIXME: Use path.buildCodeFrameError
    throw new Error("UpdateExpression's not in ExpressionStatement's are not supported.");
  }
  if (node.operator !== '++' && node.operator !== '--') {
    // FIXME: Use path.buildCodeFrameError
    throw new Error(`Invalid UpdateExpression operator ${node.operator}`);
  }

  const right = t.binaryExpression(
    node.operator === '++' ? '+' : '-',
    this.transform(node.argument),
    t.numericLiteral(1),
  );
  return t.assignmentStatement([this.transform(node.argument)], [right]);
}
github ark120202 / babel-lua / packages / babel-plugin-lua-generator / src / transformers / expressions.js View on Github external
export function LogicalExpression(node) {
  if (node.operator !== '&&' && node.operator !== '||') {
    // FIXME: Use path.buildCodeFrameError
    throw new Error(`${node.operator} is unsupported logical operator`);
  }
  const operator = node.operator === '&&' ? 'and' : 'or';
  return t.binaryExpression(operator, this.transform(node.left), this.transform(node.right));
}
github ark120202 / babel-lua / packages / babel-plugin-lua-generator / src / transformers / expressions.js View on Github external
export function BinaryExpression(node) {
  const operator = operatorMap.has(node.operator) ? operatorMap.get(node.operator) : node.operator;
  return t.binaryExpression(operator, this.transform(node.left), this.transform(node.right));
}