src/Pure/Isar/code_unit.ML
changeset 26939 1035c89b4c02
parent 26747 f32fa5f5bdd1
child 26970 bc28e7bcb765
equal deleted inserted replaced
26938:64e850c3da9e 26939:1035c89b4c02
    60 fun error_thm f thm = f thm handle BAD_THM msg => error msg;
    60 fun error_thm f thm = f thm handle BAD_THM msg => error msg;
    61 fun warning_thm f thm = SOME (f thm) handle BAD_THM msg
    61 fun warning_thm f thm = SOME (f thm) handle BAD_THM msg
    62   => (warning ("code generator: " ^ msg); NONE);
    62   => (warning ("code generator: " ^ msg); NONE);
    63 fun try_thm f thm = SOME (f thm) handle BAD_THM _ => NONE;
    63 fun try_thm f thm = SOME (f thm) handle BAD_THM _ => NONE;
    64 
    64 
    65 fun string_of_typ thy = setmp show_sorts true (Sign.string_of_typ thy);
    65 fun string_of_typ thy = setmp show_sorts true (Syntax.string_of_typ_global thy);
    66 fun string_of_const thy c = case AxClass.inst_of_param thy c
    66 fun string_of_const thy c = case AxClass.inst_of_param thy c
    67  of SOME (c, tyco) => Sign.extern_const thy c ^ " " ^ enclose "[" "]" (Sign.extern_type thy tyco)
    67  of SOME (c, tyco) => Sign.extern_const thy c ^ " " ^ enclose "[" "]" (Sign.extern_type thy tyco)
    68   | NONE => Sign.extern_const thy c;
    68   | NONE => Sign.extern_const thy c;
    69 
    69 
    70 fun no_args thy = length o fst o strip_type o Sign.the_const_type thy;
    70 fun no_args thy = length o fst o strip_type o Sign.the_const_type thy;
   267 
   267 
   268 (* reading constants as terms *)
   268 (* reading constants as terms *)
   269 
   269 
   270 fun check_bare_const thy t = case try dest_Const t
   270 fun check_bare_const thy t = case try dest_Const t
   271  of SOME c_ty => c_ty
   271  of SOME c_ty => c_ty
   272   | NONE => error ("Not a constant: " ^ Sign.string_of_term thy t);
   272   | NONE => error ("Not a constant: " ^ Syntax.string_of_term_global thy t);
   273 
   273 
   274 fun check_const thy = subst_alias thy o AxClass.unoverload_const thy o apfst (subst_alias thy)
   274 fun check_const thy = subst_alias thy o AxClass.unoverload_const thy o apfst (subst_alias thy)
   275   o check_bare_const thy;
   275   o check_bare_const thy;
   276 
   276 
   277 fun read_bare_const thy = check_bare_const thy o Syntax.read_term_global thy;
   277 fun read_bare_const thy = check_bare_const thy o Syntax.read_term_global thy;