getting dependency graph of SML source files from CM

View: New views
7 Messages — Rating Filter:   Alert me  

getting dependency graph of SML source files from CM

by Joe Wells :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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
_______________________________________________
Smlnj-list mailing list
Smlnj-list@...
https://lists.sourceforge.net/lists/listinfo/smlnj-list

Re: getting dependency graph of SML source files from CM

by vnorrman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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.

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
> _______________________________________________
> Smlnj-list mailing list
> Smlnj-list@...
> https://lists.sourceforge.net/lists/listinfo/smlnj-list
>

------------------------------------------------------------------------------
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
_______________________________________________
Smlnj-list mailing list
Smlnj-list@...
https://lists.sourceforge.net/lists/listinfo/smlnj-list

Re: getting dependency graph of SML source files from CM

by Joe Wells :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Vesa A Norrman <vnorrman@...> 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
_______________________________________________
Smlnj-list mailing list
Smlnj-list@...
https://lists.sourceforge.net/lists/listinfo/smlnj-list

Parent Message unknown Re: getting dependency graph of SML source files from CM

by Matthias Blume-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Joe,

the idea is to use CM.Graph.graph.  The type definition is in library $/pgraph.cm.  If you include a reference to that in your own .cm file, you should be good.  (If you are experimenting at the SML/NJ interactive prompt, just say CM.autoload "$/pgraph.cm";).

While in principle you can just work with that data structure (see sml/pgraph/pgraph.sml for its definition) directly, you can also take advantage of a number of utility routines that are provided by library $/pgraph-util.cm.  (If you want to do that you need to request "pgraph" in config/targets when you install SML/NJ.  You can do this after the fact and re-run config/install.sh if you didn't do it initially.)

One particular utility routine is FormatPortable.output, which renders the dependency graph as a "generic" SML program which describes the post-order walk of the graph and which can be instantiated with different operations to be performed at each node -- for example for compilation or for reconstruction of the original graph, but the possibilities are open-ended since you can write your own structure "PGOps" to be plugged into the process.  Just play with this and you'll see what I mean...

Matthias
 
On Monday, August 03, 2009, at 06:54AM, "Joe Wells" <jbw@...> 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
>_______________________________________________
>Smlnj-list mailing list
>Smlnj-list@...
>https://lists.sourceforge.net/lists/listinfo/smlnj-list
>
>

------------------------------------------------------------------------------
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
_______________________________________________
Smlnj-list mailing list
Smlnj-list@...
https://lists.sourceforge.net/lists/listinfo/smlnj-list

Re: getting dependency graph of SML source files from CM

by vnorrman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 <vnorrman@...> 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
_______________________________________________
Smlnj-list mailing list
Smlnj-list@...
https://lists.sourceforge.net/lists/listinfo/smlnj-list

Re: getting dependency graph of SML source files from CM

by Joe Wells :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Matthias Blume <matthias_blume@...> writes:

> Hi Joe,
>
> the idea is to use CM.Graph.graph.  The type definition is in
> library $/pgraph.cm.  If you include a reference to that in your own
> .cm file, you should be good.  (If you are experimenting at the
> SML/NJ interactive prompt, just say CM.autoload "$/pgraph.cm";).

Excellent!

Is there a general way I could have found this out?  How can I find
all the values of $FOO.cm which contribute in some way to modules CM
already knows something about?  I need to know this to force CM to
autoload all of them to make all ?.Xyzzy.foo be resolved so I can
print the types of everything CM knows about.

> While in principle you can just work with that data structure (see
> sml/pgraph/pgraph.sml for its definition) directly, you can also
> take advantage of a number of utility routines that are provided by
> library $/pgraph-util.cm.  (If you want to do that you need to
> request "pgraph" in config/targets when you install SML/NJ.  You can
> do this after the fact and re-run config/install.sh if you didn't do
> it initially.)

What do I do if my Linux distribution did not install this?  What is
the correct procedure (not including installing CML/NJ from scratch
myself)?

> One particular utility routine is FormatPortable.output, which
> renders the dependency graph as a "generic" SML program which
> describes the post-order walk of the graph and which can be
> instantiated with different operations to be performed at each node
> -- for example for compilation or for reconstruction of the original
> graph, but the possibilities are open-ended since you can write your
> own structure "PGOps" to be plugged into the process.  Just play
> with this and you'll see what I mean...

Thanks!

--
Joe

> Matthias
>  
> On Monday, August 03, 2009, at 06:54AM, "Joe Wells" <jbw@...> 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
>>_______________________________________________
>>Smlnj-list mailing list
>>Smlnj-list@...
>>https://lists.sourceforge.net/lists/listinfo/smlnj-list
>>
>>


--
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
_______________________________________________
Smlnj-list mailing list
Smlnj-list@...
https://lists.sourceforge.net/lists/listinfo/smlnj-list

Re: getting dependency graph of SML source files from CM

by Joe Wells :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Joe Wells <jbw@...> writes:

> Matthias Blume <matthias_blume@...> writes:
>
>> Hi Joe,
>>
>> the idea is to use CM.Graph.graph.  The type definition is in
>> library $/pgraph.cm.  If you include a reference to that in your own
>> .cm file, you should be good.  (If you are experimenting at the
>> SML/NJ interactive prompt, just say CM.autoload "$/pgraph.cm";).
>
> Excellent!

Oops.  What do I do about the ?.CM.lib type?  After “CM.autoload
"$/pgraph.cm"” I get this type for CM.Graph.graph:

    string
    -> {graph:PortableGraph.graph, imports:?.CM.lib list,
        nativesrc:string -> string} option

What file do I load to get ?.CM.lib defined properly?

Thanks very much for your help in finding answers!

--
Joe

>> On Monday, August 03, 2009, at 06:54AM, "Joe Wells" <jbw@...> 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.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.
[...]


--
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
_______________________________________________
Smlnj-list mailing list
Smlnj-list@...
https://lists.sourceforge.net/lists/listinfo/smlnj-list