# File lib/rcodetools/xmpfilter.rb, line 130
  def annotate(code)
    idx = 0
    code = code.gsub(/ # !>.*/, '')
    newcode = code.gsub(SINGLE_LINE_RE){ prepare_line($1, idx += 1) }
    newcode.gsub!(MULTI_LINE_RE){ prepare_line($1, idx += 1, true)}
    File.open(@dump, "w"){|f| f.puts newcode} if @dump
    stdout, stderr = execute(newcode)
    output = stderr.readlines
    runtime_data = extract_data(output)
    idx = 0
    annotated = code.gsub(SINGLE_LINE_RE) { |l|
      expr = $1
      if /^\s*#/ =~ l
        l 
      else
        annotated_line(l, expr, runtime_data, idx += 1)
      end
    }
    annotated.gsub!(/ # !>.*/, '')
    annotated.gsub!(/# (>>|~>)[^\n]*\n/m, "");
    annotated.gsub!(MULTI_LINE_RE) { |l|
      annotated_multi_line(l, $1, $3, runtime_data, idx += 1)
    }
    ret = final_decoration(annotated, output)
    if @output_stdout and (s = stdout.read) != ""
      ret << s.inject(""){|s,line| s + "# >> #{line}".chomp + "\n" }
    end
    ret
  end