Skip to content

Commit

Permalink
Rename funcgtion
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianGCalderon committed Oct 17, 2024
1 parent 6781a4c commit 19f2fc1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,25 @@ pub fn find_entry_point_by_name<'a>(
.find(|x| x.id.debug_name.as_ref().map(|x| x.as_str()) == Some(name))
}

// If type is a single element container, finds it's inner type
// If type is invisible to sierra (i.e. a single element container),
// finds it's actual concrete type recursively.
// If not, returns the current type
pub fn find_inner_type(
pub fn find_real_type(
registry: &ProgramRegistry<CoreType, CoreLibfunc>,
ty: &ConcreteTypeId,
) -> ConcreteTypeId {
match registry.get_type(ty).unwrap() {
cairo_lang_sierra::extensions::core::CoreTypeConcrete::Box(info) => {
find_inner_type(registry, &info.ty)
find_real_type(registry, &info.ty)
}
cairo_lang_sierra::extensions::core::CoreTypeConcrete::Uninitialized(info) => {
find_inner_type(registry, &info.ty)
find_real_type(registry, &info.ty)
}
cairo_lang_sierra::extensions::core::CoreTypeConcrete::Span(info) => {
find_inner_type(registry, &info.ty)
find_real_type(registry, &info.ty)
}
cairo_lang_sierra::extensions::core::CoreTypeConcrete::Snapshot(info) => {
find_inner_type(registry, &info.ty)
find_real_type(registry, &info.ty)
}
_ => ty.clone(),
}
Expand Down
4 changes: 2 additions & 2 deletions src/vm/array.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::EvalAction;
use crate::{find_inner_type, Value};
use crate::{find_real_type, Value};
use cairo_lang_sierra::{
extensions::{
array::ArrayConcreteLibfunc,
Expand Down Expand Up @@ -47,7 +47,7 @@ fn eval_span_from_tuple(
};

let ty = &info.branch_signatures()[0].vars[0].ty;
let ty = find_inner_type(registry, ty);
let ty = find_real_type(registry, ty);

let CoreTypeConcrete::Array(info) = registry.get_type(&ty).unwrap() else {
panic!()
Expand Down

0 comments on commit 19f2fc1

Please sign in to comment.