-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
playground: make jsoo_main compile #538
Merged
Merged
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
0653696
playground: make jsoo_main compile
jchavarri bea1835
Merge branch 'main' into playground-1
jchavarri 6944289
playground: updates after merging main
jchavarri eb98362
Merge branch 'main' into playground-1
jchavarri 0809424
playground: use private melange comp libs
jchavarri 9cbe9c5
playground: pick up change in translmod
jchavarri ec1fbe3
playground: better error handling
jchavarri ba38c05
playground: remove hardcoded BS_BROWSER
jchavarri ca209c4
opam: add jsoo
jchavarri d1ce4ed
playground: update in-code comment
jchavarri 01c797b
playground: add new profile browser
jchavarri 4e64b6f
playground: build in ci
jchavarri b178930
Revert "playground: pick up change in translmod"
jchavarri 0137a6b
Merge branch 'main' into playground-1
jchavarri b9a2554
playground: add dev mode for faster builds
jchavarri 08be825
playground: apply ppxlib driver on structure
jchavarri b23d4f4
playground: add comment
jchavarri 5ef2d1f
Merge branch 'main' into playground-1
jchavarri e05becc
Merge branch 'main' into playground-1
jchavarri 5f7c877
playground: fix errors after merging main
jchavarri dc56afc
Merge branch 'main' into playground-1
jchavarri 529df6a
fixes after merge
jchavarri abdb6ae
remove unneeded exposure of ppx_entry
jchavarri df0a373
remove d_browser
jchavarri 655102b
playground: update makefile with new paths
jchavarri ef574d0
add test for playground
jchavarri c4ad80d
playground: remove obsolete comment
jchavarri 1620cbc
playground: open melange_comp_libs in flags
jchavarri f478585
playground: add more tests
jchavarri 9329c87
playground: remove str_of_formatted
jchavarri 68cc036
playground: add failing test with bs.deriving
jchavarri a255638
playground: fix test by replacing bs.deriving with deriving
jchavarri 53dc2dc
fix: ppxlib AST conversion
anmonteiro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
Generate runtime cmijs for building against melange libs from the playground | ||
|
||
$ find $DUNE_SOURCEROOT/_build/default/jscomp/stdlib/.stdlib.objs/melange -name "*.cmi" -or -name "*.cmj" | xargs js_of_ocaml build-fs -o stdlib-cmijs.js | ||
$ find $DUNE_SOURCEROOT/_build/default/jscomp/runtime/.runtime.objs/melange -name "*.cmi" -or -name "*.cmj" | xargs js_of_ocaml build-fs -o runtime-cmijs.js | ||
$ find $DUNE_SOURCEROOT/_build/default/jscomp/others/.belt.objs/melange -name "*.cmi" -or -name "*.cmj" | xargs js_of_ocaml build-fs -o belt-cmijs.js | ||
|
||
Prepare an input file to test some snippets to exercise common functionality | ||
|
||
$ cat > input.js <<EOF | ||
> require(process.env.DUNE_SOURCEROOT + '/_build/default/bin/jsoo_main.bc.js'); | ||
> require('./stdlib-cmijs.js'); | ||
> require('./runtime-cmijs.js'); | ||
> require('./belt-cmijs.js'); | ||
> console.log(ocaml.compile("let t = 1")); | ||
> console.log(ocaml.compile(\`let john = [%bs.obj { name = "john"; age = 99 }] let t = john##name\`)); | ||
> console.log(ocaml.compile(\`let foo = Belt.List.map\`)); | ||
> console.log(ocaml.compile(\`let +foo\`)); | ||
> console.log(ocaml.compile(\`let foo = "" + 2\`)); | ||
> console.log(ocaml.compile(\`type person = { | ||
> name: string ; | ||
> age: int | ||
> }[@@deriving abstract] | ||
> | ||
> let person1: person = person ~name:"joe" ~age:10\`)); | ||
> EOF | ||
|
||
$ node input.js | ||
{ | ||
js_code: '// Generated by Melange\n' + | ||
"'use strict';\n" + | ||
'\n' + | ||
'\n' + | ||
'var t = 1;\n' + | ||
'\n' + | ||
'exports.t = t;\n' + | ||
'/* No side effect */\n' | ||
} | ||
{ | ||
js_code: '// Generated by Melange\n' + | ||
"'use strict';\n" + | ||
'\n' + | ||
'\n' + | ||
'var john = {\n' + | ||
' name: "john",\n' + | ||
' age: 99\n' + | ||
'};\n' + | ||
'\n' + | ||
'var t = john.name;\n' + | ||
'\n' + | ||
'exports.john = john;\n' + | ||
'exports.t = t;\n' + | ||
'/* t Not a pure module */\n' | ||
} | ||
{ | ||
js_code: '// Generated by Melange\n' + | ||
"'use strict';\n" + | ||
'\n' + | ||
'var Belt_List = require("./stdlib/belt_List.js");\n' + | ||
'\n' + | ||
'var foo = Belt_List.map;\n' + | ||
'\n' + | ||
'exports.foo = foo;\n' + | ||
'/* No side effect */\n' | ||
} | ||
{ | ||
js_error_msg: 'Line 1, 5:\n Error Syntax error', | ||
row: 0, | ||
column: 5, | ||
endRow: 0, | ||
endColumn: 8, | ||
text: 'Syntax error', | ||
type: 'error' | ||
} | ||
{ | ||
js_error_msg: 'Line 1, 10:\n' + | ||
' Error This expression has type string but an expression was expected of type int', | ||
row: 0, | ||
column: 10, | ||
endRow: 0, | ||
endColumn: 12, | ||
text: 'This expression has type string but an expression was expected of type int', | ||
type: 'error' | ||
} | ||
{ | ||
js_code: '// Generated by Melange\n' + | ||
"'use strict';\n" + | ||
'\n' + | ||
'\n' + | ||
'var person1 = {\n' + | ||
' name: "joe",\n' + | ||
' age: 10\n' + | ||
'};\n' + | ||
'\n' + | ||
'exports.person1 = person1;\n' + | ||
'/* No side effect */\n' | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'm pretty sure this is wrong. You probably copied it from
melc.ml
.This is applying the PPXes and converting the preprocessed AST to the current switch version. Also
Parsetree.structure
isn't what you think it is because youopen
edMelange_compiler_libs
globally.In the playground, we just need this AST version to be the Melange_compiler_libs parsetree, I think? so we might not need to make the copy at all?
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 just pushed 53dc2dc fixing this
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.
Just curious, I noticed you left the
copy_structure
calls, why does ppxlib need them?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.
Ppxlib has its own version of the AST. So we need to convert from the melange version to its internal AST version and back. Right now that’s 4.14 so we technically don’t need these. But it’s better to avoid bugs when ppxlib bumps AST versions.