mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
feat(bindings)!: add RVM/Program support across FFI and language bindings (#565)
- FFI: add RVM/Program APIs, execution state accessors, HostAwait handling, and buffer/result helpers in rvm.rs, common.rs, engine.rs. - Compiler: emit HostAwait for __builtin_host_await in function_calls.rs. - RVM tests: add HostAwait regression cases and extend harness for suspend/resume responses in host_await.yaml and mod.rs. - C/C++: add RVM tests/examples and wrapper updates in rvm_tests.c, rvm_tests.cpp, regorus.hpp, plus CMake wiring. - C#: add Program/Rvm bindings, SafeHandle/PInvoke, tests, and example usage in Regorus, RvmProgramTests.cs, Program.cs, and README updates. - Go: add Program/Rvm bindings, tests, and examples in rvm.go, rvm_test.go, main.go. - Java: add Program/Rvm bindings, JNI glue, and examples in lib.rs, regorus, Test.java. - Python: add Program/Rvm bindings and examples in lib.rs, test.py. - WASM: add Program/Rvm bindings and examples in lib.rs, test.js. - Tooling: wire binding tests in xtask and ignore generated Java artifacts in .gitignore. Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
committed by
GitHub
parent
0316ccd90c
commit
3f7a5496dc
@@ -28,6 +28,9 @@ enum CallTarget {
|
||||
builtin_index: u16,
|
||||
expected_args: Option<usize>,
|
||||
},
|
||||
HostAwait {
|
||||
expected_args: Option<usize>,
|
||||
},
|
||||
}
|
||||
|
||||
impl<'a> Compiler<'a> {
|
||||
@@ -56,6 +59,7 @@ impl<'a> Compiler<'a> {
|
||||
let expected_args = match &call_target {
|
||||
CallTarget::User { expected_args, .. } => *expected_args,
|
||||
CallTarget::Builtin { expected_args, .. } => *expected_args,
|
||||
CallTarget::HostAwait { expected_args } => *expected_args,
|
||||
};
|
||||
|
||||
if let Some(expected) = expected_args {
|
||||
@@ -122,6 +126,26 @@ impl<'a> Compiler<'a> {
|
||||
});
|
||||
self.emit_instruction(Instruction::BuiltinCall { params_index }, &span);
|
||||
}
|
||||
CallTarget::HostAwait { .. } => {
|
||||
if arg_regs.len() != 2 {
|
||||
return Err(CompilerError::General {
|
||||
message: format!(
|
||||
"__builtin_host_await expects 2 arguments, got {}",
|
||||
arg_regs.len()
|
||||
),
|
||||
}
|
||||
.at(&span));
|
||||
}
|
||||
|
||||
self.emit_instruction(
|
||||
Instruction::HostAwait {
|
||||
dest,
|
||||
arg: arg_regs[0],
|
||||
id: arg_regs[1],
|
||||
},
|
||||
&span,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some((plan, plan_span)) = &out_param_plan {
|
||||
@@ -162,6 +186,12 @@ impl<'a> Compiler<'a> {
|
||||
full_fcn_path: &str,
|
||||
span: &Span,
|
||||
) -> Result<CallTarget> {
|
||||
if original_fcn_path == "__builtin_host_await" {
|
||||
return Ok(CallTarget::HostAwait {
|
||||
expected_args: Some(2),
|
||||
});
|
||||
}
|
||||
|
||||
if self.is_user_defined_function(full_fcn_path) {
|
||||
let rule_index = self.get_or_assign_rule_index(full_fcn_path)?;
|
||||
let expected_args = self
|
||||
|
||||
Reference in New Issue
Block a user