@@ -19,11 +19,11 @@ use crate::architecture::Architecture;
1919use crate :: architecture:: CoreArchitecture ;
2020use crate :: basic_block:: BasicBlock ;
2121use crate :: function:: { Location , NativeBlock } ;
22- use crate :: high_level_il as hlil;
2322use crate :: low_level_il as llil;
2423use crate :: medium_level_il as mlil;
2524use crate :: string:: IntoCStr ;
2625use crate :: string:: { raw_to_string, strings_to_string_list, BnString } ;
26+ use crate :: { high_level_il as hlil, BN_INVALID_EXPR } ;
2727
2828use crate :: rc:: * ;
2929
@@ -266,8 +266,7 @@ pub struct InstructionTextToken {
266266 pub text : String ,
267267 pub confidence : u8 ,
268268 pub context : InstructionTextTokenContext ,
269- // TODO: Document that this is not necessary to set and that this is valid in a limited context.
270- pub expr_index : usize ,
269+ pub expr_index : Option < usize > ,
271270 pub kind : InstructionTextTokenKind ,
272271}
273272
@@ -278,7 +277,10 @@ impl InstructionTextToken {
278277 text : raw_to_string ( value. text ) . unwrap ( ) ,
279278 confidence : value. confidence ,
280279 context : value. context . into ( ) ,
281- expr_index : value. exprIndex ,
280+ expr_index : match value. exprIndex {
281+ BN_INVALID_EXPR => None ,
282+ index => Some ( index) ,
283+ } ,
282284 kind : InstructionTextTokenKind :: from_raw ( value) ,
283285 }
284286 }
@@ -305,7 +307,7 @@ impl InstructionTextToken {
305307 // NOTE: Expected to be freed with `InstructionTextToken::free_raw`.
306308 typeNames : strings_to_string_list ( & type_names) ,
307309 namesCount : type_names. len ( ) ,
308- exprIndex : value. expr_index ,
310+ exprIndex : value. expr_index . unwrap_or ( BN_INVALID_EXPR ) ,
309311 }
310312 }
311313
@@ -326,7 +328,7 @@ impl InstructionTextToken {
326328 text : text. into ( ) ,
327329 confidence : MAX_CONFIDENCE ,
328330 context : InstructionTextTokenContext :: Normal ,
329- expr_index : 0 ,
331+ expr_index : None ,
330332 kind,
331333 }
332334 }
@@ -341,7 +343,7 @@ impl InstructionTextToken {
341343 text : text. into ( ) ,
342344 confidence : MAX_CONFIDENCE ,
343345 context : InstructionTextTokenContext :: Normal ,
344- expr_index : 0 ,
346+ expr_index : None ,
345347 kind,
346348 }
347349 }
0 commit comments