X-Git-Url: http://nitlanguage.org diff --git a/src/nitserial.nit b/src/nitserial.nit index 0b60a1b..9c8a07b 100644 --- a/src/nitserial.nit +++ b/src/nitserial.nit @@ -25,42 +25,11 @@ # generate and include its own serialization support module. module nitserial -import frontend -import rapid_type_analysis -import model_utils import template +import gen_nit -# A Nit module -# -# TODO add more features and move to lib -class NitModule - super Template - - var header: nullable Writable = null - - # The module's name - var name: Writable - - # Imports from this module - var imports = new Array[Writable] - - # Main content of this module - var content = new Array[Writable] - - redef fun rendering - do - var header = header - if header != null then add header - - var name = name - add "module {name}\n\n" - - for i in imports do add "import {i}\n" - add "\n" - - for l in content do add "{l}\n" - end -end +import frontend +import rapid_type_analysis redef class ToolContext # Where do we put a single result? @@ -70,7 +39,7 @@ redef class ToolContext var opt_dir: OptionString = new OptionString("Output directory", "--dir") # Depth of the visit and generation - var opt_depth = new OptionEnum(["module", "group", "project"], + var opt_depth = new OptionEnum(["module", "group", "package"], "Depth of the visit and generation", 0, "-d", "--depth") redef init @@ -94,7 +63,7 @@ end redef class MClassType redef fun is_visible_from(mmodule) do - return mmodule.is_visible(mclass.intro_mmodule, public_visibility) + return mmodule.is_visible(mclass.intro_mmodule, mclass.visibility) end end @@ -153,7 +122,7 @@ for mmodule in mmodules do else if module_path.has_suffix(".nit") then module_name = module_path.basename(".nit") else - module_name = module_path.basename("") + module_name = module_path.basename module_path += ".nit" end @@ -161,14 +130,14 @@ for mmodule in mmodules do var importations = null var mgroup = mmodule.mgroup if toolcontext.opt_depth.value == 1 and mgroup != null then - modelbuilder.visit_group mgroup + modelbuilder.scan_group mgroup target_modules = mgroup.mmodules else if toolcontext.opt_depth.value == 2 then - # project + # package target_modules = new Array[MModule] importations = new Array[MModule] if mgroup != null then - for g in mgroup.mproject.mgroups do + for g in mgroup.mpackage.mgroups do target_modules.add_all g.mmodules end @@ -219,6 +188,7 @@ redef class Deserializer if mtype isa MGenericType and mtype.is_subtype(m, null, serializable_type) and mtype.is_visible_from(mmodule) and + mtype.mclass.kind == concrete_kind and not compiled_types.has(mtype) then compiled_types.add mtype