1
1
mirror of https://github.com/github/semantic.git synced 2024-12-19 12:51:52 +03:00

Document why sourceSpan isn’t evaluated eagerly any more.

This commit is contained in:
Rob Rix 2016-08-15 17:41:13 -04:00
parent fddb9dd90a
commit 5a979aaf5b

View File

@ -116,6 +116,7 @@ documentToTerm language document blob = alloca $ \ root -> do
, spanEnd = SourcePos (fromIntegral $ ts_node_p_end_point_row node) (fromIntegral $ ts_node_p_end_point_column node) }
-- Note: The strict application here is semantically important. Without it, we may not evaluate the range until after weve exited the scope that `node` was allocated within, meaning `alloca` will free it & other stack data may overwrite it.
-- We dont evaluate `sourceSpan` eagerly so that terms which dont use it dont pay the toll for it. This places the onus for evaluating it on the termConstructor function.
let info = range `seq` range .: (categoriesForLanguage language (toS name)) .: RNil
pure $! termConstructor (source blob) sourceSpan info children
getChild node n out = ts_node_p_named_child node n out >> toTerm out