Commit f95b2632 authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[torque] fix assignment with operator

Change-Id: I4710d317cf9f5686551a3df6e98619bab79387fa
Reviewed-on: https://chromium-review.googlesource.com/1156698
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54827}
parent 6d0c017e
...@@ -491,7 +491,7 @@ VisitResult ImplementationVisitor::Visit(AssignmentExpression* expr) { ...@@ -491,7 +491,7 @@ VisitResult ImplementationVisitor::Visit(AssignmentExpression* expr) {
GenerateFetchFromLocation(expr->location, location_ref); GenerateFetchFromLocation(expr->location, location_ref);
assignment_value = Visit(expr->value); assignment_value = Visit(expr->value);
Arguments args; Arguments args;
args.parameters = {assignment_value, assignment_value}; args.parameters = {location_value, assignment_value};
assignment_value = GenerateCall(*expr->op, args); assignment_value = GenerateCall(*expr->op, args);
GenerateAssignToLocation(expr->location, location_ref, assignment_value); GenerateAssignToLocation(expr->location, location_ref, assignment_value);
} else { } else {
......
...@@ -702,7 +702,7 @@ base::Optional<ParseResult> MakeNameAndType( ...@@ -702,7 +702,7 @@ base::Optional<ParseResult> MakeNameAndType(
base::Optional<ParseResult> ExtractAssignmentOperator( base::Optional<ParseResult> ExtractAssignmentOperator(
ParseResultIterator* child_results) { ParseResultIterator* child_results) {
auto op = child_results->NextAs<std::string>(); auto op = child_results->NextAs<std::string>();
base::Optional<std::string> result = std::string(op.begin() + 1, op.end()); base::Optional<std::string> result = std::string(op.begin(), op.end() - 1);
return ParseResult(std::move(result)); return ParseResult(std::move(result));
} }
......
...@@ -303,24 +303,24 @@ module test { ...@@ -303,24 +303,24 @@ module test {
// are (not) present. // are (not) present.
macro TestForLoop() { macro TestForLoop() {
let sum: Smi = 0; let sum: Smi = 0;
for (let i: Smi = 0; i < 5; ++i) sum = sum + i; for (let i: Smi = 0; i < 5; ++i) sum += i;
check(sum == 10); check(sum == 10);
sum = 0; sum = 0;
let j: Smi = 0; let j: Smi = 0;
for (; j < 5; ++j) sum = sum + j; for (; j < 5; ++j) sum += j;
check(sum == 10); check(sum == 10);
sum = 0; sum = 0;
j = 0; j = 0;
for (; j < 5;) sum = sum + j++; for (; j < 5;) sum += j++;
check(sum == 10); check(sum == 10);
// Check that break works. No test expression. // Check that break works. No test expression.
sum = 0; sum = 0;
for (let i: Smi = 0;; ++i) { for (let i: Smi = 0;; ++i) {
if (i == 5) break; if (i == 5) break;
sum = sum + i; sum += i;
} }
check(sum == 10); check(sum == 10);
...@@ -328,7 +328,7 @@ module test { ...@@ -328,7 +328,7 @@ module test {
j = 0; j = 0;
for (;;) { for (;;) {
if (j == 5) break; if (j == 5) break;
sum = sum + j; sum += j;
j++; j++;
} }
check(sum == 10); check(sum == 10);
...@@ -338,7 +338,7 @@ module test { ...@@ -338,7 +338,7 @@ module test {
sum = 0; sum = 0;
for (let i: Smi = 0; i < 5; ++i) { for (let i: Smi = 0; i < 5; ++i) {
if (i == 3) continue; if (i == 3) continue;
sum = sum + i; sum += i;
} }
check(sum == 7); check(sum == 7);
...@@ -346,7 +346,7 @@ module test { ...@@ -346,7 +346,7 @@ module test {
j = 0; j = 0;
for (; j < 5; ++j) { for (; j < 5; ++j) {
if (j == 3) continue; if (j == 3) continue;
sum = sum + j; sum += j;
} }
check(sum == 7); check(sum == 7);
...@@ -357,7 +357,7 @@ module test { ...@@ -357,7 +357,7 @@ module test {
j++; j++;
continue; continue;
} }
sum = sum + j; sum += j;
j++; j++;
} }
check(sum == 7); check(sum == 7);
...@@ -366,7 +366,7 @@ module test { ...@@ -366,7 +366,7 @@ module test {
for (let i: Smi = 0;; ++i) { for (let i: Smi = 0;; ++i) {
if (i == 3) continue; if (i == 3) continue;
if (i == 5) break; if (i == 5) break;
sum = sum + i; sum += i;
} }
check(sum == 7); check(sum == 7);
...@@ -379,7 +379,7 @@ module test { ...@@ -379,7 +379,7 @@ module test {
} }
if (j == 5) break; if (j == 5) break;
sum = sum + j; sum += j;
j++; j++;
} }
check(sum == 7); check(sum == 7);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment