Skip to content

Commit

Permalink
WIP: Make it work with structs
Browse files Browse the repository at this point in the history
  • Loading branch information
cburgdorf committed Aug 30, 2022
1 parent 1ceb219 commit c258991
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions crates/codegen/src/db/queries/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,22 @@ pub fn abi_type(db: &dyn CodegenDb, ty: TypeId) -> AbiType {

// TODO: This need to be adjusted to work with structs
pub fn abi_event(db: &dyn CodegenDb, ty: TypeId) -> AbiEvent {
debug_assert!(ty.is_event(db.upcast()));
//debug_assert!(ty.is_string(db.upcast()));
let legalized_ty = db.codegen_legalized_type(ty);

let legalized_ty_data = legalized_ty.data(db.upcast());
let event_def = match &legalized_ty_data.kind {
ir::TypeKind::Event(def) => def,
ir::TypeKind::Struct(def) => def,
_ => unreachable!(),
};

let fields = event_def
.fields
.iter()
.map(|(name, ty, indexed)| {
.map(|(name, ty)| {
let ty = db.codegen_abi_type(*ty);
AbiEventField::new(name.to_string(), ty, *indexed)
// TODO: Support indexed fields when structs support #indexed attribute
AbiEventField::new(name.to_string(), ty, false)
})
.collect();

Expand Down

0 comments on commit c258991

Please sign in to comment.