-
Notifications
You must be signed in to change notification settings - Fork 38
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
C API function type #557
C API function type #557
Conversation
5cd07b1
to
9c3ee98
Compare
Codecov Report
@@ Coverage Diff @@
## master #557 +/- ##
==========================================
- Coverage 98.26% 98.26% -0.01%
==========================================
Files 63 63
Lines 9238 9282 +44
==========================================
+ Hits 9078 9121 +43
- Misses 160 161 +1 |
9c3ee98
to
04f67e6
Compare
2012ccf
to
baa54bc
Compare
baa54bc
to
7f57cea
Compare
7f57cea
to
0e2ac03
Compare
0e2ac03
to
e94168c
Compare
|
||
inline fizzy::FuncType unwrap(const FizzyFunctionType& type) | ||
{ | ||
fizzy::FuncType func_type{std::vector<fizzy::ValType>(type.inputs_size), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could optimize it later on the C++ side to not require vector allocation to pass function type (i.e. replace vector
with span
in fizzy::FuncType
)
9ac35b0
to
c0dc40d
Compare
487bc44
to
963dbba
Compare
6871e47
to
c517410
Compare
dfdbfbf
to
6525b9d
Compare
@@ -108,25 +145,20 @@ void fizzy_free_module(const FizzyModule* module) | |||
delete unwrap(module); | |||
} | |||
|
|||
FizzyFunctionType fizzy_get_function_type(const FizzyModule* module, uint32_t func_idx) | |||
{ | |||
return wrap(unwrap(module)->get_function_type(func_idx)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: get_function_type
returns reference to fizzy::FuncType
stored in module, then wrap
returns pointers to its vector's data.
This will create their copies in each translation unit that includes |
They are going to be used as compile-time constants, unlikely to be emitted at all. |
@gumb0 can you please rebase and squash? |
Done, squashed the last commit. |
include/fizzy/fizzy.h
Outdated
/// Input types array size. | ||
size_t inputs_size; | ||
/// Pointer to output types array. | ||
const FizzyValueType* outputs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ok, but also can be greatly simplified by defining FizzyValueTypeVoid
and using FizzyValueType output_type
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, I'll try it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move it to the front.
static const FizzyValueType FizzyValueTypeF32 = 0x7d; | ||
static const FizzyValueType FizzyValueTypeF64 = 0x7c; | ||
/// Special value, can be used only as function outuput type. | ||
static const FizzyValueType FizzyValueTypeVoid = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defining it as 0
allows user to create void type with no params as {}
, at least in C++, probably in C, too.
include/fizzy/fizzy.h
Outdated
/// Function type. | ||
typedef struct FizzyFunctionType | ||
{ | ||
/// Output type, can be FizzyValueTypeVoid, if function has no output. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Output type, can be FizzyValueTypeVoid, if function has no output. | |
/// Output type, equals to FizzyValueTypeVoid, if function has no output. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
/// defined in module. | ||
/// | ||
/// @note All module function indices are greater than all imported function indices. | ||
FizzyFunctionType fizzy_get_function_type(const FizzyModule* module, uint32_t func_idx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens on invalid index?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a sentence.
Needs rebase. |
Rebased. |
95246c5
to
9991225
Compare
include/fizzy/fizzy.h
Outdated
/// | ||
/// @param module Pointer to module. | ||
/// @param func_idx Function index. Can be either index of an imported function or of a function | ||
/// defined in module. Behaviour is undefined, index is not valid according to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// defined in module. Behaviour is undefined, index is not valid according to | |
/// defined in module. Behaviour is undefined if index is not valid according to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks okayish to me.
No description provided.