Skip to main content

Crate bhc_query

Crate bhc_query 

Source
Expand description

Query-based compilation system for BHC.

This crate provides the infrastructure for incremental, demand-driven compilation using a query-based architecture similar to rustc’s query system and salsa.

§Overview

The query system allows the compiler to:

  • Incrementally recompute only what has changed between compilations
  • Demand-driven evaluation where queries are only computed when needed
  • Automatic memoization of query results
  • Cycle detection for recursive queries

§Architecture

Queries are defined as traits that can be implemented by a database. The database stores memoized results and tracks dependencies between queries.

┌─────────────────────────────────────────────────────┐
│                    QueryDatabase                     │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐ │
│  │  Query A    │  │  Query B    │  │  Query C    │ │
│  │  (cached)   │──│  (cached)   │──│  (pending)  │ │
│  └─────────────┘  └─────────────┘  └─────────────┘ │
│                    Dependencies                      │
└─────────────────────────────────────────────────────┘

Structs§

MemoizedResult
A memoized query result with revision tracking.
QueryId
A unique identifier for a query invocation.
QueryRuntime
A runtime for executing queries with a database.
QueryStorage
Storage for a specific query type.
Revision
A revision number tracking database state changes.
SimpleDatabase
A simple in-memory query database implementation.

Enums§

QueryError
Error types for the query system.
QueryState
The state of a query computation.

Traits§

InputQuery
Marker trait for input queries that can be set directly.
Query
A query definition with its computation function.
QueryDatabase
The central database trait that all query databases must implement.
QueryKey
Trait for types that can be used as query keys.
QueryValue
Trait for types that can be used as query values.

Type Aliases§

QueryResult
Result type for query computations.