-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
doc: some WASM documentation #23810
base: master
Are you sure you want to change the base?
doc: some WASM documentation #23810
Conversation
Connected to Huly®: V_0.6-22219 |
pub type LabelIndex = int | ||
|
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.
why delete that?
pub fn (mut func Function) unreachable() { | ||
func.code << 0x00 | ||
func.code << 0x00 // unreachable | ||
} | ||
|
||
// nop instruction, does nothing. | ||
// WebAssembly instruction: `nop`. | ||
pub fn (mut func Function) nop() { | ||
func.code << 0x01 | ||
func.code << 0x01 // nop | ||
} |
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.
that clarifies nothing - the method is already named that
pub fn (mut func Function) c_return() { | ||
func.code << 0x0F // return | ||
} | ||
|
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.
why move the method, especially in a PR that is titled "some WASM documentation"?
enum Subsection as u8 { | ||
name_module | ||
name_function | ||
name_local | ||
// see: https://github.com/WebAssembly/extended-name-section |
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.
why move the comment?
is not its position chosen because the values that follow are mentioned in the link?
v128_t = 0x7b // 128-bit vector (SIMD) | ||
funcref_t = 0x70 // Function reference | ||
externref_t = 0x6f // External reference | ||
} | ||
|
||
// RefType represents reference types in WebAssembly. | ||
pub enum RefType as u8 { | ||
funcref_t = 0x70 | ||
externref_t = 0x6f | ||
funcref_t = 0x70 // Function reference | ||
externref_t = 0x6f // External reference |
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.
there is no need for those comments - they clarify nothing, just duplicate the already existing names, and make it arguably harder to read (more info to absorb, that is slightly different, so you have to think about the difference, rather than just ignore it ...)
functypes []FuncType // Unique function type signatures | ||
functions map[string]Function // Named functions defined in the module | ||
globals []Global // Global variables | ||
memory ?Memory // Single memory instances (Make it a array for multiple memories) |
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.
memory ?Memory // Single memory instances (Make it a array for multiple memories) | |
memory ?Memory // Single memory instances (Make it a array for multiple memories) |
that is not needed too and makes it more confusing - anyone reading that code should know that ?Type
is a single thing, and that []Type
means an array of potentially several. Putting that comment makes the reader think about why that is mentioned specifically, when it is obvious.
functions map[string]Function // Named functions defined in the module | ||
globals []Global // Global variables | ||
memory ?Memory // Single memory instances (Make it a array for multiple memories) | ||
start ?string // Optional start function name |
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.
start ?string // Optional start function name | |
start ?string // start function name |
global_imports []GlobalImport // Imported globals | ||
segments []DataSegment // Data segments (active or passive) | ||
debug bool // Whether to include debug info | ||
mod_name ?string // Optional module name for debug info |
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.
mod_name ?string // Optional module name for debug info | |
mod_name ?string // module name for debug info |
there is no need to duplicate info that is already present in the type itself
fn_imports []FunctionImport // Imported functions | ||
global_imports []GlobalImport // Imported globals |
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.
are those really needed?
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.
imho the names of the fields are good enough, without the comments
pub mut: | ||
export_name ?string | ||
export_name ?string // Optional export name (defaults to name if unset) |
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.
export_name ?string // Optional export name (defaults to name if unset) | |
export_name ?string // export name (defaults to name if unset) |
typ ValType | ||
name ?string | ||
typ ValType // Type of the local (e.g., i32, v128) | ||
name ?string // Optional name for debug info |
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.
name ?string // Optional name for debug info | |
name ?string // name for debug info |
mod.buf << 0x60 // function type indicator | ||
mod.buf << 0x60 // Function type indicator |
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.
why capitalize inline comments?
$compile_error('values can only be int, i32, i64, f32, f64') | ||
$compile_error('Constant expressions only support be int, i32, i64, f32 and f64') |
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.
the previous error was clearer
This module does not perform verification of the WebAssembly output. | ||
This module does not perform verification of the WebAssembly output, yet. |
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.
there is no need of the yet
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.
it either does, or it does not
os.write_file_array('add.wasm', mod)! | ||
os.write_file_array('add.wasm', mod) or { panic('Write failed: ${err}') } |
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.
The previous line was clearer - in an example like that, clarity of the main purpose is important, and just ! to propagate the potential error is clearer, since the error handling is not the main point of the example.
max ?u32 | ||
name string // Name for debugging or export | ||
export bool // Whether to export the memory | ||
min u32 // Minimum size in pages (64KiB each) |
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.
Are you sure, that it is in pages, and not in bytes?
just some docs and better messages for assets.