trans/temp.sml
         trans/label.sml
+       trans/stringref.sml
        trans/tree.sml
        trans/treeutils.sml
        trans/trans.sml
 
--- /dev/null
+(* L3 Compiler
+ * Stringreforaries
+ * Like temporaries, except more different
+ * Author: Joshua Wise <jwise@cs.cmu.edu>
+ *)
+
+signature STRINGREF = 
+sig
+  type stringref
+
+  val reset : unit -> unit     (* resets stringref numbering *)
+  val new : string -> stringref        (* returns a unique new stringref *)
+  val name : stringref -> string       (* returns the name of a stringref *)
+  val compare : stringref * stringref -> order (* comparison function *)
+end
+
+structure Stringref :> STRINGREF = 
+struct
+  type stringref = int
+
+  local
+    val counter = ref 1
+    val strings = ref []
+  in
+    (* warning: calling reset() may jeopardize uniqueness of stringrefs! *)
+    fun reset () = ( counter := 1 ; strings := [] )
+    fun new (s : string) = !counter before ( strings := (!counter, s) :: !strings ; counter := !counter + 1 )
+  end
+
+  fun name t = "S" ^ Int.toString t
+                     
+  fun compare (t1,t2) = Int.compare (t1,t2)
+end
 
         (* after type-checking, id must be declared; do not guard lookup *)
             T.TEMP (Symbol.look' env id)
         | trans_exp env vartypes (A.ConstExp c) = T.CONST(c)
+        | trans_exp env vartypes (A.StringExp s) = T.STRING(Stringref.new s)
         | trans_exp env vartypes (A.OpExp(oper, [e1, e2])) =
             T.BINOP(trans_oper oper, trans_exp env vartypes e1, trans_exp env vartypes e2)
         | trans_exp env vartypes (A.OpExp(oper, [e])) =
 
     | CALL of Ast.ident * exp list
     | MEMORY of exp
     | ALLOC of exp
+    | STRING of Stringref.stringref
     | COND of exp * exp * exp
     | STMVAR of stm list * exp
     | NULLPTR
     | CALL of Ast.ident * exp list
     | MEMORY of exp
     | ALLOC of exp
+    | STRING of Stringref.stringref
     | COND of exp * exp * exp
     | STMVAR of stm list * exp
     | NULLPTR
 
     | effect (T.UNOP (_, a)) = effect a
     | effect (T.MEMORY _) = true
     | effect (T.ALLOC _) = true
+    | effect (T.STRING _) = false
     | effect (T.COND (a, b, c)) = (effect a) orelse (effect b) orelse (effect c)
     | effect (T.STMVAR (sl, e)) = true (* Has to be, to be safe <--- jwise is an assclown, he was too lazy to write a effect_stm *)
     | effect (T.NULLPTR) = false
           Symbol.name f ^ "(" ^ (String.concatWith ", " (List.map (fn e => pp_exp e) l)) ^ ")"
       | pp_exp (T.MEMORY (exp)) = "M[" ^ pp_exp exp ^ "]"
       | pp_exp (T.ALLOC(e)) = "NEW(" ^ pp_exp e ^ ")"
+      | pp_exp (T.STRING(s)) = "STRING(" ^ (Stringref.name s) ^ ")"
       | pp_exp (T.COND(c,e1,e2)) = "(" ^ pp_exp c ^ ") ? (" ^ pp_exp e1 ^ ") : (" ^ pp_exp e2 ^ ")"
       | pp_exp (T.STMVAR(sl,v)) = "({" ^ (foldr (fn (st,s) => (pp_stm st) ^ "; " ^ s) "" sl) ^ (pp_exp v) ^ "})"
       | pp_exp (T.NULLPTR) = "NULL"