How to use the babel-types.assignmentExpression function in babel-types

To help you get started, we’ve selected a few babel-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 ifgyong / demo / React-native / Helloword / node_modules / babel-plugin-transform-regenerator / node_modules / regenerator-transform / src / emit.js View on Github external
expr.operator,
                // Can't (and don't need to) break up the syntax of the argument.
                // Think about delete a[b].
                self.explodeExpression(path.get("argument")),
                !!expr.prefix
            ));

        case "BinaryExpression":
            return finish(t.binaryExpression(
                expr.operator,
                explodeViaTempVar(null, path.get("left")),
                explodeViaTempVar(null, path.get("right"))
            ));

        case "AssignmentExpression":
            return finish(t.assignmentExpression(
                expr.operator,
                self.explodeExpression(path.get("left")),
                self.explodeExpression(path.get("right"))
            ));

        case "UpdateExpression":
            return finish(t.updateExpression(
                expr.operator,
                self.explodeExpression(path.get("argument")),
                expr.prefix
            ));

        case "YieldExpression":
            after = loc();
            let arg = expr.argument && self.explodeExpression(path.get("argument"));
github babel / babel / packages / babel-core / src / transformation / modules / lib / remaps.js View on Github external
UpdateExpression(node, parent, scope, { formatter }) {
    let exported = formatter.getExport(node.argument, scope);
    if (!exported) return;

    this.skip();

    // expand to long file assignment expression
    let assign = t.assignmentExpression(node.operator[0] + "=", node.argument, t.numberLiteral(1));

    // remap this assignment expression
    let remapped = formatter.remapExportAssignment(assign, exported);

    // we don't need to change the result
    if (t.isExpressionStatement(parent) || node.prefix) {
      return remapped;
    }

    let nodes = [];
    nodes.push(remapped);

    let operator;
    if (node.operator === "--") {
      operator = "+";
    } else { // "++"
github roman01la / html-to-react-components / lib / module.js View on Github external
function toCJSModule(name, component, children, delimiter) {
  var modules = [getCJSImportDeclaration("React", "react")].concat(
    children.map(function(child) {
      return getCJSImportDeclaration(
        child,
        "./" + toFileName(delimiter, child)
      );
    })
  );

  return t.program(
    modules.concat([
      component,
      t.expressionStatement(
        t.assignmentExpression(
          "=",
          t.memberExpression(t.identifier("module"), t.identifier("exports")),
          t.identifier(name)
        )
      )
    ])
  );
}
github plasma-umass / Stopify / src / callcc / toModule.ts View on Github external
function fakeModule(path: NodePath) {
  const isStop = t.identifier("$isStop");
  const onStop = t.identifier("$onStop");
  const onDone = t.identifier("$onDone");
  const opts = t.identifier("$opts");

  path.node.body.push(t.returnStatement(t.callExpression(onDone, [])));

  path.node.body = [t.expressionStatement(
    t.assignmentExpression(
      '=',
      t.memberExpression(t.identifier('module'), t.identifier('exports')),
      t.functionExpression(
        void 0,
        [isStop, onStop, onDone, opts], 
        t.blockStatement(path.node.body))))];
}
const visitor: Visitor = {
github Tencent / omi / packages / cax-omip / scripts / taro-transformer-wx / lib / src / class.js View on Github external
}
                            classBody.push(t.classProperty(t.identifier(anonymousFuncName + 'Array'), t.arrayExpression([])));
                            const arrayFunc = t.memberExpression(t.memberExpression(t.thisExpression(), t.identifier(anonymousFuncName + 'Array')), t.identifier(index.name), true);
                            classBody.push(t.classMethod('method', t.identifier(anonymousFuncName), [t.identifier(index.name), t.identifier('e')], t.blockStatement([
                                isCatch ? t.expressionStatement(t.callExpression(t.memberExpression(t.identifier('e'), t.identifier('stopPropagation')), [])) : t.emptyStatement(),
                                t.expressionStatement(t.logicalExpression('&&', arrayFunc, t.callExpression(arrayFunc, [t.identifier('e')])))
                            ])));
                            exprPath.replaceWith(t.callExpression(t.memberExpression(t.memberExpression(t.thisExpression(), t.identifier(anonymousFuncName)), t.identifier('bind')), [t.thisExpression(), t.identifier(index.name)]));
                            stemParent.insertBefore(t.expressionStatement(t.assignmentExpression('=', arrayFunc, expr)));
                        }
                        else {
                            classBody.push(t.classMethod('method', t.identifier(anonymousFuncName), [t.identifier('e')], t.blockStatement([
                                isCatch ? t.expressionStatement(t.callExpression(t.memberExpression(t.identifier('e'), t.identifier('stopPropagation')), [])) : t.emptyStatement()
                            ])));
                            exprPath.replaceWith(t.memberExpression(t.thisExpression(), t.identifier(anonymousFuncName)));
                            stemParent.insertBefore(t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier(anonymousFuncName)), expr)));
                        }
                    }
                    else {
                        throw utils_1.codeFrameError(path.node, '组件事件传参只能在使用匿名箭头函数,或使用类作用域下的确切引用(this.handleXX || this.props.handleXX),或使用 bind。');
                    }
                }
                const jsx = path.findParent(p => p.isJSXOpeningElement());
                if (!jsx)
                    return;
                const jsxName = jsx.node.name;
                if (!t.isJSXIdentifier(jsxName))
                    return;
                if (expression.isJSXElement())
                    return;
                if (constant_1.DEFAULT_Component_SET.has(jsxName.name) || expression.isIdentifier() || expression.isMemberExpression() || expression.isLiteral() || expression.isLogicalExpression() || expression.isConditionalExpression() || key.name.startsWith('on') || expression.isCallExpression())
                    return;
github Tencent / omi / packages / omip / my-app-ts / scripts / taro-transformer-wx / lib / src / class.js View on Github external
const loopCallExpr = path.findParent(p => utils_1.isArrayMapCallExpression(p));
                        let index;
                        if (loopCallExpr) {
                            index = lodash_1.get(loopCallExpr, 'node.arguments[0].params[1]');
                            if (!t.isIdentifier(index)) {
                                index = t.identifier('__index' + counter);
                                lodash_1.set(loopCallExpr, 'node.arguments[0].params[1]', index);
                            }
                            classBody.push(t.classProperty(t.identifier(anonymousFuncName + 'Array'), t.arrayExpression([])));
                            const arrayFunc = t.memberExpression(t.memberExpression(t.thisExpression(), t.identifier(anonymousFuncName + 'Array')), t.identifier(index.name), true);
                            classBody.push(t.classMethod('method', t.identifier(anonymousFuncName), [t.identifier(index.name), t.identifier('e')], t.blockStatement([
                                isCatch ? t.expressionStatement(t.callExpression(t.memberExpression(t.identifier('e'), t.identifier('stopPropagation')), [])) : t.emptyStatement(),
                                t.expressionStatement(t.logicalExpression('&&', arrayFunc, t.callExpression(arrayFunc, [t.identifier('e')])))
                            ])));
                            exprPath.replaceWith(t.callExpression(t.memberExpression(t.memberExpression(t.thisExpression(), t.identifier(anonymousFuncName)), t.identifier('bind')), [t.thisExpression(), t.identifier(index.name)]));
                            stemParent.insertBefore(t.expressionStatement(t.assignmentExpression('=', arrayFunc, expr)));
                        }
                        else {
                            classBody.push(t.classMethod('method', t.identifier(anonymousFuncName), [t.identifier('e')], t.blockStatement([
                                isCatch ? t.expressionStatement(t.callExpression(t.memberExpression(t.identifier('e'), t.identifier('stopPropagation')), [])) : t.emptyStatement()
                            ])));
                            exprPath.replaceWith(t.memberExpression(t.thisExpression(), t.identifier(anonymousFuncName)));
                            stemParent.insertBefore(t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier(anonymousFuncName)), expr)));
                        }
                    }
                    else {
                        throw utils_1.codeFrameError(path.node, '组件事件传参只能在使用匿名箭头函数,或使用类作用域下的确切引用(this.handleXX || this.props.handleXX),或使用 bind。');
                    }
                }
                const jsx = path.findParent(p => p.isJSXOpeningElement());
                if (!jsx)
                    return;
github sx1989827 / DOClever / SBDocClient / node_modules / regenerator-transform / src / emit.js View on Github external
let keyIterNextFn = self.makeTempVar();
    self.emitAssign(
      keyIterNextFn,
      t.callExpression(
        util.runtimeProperty("keys"),
        [self.explodeExpression(path.get("right"))]
      )
    );

    self.mark(head);

    let keyInfoTmpVar = self.makeTempVar();
    self.jumpIf(
      t.memberExpression(
        t.assignmentExpression(
          "=",
          keyInfoTmpVar,
          t.callExpression(keyIterNextFn, [])
        ),
        t.identifier("done"),
        false
      ),
      after
    );

    self.emitAssign(
      stmt.left,
      t.memberExpression(
        keyInfoTmpVar,
        t.identifier("value"),
        false
github kgrz / babel-plugin-console-perf / index.js View on Github external
const assignArgument = (identifier, argument, opts) => {
	if (opts.blockDepth === 1) {
		return t.variableDeclaration(
			'let',
			[
				t.variableDeclarator(
					t.identifier('_babel_temp_alias'),
					argument
				)
			]
		);
	} else {
		return t.expressionStatement(
			t.assignmentExpression(
				"=",
				t.identifier('_babel_temp_alias'),
				argument
			)
		);
	}
}
github babel / babel / packages / babel-core / src / transformation / transformers / es6 / object-super.js View on Github external
ObjectExpression(node, parent, scope, file) {
    var objectRef;
    var getObjectRef = () => objectRef = objectRef || scope.generateUidIdentifier("obj");

    var propPaths = this.get("properties");
    for (var i = 0; i < node.properties.length; i++) {
      Property(propPaths[i], node.properties[i], scope, getObjectRef, file);
    }

    if (objectRef) {
      scope.push({ id: objectRef });
      return t.assignmentExpression("=", objectRef, node);
    }
  }
};