euddraft
euddraft copied to clipboard
var -= ConstExpr causes OverflowError
Only reproducible when Cython enabled:
function afterTriggerExec() {
var x;
x -= Db(4);
}
[1/3 Step] Collecting objects... ========================================== [Error] Python int too large to convert to C unsigned long Traceback (most recent call last): File "E:\euddraft\applyeuddraft.py", line 186, in applyEUDDraft ep.SaveMap(ofname, payloadMain, sectorSize=sectorSize) File "C:\Py\lib\site-packages\eudplib-0.67.1-py3.8-win32.egg\eudplib\maprw\savemap.py", line 73, in SaveMap applyInjector(chkt, root) File "C:\Py\lib\site-packages\eudplib-0.67.1-py3.8-win32.egg\eudplib\maprw\injector\applyInjector.py", line 52, in applyInjector payload = c.CreatePayload(root) File "C:\Py\lib\site-packages\eudplib-0.67.1-py3.8-win32.egg\eudplib\core\allocator\payload.py", line 376, in CreatePayload CollectObjects(root) File "C:\Py\lib\site-packages\eudplib-0.67.1-py3.8-win32.egg\eudplib\core\allocator\payload.py", line 160, in CollectObjects obj.CollectDependency(objc) File "C:\Py\lib\site-packages\eudplib-0.67.1-py3.8-win32.egg\eudplib\core\rawtrigger\rawtriggerdef.py", line 149, in CollectDependency act.CollectDependency(pbuffer) File "C:\Py\lib\site-packages\eudplib-0.67.1-py3.8-win32.egg\eudplib\core\rawtrigger\action.py", line 141, in CollectDependency wdw(fld[5]) File "C:\Py\lib\site-packages\eudplib-0.67.1-py3.8-win32.egg\eudplib\core\allocator\payload.py", line 112, in WriteDword constexpr.Evaluate(number) File "eudplib\core\allocator\constexpr.pyx", line 216, in eudplib.core.allocator.constexpr.Evaluate File "eudplib\core\allocator\constexpr.pyx", line 221, in eudplib.core.allocator.constexpr.Evaluate File "eudplib\core\allocator\constexpr.pyx", line 52, in eudplib.core.allocator.constexpr.ConstExpr.Evaluate File "eudplib\core\allocator\constexpr.pyx", line 53, in eudplib.core.allocator.constexpr.ConstExpr.Evaluate File "eudplib\core\allocator\rlocint.pyx", line 80, in eudplib.core.allocator.rlocint.RlocInt_C.__mul__ File "eudplib\core\allocator\rlocint.pyx", line 35, in eudplib.core.allocator.rlocint.RlocInt_C.__cinit__ OverflowError: Python int too large to convert to C unsigned long
- [ ] Negative
ConstExpr.rlocmode
loss its signedness - [ ]
4 * 4294967292 = 17179869168
is too large forsize_t rlocmode
ofRlocInt_C
Another footgun example)
const array = EUDArray(8);
function afterTriggerExec() {
setcurpl(P1);
const x = dwread_cp(EPD(array));
}
Falsy optimization by negating ConstExpr
class EUDVariable(VariableBase):
def __sub__(self, other):
t = EUDVariable()
# FIXME: unsupported EUD error after EUDStruct.free() with IsConstExpr
if isinstance(other, int):
SeqCompute(
[
(t, bt.SetTo, -other),
(t, bt.Add, self),
]
)
else:
SeqCompute(
[
(t, bt.SetTo, 0xFFFFFFFF),
(t, bt.Subtract, other),
(t, bt.Add, 1),
(t, bt.Add, self),
]
)
return t.makeR()