mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
feat(rvm): extend program metadata and bump serialization to v6 (#654)
Add typed metadata support to RVM programs so that language frontends can store language identity and arbitrary annotations alongside the compiled bytecode. Program metadata: - Add `language` field to identify the source language (e.g. "rego", "azure_policy") so the VM can adjust semantics at runtime - Add `annotations` map (BTreeMap<String, MetadataValue>) for frontend-specific key-value metadata - Add MetadataValue enum with String, Bool, Integer, Float, Array, and Object variants, plus full serde support - Add to_value() conversion for runtime access from VM instructions - Add has_host_await flag with recompute_host_await_presence() Serialization: - Bump binary format version from 5 to 6 - Add JSON serialization for the new metadata fields Assembly listing: - Display language and annotations in the program header Compiler: - Track has_host_await during Rego compilation
This commit is contained in:
committed by
GitHub
parent
db8a9abf13
commit
95bffcb5f9
@@ -259,6 +259,9 @@ impl<'a> Compiler<'a> {
|
||||
}
|
||||
|
||||
pub fn emit_instruction(&mut self, instruction: Instruction, span: &Span) {
|
||||
if matches!(instruction, Instruction::HostAwait { .. }) {
|
||||
self.program.has_host_await = true;
|
||||
}
|
||||
self.program.instructions.push(instruction);
|
||||
|
||||
let source_path = span.source.get_path().to_string();
|
||||
|
||||
@@ -23,8 +23,8 @@ pub use error::{CompilerError, Result, SpannedCompilerError};
|
||||
use crate::ast::ExprRef;
|
||||
use crate::lexer::Span;
|
||||
use crate::rvm::program::{Program, RuleType, SpanInfo};
|
||||
use crate::value::Value;
|
||||
use crate::CompiledPolicy;
|
||||
use crate::Value;
|
||||
use alloc::collections::{BTreeMap, BTreeSet};
|
||||
use alloc::string::String;
|
||||
use alloc::vec;
|
||||
|
||||
Reference in New Issue
Block a user