Skip to main content

lex_ir_json

Function lex_ir_json 

Source
pub fn lex_ir_json(text: &str) -> String
Expand description

Colours a disassembly and answers a colour for every part of it.

{"ok":bool,"spans":[{"at":int,"len":int,"kind":string}]}

The same shape lex_json answers, and for the same consumer: the spans tile the text in UTF-16 code units, so a page renders the pane by walking them and slicing the string it already has.

text is what compile_json’s ir field held. It is passed back in rather than coloured on the way out because a colouring belongs to the text a page is showing, and a page shows one disassembly while a run answers another every time it is asked; sending both together would put a second copy of the tiling into every run answer for the sake of saving a call that costs one pass over a string.

kind adds slot to lex_json’s six. ok means something different here: not that the text parsed — it was written by cove_ir::print::program and always does — but that every line of it was a line shape that module documents. A false answer is a printer this module has not caught up with, and highlight says where that is asserted.