@@ -4,7 +4,7 @@ use midenc_hir::{
44 FunctionType , SymbolNameComponent , SymbolPath , Type ,
55} ;
66
7- use super :: { crypto, debug, felt, mem} ;
7+ use super :: { advice , crypto, debug, felt, mem} ;
88
99/// Error raised when an attempt is made to use or load an unrecognized intrinsic
1010#[ derive( Debug , thiserror:: Error , Diagnostic ) ]
@@ -26,6 +26,8 @@ pub enum Intrinsic {
2626 Felt ( Symbol ) ,
2727 /// A cryptographic intrinsic
2828 Crypto ( Symbol ) ,
29+ /// An advice intrinsic
30+ Advice ( Symbol ) ,
2931}
3032
3133/// Attempt to recognize an intrinsic function from the given [SymbolPath].
@@ -62,8 +64,9 @@ impl TryFrom<&SymbolPath> for Intrinsic {
6264 match kind {
6365 symbols:: Debug => Ok ( Self :: Debug ( function) ) ,
6466 symbols:: Mem => Ok ( Self :: Mem ( function) ) ,
65- symbols:: Felt => Ok ( Self :: Felt ( function) ) ,
67+ symbols:: FeltModule => Ok ( Self :: Felt ( function) ) ,
6668 symbols:: Crypto => Ok ( Self :: Crypto ( function) ) ,
69+ symbols:: Advice => Ok ( Self :: Advice ( function) ) ,
6770 _ => Err ( UnknownIntrinsicError ( path. clone ( ) ) ) ,
6871 }
6972 }
@@ -83,8 +86,9 @@ impl Intrinsic {
8386 match self {
8487 Self :: Debug ( _) => symbols:: Debug ,
8588 Self :: Mem ( _) => symbols:: Mem ,
86- Self :: Felt ( _) => symbols:: Felt ,
89+ Self :: Felt ( _) => symbols:: FeltModule ,
8790 Self :: Crypto ( _) => symbols:: Crypto ,
91+ Self :: Advice ( _) => symbols:: Advice ,
8892 }
8993 }
9094
@@ -95,6 +99,7 @@ impl Intrinsic {
9599 Self :: Mem ( _) => SymbolPath :: from_iter ( mem:: MODULE_PREFIX . iter ( ) . copied ( ) ) ,
96100 Self :: Felt ( _) => SymbolPath :: from_iter ( felt:: MODULE_PREFIX . iter ( ) . copied ( ) ) ,
97101 Self :: Crypto ( _) => SymbolPath :: from_iter ( crypto:: MODULE_PREFIX . iter ( ) . copied ( ) ) ,
102+ Self :: Advice ( _) => SymbolPath :: from_iter ( advice:: MODULE_PREFIX . iter ( ) . copied ( ) ) ,
98103 }
99104 }
100105
@@ -104,7 +109,8 @@ impl Intrinsic {
104109 Self :: Debug ( function)
105110 | Self :: Mem ( function)
106111 | Self :: Felt ( function)
107- | Self :: Crypto ( function) => * function,
112+ | Self :: Crypto ( function)
113+ | Self :: Advice ( function) => * function,
108114 }
109115 }
110116
@@ -138,6 +144,7 @@ impl Intrinsic {
138144 _ => None ,
139145 }
140146 }
147+ Self :: Advice ( function) => advice:: function_type ( * function) ,
141148 }
142149 }
143150
@@ -150,6 +157,10 @@ impl Intrinsic {
150157 mem:: function_type ( * function) . map ( IntrinsicsConversionResult :: FunctionType )
151158 }
152159 Self :: Debug ( _) | Self :: Felt ( _) => Some ( IntrinsicsConversionResult :: MidenVmOp ) ,
160+ Self :: Advice ( _function) => self
161+ . function_type ( )
162+ . map ( IntrinsicsConversionResult :: FunctionType )
163+ . or ( Some ( IntrinsicsConversionResult :: MidenVmOp ) ) ,
153164 // Crypto intrinsics are converted to function calls
154165 Self :: Crypto ( _function) => self
155166 . function_type ( )
0 commit comments