예제 #1
0
        static string CreateGlobalDeclaration(ICppScope localScope, Action <ICppScope> action)
        {
            var scope = new CppScope {
                Globals = localScope.Globals
            };

            action(scope);
            return(scope.Declaration.Build());
        }
예제 #2
0
파일: CppScope.cs 프로젝트: konsultaner/REC
 public void WithRuntimeIndented(Action <ICppScope> action)
 {
     Runtime.WithIndent(
         subRuntime => {
         var sub = new CppScope {
             Globals        = Globals,
             Declaration    = Declaration,
             Runtime        = subRuntime,
             LocalNameCount = LocalNameCount
         };
         action(sub);
     });
 }
예제 #3
0
        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: "}");
        }