From fd2e2e58be34972291f479b635286f6a300cf53b Mon Sep 17 00:00:00 2001 From: Garrit Franke Date: Sat, 5 Dec 2020 19:01:44 +0100 Subject: [PATCH] Print result of main for js target --- .gitignore | 3 ++- examples/hello_world.sb | 2 +- src/generator/js.rs | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 64ee209..d05ddff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ target/ -.vscode/ \ No newline at end of file +.vscode/ +examples_out/ \ No newline at end of file diff --git a/examples/hello_world.sb b/examples/hello_world.sb index f8084c3..26184fd 100644 --- a/examples/hello_world.sb +++ b/examples/hello_world.sb @@ -1,5 +1,5 @@ fn main() { - return; + return "Hello World"; } fn fib() {} \ No newline at end of file diff --git a/src/generator/js.rs b/src/generator/js.rs index 526dc45..2d6e32f 100644 --- a/src/generator/js.rs +++ b/src/generator/js.rs @@ -11,7 +11,8 @@ impl Generator for JsGenerator { .map(|f| generate_function(f)) .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; }