static void compile(string line, string code)
You're passing code in as a string, but not requesting it to return with any data, yet your usage of the function clearly states that you're trying to alter it with each call. Change the call to a ref.
static void compile(string line, ref string code)
and call it with a ref, e.g. compile("function Main {", ref code);