How to use the lua-types.nilLiteral 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 UnaryExpression(node) {
  switch (node.operator) {
    case 'void':
      return t.binaryExpression('and', this.transform(node.argument), t.nilLiteral());
    case 'delete':
      return t.assignmentStatement([this.transform(node.argument)], [t.nilLiteral()]);
    case '!':
      return t.unaryExpression('not', this.transform(node.argument));
    case '+':
      return t.callExpression(t.identifier('tonumber'), [this.transform(node.argument)]);
    case '-':
    case '~':
      return t.unaryExpression(node.operator, this.transform(node.argument));
    default:
      // FIXME: Use path.buildCodeFrameError
      throw new Error(`${node.operator} is unsupported unary operator`);
  }
}
github ark120202 / babel-lua / packages / babel-plugin-lua-generator / src / transformers / types.js View on Github external
export function Identifier(node) {
  if (node.name === 'undefined') return t.nilLiteral();
  return t.identifier(node.name);
}