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:
parent
fddb9dd90a
commit
5a979aaf5b
@ -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 we’ve exited the scope that `node` was allocated within, meaning `alloca` will free it & other stack data may overwrite it.
|
||||
-- We don’t evaluate `sourceSpan` eagerly so that terms which don’t use it don’t 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
|
||||
|
Loading…
Reference in New Issue
Block a user