1pub const KERNEL_VERSION: &str = env!("CARGO_PKG_VERSION");
10
11pub mod artifact;
12pub mod benchmark;
13mod builtin_id;
14pub mod compiler;
15pub mod opcode;
16mod portable_builtin;
17pub mod program;
18mod runtime_limits;
19mod schema;
20pub mod type_contract;
21pub mod value;
22
23pub use artifact::{
24 compile_program, semantic_abi_fingerprint_hex, ArtifactLimits, Diagnostic, EntryKind,
25 ProgramArtifact, ARTIFACT_VERSION,
26};
27pub use benchmark::{
28 benchmark_terminal_digest, portable_benchmark_json_schema, BenchmarkBuildProfile,
29 BenchmarkEntryKind, BenchmarkProvenance, BenchmarkStatistics, BenchmarkStatisticsError,
30 BenchmarkTarget, CompileMeasurements, DispatchMeasurements, PortableBenchmarkReceipt,
31 PORTABLE_BENCHMARK_SCHEMA_VERSION, PORTABLE_MAX_COMPILE_ITERATIONS,
32 PORTABLE_MAX_DISPATCH_ITERATIONS, PORTABLE_MAX_WORKERS,
33};
34pub use builtin_id::BuiltinId;
35pub use compiler::{CompileError, CompiledCallableEntry, Compiler, CompilerOptions};
36pub use execution::{
37 replay, resume, start, CapabilityRequest, CapabilityResult, DataValue, Execution, GrantSet,
38 ValueShape,
39};
40pub use opcode::{
41 opcode_abi_fingerprint, Op, OperandKind, Portability, OPCODE_ABI_ARTIFACT_VERSION,
42 OPCODE_ABI_FINGERPRINT_V1,
43};
44pub use program::{Chunk, CompiledFunction, Constant, LocalSlotInfo, ParamSlot};
45
46pub mod chunk {
49 pub use crate::program::*;
50 pub use crate::Op;
51}
52
53pub fn compile_source(source: &str) -> Result<Chunk, String> {
55 let program = harn_parser::check_source_strict(source).map_err(|error| error.to_string())?;
56 Compiler::new()
57 .compile(&program)
58 .map_err(|error| error.to_string())
59}
60
61pub fn compile_source_named(source: &str, pipeline_name: &str) -> Result<Chunk, String> {
62 let program = harn_parser::check_source_strict(source).map_err(|error| error.to_string())?;
63 let exists = program.iter().any(|node| {
64 let (_, inner) = harn_parser::peel_attributes(node);
65 matches!(&inner.node, harn_parser::Node::Pipeline { name, .. } if name == pipeline_name)
66 });
67 if !exists {
68 return Err(format!("no pipeline named `{pipeline_name}` in source"));
69 }
70 Compiler::new()
71 .compile_named(&program, pipeline_name)
72 .map_err(|error| error.to_string())
73}
74pub mod execution;