Skip to content

Commit a6b07f9

Browse files
committed
Reworked handling of statics to preserve more info.
1 parent 97c4fa5 commit a6b07f9

File tree

28 files changed

+534
-513
lines changed

28 files changed

+534
-513
lines changed

cilly/src/bin/asmedit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ fn misolate(asm: &mut Assembly, isolate_id: Interned<MethodRef>) {
360360
}
361361
fn parse_id(id: &str, asm: &Assembly) -> Interned<MethodRef> {
362362
if let Ok(id) = id.parse::<u32>() {
363-
unsafe { Interned::from_index(NonZeroU32::new(id).unwrap()) }
363+
Interned::from_index(NonZeroU32::new(id).unwrap())
364364
} else {
365365
let Some(mut iter) = asm.find_methods_matching(id) else {
366366
panic!("{id:?} is neithier a method name nor a method id")

cilly/src/v2/asm.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ impl Assembly {
185185
let method_def_idxs: Box<[_]> = self.method_defs.keys().copied().collect();
186186
for method in method_def_idxs {
187187
let mut tmp_method = self.method_def(method).clone();
188-
tmp_method.typecheck(self);
188+
if let Err(err) = tmp_method.typecheck(self) {
189+
eprintln!("{err:?}");
190+
};
189191
}
190192
}
191193
#[must_use]

cilly/src/v2/asm_link.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ impl Assembly {
108108
super::Const::Null(cref) => super::Const::Null(self.translate_class_ref(source, *cref)),
109109
super::Const::ByteBuffer { data, tpe } => {
110110
let tpe = self.translate_type(source, source[*tpe]);
111-
(super::Const::ByteBuffer {
111+
super::Const::ByteBuffer {
112112
data: self.alloc_const_data(&source.const_data[*data]),
113113
tpe: self.alloc_type(tpe),
114-
})
114+
}
115115
}
116116
_ => cst.clone(),
117117
}

cilly/src/v2/builtins/atomics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{
22
asm::MissingMethodPatcher,
33
bimap::Interned,
4-
cilnode::{ExtendKind, MethodKind, PtrCastRes},
4+
cilnode::{ExtendKind, MethodKind},
55
cilroot::BranchCond,
66
BasicBlock, BinOp, CILNode, CILRoot, ClassRef, Const, Int, MethodImpl, MethodRef, Type,
77
};

cilly/src/v2/builtins/int128/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{
2-
asm::MissingMethodPatcher, cilnode::UnOp, Assembly, BasicBlock, BinOp, BranchCond, CILNode,
3-
CILRoot, ClassRef, Const, Int, MethodImpl, Type,
2+
asm::MissingMethodPatcher, Assembly, BasicBlock, BinOp, BranchCond, CILNode, CILRoot, ClassRef,
3+
Const, Int, MethodImpl, Type,
44
};
55

66
fn op_direct(

cilly/src/v2/builtins/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,8 @@ pub fn insert_exeception_stub(asm: &mut Assembly, patcher: &mut MissingMethodPat
429429
Some(NonZeroU32::new(8).unwrap()),
430430
None,
431431
true,
432-
));
432+
))
433+
.unwrap();
433434
insert_catch_unwind_stub(asm, patcher);
434435
}
435436
pub fn insert_exception(asm: &mut Assembly, patcher: &mut MissingMethodPatcher) {

cilly/src/v2/builtins/simd/binop.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{
22
asm::MissingMethodPatcher, tpe::simd::SIMDElem, Assembly, BasicBlock, BinOp, CILNode, CILRoot,
3-
Const, Int, Interned, MethodImpl, MethodRef, Type,
3+
Const, Interned, MethodImpl, MethodRef, Type,
44
};
55
macro_rules! binop {
66
($op_name:ident,$op_dotnet:literal) => {
@@ -108,7 +108,7 @@ fn simd_binop(
108108
}
109109
pub fn fallback_simd(asm: &mut Assembly, patcher: &mut MissingMethodPatcher) {
110110
simd_binop(
111-
|asm, lhs, rhs, elem, res_tpe| {
111+
|asm, lhs, rhs, _, res_tpe| {
112112
let res = asm.biop(lhs, rhs, BinOp::Lt);
113113
asm.int_cast(
114114
res,
@@ -121,7 +121,7 @@ pub fn fallback_simd(asm: &mut Assembly, patcher: &mut MissingMethodPatcher) {
121121
patcher,
122122
);
123123
simd_binop(
124-
|asm, lhs, rhs, elem, res_tpe| {
124+
|asm, lhs, rhs, _, res_tpe| {
125125
let res = asm.biop(lhs, rhs, BinOp::Eq);
126126
asm.int_cast(
127127
res,

cilly/src/v2/builtins/simd/eq.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use crate::{
2-
asm::MissingMethodPatcher,
3-
bimap::Interned,
4-
tpe::simd::{SIMDElem, SIMDVector},
5-
Assembly, BasicBlock, BinOp, CILNode, CILRoot, Const, MethodImpl, MethodRef, Type,
2+
asm::MissingMethodPatcher, bimap::Interned, Assembly, BasicBlock, CILNode, CILRoot, MethodImpl,
3+
MethodRef, Type,
64
};
75

86
use super::dotnet_vec_cast;

cilly/src/v2/c_exporter/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,13 +715,15 @@ impl CExporter {
715715
CILNode::LdStaticField(static_field_idx) => {
716716
let field = asm[static_field_idx];
717717
let class = asm[field.owner()].clone();
718-
let fname = class_member_name(&asm[class.name()], &asm[field.name()]);
718+
let fname =
719+
class_member_name(&asm[class.name()], &escape_nonfn_name(&asm[field.name()]));
719720
fname.to_string()
720721
}
721722
CILNode::LdStaticFieldAdress(static_field_idx) => {
722723
let field = asm[static_field_idx];
723724
let class = asm[field.owner()].clone();
724-
let fname = class_member_name(&asm[class.name()], &asm[field.name()]);
725+
let fname =
726+
class_member_name(&asm[class.name()], &escape_nonfn_name(&asm[field.name()]));
725727
format!("&{}", fname)
726728
}
727729
CILNode::LdFtn(method) => mref_to_name(&asm[method], asm),
@@ -951,7 +953,8 @@ impl CExporter {
951953
CILRoot::SetStaticField { field, val } => {
952954
let field = asm[field];
953955
let class = asm[field.owner()].clone();
954-
let fname = class_member_name(&asm[class.name()], &asm[field.name()]);
956+
let fname =
957+
class_member_name(&asm[class.name()], &escape_nonfn_name(&asm[field.name()]));
955958
let val = Self::node_to_string(asm[val].clone(), asm, locals, inputs, sig)?;
956959
format!("{fname} = {val};")
957960
}

cilly/src/v2/cilroot.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use serde::{Deserialize, Serialize};
22

33
use super::{
4-
bimap::{BiMapIndex, Interned, IntoBiMapIndex},
5-
cilnode::IsPure,
6-
Assembly, CILNode, FieldDesc, Float, FnSig, Int, MethodRef, StaticFieldDesc, Type,
4+
bimap::Interned, cilnode::IsPure, Assembly, CILNode, FieldDesc, Float, FnSig, Int, MethodRef,
5+
StaticFieldDesc, Type,
76
};
87
use crate::{cil_root::CILRoot as V1Root, IString};
98
//use crate::cil_node::CILNode as V1Node;

0 commit comments

Comments
 (0)