Skip to content

Commit

Permalink
Set a fixed order
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoletta committed Oct 9, 2023
1 parent 4bdeecd commit 92917e2
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions cairo1-run/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,27 +520,21 @@ fn get_function_builtins(func: &Function) -> (Vec<BuiltinName>, HashMap<cairo_la
let entry_params = &func.signature.param_types;
let mut builtins = Vec::new();
let mut builtin_offset :HashMap<cairo_lang_sierra::ids::GenericTypeId, i16> = HashMap::new();
// Fetch builtins from the entry_params
for type_id in entry_params {
if type_id.debug_name == Some("RangeCheck".into()) {
builtins.push(BuiltinName::range_check);
}

if type_id.debug_name == Some("Pedersen".into()) {
builtins.push(BuiltinName::pedersen);
}

if type_id.debug_name == Some("Bitwise".into()) {
builtins.push(BuiltinName::bitwise);
}

if type_id.debug_name == Some("EcOp".into()) {
builtins.push(BuiltinName::ec_op);
}

if type_id.debug_name == Some("Poseidon".into()) {
builtins.push(BuiltinName::poseidon);
}
// Fetch builtins from the entry_params in the standard order
if entry_params.iter().any(|ti| ti.debug_name == Some("Pedersen".into())) {
builtins.push(BuiltinName::pedersen);
}
if entry_params.iter().any(|ti| ti.debug_name == Some("RangeCheck".into())) {
builtins.push(BuiltinName::range_check);
}
if entry_params.iter().any(|ti| ti.debug_name == Some("Bitwise".into())) {
builtins.push(BuiltinName::bitwise);
}
if entry_params.iter().any(|ti| ti.debug_name == Some("EcOp".into())) {
builtins.push(BuiltinName::ec_op);
}
if entry_params.iter().any(|ti| ti.debug_name == Some("Poseidon".into())) {
builtins.push(BuiltinName::poseidon);
}
let first_offset = builtins.len() as i16 + 2;
for (i, builtin) in builtins.iter().enumerate() {
Expand Down

0 comments on commit 92917e2

Please sign in to comment.