Re: getting dependency graph of SML source files from CM

Vesa A Norrman <[email protected]> Thu, 6 Aug 2009 10:55:05 +0300 (EEST)
Newsgroups gmane.comp.lang.sml.smlnj
Message-ID <[email protected]>
Yes it stops immediately when it finds errors. There is no way to change 
that.

  - Vesa

On Wed, 5 Aug 2009, Joe Wells wrote:

> Vesa A Norrman <[email protected]> writes:
>
>> If you need the order of source files you can do like this
>>
>> o remove all .cm directories
>> o run CM.make
>> o look at [compiling code.sml] type of messages. that is the order.
>
> A good idea!
>
> Does this work when there are type errors?  I think it aborts in the
> middle in this case.  I expect to be analyzing files that are likely
> to contain type errors, and I would like to not have to abort at the
> first error detected.
>
> Any other suggestions?
>
> -- 
> Thanks,
>
> Joe
>
>> I don't know if the dependency graph can be printed in any way.
>>
>>  - Vesa
>>
>> On Mon, 3 Aug 2009, Joe Wells wrote:
>>
>>> I'm using SML/NJ 110.54.
>>>
>>> I want to get output like this for all the files referenced by a
>>> particular CM file:
>>>
>>>  file1.sml depends on file2.sml and file2.sig
>>>  file2.sml depends on file3.sml and file3.sig
>>>
>>> Is there any way to get CM to give me this information?  I need it for
>>> a program analysis tool.  It is important to do things in the same way
>>> as CM does them.
>>>
>>> I can use CM.sources like this to get the list of SML source files CM
>>> will use:
>>>
>>>    CM.sources NONE "sources.cm"
>>>  ? SOME
>>>        [{class="sml",derived=false,file="file1.sml"},
>>>         {class="cm",derived=false,file="sources.cm"},
>>>         {class="sml",derived=false,file="file2.sml"},
>>>         {class="sml",derived=false,file="file2.sig"},
>>>         {class="sml",derived=false,file="file3.sml"},
>>>         {class="sml",derived=false,file="file3.sig"},...]
>>>
>>> I do not know if I can depend on the order of the items in the list
>>> output by CM.sources.
>>>
>>> I can use CM.Graph like this to get the dependency graph CM uses to
>>> decide which order the SML files must be compiled in:
>>>
>>>    CM.Graph.graph "sources.cm"
>>>  ? SOME
>>>      {graph=GRAPH
>>>               {defs=[DEF {lhs="str2",rhs=SYM (STR,"TextIO")},
>>>                      DEF {lhs="ss1",rhs=SYMS ["str2"]},
>>>                      DEF {lhs="e3",rhs=IMPORT {lib="l4",syms="ss1"}},
>>>                      DEF {lhs="str6",rhs=SYM (STR,"String")},
>>>                      DEF {lhs="ss5",rhs=SYMS ["str6"]},
>>>                      ...,
>>>                      DEF {lhs="e21",rhs=IMPORT {lib="l22",syms="ss19"}},
>>>                      DEF {lhs="str24",rhs=SYM (STR,"Option")},
>>>                      DEF {lhs="ss23",rhs=SYMS ["str24"]},
>>>                      ...,
>>>                      DEF
>>>                        {lhs="e26",
>>>                         rhs=COMPILE
>>>                               {env="e21",src=("file4.sig",false),syms="ss27"}},
>>>                      ...],
>>>                export="e0",
>>>                imports=["l4","l22","l214","l147"]},
>>>       imports=[-,-,-,-],
>>>       nativesrc=fn}
>>>
>>> This looks like it probably contains the information I want.
>>>
>>> Unfortunately, the type of the graph record component is reported as
>>> ?.PortableGraph.graph, and there seem to be no accessors provided for
>>> this type.
>>>
>>> I can get output like the above from CM.Graph.graph by setting
>>> Control.Print.printDepth and Control.Print.printLength and using the
>>> top-level REPL's pretty printer.  If needed, I could then use the
>>> compiler together with my own definition of the graph datatype to
>>> parse and load the data, but then I would need to understand the data
>>> structure to figure out how to extract the inter-file dependencies.
>>> Also, I'm a bit worried about the value of ?[-,-,-,-]? for the imports
>>> field and what might be hidden behind the hyphens.
>>>
>>> Thanks for any time you can spend on answering my question!
>>>
>>> --
>>> Joe
>
>
> -- 
> Heriot-Watt University is a Scottish charity
> registered under charity number SC000278.
>
>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july