Added specific code generator for number_of.
authorberghofe
Sun, 29 Feb 2004 23:05:48 +0100
changeset 14417 34ffa53db76c
parent 14416 1f256287d4f0
child 14418 b62323c85134
Added specific code generator for number_of.
src/HOL/Integ/NatBin.thy
--- a/src/HOL/Integ/NatBin.thy	Thu Feb 26 17:08:23 2004 +0100
+++ b/src/HOL/Integ/NatBin.thy	Sun Feb 29 23:05:48 2004 +0100
@@ -841,4 +841,19 @@
   "op <=" :: "int => int => bool" ("(_ <=/ _)")
   "neg"                         ("(_ < 0)")
 
+ML {*
+fun number_of_codegen thy gr s b (Const ("Numeral.number_of",
+      Type ("fun", [_, Type ("IntDef.int", [])])) $ bin) =
+        (Some (gr, Pretty.str (string_of_int (HOLogic.dest_binum bin)))
+        handle TERM _ => None)
+  | number_of_codegen thy gr s b (Const ("Numeral.number_of",
+      Type ("fun", [_, Type ("nat", [])])) $ bin) =
+        Some (Codegen.invoke_codegen thy s b (gr,
+          Const ("IntDef.nat", HOLogic.intT --> HOLogic.natT) $
+            (Const ("Numeral.number_of", HOLogic.binT --> HOLogic.intT) $ bin)))
+  | number_of_codegen _ _ _ _ _ = None;
+*}
+
+setup {* [Codegen.add_codegen "number_of_codegen" number_of_codegen] *}
+
 end