about summary refs log tree commit diff stats
path: root/subx/029translate.cc
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-08-04 15:54:51 -0700
committerKartik Agaram <vc@akkartik.com>2018-08-04 15:54:51 -0700
commit55b4627de1fcdd5f139994759d0929515204b6d8 (patch)
tree6b4f2d70134134dd187b9a1f17c51ca179ea2b0f /subx/029translate.cc
parenta2001d15a1a6a5a726dbe6b2b88d3f72d5d5e391 (diff)
downloadmu-55b4627de1fcdd5f139994759d0929515204b6d8.tar.gz
4473
Better organize registration of transforms in main().
Diffstat (limited to 'subx/029translate.cc')
-rw-r--r--subx/029translate.cc41
1 files changed, 22 insertions, 19 deletions
diff --git a/subx/029translate.cc b/subx/029translate.cc
index 166762d9..1d5e940e 100644
--- a/subx/029translate.cc
+++ b/subx/029translate.cc
@@ -16,6 +16,25 @@
 //:
 //: Higher levels usually transform code on the basis of metadata.
 
+:(before "End Main")
+if (is_equal(argv[1], "translate")) {
+  START_TRACING_UNTIL_END_OF_SCOPE;
+  assert(argc > 3);
+  program p;
+  ifstream fin(argv[2]);
+  if (!fin) {
+    cerr << "could not open " << argv[2] << '\n';
+    return 1;
+  }
+  parse(fin, p);
+  if (trace_contains_errors()) return 1;
+  transform(p);
+  if (trace_contains_errors()) return 1;
+  save_elf(p, argv[3]);
+  if (trace_contains_errors()) unlink(argv[3]);
+  return 0;
+}
+
 //: Ordering transforms is a well-known hard problem when building compilers.
 //: In our case we also have the additional notion of layers. The ordering of
 //: layers can have nothing in common with the ordering of transforms when
@@ -77,25 +96,9 @@
 //: goals are basically to always have a working program after any layer, to
 //: have the order of layers make narrative sense, and to order transforms
 //: correctly at runtime.
-
-:(before "End Main")
-if (is_equal(argv[1], "translate")) {
-  START_TRACING_UNTIL_END_OF_SCOPE;
-  assert(argc > 3);
-  program p;
-  ifstream fin(argv[2]);
-  if (!fin) {
-    cerr << "could not open " << argv[2] << '\n';
-    return 1;
-  }
-  parse(fin, p);
-  if (trace_contains_errors()) return 1;
-  transform(p);
-  if (trace_contains_errors()) return 1;
-  save_elf(p, argv[3]);
-  if (trace_contains_errors()) unlink(argv[3]);
-  return 0;
-}
+:(before "End One-time Setup")
+// Begin Transforms
+// End Transforms
 
 :(code)
 // write out a program to a bare-bones ELF file