/= %= <<= >>= &= |= ^=
This commit is contained in:
@@ -336,6 +336,9 @@ struct rxcc {
|
|||||||
.CompoundAssignmentMultiplication: [
|
.CompoundAssignmentMultiplication: [
|
||||||
.Token(type: .COMPOUND_ASSIGNMENT_MULTIPLICATION),
|
.Token(type: .COMPOUND_ASSIGNMENT_MULTIPLICATION),
|
||||||
],
|
],
|
||||||
|
.CompoundAssignmentDivision: [
|
||||||
|
.Token(type: .COMPOUND_ASSIGNMENT_DIVISION),
|
||||||
|
],
|
||||||
.CompoundAssignmentModulo: [
|
.CompoundAssignmentModulo: [
|
||||||
.Token(type: .COMPOUND_ASSIGNMENT_MODULO),
|
.Token(type: .COMPOUND_ASSIGNMENT_MODULO),
|
||||||
],
|
],
|
||||||
@@ -820,6 +823,50 @@ struct rxcc {
|
|||||||
text += " movl\t%eax, \(variables[variable]!)(%ebp)\n"
|
text += " movl\t%eax, \(variables[variable]!)(%ebp)\n"
|
||||||
break
|
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:
|
default:
|
||||||
print("ERROR: Unknown assignment type \"\(node.children[0].variant)\"")
|
print("ERROR: Unknown assignment type \"\(node.children[0].variant)\"")
|
||||||
break
|
break
|
||||||
|
|||||||
26
test.c
26
test.c
@@ -1,8 +1,26 @@
|
|||||||
int main() {
|
int main() {
|
||||||
int tomas = 1;
|
int tomas = 8;
|
||||||
int jefferson = 3;
|
tomas /= 2;
|
||||||
tomas *= jefferson;
|
tomas *= 3;
|
||||||
|
tomas %= 7;
|
||||||
|
tomas <<= 7;
|
||||||
|
tomas >>= 1;
|
||||||
|
tomas += 31;
|
||||||
|
tomas &= 21;
|
||||||
|
tomas |= 3;
|
||||||
|
tomas |= 303;
|
||||||
|
tomas ^= 23;
|
||||||
|
tomas ^= 27;
|
||||||
|
tomas &= 302;
|
||||||
|
tomas ^= 392;
|
||||||
|
|
||||||
|
int jefferson;
|
||||||
|
jefferson = 3 + tomas / (~3 - 90);
|
||||||
|
|
||||||
jefferson *= tomas;
|
jefferson *= tomas;
|
||||||
return tomas * jefferson;
|
|
||||||
|
int three = tomas | jefferson;
|
||||||
|
|
||||||
|
return three;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user