From ddb69212f03a82e980144594d809a072b50e7f19 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Sat, 11 Feb 2023 09:40:25 -0800 Subject: Finish the compiler. Just joking. But we did manage to compile a program from SML to bytecode. --- syntax.sml | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'syntax.sml') diff --git a/syntax.sml b/syntax.sml index 2e2cc11..5ed5954 100644 --- a/syntax.sml +++ b/syntax.sml @@ -125,4 +125,14 @@ struct end val cexpToString : cexp -> string = cexpToStringI "" + + fun opcodeToString (oper : opcode) : string = + case oper of + OAlloc (r, s) => "OAlloc (" ^ Int.toString r ^ ", " ^ valueToString s ^ ")" + | OCall => "OCall" + | OPoke (i, p, v) => "OPoke (" ^ Int.toString i ^ ", " ^ Int.toString p ^ ", " ^ valueToString v ^ ")" + | OPeek (r, i, p) => "OPeek (" ^ Int.toString r ^ ", " ^ Int.toString i ^ ", " ^ valueToString p ^ ")" + | OShuf (d, s) => "OShuf (" ^ Int.toString d ^ ", " ^ valueToString s ^ ")" + | OExit v => "OExit " ^ valueToString v + | OLabel l => "OLabel " ^ Int.toString l end -- cgit v1.3.1