static string CreateGlobalDeclaration(ICppScope localScope, Action <ICppScope> action) { var scope = new CppScope { Globals = localScope.Globals }; action(scope); return(scope.Declaration.Build()); }
public void WithRuntimeIndented(Action <ICppScope> action) { Runtime.WithIndent( subRuntime => { var sub = new CppScope { Globals = Globals, Declaration = Declaration, Runtime = subRuntime, LocalNameCount = LocalNameCount }; action(sub); }); }
public static void Generate(TextWriter writer, IExpressionBlock block) { writer.WriteLine(value: "#include <stdint.h>"); writer.WriteLine(value: "#include <tuple>"); var scope = new CppScope(); Dynamic(block, scope); foreach (var global in scope.Globals) { writer.WriteLine(global.Value); } writer.WriteLine(scope.Declaration.Build()); writer.WriteLine(value: "int main(int argc, char** argv) {"); writer.WriteLine(scope.Runtime.Build()); writer.WriteLine(value: " return 0;"); writer.WriteLine(value: "}"); }