/= %= <<= >>= &= |= ^=

This commit is contained in:
2026-02-13 20:02:36 -05:00
parent 1dd755ffcb
commit c0afec233b
2 changed files with 69 additions and 4 deletions

View File

@@ -336,6 +336,9 @@ struct rxcc {
.CompoundAssignmentMultiplication: [
.Token(type: .COMPOUND_ASSIGNMENT_MULTIPLICATION),
],
.CompoundAssignmentDivision: [
.Token(type: .COMPOUND_ASSIGNMENT_DIVISION),
],
.CompoundAssignmentModulo: [
.Token(type: .COMPOUND_ASSIGNMENT_MODULO),
],
@@ -820,6 +823,50 @@ struct rxcc {
text += " movl\t%eax, \(variables[variable]!)(%ebp)\n"
break
case .CompoundAssignmentDivision:
text += " movl\t%eax, %ecx\n" // Move e2 to ecx
text += " movl\t\(variables[variable]!)(%ebp), %eax\n" // Fetch e1 from variable into eax
text += " cdq\n" // Extend eax into edx
text += " idivl\t%ecx\n" // Perform edx:eax / ecx
text += " movl\t%eax, \(variables[variable]!)(%ebp)\n"
break
case .CompoundAssignmentModulo:
text += " movl\t%eax, %ecx\n" // Move e2 to ecx
text += " movl\t\(variables[variable]!)(%ebp), %eax\n" // Fetch e1 from variable into eax
text += " cdq\n" // Extend eax into edx
text += " idivl\t%ecx\n" // Perform edx:eax / ecx
text += " movl\t%edx, \(variables[variable]!)(%ebp)\n"
break
case .CompoundAssignmentBitwiseShiftLeft:
text += " movl\t%eax, %ecx\n" // Move e2 to ecx
text += " movl\t\(variables[variable]!)(%ebp), %eax\n" // Move e2 to ecx
text += " sal \t%cl, %eax\n" // Perform e1 << e2; result in e1
text += " movl\t%eax, \(variables[variable]!)(%ebp)\n" // Move e2 to ecx
break
case .CompoundAssignmentBitwiseShiftRight:
text += " movl\t%eax, %ecx\n" // Move e2 to ecx
text += " movl\t\(variables[variable]!)(%ebp), %eax\n" // Move e2 to ecx
text += " sar \t%cl, %eax\n" // Perform e1 << e2; result in e1
text += " movl\t%eax, \(variables[variable]!)(%ebp)\n" // Move e2 to ecx
break
case .CompoundAssignmentBitwiseAnd:
text += " and \t%eax, \(variables[variable]!)(%ebp)\n"
break
case .CompoundAssignmentBitwiseOr:
text += " or \t%eax, \(variables[variable]!)(%ebp)\n"
break
case .CompoundAssignmentBitwiseXOR:
text += " xor \t%eax, \(variables[variable]!)(%ebp)\n"
break
default:
print("ERROR: Unknown assignment type \"\(node.children[0].variant)\"")
break