1
+ use cairo_lang_sierra:: extensions:: NamedType ;
2
+ use cairo_lang_sierra:: extensions:: bitwise:: BitwiseType ;
3
+ use cairo_lang_sierra:: extensions:: circuit:: { AddModType , MulModType } ;
4
+ use cairo_lang_sierra:: extensions:: ec:: EcOpType ;
5
+ use cairo_lang_sierra:: extensions:: pedersen:: PedersenType ;
6
+ use cairo_lang_sierra:: extensions:: poseidon:: PoseidonType ;
7
+ use cairo_lang_sierra:: extensions:: range_check:: { RangeCheck96Type , RangeCheckType } ;
8
+ use cairo_lang_sierra:: extensions:: segment_arena:: SegmentArenaType ;
1
9
use cairo_lang_sierra:: ids:: GenericTypeId ;
2
10
use cairo_lang_sierra:: program:: ProgramArtifact ;
11
+ use cairo_vm:: types:: builtin_name:: BuiltinName ;
3
12
use camino:: Utf8PathBuf ;
4
13
use std:: sync:: Arc ;
5
14
use universal_sierra_compiler_api:: AssembledProgramWithDebugInfo ;
@@ -8,6 +17,20 @@ pub mod raw;
8
17
pub mod with_config;
9
18
pub mod with_config_resolved;
10
19
20
+ // If modifying this, make sure that the order of builtins matches that from
21
+ // `#[implicit_precedence(...)` in generated test code.
22
+ const BUILTIN_ORDER : [ ( BuiltinName , GenericTypeId ) ; 9 ] = [
23
+ ( BuiltinName :: pedersen, PedersenType :: ID ) ,
24
+ ( BuiltinName :: range_check, RangeCheckType :: ID ) ,
25
+ ( BuiltinName :: bitwise, BitwiseType :: ID ) ,
26
+ ( BuiltinName :: ec_op, EcOpType :: ID ) ,
27
+ ( BuiltinName :: poseidon, PoseidonType :: ID ) ,
28
+ ( BuiltinName :: segment_arena, SegmentArenaType :: ID ) ,
29
+ ( BuiltinName :: range_check96, RangeCheck96Type :: ID ) ,
30
+ ( BuiltinName :: add_mod, AddModType :: ID ) ,
31
+ ( BuiltinName :: mul_mod, MulModType :: ID ) ,
32
+ ] ;
33
+
11
34
#[ derive( Debug , PartialEq , Clone , Copy , Hash , Eq ) ]
12
35
pub enum TestTargetLocation {
13
36
/// Main crate in a package
@@ -23,6 +46,19 @@ pub struct TestDetails {
23
46
pub return_types : Vec < ( GenericTypeId , i16 ) > ,
24
47
}
25
48
49
+ impl TestDetails {
50
+ #[ must_use]
51
+ pub fn builtins ( & self ) -> Vec < BuiltinName > {
52
+ let mut builtins = vec ! [ ] ;
53
+ for ( builtin_name, builtin_ty) in BUILTIN_ORDER {
54
+ if self . parameter_types . iter ( ) . any ( |( ty, _) | ty == & builtin_ty) {
55
+ builtins. push ( builtin_name) ;
56
+ }
57
+ }
58
+ builtins
59
+ }
60
+ }
61
+
26
62
#[ derive( Debug , Clone ) ]
27
63
pub struct TestTarget < C > {
28
64
pub tests_location : TestTargetLocation ,
0 commit comments