Explorer

core.build-type-env-parts

description
Add each part's declared type to the part type environment, and for a type part also the type it declares under the key `{hash}#definition`
type
Fn(
  entries: List<Record{
    part_definition_event_hash: String,
    part_type: @core.expression,
    type_declaration: Union{#none, #some(@core.expression)}
  }>,
  index: Number,
  accum: @core.part-type-env
) -> @core.part-type-env
expression
fn(entries$0, index$1, accum$2) =>
  match @core.list-get(list: $0, index: $1) {
    #none(_) =>
      $2,
    #some(item$1007) =>
      let entry$3 = $1007;
      match @core.type-declaration-to-type-ast(expr: $3.part_type) {
        #none(_) =>
          @core.build-type-env-parts(entries: $0, index: @core.plus(left: $1, right: 1), accum: $2),
        #some(part_type$7) =>
          let with_type$4 = @core.list-append(list: $2, item: {part_definition_event_hash: $3.part_definition_event_hash, part_type: $7});
          @core.build-type-env-parts(
            entries: $0,
            index: @core.plus(left: $1, right: 1),
            accum: match $3.type_declaration {
              #none(_) =>
                $4,
              #some(declaration$5) =>
                match @core.type-declaration-to-type-ast(expr: $5) {
                  #none(_) =>
                    $4,
                  #some(declared$6) =>
                    @core.list-append(
                      list: $4,
                      item: {
                        part_definition_event_hash: @core.string-concat(left: $3.part_definition_event_hash, right: "#definition"),
                        part_type: $6
                      }
                    )
                }
            }
          )
      }
  }
visibility
public
core.build-type-env-parts (project definy, branch compiled-tests, snapshot i6TqClmqVS9FK8rKOvJ43l6Tevx8pvYJ5-zaQqNwemc)
id: 4c_OlbHlwR-2KWcAiyJa68fClweU9D7bfMmYrI-hvYI
content hash: Bssg-MwQJd0x6HE9Ji9CK9JS1JvzAAO4CRicsYUnyUI