<commit_before>'use strict';

const Value = require('./Value');
const CompletionRecord = require('./CompletionRecord');
const ClosureValue = require('./values/ClosureValue');
const ObjectValue = require('./values/ObjectValue');
const FutureValue = require('./values/FutureValue');
const RegExpValue = require('./values/RegExpValue');
const PropertyDescriptor = require('./values/PropertyDescriptor');
const ErrorValue = require('./values/ErrorValue');
const ArrayValue = require('./values/ArrayValue');
const EvaluatorInstruction = require('./EvaluatorInstruction');



function *evaluateArrayExpression(e, n, s) {
	//let result = new ObjectValue();
	let result = new Array(n.elements.length);
	for ( let i = 0; i < n.elements.length; ++i ) {
		if ( n.elements[i] ) {
			result[i] = yield * e.branch(n.elements[i], s);
		}
	}
	if ( e.yieldPower >= 3 ) yield EvaluatorInstruction.stepMinor;
	return ArrayValue.make(result, e.realm);
}

function *evaluateAssignmentExpression(e, n, s) {
	//TODO: Account for not-strict mode
	var realm = s.realm;
	let ref = yield * e.resolveRef(n.left, s, n.operator === '=');

	if ( !ref && s.strict ) {
		return CompletionRecord.makeReferenceError(s.realm, `Invalid refrence in assignment.`);
	}

	let argument = yield * e.branch(n.right, s);
	let value;
	let cur;
	if ( e.yieldPower >= 3 ) yield EvaluatorInstruction.stepMinor;
	switch ( n.operator ) {
		case '=':
			value = argument;
			break;
		case '+=':
			cur = yield * ref.getValue();
			value = yield * cur.add(argument, realm);
			break;
		case '-=':
			cur = yield * ref.getValue();
			value = yield * cur.subtract(argument, realm);
			break;
		case '*=':
			cur = yield * ref.getValue();
			value = yield * cur.multiply(argument, realm);
			break;
		case '/=':
			cur = yield * ref.getValue();
			value = yield * cur.divide(argument, realm);
			break;
		case '%=':
			cur = yield * ref.getValue();
			value = yield * cur.mod(argument, realm);
			break;
		case '<<=':
			cur = yield * ref.getValue();
			value = yield * cur.shiftLeft(argument, realm);
			break;
		case '>>=':
			cur = yield * ref.getValue();
			value = yield * cur.shiftRight(argument, realm);
			break;
		case '>>>=':
			cur = yield * ref.getValue();
			value = yield * cur.shiftRightZF(argument, realm);
			break;
		case '|=':
			cur = yield * ref.getValue();
			value = yield * cur.bitOr(argument, realm);
			break;
		case '&=':
			cur = yield * ref.getValue();
			value = yield * cur.bitAnd(argument, realm);
			break;
		case '^=':
			cur = yield * ref.getValue();
			value = yield * cur.bitXor(argument, realm);
			break;
		case '**=':
			cur = yield * ref.getValue();
			value = yield * cur.pow(argument, realm);
			break;
		default:
			throw new Error('Unknown assignment operator: ' + n.operator);<commit_msg>fix x *= x *= 2<commit_after>'use strict';

const Value = require('./Value');
const CompletionRecord = require('./CompletionRecord');
const ClosureValue = require('./values/ClosureValue');
const ObjectValue = require('./values/ObjectValue');
const FutureValue = require('./values/FutureValue');
const RegExpValue = require('./values/RegExpValue');
const PropertyDescriptor = require('./values/PropertyDescriptor');
const ErrorValue = require('./values/ErrorValue');
const ArrayValue = require('./values/ArrayValue');
const EvaluatorInstruction = require('./EvaluatorInstruction');



function *evaluateArrayExpression(e, n, s) {
	//let result = new ObjectValue();
	let result = new Array(n.elements.length);
	for ( let i = 0; i < n.elements.length; ++i ) {
		if ( n.elements[i] ) {
			result[i] = yield * e.branch(n.elements[i], s);
		}
	}
	if ( e.yieldPower >= 3 ) yield EvaluatorInstruction.stepMinor;
	return ArrayValue.make(result, e.realm);
}

function *evaluateAssignmentExpression(e, n, s) {
	//TODO: Account for not-strict mode
	var realm = s.realm;
	let ref = yield * e.resolveRef(n.left, s, n.operator === '=');

	if ( !ref && s.strict ) {
		return CompletionRecord.makeReferenceError(s.realm, `Invalid refrence in assignment.`);
	}

	let cur = n.operator == '=' ? Value.undef : yield * ref.getValue();
	let argument = yield * e.branch(n.right, s);
	let value;

	if ( e.yieldPower >= 3 ) yield EvaluatorInstruction.stepMinor;
	switch ( n.operator ) {
		case '=':
			value = argument;
			break;
		case '+=':
			value = yield * cur.add(argument, realm);
			break;
		case '-=':
			value = yield * cur.subtract(argument, realm);
			break;
		case '*=':
			value = yield * cur.multiply(argument, realm);
			break;
		case '/=':
			value = yield * cur.divide(argument, realm);
			break;
		case '%=':
			value = yield * cur.mod(argument, realm);
			break;
		case '<<=':
			value = yield * cur.shiftLeft(argument, realm);
			break;
		case '>>=':
			value = yield * cur.shiftRight(argument, realm);
			break;
		case '>>>=':
			value = yield * cur.shiftRightZF(argument, realm);
			break;
		case '|=':
			value = yield * cur.bitOr(argument, realm);
			break;
		case '&=':
			value = yield * cur.bitAnd(argument, realm);
			break;
		case '^=':
			value = yield * cur.bitXor(argument, realm);
			break;
		case '**=':
			value = yield * cur.pow(argument, realm);
			break;
		default:
			throw new Error('Unknown assignment operator: ' + n.operator);
{'fraction_non_alphanumeric': 0.17043278437380313, 'fraction_numerical': 0.0013404825737265416, 'mean_word_length': 3.713898916967509, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2726341', 'n_tokens_mistral': 1883, 'n_tokens_neox': 1692, 'n_words': 424}