llvm/codegen: extract wrapper/object emission into object.rs; dedupe mod.rs. runner/json_v0_bridge: introduce BridgeEnv + VarScope to unify lowering paths (lower_expr/args) and cache env flags; thread env through stmt lowering; minor HashMap type cleanups. Build + PyVM stage-2 smokes passed.
This commit is contained in:
@ -1,27 +1,39 @@
|
||||
use std::collections::HashMap;
|
||||
use crate::mir::instruction::{ConstValue, MirInstruction};
|
||||
use crate::mir::ValueId;
|
||||
use crate::mir::instruction::{MirInstruction, ConstValue};
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub(super) fn sanitize_symbol(name: &str) -> String {
|
||||
name.chars()
|
||||
.map(|c| match c { '.' | '/' | '-' => '_', other => other })
|
||||
.map(|c| match c {
|
||||
'.' | '/' | '-' => '_',
|
||||
other => other,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub(super) fn build_const_str_map(f: &crate::mir::function::MirFunction) -> HashMap<ValueId, String> {
|
||||
pub(super) fn build_const_str_map(
|
||||
f: &crate::mir::function::MirFunction,
|
||||
) -> HashMap<ValueId, String> {
|
||||
let mut m = HashMap::new();
|
||||
for bid in f.block_ids() {
|
||||
if let Some(b) = f.blocks.get(&bid) {
|
||||
for inst in &b.instructions {
|
||||
if let MirInstruction::Const { dst, value: ConstValue::String(s) } = inst {
|
||||
if let MirInstruction::Const {
|
||||
dst,
|
||||
value: ConstValue::String(s),
|
||||
} = inst
|
||||
{
|
||||
m.insert(*dst, s.clone());
|
||||
}
|
||||
}
|
||||
if let Some(MirInstruction::Const { dst, value: ConstValue::String(s) }) = &b.terminator {
|
||||
if let Some(MirInstruction::Const {
|
||||
dst,
|
||||
value: ConstValue::String(s),
|
||||
}) = &b.terminator
|
||||
{
|
||||
m.insert(*dst, s.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
m
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user