jserv / amacc

Small C Compiler generating ELF executable Arm architecture, supporting JIT execution
Other
1.01k stars 159 forks source link

Add compound assignment #35

Closed yodalee closed 6 years ago

yodalee commented 6 years ago

Add support to compound assignment +=, -=, *=. However, single line with multiple compound assignment to same variable will not work in this implementation. like: a += a += 10;

jserv commented 6 years ago

Fix CI failure and append test cases.

yodalee commented 6 years ago

It is interesting that I cannot reproduce the error on my computer. I think I need more time to investigate it. The expression a += a += 10 is perfectly legal according to standard. Though it is stupid to write like that. I think we can ignore it. It is still possible to implement it by adding some new opcode I think.

yodalee commented 6 years ago

Oh great. I update to upstream and I can reproduce the error now.

jserv commented 6 years ago

@yodalee, why would you like to introduce new opcodes? And, how do the proposed opcode look like?

yodalee commented 6 years ago

Update to solve the regression fail. The reason is actually stupid: amacc currently require variable declaration appears before statement.

jserv commented 6 years ago

The reason is actually stupid: amacc currently require variable declaration appears before statement.

Issue #36 aims to resolve such known restriction.

jserv commented 6 years ago

@yodalee, Please append new test cases as well.

yodalee commented 6 years ago

Update some tiny test to compound assign. About the new opcode to solve the expression a += a += 10. I think I need some time to consider about it.

yodalee commented 6 years ago

Updated.

yodalee commented 6 years ago

Thanks @jserv