Merge pull request #11 from kavika13/master

Implement trap on indirect call type mismatch
extensions
Volodymyr Shymanskyy 5 years ago committed by GitHub
commit 99f6011137
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -149,6 +149,7 @@ d_m3ErrorConst (trapOutOfBoundsMemoryAccess, "[trap] out of bounds memory acc
d_m3ErrorConst (trapDivisionByZero, "[trap] integer divide by zero")
d_m3ErrorConst (trapIntegerOverflow, "[trap] integer overflow")
d_m3ErrorConst (trapIntegerConversion, "[trap] invalid conversion to integer")
d_m3ErrorConst (trapIndirectCallTypeMismatch, "[trap] indirect call type mismatch")
d_m3ErrorConst (trapTableIndexOutOfRange, "[trap] undefined element")
d_m3ErrorConst (trapExit, "[trap] program called exit")
d_m3ErrorConst (trapUnreachable, "[trap] unreachable executed")

@ -43,7 +43,6 @@ d_m3OpDef (Call)
}
// TODO: should trap "indirect call type mismatch"
d_m3OpDef (CallIndirect)
{
IM3Module module = immediate (IM3Module);
@ -62,6 +61,24 @@ d_m3OpDef (CallIndirect)
if (function)
{
if (type->numArgs != function->funcType->numArgs)
{
return c_m3Err_trapIndirectCallTypeMismatch;
}
if (type->returnType != function->funcType->returnType)
{
return c_m3Err_trapIndirectCallTypeMismatch;
}
for (u32 argIndex = 0; argIndex < type->numArgs; ++argIndex)
{
if (type->argTypes[argIndex] != function->funcType->argTypes[argIndex])
{
return c_m3Err_trapIndirectCallTypeMismatch;
}
}
if (not function->compiled)
r = Compile_Function (function);

Loading…
Cancel
Save