forked from Mirrors/wasm3
parent
df9aba5bcf
commit
fa9248f70f
@ -0,0 +1,33 @@
|
||||
//
|
||||
// m3_function.c
|
||||
//
|
||||
// Created by Steven Massey on 4/7/21.
|
||||
// Copyright © 2021 Steven Massey. All rights reserved.
|
||||
//
|
||||
|
||||
#include "m3_function.h"
|
||||
|
||||
|
||||
|
||||
M3Result AllocFuncType (IM3FuncType * o_functionType, u32 i_numTypes)
|
||||
{
|
||||
*o_functionType = (IM3FuncType) m3_Malloc (sizeof (M3FuncType) + i_numTypes);
|
||||
return (*o_functionType) ? m3Err_none : m3Err_mallocFailed;
|
||||
}
|
||||
|
||||
|
||||
bool AreFuncTypesEqual (const IM3FuncType i_typeA, const IM3FuncType i_typeB)
|
||||
{
|
||||
if (i_typeA->numRets == i_typeB->numRets && i_typeA->numArgs == i_typeB->numArgs)
|
||||
{
|
||||
return (memcmp (i_typeA->types, i_typeB->types, i_typeA->numRets + i_typeA->numArgs) == 0);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 GetFuncTypeNumReturns (const IM3FuncType i_funcType)
|
||||
{
|
||||
return i_funcType ? i_funcType->numRets : 0;
|
||||
}
|
||||
|
@ -0,0 +1,35 @@
|
||||
//
|
||||
// m3_function.h
|
||||
//
|
||||
// Created by Steven Massey on 4/7/21.
|
||||
// Copyright © 2021 Steven Massey. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef m3_function_h
|
||||
#define m3_function_h
|
||||
|
||||
#include "m3_core.h"
|
||||
|
||||
d_m3BeginExternC
|
||||
|
||||
|
||||
typedef struct M3FuncType
|
||||
{
|
||||
struct M3FuncType * next;
|
||||
|
||||
u32 numRets;
|
||||
u32 numArgs;
|
||||
u8 types []; // returns, then args
|
||||
}
|
||||
M3FuncType;
|
||||
|
||||
typedef M3FuncType * IM3FuncType;
|
||||
|
||||
|
||||
M3Result AllocFuncType (IM3FuncType * o_functionType, u32 i_numTypes);
|
||||
bool AreFuncTypesEqual (const IM3FuncType i_typeA, const IM3FuncType i_typeB);
|
||||
u32 GetFuncTypeNumReturns (const IM3FuncType i_funcType);
|
||||
|
||||
d_m3EndExternC
|
||||
|
||||
#endif /* m3_function_h */
|
Loading…
Reference in new issue