toScript method

String toScript({
  1. DartBlockTypedLanguage language = DartBlockTypedLanguage.java,
})

Export the DartBlock program to a typed language.

  • Java: creates a Launcher class which will contain the main function of the DartBlock as the main method, as well as the custom functions as static methods of the same class.

Implementation

String toScript({
  DartBlockTypedLanguage language = DartBlockTypedLanguage.java,
}) {
  switch (language) {
    case DartBlockTypedLanguage.java:
      return "class Launcher {\n"
          "\t${mainFunction.toScript(language: language)}${customFunctions.isNotEmpty ? '\n\n\t' : ''}${customFunctions.map((e) => e.toScript(language: language)).join("\n\n\t")}"
          "\n}";
  }
}