def encode

bolt@1.27.0.0 · src/lsp/semantic.bend:400

import bolt@1.27.0.0/src/lsp/semantic.bend as Semantic
import Base

400# LSP's encoding: five numbers a token, positions relative to the previous
401# token (a line delta, and a column delta on the same line, absolute on a new
402# one)
403def encode(sems: List<&2, Sem>, +pl: U32, +pc: U32) -> List<&2, U32>:
404  match sems:
405    case Nil{}:
406      Nil{}
407    case Con{Sem{+line, +col, len, typ}, rest}:
408      +same = U32.is_eq(line, pl)
409      +dcol = Bool.pick(U32, same, (col - pc : U32), col)
410      (line - pl : U32) <> (dcol <> (len <> (typ <> (0 <> encode(rest, line, col)))))

Uses (6)

Used by (1)