-
- val output = foldr (fn (func, code) => (processir ("calloc" (* lololololol *) :: (Symbol.elems externs)) func) ^ code)
- (".file\t\"" ^ source ^ "\"\n.ident\t\"15-411 ASS compiler by czl@ and jwise@\"\n" ^
- ".ident \"Optimizations enabled: " ^ String.concat (map (fn x => (#shortname x) ^ " ") (!enabledopts)) ^ "\"\n") ir
+
+ val code = map (fn func => processir ("calloc" (* lololololol *) :: (Symbol.elems externs)) func) ir
+ val strings = map (fn (sn, s) => String.concat (
+ [Stringref.name sn, ": .word "] @
+ (map (fn c => (Int.toString (ord c)) ^ ", ") (String.explode s)) @
+ ["0\n"]
+ ) ) (Stringref.all ())
+
+ val output =
+ String.concat (
+ ".file\t\"" :: source :: "\"\n" ::
+ ".ident\t\"15-411 ASS compiler by czl@ and jwise@\"\n" ::
+ ".ident \"Optimizations enabled: " :: (map (fn x => (#shortname x) ^ " ") (!enabledopts)) @ [ "\"\n" ] @
+ code @
+ [ ".section .rodata\n" ] @
+ strings )