summary refs log tree commit diff stats
path: root/tests/init
Commit message (Expand)AuthorAgeFilesLines
* new tester; all tests categorizedAraq2014-01-132-0/+54
a3'>^
4f1b89c30 ^
e25474154 ^









e25474154 ^
e25474154 ^



e25474154 ^

fd522aa40 ^
e25474154 ^

fd522aa40 ^

e25474154 ^

e25474154 ^
fd522aa40 ^
e25474154 ^


d171a8b36 ^
e25474154 ^
92e10e4b1 ^
d171a8b36 ^
e25474154 ^



73c6efdf6 ^
e25474154 ^


92b8fac94 ^
e25474154 ^

36e25a684 ^
e25474154 ^


e25474154 ^

091c1b307 ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56


                               
                                         









                                                                  
                                  



                               

                 
                                                                        

                                                     

                                                                        

                                                          
            
                 


                                         
                                             
                                                 
                                     
                                           



                                                                               
           


                                          
                                                                        

                                          
                                         


                   

            

                                                                          
#
#
#           The Nimrod Compiler
#        (c) Copyright 2012 Andreas Rumpf
#
#    See the file "copying.txt", included in this
#    distribution, for details about the copyright.
#

# This module implements a dependency file generator.

import 
  os, options, ast, astalgo, msgs, ropes, idents, passes, importer

proc generateDot*(project: string)

type 
  TGen = object of TPassContext
    module*: PSym
  PGen = ref TGen

var gDotGraph: PRope # the generated DOT file; we need a global variable

proc addDependencyAux(importing, imported: string) = 
  appf(gDotGraph, "$1 -> $2;$n", [toRope(importing), toRope(imported)]) 
  # s1 -> s2_4[label="[0-9]"];
  
proc addDotDependency(c: PPassContext, n: PNode): PNode = 
  result = n
  var g = PGen(c)
  case n.kind
  of nkImportStmt: 
    for i in countup(0, sonsLen(n) - 1): 
      var imported = getModuleName(n.sons[i])
      addDependencyAux(g.module.name.s, imported)
  of nkFromStmt, nkImportExceptStmt: 
    var imported = getModuleName(n.sons[0])
    addDependencyAux(g.module.name.s, imported)
  of nkStmtList, nkBlockStmt, nkStmtListExpr, nkBlockExpr: 
    for i in countup(0, sonsLen(n) - 1): discard addDotDependency(c, n.sons[i])
  else: 
    discard

proc generateDot(project: string) = 
  writeRope(ropef("digraph $1 {$n$2}$n", [
      toRope(changeFileExt(extractFilename(project), "")), gDotGraph]), 
            changeFileExt(project, "dot"))

proc myOpen(module: PSym): PPassContext =
  var g: PGen
  new(g)
  g.module = module
  result = g

const gendependPass* = makePass(open = myOpen, process = addDotDependency)