-
Notifications
You must be signed in to change notification settings - Fork 267
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
Adds Module.SectionSize and constrains text parsing rules #231
Conversation
This consolidates more code around SectionID, notably consistently getting and using section ID length. This also enforces rules in text parsing such as up to one memory, and imported functions can't be defined after regular ones. Signed-off-by: Adrian Cole <adrian@tetrate.io>
positionModuleExportFunc | ||
positionModuleExportMemory | ||
positionModuleStart | ||
positionImport |
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.
a couple more refactors left (not now) and I'll be able to substitute sectionID for the top-level parsing position, and take these out.
@@ -331,7 +361,7 @@ func (p *moduleParser) addFunctionName(name string) { | |||
// Ex. If there is no signature `(import "" "main" (func))` | |||
// calls onImportFunc here ---^ | |||
func (p *moduleParser) parseImportFunc(tok tokenType, tokenBytes []byte, line, col uint32) (tokenParser, error) { | |||
idx := wasm.Index(len(p.module.ImportSection)) | |||
idx := p.module.SectionSize(wasm.SectionIDImport) |
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.
I have in-flight work to make an import parser. Due to this module.SectionSize
function, I can decouple the parser from needing a reference to the module via a function type like... func(SectionID) uint32
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 fine except the inconsistency on custom sections
ps there's another need not addressed here, which is count by second index. Ex.
I didn't address this, yet but I think at some point we can refactor things so that you can for example, tell the function index namespace count w/o a for loop. |
|
Thanks for the notes on |
…s#231) This consolidates more code around SectionID, notably consistently getting and using section ID length. This also enforces rules in text parsing such as up to one memory, and imported functions can't be defined after regular ones. Signed-off-by: Adrian Cole <adrian@tetrate.io> Signed-off-by: r8d8 <ckryvomaz@gmail.com>
This consolidates more code around SectionID, notably consistently
getting and using section ID length. This also enforces rules in text
parsing such as up to one memory, and imported functions can't be
defined after regular ones.