src/Tools/Code/code_scala.ML
changeset 37437 4202e11ae7dc
parent 37384 5aba26803073
child 37439 c72a43a7d2c5
equal deleted inserted replaced
37433:a2a89563bfcb 37437:4202e11ae7dc
   127         (applify "(" ")" NOBR
   127         (applify "(" ")" NOBR
   128           (applify "[" "]" NOBR p (map (str o lookup_tyvar tyvars o fst) vs))
   128           (applify "[" "]" NOBR p (map (str o lookup_tyvar tyvars o fst) vs))
   129             (map2 (fn param => fn ty => print_typed tyvars
   129             (map2 (fn param => fn ty => print_typed tyvars
   130                 ((str o lookup_var vars) param) ty)
   130                 ((str o lookup_var vars) param) ty)
   131               params tys)) implicits) ty, str " ="]
   131               params tys)) implicits) ty, str " ="]
   132     fun print_stmt (name, Code_Thingol.Fun (_, ((vs, ty), raw_eqs))) = (case filter (snd o snd) raw_eqs
   132     fun print_stmt (name, Code_Thingol.Fun (_, (((vs, ty), raw_eqs), _))) = (case filter (snd o snd) raw_eqs
   133          of [] =>
   133          of [] =>
   134               let
   134               let
   135                 val (tys, ty') = Code_Thingol.unfold_fun ty;
   135                 val (tys, ty') = Code_Thingol.unfold_fun ty;
   136                 val params = Name.invents (snd reserved) "a" (length tys);
   136                 val params = Name.invents (snd reserved) "a" (length tys);
   137                 val tyvars = intro_vars (map fst vs) reserved;
   137                 val tyvars = intro_vars (map fst vs) reserved;
   349     val reserved = fold (insert (op =) o fst) includes raw_reserved;
   349     val reserved = fold (insert (op =) o fst) includes raw_reserved;
   350     val (deresolver, (the_module_name, sca_program)) = scala_program_of_program labelled_name
   350     val (deresolver, (the_module_name, sca_program)) = scala_program_of_program labelled_name
   351       module_name reserved raw_module_alias program;
   351       module_name reserved raw_module_alias program;
   352     val reserved = make_vars reserved;
   352     val reserved = make_vars reserved;
   353     fun args_num c = case Graph.get_node program c
   353     fun args_num c = case Graph.get_node program c
   354      of Code_Thingol.Fun (_, ((_, ty), [])) => (length o fst o Code_Thingol.unfold_fun) ty
   354      of Code_Thingol.Fun (_, (((_, ty), []), _)) => (length o fst o Code_Thingol.unfold_fun) ty
   355       | Code_Thingol.Fun (_, (_, ((ts, _), _) :: _)) => length ts
   355       | Code_Thingol.Fun (_, ((_, ((ts, _), _) :: _), _)) => length ts
   356       | Code_Thingol.Datatypecons (_, tyco) =>
   356       | Code_Thingol.Datatypecons (_, tyco) =>
   357           let val Code_Thingol.Datatype (_, (_, constrs)) = Graph.get_node program tyco
   357           let val Code_Thingol.Datatype (_, (_, constrs)) = Graph.get_node program tyco
   358           in (length o the o AList.lookup (op =) constrs) c end
   358           in (length o the o AList.lookup (op =) constrs) c end
   359       | Code_Thingol.Classparam (_, class) =>
   359       | Code_Thingol.Classparam (_, class) =>
   360           let val Code_Thingol.Class (_, (_, (_, classparams))) = Graph.get_node program class
   360           let val Code_Thingol.Class (_, (_, (_, classparams))) = Graph.get_node program class