-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A batch of improvements for the '__emit' operator #421
Conversation
…iple of cell size
…ments of type 'local variable'
…s of type 'label'
… arguments) to 'stor.s.pri/alt', 'inc.s', 'dec.s' and 'zero.s'
…ges as "-reference-"
… sign Example: L1: __emit const.pri -L1; Before: error 001: expected token: "-any value-", but found "-L1" After: error 001: expected token: "-any value-", but found "-(-label-)"
There are a few things I'm still not sure about:
__emit casetbl 2 lbl_default;
__emit case 0 lbl_case0;
new x = 0; // This line will become a part of the case table, which is obviously wrong
__emit case 1 lbl_case1; I think it would be better to only allow the use of those instructions in block mode, like this: __emit
{
casetbl 2 :lbl_default
case 0 :lbl_case0
case 1 :lbl_case1
lbl_default:
// ...
lbl_case0:
// ...
lbl_case1:
// ...
} That way it would be impossible to put any other code inbetween case table entries, but this would require adding a new error and I'm not sure how to phrase such error (not a native English speaker) - any help/suggestions on how to properly phrase it would be nice. If and when this is done, it would be possible to improve control over the
|
Ok, I reimplemented the pseudo-opcodes, now all of them can handle array access. I still need help with formulating the error messages in order to improve control over case table entries made with |
Apparently shifting a 32-bit signed value by 31 bits is UB...
Looks good 👍 though I'm not well versed in the new |
What this PR does / why we need it:
Added 'universal' pseudo-opcodes, designed to be primarily used in macros.
load.u.pri/alt
- load value (may be an expression) into PRI/ALT.stor.u.pri/alt
- store value in PRI/ALT into the operand.addr.u.pri/alt
- load operand address into PRI/ALT.push.u
- push value (may be an expression) into the stack.push.adr.u
- obtain operand address and push it into the stack.zero.u
- write value0
into the operand.inc.u
- increase the value stored in the operand by 1.dec.u
- decrease the value stored in the operand by 1.Example:
NOTE: For this purpose I reused error 011 which previously wasn't used anywhere.
Fixed crash (Crash if unused emit native #412) when referencing a previously unused native function.
Removed index check for operands of
lctrl
andsctrl
.Opcodes
stor.s.pri/alt
,inc.s
,dec.s
, andzero.s
don't accept variables and arrays passed by reference anymore.Allowed negative offsets for arguments of type 'local variable' (Operator emit negative values #413).
Added tests.
NOTE: Since the compiler can only display up to 26 errors, I had to split the tests into 7 different *.pwn files (+ the extra one to check the generated bytecode).
Fixed a lot of minor bugs discovered with the newly added tests.
Which issue(s) this PR fixes:
Closes #346
Fixes #412
Fixes #413
What kind of pull this is:
Additional Documentation: