fix(bridge): implement env.box_introspect.kind lowering + Stage0 build fixes
Phase 25.1b type system groundwork - env.* namespace support in Bridge layer
Changes:
- Bridge layer (JSON v0 → MIR):
- Add 'env' as well-known variable in MapVars::resolve()
- Implement env.box_introspect.kind(value) → ExternCall lowering
- Pattern: Method { recv: Method { recv: Var("env"), method: "box_introspect" }, method: "kind" }
- VM/extern fixes:
- Add Arc::from() conversion for env.box_introspect.kind result
- Fix MapBox API usage in extern_functions.rs logging
- Build fixes:
- Comment out missing llvm_legacy/llvm modules in src/backend/mod.rs
- Comment out missing gui_visual_node_prototype in Cargo.toml
- New files:
- lang/src/shared/common/box_type_inspector_box.hako (type introspection API)
Context:
- Enables BoxTypeInspectorBox to query runtime Box types via env.box_introspect.kind
- Required for selfhost MirBuilder type-aware lowering (multi-carrier loops, etc.)
- Part of Phase 25.1b "no fallback" selfhosting strategy
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -80,6 +80,19 @@ impl<'a> VarScope for MapVars<'a> {
|
||||
self.vars.insert(name.to_string(), dst);
|
||||
return Ok(Some(dst));
|
||||
}
|
||||
// Phase 25.1b: Treat `env` as a well-known global for env.box_introspect.* etc.
|
||||
// Similar to hostbridge, we need a placeholder value for the nested method pattern.
|
||||
if name == "env" {
|
||||
let dst = f.next_value_id();
|
||||
if let Some(bb) = f.get_block_mut(cur_bb) {
|
||||
bb.add_instruction(MirInstruction::Const {
|
||||
dst,
|
||||
value: ConstValue::String("env".into()),
|
||||
});
|
||||
}
|
||||
self.vars.insert(name.to_string(), dst);
|
||||
return Ok(Some(dst));
|
||||
}
|
||||
if name == "me" {
|
||||
if env.allow_me_dummy {
|
||||
let dst = f.next_value_id();
|
||||
@ -363,6 +376,29 @@ pub(super) fn lower_expr_with_scope<S: VarScope>(
|
||||
}
|
||||
return Ok((dst, cur2));
|
||||
}
|
||||
// Phase 25.1b: Handle env.box_introspect.kind(value) pattern
|
||||
// Pattern: Method { recv: Method { recv: Var("env"), method: "box_introspect" }, method: "kind", args }
|
||||
if let ExprV0::Method { recv: inner_recv, method: inner_method, args: inner_args } = &**recv {
|
||||
if matches!(&**inner_recv, ExprV0::Var { name } if name == "env")
|
||||
&& inner_method == "box_introspect"
|
||||
&& inner_args.is_empty() {
|
||||
|
||||
// Lower args for the final method call
|
||||
let (arg_ids, cur2) = lower_args_with_scope(env, f, cur_bb, args, vars)?;
|
||||
let dst = f.next_value_id();
|
||||
|
||||
if let Some(bb) = f.get_block_mut(cur2) {
|
||||
bb.add_instruction(MirInstruction::ExternCall {
|
||||
dst: Some(dst),
|
||||
iface_name: "env.box_introspect".into(),
|
||||
method_name: method.clone(),
|
||||
args: arg_ids,
|
||||
effects: EffectMask::READ,
|
||||
});
|
||||
}
|
||||
return Ok((dst, cur2));
|
||||
}
|
||||
}
|
||||
let (recv_v, cur) = lower_expr_with_scope(env, f, cur_bb, recv, vars)?;
|
||||
let (arg_ids, cur2) = lower_args_with_scope(env, f, cur, args, vars)?;
|
||||
let dst = f.next_value_id();
|
||||
|
||||
Reference in New Issue
Block a user