src/Pure/Tools/codegen_serializer.ML
changeset 22836 0e52bb862910
parent 22799 ed7d53db2170
child 22845 5f9138bcb3d7
equal deleted inserted replaced
22835:37d3a984d730 22836:0e52bb862910
   229   let
   229   let
   230     fun dest_bit (IConst (c, _)) = if c = c_bit0 then SOME 0
   230     fun dest_bit (IConst (c, _)) = if c = c_bit0 then SOME 0
   231           else if c = c_bit1 then SOME 1
   231           else if c = c_bit1 then SOME 1
   232           else NONE
   232           else NONE
   233       | dest_bit _ = NONE;
   233       | dest_bit _ = NONE;
   234     fun dest_numeral (IConst (c, _)) = if c = c_pls then SOME 0
   234     fun dest_numeral (IConst (c, _)) = if c = c_pls then SOME (IntInf.fromInt 0)
   235           else if c = c_min then SOME ~1
   235           else if c = c_min then SOME (IntInf.fromInt ~1)
   236           else NONE
   236           else NONE
   237       | dest_numeral (IConst (c, _) `$ t1 `$ t2) =
   237       | dest_numeral (IConst (c, _) `$ t1 `$ t2) =
   238           if c = c_bit then case (dest_numeral t1, dest_bit t2)
   238           if c = c_bit then case (dest_numeral t1, dest_bit t2)
   239            of (SOME n, SOME b) => SOME (2 * n + IntInf.fromInt b)
   239            of (SOME n, SOME b) => SOME (IntInf.fromInt 2 * n + IntInf.fromInt b)
   240             | _ => NONE
   240             | _ => NONE
   241           else NONE
   241           else NONE
   242       | dest_numeral _ = NONE;
   242       | dest_numeral _ = NONE;
   243   in dest_numeral end;
   243   in dest_numeral end;
   244 
   244