Rogue's Trace Command

I finally got around to reimplementing a low-priority, high-utility command that I first made in Bard: the trace command.

trace just prints out where in the source code the program is executing and/or the given arguments as a string along with what each one evaluates to. That sounds a little confusing but a quick example will clear it up:

     1	println "Starting test"
     2	
     3	local x = 3
     4	local y = x + 1
     5	
     6	trace
     7	trace x, y
     8	@trace "{", x+y, "}"

The output:

Starting test
[Global.on_launch() Test.rogue:6]
x:3 y:4
[Global.on_launch() Test.rogue:8]   {x+y:7}

Behavioral details:

  1. trace by itself prints out the executing source location - class, method, filename, line number. This is just a literal string generated by the compiler at compile-time.

  2. trace expression1, expression2, ... prints out the verbatim text of each expression followed by the runtime value of that expression. Any literal strings print without being evaluated again. And again this is a simple stringbuilder output at runtime and the only mild complexity happens at compile time; the compiler turns trace x+1 into println StringBuilder().print("x+1:").print(x+1).

  3. Expression tracing doesn't automatically print out the source location (a change for the Rogue version). You can write @trace instead of trace to always prefix the output with the source location.