mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-13 03:42:35 -06:00
bcf6bb8f49
This commit adds support for built-in functions. Previously there was no way for the host environment to supply functions that could be invoked from inside the wasm runtime. This change updates the wasm library to declare callbacks that can be invoked by the policy. The host environment should implement the callbacks by using the first argument to dispatch to appropriate built-in function implementation. The second callback argument is reserved for future use. The remaining arguments represent the operands passed to the call in the policy. This approach is used for now because it avoids the need to update the function index when compiling the policy executable which would require relinking the wasm library object files (because if built-in imports were added dynamically the function index would be shifted by some number and all of the call instructions in the wasm library would have to be rewritten.) Signed-off-by: Torin Sandall <torinsandall@gmail.com>