-
Notifications
You must be signed in to change notification settings - Fork 97
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
[WIP] Source map #36
[WIP] Source map #36
Conversation
@@ -39,6 +39,8 @@ let argspec = Arg.align | |||
"--dfinity", | |||
Arg.Unit (fun () -> compile_mode := Pipeline.DfinityMode), | |||
" compile for dfinity"; | |||
"--map", Arg.Set Flags.source_map, " output source map"; | |||
"--disable-prelude", Arg.Clear Flags.prelude, " disable prelude"; |
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 do you need to be able to disable the prelude?
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.
More of a temporary thing to reduce the output size, and to avoid dealing with prelude as a source
src/encodeMap.ml
Outdated
Vlq.Base64.encode buf4 (ic - !prev_ic); (* input column *) | ||
map := !map @ [Buffer.contents buf1; Buffer.contents buf2; Buffer.contents buf3; Buffer.contents buf4] @ [","]; | ||
|
||
if !filename = "" then filename := file; |
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 looks hackish. Shouldn’t there be a list of source files, and the sources index
point to the corresponding one?
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.
Yes, fixed now
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 going into the right direction, thanks a lot!
Eventually we want to default to foo.wasm
if the input is foo.as
(and probably only if there is only one) - you can add that, if you want, but don't feel obliged; I can do that when I get back to coding. (It can be discouraging if a contribution gets tired to cleaning up other people's code :-))
Added! |
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.
Great! :-)
Ok, this can probably be merged now, @nomeata? |
src/js_main.ml
Outdated
method compileWat mode s = js_compile_wat mode s | ||
method compileWasm mode s = js_compile_wasm mode s | ||
method compileWat mode s source_map = js_compile_wat mode s source_map | ||
method compileWasm mode s source_map = js_compile_wasm mode s source_map |
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.
Could we keep the source string as the last argument?
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 actually prefer source string as the first arg, so we can do this:
asc.compileWasm(source, { mode: 'dfinity', sourceMap: true, ... })
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 motivation behind my asking is that making the input the last parameter generally supports function composition and partial application.
I think this describes it quite well: https://wiki.haskell.org/Parameter_order
Refactored a bit - moved SourceMap into its own module but there is still code duplication |
But now we have a code copy that only produce a Wouldn’t it be cleaner to just use the |
That was my initial idea, I can revert if we want to do that. |
I am in favor. Seems the lesser of two evils. |
Ok, I reverted back to |
Okay, I don't have a better suggestion for now, so SGTM. |
Merged! |
No description provided.