mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 19:31:08 +01:00
Noticed these issues when trying to query raw semir with [yq](https://github.com/mikefarah/yq) - Removed additional "}" within PrintClassFields - Removed additional "}" after is_frozen_period_self - Surround `int(value: 123)` in quotes to avoid issues parsing the additional ':' - Updated DeclaredFacetType::Print to have valid YAML structure - Constraints are added to inline list (i.e. wrapping in `[ ... ]`) - Switched Outer seperator to Comma. The last two may be up for debate, maybe there's no intention for raw semir to be true valid yaml but I think its quite useful, for example I can now do the following: ```sh carbon compile examples/sieve.carbon --phase=check --dump-raw-sem-ir | yq ' .sem_ir | select(.names as $n | .classes[] | .name as $k | $n[$k] == "Sieve") | . as $ir | $ir.classes[] | select(.name as $k | $ir.names[$k] == "Sieve" and .body_block_id != "inst_block_empty") | . as $c | ($ir.inst_blocks[$c.body_block_id][] as $i | $ir.insts[$i]) ' ``` outputs: ```yaml {kind: ImplDecl, arg0: impl41000000, arg1: inst_block41000008} {kind: ImplSelfWitness, arg0: inst41000014, arg1: specific_interface41000000, type: type(inst(WitnessType))} {kind: FunctionDecl, arg0: function41000000, arg1: inst_block41000013, type: type(inst41000030)} {kind: FunctionDecl, arg0: function41000001, arg1: inst_block41000023, type: type(inst4100005B)} {kind: FieldDecl, arg0: field41000000, arg1: region41000002, type: type(inst41000065)} {kind: CompleteTypeWitness, arg0: inst41000067, type: type(inst(WitnessType))} ```