This commit is contained in:
bQUARKz 2026-02-10 09:45:12 +00:00
parent d511ae4fe9
commit 07e9871b13
Signed by: bquarkz
SSH Key Fingerprint: SHA256:Z7dgqoglWwoK6j6u4QC87OveEq74WOhFN+gitsxtkf8
14 changed files with 459 additions and 4 deletions

View File

@ -390,6 +390,7 @@ mod tests {
let function = Function { let function = Function {
id: FunctionId(0), id: FunctionId(0),
name: "main".to_string(), name: "main".to_string(),
sig: crate::ir_core::SigId(0),
params: vec![], params: vec![],
return_type: Type::Void, return_type: Type::Void,
body: vec![ body: vec![
@ -428,6 +429,7 @@ mod tests {
// let func = Function { // let func = Function {
// id: FunctionId(1), // id: FunctionId(1),
// name: "main".to_string(), // name: "main".to_string(),
// sig: crate::ir_core::SigId(0),
// params: vec![], // params: vec![],
// return_type: Type::Void, // return_type: Type::Void,
// body: vec![ // body: vec![
@ -490,6 +492,7 @@ mod tests {
let func = Function { let func = Function {
id: FunctionId(1), id: FunctionId(1),
name: "main".to_string(), name: "main".to_string(),
sig: crate::ir_core::SigId(0),
params: vec![], params: vec![],
return_type: Type::Void, return_type: Type::Void,
body: vec![ body: vec![

View File

@ -339,6 +339,10 @@ mod tests {
functions: vec![Function { functions: vec![Function {
id: FunctionId(1), id: FunctionId(1),
name: "main".to_string(), name: "main".to_string(),
sig: {
let mut i = global_signature_interner().lock().unwrap();
i.intern(Signature { params: vec![], return_type: Type::Void })
},
param_slots: 0, param_slots: 0,
local_slots: 0, local_slots: 0,
return_slots: 0, return_slots: 0,

View File

@ -5,7 +5,7 @@ use crate::frontends::pbs::contracts::ContractRegistry;
use crate::frontends::pbs::symbols::*; use crate::frontends::pbs::symbols::*;
use crate::frontends::pbs::types::PbsType; use crate::frontends::pbs::types::PbsType;
use crate::ir_core::ids::{FieldId, FunctionId, TypeId, ValueId}; use crate::ir_core::ids::{FieldId, FunctionId, TypeId, ValueId};
use crate::ir_core::{Block, ConstPool, Function, Instr, InstrKind, Module, Param, Program, Terminator, Type}; use crate::ir_core::{Block, ConstPool, Function, Instr, InstrKind, Module, Param, Program, Terminator, Type, Signature, global_signature_interner};
use prometeu_analysis::{NameInterner, NodeId}; use prometeu_analysis::{NameInterner, NodeId};
use std::collections::HashMap; use std::collections::HashMap;
@ -404,9 +404,20 @@ impl<'a> Lowerer<'a> {
}; };
let return_slots = self.get_type_slots(&ret_ty); let return_slots = self.get_type_slots(&ret_ty);
// Build Signature and intern to SigId
let func_sig = Signature {
params: params.iter().map(|p| p.ty.clone()).collect(),
return_type: ret_ty.clone(),
};
let sig_id = {
let mut interner = global_signature_interner().lock().unwrap();
interner.intern(func_sig)
};
let func = Function { let func = Function {
id: func_id, id: func_id,
name: func_name, name: func_name,
sig: sig_id,
params, params,
return_type: ret_ty, return_type: ret_ty,
blocks: Vec::new(), blocks: Vec::new(),
@ -476,12 +487,22 @@ impl<'a> Lowerer<'a> {
let ret_ty = self.lower_type_node(n.ret); let ret_ty = self.lower_type_node(n.ret);
let return_slots = self.get_type_slots(&ret_ty); let return_slots = self.get_type_slots(&ret_ty);
// Build Signature and intern to SigId (espelha lower_function)
let func_sig = Signature {
params: params.iter().map(|p| p.ty.clone()).collect(),
return_type: ret_ty.clone(),
};
let sig_id = {
let mut interner = global_signature_interner().lock().unwrap();
interner.intern(func_sig)
};
// Inicializa a função atual (espelha lower_function) // Inicializa a função atual (espelha lower_function)
let func = Function { let func = Function {
id: func_id, id: func_id,
// Nome público da função no módulo: use apenas o nome do método. // Nome público da função no módulo: use apenas o nome do método.
// O module_path fará a desambiguação durante export/link. // O module_path fará a desambiguação durante export/link.
name: method_name, name: method_name,
sig: sig_id,
params, params,
return_type: ret_ty, return_type: ret_ty,
blocks: Vec::new(), blocks: Vec::new(),
@ -1530,9 +1551,20 @@ impl<'a> Lowerer<'a> {
let ret_ty = if let Some(ret) = n.ret { self.lower_type_node(ret) } else { Type::Void }; let ret_ty = if let Some(ret) = n.ret { self.lower_type_node(ret) } else { Type::Void };
let return_slots = self.get_type_slots(&ret_ty); let return_slots = self.get_type_slots(&ret_ty);
// Build Signature and intern to SigId
let func_sig = Signature {
params: params.iter().map(|p| p.ty.clone()).collect(),
return_type: ret_ty.clone(),
};
let sig_id = {
let mut interner = global_signature_interner().lock().unwrap();
interner.intern(func_sig)
};
let func = Function { let func = Function {
id: func_id, id: func_id,
name: full_name, name: full_name,
sig: sig_id,
params, params,
return_type: ret_ty, return_type: ret_ty,
blocks: Vec::new(), blocks: Vec::new(),

View File

@ -1,5 +1,5 @@
use super::block::Block; use super::block::Block;
use super::ids::FunctionId; use super::ids::{FunctionId, SigId};
use super::types::Type; use super::types::Type;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -16,6 +16,8 @@ pub struct Param {
pub struct Function { pub struct Function {
pub id: FunctionId, pub id: FunctionId,
pub name: String, pub name: String,
#[serde(skip)]
pub sig: SigId,
pub params: Vec<Param>, pub params: Vec<Param>,
pub return_type: Type, pub return_type: Type,
pub blocks: Vec<Block>, pub blocks: Vec<Block>,

View File

@ -15,6 +15,11 @@ pub struct ConstId(pub u32);
#[serde(transparent)] #[serde(transparent)]
pub struct TypeId(pub u32); pub struct TypeId(pub u32);
/// Unique identifier for a function signature (params + return type).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)]
#[serde(transparent)]
pub struct SigId(pub u32);
/// Unique identifier for a value (usually a local slot). /// Unique identifier for a value (usually a local slot).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(transparent)] #[serde(transparent)]

View File

@ -8,6 +8,7 @@ pub mod block;
pub mod instr; pub mod instr;
pub mod terminator; pub mod terminator;
pub mod validate; pub mod validate;
pub mod signature;
pub use block::*; pub use block::*;
pub use const_pool::*; pub use const_pool::*;
@ -19,6 +20,7 @@ pub use program::*;
pub use terminator::*; pub use terminator::*;
pub use types::*; pub use types::*;
pub use validate::*; pub use validate::*;
pub use signature::*;
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
@ -37,6 +39,10 @@ mod tests {
functions: vec![Function { functions: vec![Function {
id: FunctionId(10), id: FunctionId(10),
name: "entry".to_string(), name: "entry".to_string(),
sig: {
let mut i = global_signature_interner().lock().unwrap();
i.intern(Signature { params: vec![], return_type: Type::Void })
},
param_slots: 0, param_slots: 0,
local_slots: 0, local_slots: 0,
return_slots: 0, return_slots: 0,

View File

@ -0,0 +1,366 @@
use crate::ir_core::ids::SigId;
use crate::ir_core::types::Type;
use std::collections::HashMap;
use std::sync::{Mutex, OnceLock};
/// Canonical function signature: params + return type.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Signature {
pub params: Vec<Type>,
pub return_type: Type,
}
impl Signature {
/// Stable, deterministic descriptor. Example:
/// fn(int;string)->void
/// fn(array{int;4};optional{string})->result{void;error{E}}
pub fn descriptor(&self) -> String {
let mut s = String::new();
s.push_str("fn(");
for (i, p) in self.params.iter().enumerate() {
if i > 0 {
s.push(';');
}
encode_type(p, &mut s);
}
s.push(')');
s.push_str("->");
encode_type(&self.return_type, &mut s);
s
}
/// Parse a descriptor previously produced by `descriptor()`
pub fn from_descriptor(desc: &str) -> Result<Self, String> {
// Expect prefix: fn( ... )-> ...
if !desc.starts_with("fn(") {
return Err("Invalid descriptor: missing fn(".to_string());
}
let rest = &desc[3..];
let close = rest.find(')').ok_or_else(|| "Invalid descriptor: missing ')'".to_string())?;
let params_blob = &rest[..close];
let after = &rest[close + 1..];
let arrow = after.strip_prefix("->").ok_or_else(|| "Invalid descriptor: missing '->'".to_string())?;
let params = if params_blob.is_empty() {
Vec::new()
} else {
let mut v = Vec::new();
for part in split_top_level(params_blob, ';')? {
let (ty, consumed) = decode_type(part)?;
if consumed != part.len() {
return Err("Trailing garbage in parameter".to_string());
}
v.push(ty);
}
v
};
let (return_type, consumed) = decode_type(arrow)?;
if consumed != arrow.len() {
return Err("Trailing garbage after return type".to_string());
}
Ok(Signature { params, return_type })
}
}
/// Global signature interner. Thread-safe and process-wide for this compiler instance.
pub struct SignatureInterner {
map: HashMap<Signature, SigId>,
rev: Vec<Signature>,
}
impl SignatureInterner {
pub fn new() -> Self {
Self { map: HashMap::new(), rev: Vec::new() }
}
pub fn intern(&mut self, sig: Signature) -> SigId {
if let Some(id) = self.map.get(&sig) {
return *id;
}
let id = SigId(self.rev.len() as u32);
self.rev.push(sig.clone());
self.map.insert(sig, id);
id
}
pub fn resolve(&self, id: SigId) -> Option<&Signature> {
self.rev.get(id.0 as usize)
}
}
static GLOBAL_INTERNER: OnceLock<Mutex<SignatureInterner>> = OnceLock::new();
pub fn global_signature_interner() -> &'static Mutex<SignatureInterner> {
GLOBAL_INTERNER.get_or_init(|| Mutex::new(SignatureInterner::new()))
}
// ==============
// Encoding/Decoding helpers for `Type`
// Canonical grammar (EBNF-ish):
// Type := "void" | "int" | "bounded" | "float" | "bool" | "string"
// | "struct{" Name "}" | "service{" Name "}" | "contract{" Name "}"
// | "error{" Name "}" | "array{" Type ";" UInt "}"
// | "optional{" Type "}" | "result{" Type ";" Type "}"
// | "fn(" [Type { ";" Type }] ")" "->" Type
// Name := escaped UTF-8 without '}' and ';' (escape via '\')
fn encode_type(ty: &Type, out: &mut String) {
match ty {
Type::Void => out.push_str("void"),
Type::Int => out.push_str("int"),
Type::Bounded => out.push_str("bounded"),
Type::Float => out.push_str("float"),
Type::Bool => out.push_str("bool"),
Type::String => out.push_str("string"),
Type::Optional(inner) => {
out.push_str("optional{");
encode_type(inner, out);
out.push('}');
}
Type::Result(ok, err) => {
out.push_str("result{");
encode_type(ok, out);
out.push(';');
encode_type(err, out);
out.push('}');
}
Type::Struct(name) => {
out.push_str("struct{");
encode_name(name, out);
out.push('}');
}
Type::Service(name) => {
out.push_str("service{");
encode_name(name, out);
out.push('}');
}
Type::Contract(name) => {
out.push_str("contract{");
encode_name(name, out);
out.push('}');
}
Type::ErrorType(name) => {
out.push_str("error{");
encode_name(name, out);
out.push('}');
}
Type::Array(inner, n) => {
out.push_str("array{");
encode_type(inner, out);
out.push(';');
out.push_str(&n.to_string());
out.push('}');
}
Type::Function { params, return_type } => {
out.push_str("fn(");
for (i, p) in params.iter().enumerate() {
if i > 0 { out.push(';'); }
encode_type(p, out);
}
out.push(')');
out.push_str("->");
encode_type(return_type, out);
}
}
}
fn encode_name(name: &str, out: &mut String) {
for ch in name.chars() {
match ch {
'\\' => out.push_str("\\\\"),
'}' => out.push_str("\\}"),
';' => out.push_str("\\;"),
_ => out.push(ch),
}
}
}
fn decode_name(s: &str) -> Result<(String, usize), String> {
let mut out = String::new();
let mut chars = s.chars().peekable();
let mut consumed = 0;
while let Some(&c) = chars.peek() {
if c == '}' { break; }
consumed += 1;
chars.next();
if c == '\\' {
let next = chars.next().ok_or_else(|| "Invalid escape in name".to_string())?;
consumed += 1;
out.push(next);
} else {
out.push(c);
}
}
Ok((out, consumed))
}
fn split_top_level(input: &str, sep: char) -> Result<Vec<&str>, String> {
let mut parts = Vec::new();
let mut depth_brace = 0i32;
let mut depth_fn = 0i32; // counts '(' nesting for nested fn types
let mut start = 0usize;
for (i, ch) in input.char_indices() {
match ch {
'{' => depth_brace += 1,
'}' => depth_brace -= 1,
'(' => depth_fn += 1,
')' => depth_fn -= 1,
_ => {}
}
if ch == sep && depth_brace == 0 && depth_fn == 0 {
parts.push(&input[start..i]);
start = i + ch.len_utf8();
}
}
parts.push(&input[start..]);
if depth_brace != 0 || depth_fn != 0 {
return Err("Unbalanced delimiters".to_string());
}
Ok(parts)
}
fn decode_type(s: &str) -> Result<(Type, usize), String> {
// Order matters; check longer keywords first to avoid prefix issues
let keywords = [
"optional{",
"result{",
"struct{",
"service{",
"contract{",
"error{",
"array{",
"fn(",
"void",
"int",
"bounded",
"float",
"bool",
"string",
];
for kw in keywords {
if s.starts_with(kw) {
match kw {
"void" => return Ok((Type::Void, 4)),
"int" => return Ok((Type::Int, 3)),
"bounded" => return Ok((Type::Bounded, 7)),
"float" => return Ok((Type::Float, 5)),
"bool" => return Ok((Type::Bool, 4)),
"string" => return Ok((Type::String, 6)),
"optional{" => {
let (inner, used) = decode_type(&s[9..])?;
let rest = &s[9 + used..];
if !rest.starts_with('}') { return Err("Missing '}' for optional".to_string()); }
return Ok((Type::Optional(Box::new(inner)), 9 + used + 1));
}
"result{" => {
let (ok, used_ok) = decode_type(&s[7..])?;
let rest = &s[7 + used_ok..];
if !rest.starts_with(';') { return Err("Missing ';' in result".to_string()); }
let (err, used_err) = decode_type(&rest[1..])?;
let rest2 = &rest[1 + used_err..];
if !rest2.starts_with('}') { return Err("Missing '}' for result".to_string()); }
return Ok((Type::Result(Box::new(ok), Box::new(err)), 7 + used_ok + 1 + used_err + 1));
}
"struct{" => {
let (name, used) = decode_name(&s[7..])?;
let rest = &s[7 + used..];
if !rest.starts_with('}') { return Err("Missing '}' for struct".to_string()); }
return Ok((Type::Struct(name), 7 + used + 1));
}
"service{" => {
let (name, used) = decode_name(&s[8..])?;
let rest = &s[8 + used..];
if !rest.starts_with('}') { return Err("Missing '}' for service".to_string()); }
return Ok((Type::Service(name), 8 + used + 1));
}
"contract{" => {
let (name, used) = decode_name(&s[9..])?;
let rest = &s[9 + used..];
if !rest.starts_with('}') { return Err("Missing '}' for contract".to_string()); }
return Ok((Type::Contract(name), 9 + used + 1));
}
"error{" => {
let (name, used) = decode_name(&s[6..])?;
let rest = &s[6 + used..];
if !rest.starts_with('}') { return Err("Missing '}' for error".to_string()); }
return Ok((Type::ErrorType(name), 6 + used + 1));
}
"array{" => {
let (inner, used) = decode_type(&s[6..])?;
let rest = &s[6 + used..];
if !rest.starts_with(';') { return Err("Missing ';' in array".to_string()); }
// parse UInt
let rest_num = &rest[1..];
let mut n_str = String::new();
let mut consumed = 0usize;
for ch in rest_num.chars() {
if ch.is_ascii_digit() { n_str.push(ch); consumed += 1; } else { break; }
}
if n_str.is_empty() { return Err("Missing array size".to_string()); }
let n: u32 = n_str.parse().map_err(|_| "Invalid array size".to_string())?;
let rest2 = &rest_num[consumed..];
if !rest2.starts_with('}') { return Err("Missing '}' for array".to_string()); }
return Ok((Type::Array(Box::new(inner), n), 6 + used + 1 + consumed + 1));
}
"fn(" => {
// parse params until ')'
let after = &s[3..];
let close = after.find(')').ok_or_else(|| "Missing ')' in fn type".to_string())?;
let params_blob = &after[..close];
let mut params = Vec::new();
if !params_blob.is_empty() {
for part in split_top_level(params_blob, ';')? {
let (p, used) = decode_type(part)?;
if used != part.len() { return Err("Trailing data in fn param".to_string()); }
params.push(p);
}
}
let rest = &after[close + 1..];
if !rest.starts_with("->") { return Err("Missing '->' in fn type".to_string()); }
let (ret, used_ret) = decode_type(&rest[2..])?;
return Ok((Type::Function { params, return_type: Box::new(ret) }, 3 + close + 1 + 2 + used_ret));
}
_ => {}
}
}
}
Err("Unknown type in descriptor".to_string())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn descriptors_are_different_for_overloads() {
let sig_i = Signature {
params: vec![Type::Int],
return_type: Type::Void,
};
let sig_s = Signature {
params: vec![Type::String],
return_type: Type::Void,
};
assert_ne!(sig_i.descriptor(), sig_s.descriptor());
}
#[test]
fn descriptor_round_trip_stable() {
let sig = Signature {
params: vec![
Type::Array(Box::new(Type::Int), 4),
Type::Optional(Box::new(Type::String)),
Type::Result(Box::new(Type::Int), Box::new(Type::ErrorType("E42".into()))),
],
return_type: Type::Void,
};
let d1 = sig.descriptor();
let parsed = Signature::from_descriptor(&d1).expect("parse ok");
let d2 = parsed.descriptor();
assert_eq!(d1, d2);
assert_eq!(sig, parsed);
}
}

View File

@ -1,7 +1,7 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::fmt; use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Type { pub enum Type {
Void, Void,
Int, Int,

View File

@ -158,6 +158,10 @@ mod tests {
Function { Function {
id: FunctionId(1), id: FunctionId(1),
name: "test".to_string(), name: "test".to_string(),
sig: {
let mut i = global_signature_interner().lock().unwrap();
i.intern(Signature { params: vec![], return_type: Type::Void })
},
param_slots: 0, param_slots: 0,
local_slots: 0, local_slots: 0,
return_slots: 0, return_slots: 0,

View File

@ -51,6 +51,7 @@ mod tests {
functions: vec![Function { functions: vec![Function {
id: FunctionId(1), id: FunctionId(1),
name: "main".to_string(), name: "main".to_string(),
sig: crate::ir_core::SigId(0),
param_slots: 0, param_slots: 0,
local_slots: 0, local_slots: 0,
return_slots: 0, return_slots: 0,
@ -128,6 +129,10 @@ mod tests {
functions: vec![ir_core::Function { functions: vec![ir_core::Function {
id: FunctionId(10), id: FunctionId(10),
name: "start".to_string(), name: "start".to_string(),
sig: {
let mut i = crate::ir_core::global_signature_interner().lock().unwrap();
i.intern(crate::ir_core::Signature { params: vec![], return_type: ir_core::Type::Void })
},
param_slots: 0, param_slots: 0,
local_slots: 0, local_slots: 0,
return_slots: 0, return_slots: 0,

View File

@ -5,7 +5,7 @@
//! than the source code AST. It is organized into Modules, Functions, and Globals. //! than the source code AST. It is organized into Modules, Functions, and Globals.
use crate::ir_core::const_pool::ConstPool; use crate::ir_core::const_pool::ConstPool;
use crate::ir_core::ids::FunctionId; use crate::ir_core::ids::{FunctionId, SigId};
use crate::ir_vm::instr::Instruction; use crate::ir_vm::instr::Instruction;
use crate::ir_vm::types::Type; use crate::ir_vm::types::Type;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -34,6 +34,9 @@ pub struct Function {
pub id: FunctionId, pub id: FunctionId,
/// The unique name of the function. /// The unique name of the function.
pub name: String, pub name: String,
/// Canonical signature id (params + return type). Not serialized yet.
#[serde(skip)]
pub sig: SigId,
/// The list of input parameters. /// The list of input parameters.
pub params: Vec<Param>, pub params: Vec<Param>,
/// The type of value this function returns. /// The type of value this function returns.

View File

@ -55,6 +55,7 @@ pub fn lower_function(
let mut vm_func = ir_vm::Function { let mut vm_func = ir_vm::Function {
id: core_func.id, id: core_func.id,
name: core_func.name.clone(), name: core_func.name.clone(),
sig: core_func.sig,
params: core_func.params.iter().map(|p| ir_vm::Param { params: core_func.params.iter().map(|p| ir_vm::Param {
name: p.name.clone(), name: p.name.clone(),
r#type: lower_type(&p.ty), r#type: lower_type(&p.ty),
@ -430,6 +431,10 @@ mod tests {
functions: vec![ir_core::Function { functions: vec![ir_core::Function {
id: FunctionId(1), id: FunctionId(1),
name: "main".to_string(), name: "main".to_string(),
sig: {
let mut i = ir_core::global_signature_interner().lock().unwrap();
i.intern(ir_core::Signature { params: vec![], return_type: ir_core::Type::Void })
},
params: vec![], params: vec![],
return_type: ir_core::Type::Void, return_type: ir_core::Type::Void,
blocks: vec![ blocks: vec![
@ -514,6 +519,10 @@ mod tests {
functions: vec![ir_core::Function { functions: vec![ir_core::Function {
id: FunctionId(1), id: FunctionId(1),
name: "test_fields".to_string(), name: "test_fields".to_string(),
sig: {
let mut i = ir_core::global_signature_interner().lock().unwrap();
i.intern(ir_core::Signature { params: vec![], return_type: ir_core::Type::Void })
},
params: vec![], params: vec![],
return_type: ir_core::Type::Void, return_type: ir_core::Type::Void,
blocks: vec![Block { blocks: vec![Block {
@ -578,6 +587,10 @@ mod tests {
functions: vec![ir_core::Function { functions: vec![ir_core::Function {
id: FunctionId(1), id: FunctionId(1),
name: "fail".to_string(), name: "fail".to_string(),
sig: {
let mut i = ir_core::global_signature_interner().lock().unwrap();
i.intern(ir_core::Signature { params: vec![], return_type: ir_core::Type::Void })
},
params: vec![], params: vec![],
return_type: ir_core::Type::Void, return_type: ir_core::Type::Void,
blocks: vec![Block { blocks: vec![Block {
@ -616,6 +629,10 @@ mod tests {
functions: vec![ir_core::Function { functions: vec![ir_core::Function {
id: FunctionId(1), id: FunctionId(1),
name: "main".to_string(), name: "main".to_string(),
sig: {
let mut i = ir_core::global_signature_interner().lock().unwrap();
i.intern(ir_core::Signature { params: vec![], return_type: ir_core::Type::Void })
},
params: vec![], params: vec![],
return_type: ir_core::Type::Void, return_type: ir_core::Type::Void,
blocks: vec![Block { blocks: vec![Block {
@ -688,6 +705,10 @@ mod tests {
functions: vec![ir_core::Function { functions: vec![ir_core::Function {
id: FunctionId(1), id: FunctionId(1),
name: "main".to_string(), name: "main".to_string(),
sig: {
let mut i = ir_core::global_signature_interner().lock().unwrap();
i.intern(ir_core::Signature { params: vec![], return_type: ir_core::Type::Void })
},
params: vec![], params: vec![],
return_type: ir_core::Type::Void, return_type: ir_core::Type::Void,
blocks: vec![Block { blocks: vec![Block {

View File

@ -27,6 +27,10 @@ fn test_hip_conformance_core_to_vm_to_bytecode() {
functions: vec![ir_core::Function { functions: vec![ir_core::Function {
id: FunctionId(1), id: FunctionId(1),
name: "main".to_string(), name: "main".to_string(),
sig: {
let mut i = ir_core::global_signature_interner().lock().unwrap();
i.intern(ir_core::Signature { params: vec![], return_type: ir_core::Type::Void })
},
param_slots: 0, param_slots: 0,
local_slots: 0, local_slots: 0,
return_slots: 0, return_slots: 0,