prosyslab-classroom / cs348-information-security

61 stars 10 forks source link

[Question][Hw5] Some questions about homework #178

Closed ee12ha0220 closed 3 years ago

ee12ha0220 commented 3 years ago
  1. How can I convert llvalue to int? For example, if I get a llvalue 10, I want to change it to int 10.
  2. How can I know if an atomic statement is assignment? I used is_assignment in utils.ml but I think it is not working.
  3. How can I define a lltype? For example, I want to define i32 and check if a llvalue has a same type with it
nubi12336 commented 3 years ago
  1. I think you can use Llvm.int64_of_const and Int64.to_int. Also, Option.get.
dinmukhamedm commented 3 years ago
  1. An ugly workaround Int64.to_int (Option.get (Llvm.int64_of_const llvalue)) worked for me
  2. For me Utils.is_assignment worked allright
  3. Maybe match ... with statement should help you, but I am not sure what you are trying to achieve
ee12ha0220 commented 3 years ago

Thanks:)