Browse Source

Print result of main for js target

github-actions
Garrit Franke 3 years ago
parent
commit
fd2e2e58be
  1. 3
      .gitignore
  2. 2
      examples/hello_world.sb
  3. 3
      src/generator/js.rs

3
.gitignore vendored

@ -1,2 +1,3 @@
target/ target/
.vscode/ .vscode/
examples_out/

2
examples/hello_world.sb

@ -1,5 +1,5 @@
fn main() { fn main() {
return; return "Hello World";
} }
fn fib() {} fn fib() {}

3
src/generator/js.rs

@ -11,7 +11,8 @@ impl Generator for JsGenerator {
.map(|f| generate_function(f)) .map(|f| generate_function(f))
.collect(); .collect();
code += "main()"; // Until we have a stdlib, it should suffice to print the result of main to stdout
code += "console.log(main())";
return code; return code;
} }

Loading…
Cancel
Save