How to use the lua-types.memberExpression 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 / statements.js View on Github external
export function ForOfStatement(node) {
  const variable = bt.isVariableDeclaration(node.left)
    ? this.transform(node.left.declarations[0].id)
    : this.transform(node.left);
  const helper = t.memberExpression(t.identifier('Reflect'), ':', t.identifier('__forOf'));

  let uid = node[FOR_OF_UID];
  // TODO: Apply visitor before transform in testing
  if (uid == null && process.env.NODE_ENV === 'test') uid = bt.identifier('_');
  if (uid == null) throw new Error('UID not found for ForOfStatement transform');

  return t.forGenericStatement(
    [this.transform(uid), variable],
    [t.callExpression(helper, [this.transform(node.right)])],
    this.transformBlock(node.body),
  );
}
github ark120202 / babel-lua / packages / babel-plugin-lua-generator / src / transformers / expressions.js View on Github external
export function MemberExpression(node, parent) {
  if (node.computed) {
    return t.indexExpression(this.transform(node.object), this.transform(node.property));
  }

  // Always pass context in calls, since most of Lua apis expect it
  const indexer =
    bt.isCallExpression(parent) && parent.callee === node && !node[NO_CONTEXT] ? ':' : '.';
  return t.memberExpression(this.transform(node.object), indexer, this.transform(node.property));
}
github ark120202 / babel-lua / packages / babel-plugin-lua-generator / src / transformers / types.js View on Github external
export function SpreadElement(node) {
  return t.callExpression(t.memberExpression(t.identifier('table'), '.', t.identifier('unpack')), [
    node.argument,
  ]);
}