Explorer

core.compile-part-references

description
Adds to ids the part IDs that the compiled code of the expression needs: like core.expression-part-references, but not inside quotes (a compiled quote holds the parts it references as string data, core.quote-parts). Each ID is added once
type
Fn(expr: @core.expression, ids: List<String>) -> List<String>
expression
fn(expr$0, ids$1) =>
  match $0 {
    #part_reference(reference$2) =>
      match @core.list-contains-string(list: $1, target: $2.part_definition_event_hash, index: 0) {
        true =>
          $1,
        false =>
          @core.list-append(list: $1, item: $2.part_definition_event_hash)
      },
    #quote(_) =>
      $1,
    _ =>
      @core.list-fold(
        T: @core.expression,
        A: List<String>,
        reducer: fn(acc$8, item$9) =>
          @core.compile-part-references(expr: $9, ids: $8),
        init: $1,
        xs: match $0 {
          #type_list(list_type$3) =>
            [$3.item_type],
          #type_code(list_type$3) =>
            [$3.value_type],
          #type_function(function_type$4) =>
            @core.list-append(
              list: @core.type-function-parameter-types(parameters: $4.parameters, index: 0),
              item: $4.return_type
            ),
          #type_record(fields$5) =>
            @core.record-item-values(items: $5, index: 0),
          #type_union(variants$6) =>
            @core.type-union-payload-types(variants: $6, index: 0),
          _ =>
            @core.expression-children(expr: $0)
        }
      )
  }
visibility
public
core.compile-part-references (project definy, branch main, snapshot CfIAXM725tR74SWd4aoTUz4-JJQfqnllblZbQ2Sv204)
id: 02VAI8q16fva3dzAU_2bxXQ2oMJbZ6JffDS246qvFo4
content hash: SSn6ULBF3UbIpSlMiPyCycfpUSleyF4bwsOka3Wflj8