Builder: reserve slots for user-defined instance methods (start at 4)\n- Deterministic per-type slot assignment via sorted names\n- Enables method_id emission for user boxes when type known\n- Docs updated
This commit is contained in:
@ -18,6 +18,7 @@ Last Updated: 2025-08-26
|
|||||||
- MIR Builder
|
- MIR Builder
|
||||||
- When receiver type can be inferred, emit `BoxCall { method_id }` (slot ID) instead of name.
|
- When receiver type can be inferred, emit `BoxCall { method_id }` (slot ID) instead of name.
|
||||||
- Add late-bind fallback path for unresolved sites (keeps current behavior).
|
- Add late-bind fallback path for unresolved sites (keeps current behavior).
|
||||||
|
- Reserve user-defined instance methods slots deterministically (start at 4; universal [0..3]).
|
||||||
- Debug scaffolding
|
- Debug scaffolding
|
||||||
- Add `MIRDebugInfo` container types (empty by default) for ID→name mapping (off by default).
|
- Add `MIRDebugInfo` container types (empty by default) for ID→name mapping (off by default).
|
||||||
- Docs
|
- Docs
|
||||||
@ -46,4 +47,3 @@ Last Updated: 2025-08-26
|
|||||||
|
|
||||||
## Roll-forward
|
## Roll-forward
|
||||||
- Proceed to 9.79b.2 (VM vtable/thunk + mono-PIC).
|
- Proceed to 9.79b.2 (VM vtable/thunk + mono-PIC).
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@ use super::{
|
|||||||
FunctionSignature, ValueId, ConstValue, BinaryOp, UnaryOp, CompareOp,
|
FunctionSignature, ValueId, ConstValue, BinaryOp, UnaryOp, CompareOp,
|
||||||
MirType, EffectMask, Effect, BasicBlockIdGenerator, ValueIdGenerator
|
MirType, EffectMask, Effect, BasicBlockIdGenerator, ValueIdGenerator
|
||||||
};
|
};
|
||||||
|
use super::slot_registry::{get_or_assign_type_id, reserve_method_slot};
|
||||||
use super::slot_registry::resolve_slot_by_type_name;
|
use super::slot_registry::resolve_slot_by_type_name;
|
||||||
use crate::ast::{ASTNode, LiteralValue, BinaryOperator};
|
use crate::ast::{ASTNode, LiteralValue, BinaryOperator};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
@ -1424,6 +1425,22 @@ impl MirBuilder {
|
|||||||
self.weak_fields_by_box.insert(name.clone(), set);
|
self.weak_fields_by_box.insert(name.clone(), set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reserve method slots for user-defined instance methods (deterministic, starts at 4)
|
||||||
|
let mut instance_methods: Vec<String> = Vec::new();
|
||||||
|
for (mname, mast) in &methods {
|
||||||
|
if let ASTNode::FunctionDeclaration { is_static, .. } = mast {
|
||||||
|
if !*is_static { instance_methods.push(mname.clone()); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
instance_methods.sort();
|
||||||
|
if !instance_methods.is_empty() {
|
||||||
|
let tyid = get_or_assign_type_id(&name);
|
||||||
|
for (i, m) in instance_methods.iter().enumerate() {
|
||||||
|
let slot = 4u16.saturating_add(i as u16);
|
||||||
|
reserve_method_slot(tyid, m, slot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Process methods - now methods is a HashMap
|
// Process methods - now methods is a HashMap
|
||||||
for (method_name, method_ast) in methods {
|
for (method_name, method_ast) in methods {
|
||||||
if let ASTNode::FunctionDeclaration { .. } = method_ast {
|
if let ASTNode::FunctionDeclaration { .. } = method_ast {
|
||||||
|
|||||||
Reference in New Issue
Block a user