src/Tools/Code/code_scala.ML
changeset 55683 5732a55b9232
parent 55681 7714287dc044
child 55684 ee49b4f7edc8
equal deleted inserted replaced
55682:def6575032df 55683:5732a55b9232
   294               str "=", str "new", print_dicttyp tyvars classtyp, str "{"], str "}")
   294               str "=", str "new", print_dicttyp tyvars classtyp, str "{"], str "}")
   295                 (map print_classparam_instance (inst_params @ superinst_params))
   295                 (map print_classparam_instance (inst_params @ superinst_params))
   296           end;
   296           end;
   297   in print_stmt end;
   297   in print_stmt end;
   298 
   298 
   299 fun scala_program_of_program ctxt module_name reserved identifiers program =
   299 fun scala_program_of_program ctxt module_name reserved identifiers exports program =
   300   let
   300   let
   301     fun namify_module name_fragment ((nsp_class, nsp_object), nsp_common) =
   301     fun namify_module name_fragment ((nsp_class, nsp_object), nsp_common) =
   302       let
   302       let
   303         val declare = Name.declare name_fragment;
   303         val declare = Name.declare name_fragment;
   304       in (name_fragment, ((declare nsp_class, declare nsp_object), declare nsp_common)) end;
   304       in (name_fragment, ((declare nsp_class, declare nsp_object), declare nsp_common)) end;
   341   in
   341   in
   342     Code_Namespace.hierarchical_program ctxt
   342     Code_Namespace.hierarchical_program ctxt
   343       { module_name = module_name, reserved = reserved, identifiers = identifiers,
   343       { module_name = module_name, reserved = reserved, identifiers = identifiers,
   344         empty_nsp = ((reserved, reserved), reserved), namify_module = namify_module,
   344         empty_nsp = ((reserved, reserved), reserved), namify_module = namify_module,
   345         namify_stmt = namify_stmt, cyclic_modules = true, empty_data = [],
   345         namify_stmt = namify_stmt, cyclic_modules = true, empty_data = [],
   346         memorize_data = memorize_implicits, modify_stmts = map modify_stmt } program
   346         memorize_data = memorize_implicits, modify_stmts = map modify_stmt } exports program
   347   end;
   347   end;
   348 
   348 
   349 fun serialize_scala ctxt { module_name, reserved_syms, identifiers,
   349 fun serialize_scala ctxt { module_name, reserved_syms, identifiers,
   350     includes, class_syntax, tyco_syntax, const_syntax } program =
   350     includes, class_syntax, tyco_syntax, const_syntax } exports program =
   351   let
   351   let
   352 
   352 
   353     (* build program *)
   353     (* build program *)
   354     val { deresolver, hierarchical_program = scala_program } =
   354     val { deresolver, hierarchical_program = scala_program } =
   355       scala_program_of_program ctxt module_name (Name.make_context reserved_syms)
   355       scala_program_of_program ctxt module_name (Name.make_context reserved_syms)
   356         identifiers program;
   356         identifiers exports program;
   357 
   357 
   358     (* print statements *)
   358     (* print statements *)
   359     fun lookup_constr tyco constr = case Code_Symbol.Graph.get_node program (Type_Constructor tyco)
   359     fun lookup_constr tyco constr = case Code_Symbol.Graph.get_node program (Type_Constructor tyco)
   360      of Code_Thingol.Datatype (_, constrs) =>
   360      of Code_Thingol.Datatype (_, constrs) =>
   361           the (AList.lookup (op = o apsnd fst) constrs constr);
   361           the (AList.lookup (op = o apsnd fst) constrs constr);