about summary refs log tree commit diff stats
path: root/subx/034discourage_raw_hex.cc
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-08-09 21:35:04 -0700
committerKartik Agaram <vc@akkartik.com>2018-08-09 21:46:12 -0700
commit90b01a1b277f457914c1a5757ecfde3af4591ab0 (patch)
tree5e6a72ac63b7dcdc4c2d689e6dff3a51802888a9 /subx/034discourage_raw_hex.cc
parentf2889b002ab36e13ac5771cf33635ec35cfc3b34 (diff)
downloadmu-90b01a1b277f457914c1a5757ecfde3af4591ab0.tar.gz
4499
More tweaks for check passes. Ensure they're never first-class
transforms.
Diffstat (limited to 'subx/034discourage_raw_hex.cc')
-rw-r--r--subx/034discourage_raw_hex.cc11
1 files changed, 5 insertions, 6 deletions
diff --git a/subx/034discourage_raw_hex.cc b/subx/034discourage_raw_hex.cc
index 8d5eac7d..2b2e2675 100644
--- a/subx/034discourage_raw_hex.cc
+++ b/subx/034discourage_raw_hex.cc
@@ -4,15 +4,14 @@
 //: While SubX will let you write raw machine code, don't do that unless you
 //: have a very good reason.
 
-:(after "Begin Level-2 Transforms")
-Transform.push_back(warn_on_raw_jumps);
+:(before "Pack Operands(segment code)")
+warn_on_raw_hex(code);
+if (trace_contains_errors()) return;
 :(code)
-void warn_on_raw_jumps(/*const*/ program& p) {
-  if (p.segments.empty()) return;
-  segment& code = p.segments.at(0);
+void warn_on_raw_hex(const segment& code) {
   trace(99, "transform") << "-- warn on raw hex instructions" << end();
   for (int i = 0;  i < SIZE(code.lines);  ++i) {
-    line& inst = code.lines.at(i);
+    const line& inst = code.lines.at(i);
     if (all_hex_bytes(inst) && has_operands(inst)) {
       warn << "'" << to_string(inst) << "': using raw hex is not recommended\n" << end();
       break;