| 1 | module scheme |
| 2 | |
| 3 | import reader |
| 4 | |
| 5 | // Graph materialization only visits nodes reachable from this subform. The |
| 6 | // existing backend supplies iterative construction, sharing and cycle support. |
| 7 | // Newly built pair/vector structure is mutable; retained source atoms preserve |
| 8 | // literal immutability. Metadata must retain its normal publication owner. |
| 9 | fn syntax_to_datum(value Value) !Value { |
| 10 | if value.tag != .syntax { |
| 11 | if value.tag == .symbol { return failure('unwrapped symbol is not a syntax identifier') } |
| 12 | if value.tag !in [.pair, .vector] { return value } |
| 13 | return map_syntax_value_graph(value, false, unsafe { nil }, unsafe { nil }, unsafe { nil }) |
| 14 | } |
| 15 | object := syntax_object_ref(value)! |
| 16 | if object.data.tree.nodes[object.index].kind !in [.pair, .vector] { |
| 17 | return graph_source_atom(object.data.tree, reader.NodeId(object.index)) |
| 18 | } |
| 19 | mut jobs := new_datum_graph_jobs() |
| 20 | defer { jobs.release() } |
| 21 | mut cache := new_scratch_datum_cache(jobs.storage) |
| 22 | return materialize_datum_graph_in(object.data.tree, reader.NodeId(object.index), mut cache, false, jobs) |
| 23 | } |
| 24 | |