Skip to content

Commit

Permalink
Added more tests + refactored the project to remove the old signature…
Browse files Browse the repository at this point in the history
… representation
  • Loading branch information
FractalFir committed Sep 12, 2024
1 parent 186b498 commit 50de7fc
Show file tree
Hide file tree
Showing 45 changed files with 750 additions and 594 deletions.
10 changes: 5 additions & 5 deletions cilly/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use crate::{
call_site::CallSite,
cil_root::CILRoot,
method::{Method, MethodType},
v2::{ClassDef, Int},
FnSig, IString, Type,
v2::{ClassDef, FnSig, Int},
IString, Type,
};

#[derive(Clone, Copy, Serialize, Deserialize, Debug)]
Expand Down Expand Up @@ -104,14 +104,14 @@ impl Assembly {
.entry(CallSite::new(
None,
".tcctor".into(),
FnSig::new([], Type::Void),
FnSig::new(Box::new([]), Type::Void),
true,
))
.or_insert_with(|| {
Method::new(
AccessModifer::Extern,
MethodType::Static,
FnSig::new([], Type::Void),
FnSig::new(Box::new([]), Type::Void),
".tcctor",
vec![
(None, self.inner.nptr(Type::Int(Int::U8))),
Expand Down Expand Up @@ -164,7 +164,7 @@ impl Assembly {
self.functions.get_mut(&CallSite::new(
None,
".cctor".into(),
FnSig::new([], Type::Void),
FnSig::new(Box::new([]), Type::Void),
true,
))
}
Expand Down
9 changes: 4 additions & 5 deletions cilly/src/bin/linker/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ use cilly::{
v2::{
asm::{MissingMethodPatcher, ILASM_FLAVOUR},
cilnode::MethodKind,
Assembly, BasicBlock, CILNode, CILRoot, ClassDef, ClassRef, Const, IlasmFlavour, Int,
MethodImpl, Type,
Assembly, BasicBlock, CILNode, CILRoot, ClassDef, ClassRef, Const, FnSig, IlasmFlavour,
Int, MethodImpl, Type,
},
FnSig,
};
//use assembly::Assembly;
use lazy_static::lazy_static;
Expand Down Expand Up @@ -267,7 +266,7 @@ fn main() {
))),
".ctor".into(),
FnSig::new(
[
Box::new([
Type::ClassRef(asm.alloc_class_ref(
ClassRef::new(
rust_exception,
Expand All @@ -277,7 +276,7 @@ fn main() {
),
)),
Type::Int(Int::USize),
],
]),
Type::Void,
),
false,
Expand Down
14 changes: 7 additions & 7 deletions cilly/src/call_site.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
v2::{Assembly, ClassRef, ClassRefIdx, Int},
FnSig, Type,
v2::{Assembly, ClassRef, ClassRefIdx, FnSig, Int},
Type,
};
use serde::{Deserialize, Serialize};

Expand All @@ -22,7 +22,7 @@ impl CallSite {
Self::new_extern(
ClassRef::marshal(asm),
"StringToCoTaskMemUTF8".into(),
FnSig::new([Type::PlatformString], Type::Int(Int::ISize)),
FnSig::new(Box::new([Type::PlatformString]), Type::Int(Int::ISize)),
true,
)
}
Expand All @@ -32,7 +32,7 @@ impl CallSite {
ClassRef::native_mem(asm),
"AlignedAlloc".into(),
FnSig::new(
[Type::Int(Int::USize), Type::Int(Int::USize)],
Box::new([Type::Int(Int::USize), Type::Int(Int::USize)]),
asm.nptr(Type::Void),
),
true,
Expand All @@ -43,7 +43,7 @@ impl CallSite {
Self::new_extern(
ClassRef::marshal(asm),
"AllocHGlobal".into(),
FnSig::new([Type::Int(Int::I32)], Type::Int(Int::ISize)),
FnSig::new(Box::new([Type::Int(Int::I32)]), Type::Int(Int::ISize)),
true,
)
}
Expand All @@ -53,11 +53,11 @@ impl CallSite {
Some(ClassRef::native_mem(asm)),
"AlignedRealloc".into(),
FnSig::new(
[
Box::new([
asm.nptr(Type::Void),
Type::Int(Int::USize),
Type::Int(Int::USize),
],
]),
asm.nptr(Type::Void),
),
true,
Expand Down
9 changes: 6 additions & 3 deletions cilly/src/cil_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,8 @@ impl<'a> IntoIterator for &'a CILRoot {
fn iter() {
use crate::{
call_site::CallSite,
v2::{hashable::HashableF32, Float, Int},
FnSig, Type,
v2::{hashable::HashableF32, Float, FnSig, Int},
Type,
};
let node = CILNode::Add(
Box::new(CILNode::Mul(
Expand Down Expand Up @@ -578,7 +578,10 @@ fn iter() {
site: Box::new(CallSite::new(
None,
"bob".to_owned().into(),
FnSig::new([Type::Int(Int::I32), Type::Float(Float::F32)], Type::Void),
FnSig::new(
Box::new([Type::Int(Int::I32), Type::Float(Float::F32)]),
Type::Void,
),
true,
)),
args: [CILNode::LdcI32(-77), CILNode::LdcF32(HashableF32(3.119765))].into(),
Expand Down
9 changes: 6 additions & 3 deletions cilly/src/cil_iter_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,8 @@ impl<'a, T: Iterator<Item = CILIterElemMut<'a>>> CILIterMutTrait<'a> for T {
fn iter() {
use crate::{
call_site::CallSite,
v2::{hashable::HashableF32, Float, Int},
FnSig, Type,
v2::{hashable::HashableF32, Float, FnSig, Int},
Type,
};
let mut node = CILNode::Add(
Box::new(CILNode::Mul(
Expand Down Expand Up @@ -615,7 +615,10 @@ fn iter() {
site: Box::new(CallSite::new(
None,
"bob".into(),
FnSig::new([Type::Int(Int::I32), Type::Float(Float::F32)], Type::Void),
FnSig::new(
Box::new([Type::Int(Int::I32), Type::Float(Float::F32)]),
Type::Void,
),
true,
)),
args: [CILNode::LdcI32(-77), CILNode::LdcF32(HashableF32(3.119765))].into(),
Expand Down
45 changes: 22 additions & 23 deletions cilly/src/cil_node.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use crate::v2::{Assembly, ClassRef, ClassRefIdx, Int, Type};
use crate::v2::{Assembly, ClassRef, ClassRefIdx, FnSig, Int, Type};
use crate::{
call,
call_site::CallSite,
cil_iter::CILIterTrait,
cil_root::CILRoot,
field_desc::FieldDescriptor,
fn_sig::FnSig,
static_field_desc::StaticFieldDescriptor,
v2::hashable::{HashableF32, HashableF64},
IString,
Expand Down Expand Up @@ -242,11 +241,11 @@ impl CILNode {
let low = u128_low_u64(value);
let high = (value >> 64) as u64;
let ctor_sig = FnSig::new(
[
Box::new([
asm.nref(Type::Int(Int::U128)),
Type::Int(Int::U64),
Type::Int(Int::U64),
],
]),
Type::Void,
);
CILNode::NewObj(Box::new(CallOpArgs {
Expand All @@ -270,11 +269,11 @@ impl CILNode {
let low = u128_low_u64(value);
let high = (value >> 64) as u64;
let ctor_sig = FnSig::new(
[
Box::new([
asm.nref(Type::Int(Int::U128)),
Type::Int(Int::U64),
Type::Int(Int::U64),
],
]),
Type::Void,
);
CILNode::NewObj(Box::new(CallOpArgs {
Expand All @@ -298,7 +297,7 @@ impl CILNode {
Some(ClassRef::gc_handle(asm)),
"Alloc".to_owned().into(),
FnSig::new(
[Type::PlatformObject],
Box::new([Type::PlatformObject]),
Type::ClassRef(ClassRef::gc_handle(asm))
),
true
Expand All @@ -310,7 +309,7 @@ impl CILNode {
Some(ClassRef::gc_handle(asm)),
"op_Explicit".to_owned().into(),
FnSig::new(
[Type::ClassRef(ClassRef::gc_handle(asm))],
Box::new([Type::ClassRef(ClassRef::gc_handle(asm))]),
Type::Int(Int::ISize)
),
true,
Expand All @@ -324,7 +323,7 @@ impl CILNode {
Some(ClassRef::gc_handle(asm)),
"FromIntPtr".to_owned().into(),
FnSig::new(
[Type::Int(Int::ISize)],
Box::new([Type::Int(Int::ISize)]),
Type::ClassRef(ClassRef::gc_handle(asm))
),
true
Expand All @@ -341,7 +340,7 @@ impl CILNode {
CallSite::new(
Some(ClassRef::gc_handle(asm)),
"get_Target".to_owned().into(),
FnSig::new([asm.nref(gc_handle_tpe)], Type::PlatformObject),
FnSig::new(Box::new([asm.nref(gc_handle_tpe)]), Type::PlatformObject),
false,
),
[gc_handle]
Expand All @@ -355,7 +354,7 @@ impl CILNode {
CallSite::builtin(
"select_u128".to_owned().into(),
FnSig::new(
[Type::Int(Int::U128), Type::Int(Int::U128), Type::Bool],
Box::new([Type::Int(Int::U128), Type::Int(Int::U128), Type::Bool]),
Type::Int(Int::U128)
),
true
Expand All @@ -366,7 +365,7 @@ impl CILNode {
CallSite::builtin(
"select_i128".to_owned().into(),
FnSig::new(
[Type::Int(Int::I128), Type::Int(Int::I128), Type::Bool],
Box::new([Type::Int(Int::I128), Type::Int(Int::I128), Type::Bool]),
Type::Int(Int::I128)
),
true
Expand All @@ -377,7 +376,7 @@ impl CILNode {
CallSite::builtin(
"select_usize".to_owned().into(),
FnSig::new(
[Type::Int(Int::USize), Type::Int(Int::USize), Type::Bool],
Box::new([Type::Int(Int::USize), Type::Int(Int::USize), Type::Bool]),
Type::Int(Int::USize)
),
true
Expand All @@ -388,7 +387,7 @@ impl CILNode {
CallSite::builtin(
"select_usize".to_owned().into(),
FnSig::new(
[Type::Int(Int::USize), Type::Int(Int::USize), Type::Bool],
Box::new([Type::Int(Int::USize), Type::Int(Int::USize), Type::Bool]),
Type::Int(Int::USize)
),
true
Expand All @@ -404,7 +403,7 @@ impl CILNode {
CallSite::builtin(
"select_isize".to_owned().into(),
FnSig::new(
[Type::Int(Int::ISize), Type::Int(Int::ISize), Type::Bool],
Box::new([Type::Int(Int::ISize), Type::Int(Int::ISize), Type::Bool]),
Type::Int(Int::ISize)
),
true
Expand All @@ -415,7 +414,7 @@ impl CILNode {
CallSite::builtin(
"select_u64".to_owned().into(),
FnSig::new(
[Type::Int(Int::U64), Type::Int(Int::U64), Type::Bool],
Box::new([Type::Int(Int::U64), Type::Int(Int::U64), Type::Bool]),
Type::Int(Int::U64)
),
true
Expand All @@ -426,7 +425,7 @@ impl CILNode {
CallSite::builtin(
"select_i64".to_owned().into(),
FnSig::new(
[Type::Int(Int::I64), Type::Int(Int::I64), Type::Bool],
Box::new([Type::Int(Int::I64), Type::Int(Int::I64), Type::Bool]),
Type::Int(Int::I64)
),
true
Expand All @@ -437,7 +436,7 @@ impl CILNode {
CallSite::builtin(
"select_u32".to_owned().into(),
FnSig::new(
[Type::Int(Int::U32), Type::Int(Int::U32), Type::Bool],
Box::new([Type::Int(Int::U32), Type::Int(Int::U32), Type::Bool]),
Type::Int(Int::U32)
),
true
Expand All @@ -448,7 +447,7 @@ impl CILNode {
CallSite::builtin(
"select_i32".to_owned().into(),
FnSig::new(
[Type::Int(Int::I32), Type::Int(Int::I32), Type::Bool],
Box::new([Type::Int(Int::I32), Type::Int(Int::I32), Type::Bool]),
Type::Int(Int::I32)
),
true
Expand All @@ -459,7 +458,7 @@ impl CILNode {
CallSite::builtin(
"select_u16".to_owned().into(),
FnSig::new(
[Type::Int(Int::U16), Type::Int(Int::U16), Type::Bool],
Box::new([Type::Int(Int::U16), Type::Int(Int::U16), Type::Bool]),
Type::Int(Int::U16)
),
true
Expand All @@ -470,7 +469,7 @@ impl CILNode {
CallSite::builtin(
"select_i16".to_owned().into(),
FnSig::new(
[Type::Int(Int::I16), Type::Int(Int::I16), Type::Bool],
Box::new([Type::Int(Int::I16), Type::Int(Int::I16), Type::Bool]),
Type::Int(Int::I16)
),
true
Expand All @@ -481,7 +480,7 @@ impl CILNode {
CallSite::builtin(
"select_u8".to_owned().into(),
FnSig::new(
[Type::Int(Int::U8), Type::Int(Int::U8), Type::Bool],
Box::new([Type::Int(Int::U8), Type::Int(Int::U8), Type::Bool]),
Type::Int(Int::U8)
),
true
Expand All @@ -492,7 +491,7 @@ impl CILNode {
CallSite::builtin(
"select_i8".to_owned().into(),
FnSig::new(
[Type::Int(Int::I8), Type::Int(Int::I8), Type::Bool],
Box::new([Type::Int(Int::I8), Type::Int(Int::I8), Type::Bool]),
Type::Int(Int::I8)
),
true
Expand Down
Loading

0 comments on commit 50de7fc

Please sign in to comment.