Skip to content

Commit 93e63b7

Browse files
committed
Add host value callbacks to bridges
1 parent 32193a3 commit 93e63b7

66 files changed

Lines changed: 7686 additions & 371 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

baml_language/crates/baml_builtins2/baml_std/baml/ns_errors/errors.baml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class HostPanic {
5656
}
5757

5858
class HostCallable {
59+
message string
5960
class_name string
6061
language string
6162
traceback string?
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// snapshot the bytecode shape for a host-callable call site.
2+
//
3+
// A `Ty::Function` parameter is bound at the FFI boundary to an
4+
// `Object::HostClosure`; calling it via `f(x)` lowers to a plain
5+
// `CallIndirect` instruction at compile time. The HostClosure-specific
6+
// dispatch (yielding `VmExecState::SysOp { operation:
7+
// SysOp::BamlHostCallHostValue, args }`) is entirely a runtime concern
8+
// — the compiler emits no synthesized wrapper for this call.
9+
function call_with_callback(callback: (int) -> string, x: int) -> string {
10+
callback(x)
11+
}

baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____03_hir.snap

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____04_5_mir.snap

Lines changed: 52 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____04_tir.snap

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

baml_language/crates/baml_tests/snapshots/compiles/__baml_std__/baml_tests__compiles____baml_std____06_codegen.snap

Lines changed: 32 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)