Sha256: 16415a62a91dba5ebad984f6d3fe8085ed7911078fd654361abce61051fc938c

Contents?: true

Size: 934 Bytes

Versions: 4

Compression:

Stored size: 934 Bytes

Contents

import Node from '../Node.js';
import checkConst from '../../utils/checkConst.js';

export default class UpdateExpression extends Node {
	initialise(transforms) {
		if (this.argument.type === 'Identifier') {
			const declaration = this.findScope(false).findDeclaration(
				this.argument.name
			);
			// special case – https://gitlab.com/Rich-Harris/buble/issues/150
			const statement = declaration && declaration.node.ancestor(3);
			if (
				statement &&
				statement.type === 'ForStatement' &&
				statement.body.contains(this)
			) {
				statement.reassigned[this.argument.name] = true;
			}
		}

		super.initialise(transforms);
	}

	transpile(code, transforms) {
		if (this.argument.type === 'Identifier') {
			// Do this check after everything has been initialized to find
			// shadowing declarations after this expression
			checkConst(this.argument, this.findScope(false));
		}
		super.transpile(code, transforms);
	}
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jass-0.9.5 vendor/node_modules/buble/src/program/types/UpdateExpression.js
jass-0.9.4 vendor/node_modules/buble/src/program/types/UpdateExpression.js
jass-0.9.3 vendor/node_modules/buble/src/program/types/UpdateExpression.js
jass-0.9.1 vendor/node_modules/buble/src/program/types/UpdateExpression.js