Class: FunctionGraph
Direct Known Subclasses
Constant Summary collapse
- @@workDir =
internal database for former scans
ENV['HOME'] + '/.codegraph'
- @@funxDBfile =
@@workDir+'/funxDB.json'
- @@funxDB =
File.exist?(@@funxDBfile) ? JSON.parse(File.open(@@funxDBfile).read) : Hash.new
- @@lock =
Mutex.new
- @@match =
{ :c => {}, :f => {} }
Instance Attribute Summary collapse
-
#adds ⇒ Object
Returns the value of attribute adds.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#excludes ⇒ Object
Returns the value of attribute excludes.
-
#funx ⇒ Object
Returns the value of attribute funx.
Instance Method Summary collapse
-
#initialize(config) ⇒ FunctionGraph
constructor
A new instance of FunctionGraph.
- #scan ⇒ Object
- #showBody(name) ⇒ Object
Methods inherited from Graph
Constructor Details
#initialize(config) ⇒ FunctionGraph
Returns a new instance of FunctionGraph.
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/codegraph.rb', line 140 def initialize(config) super(self.class.to_s) @config = config @debug = @config[:debug] @@matchBeforFuncName = @config[:matchBefor].nil? ? '[^A-z0-9_]\s*': @config[:matchBefor] @@matchAfterFuncName = @config[:matchAfter].nil? ? '( *\(| |$)' : @config[:matchAfter] @adds = @config[:adds] || [] @excludes = @config[:excludes] || [] @parser = CodeParser.new(@debug) @parser.read(*@config[:filelist]) @funx = @parser.funx end |
Instance Attribute Details
#adds ⇒ Object
Returns the value of attribute adds.
127 128 129 |
# File 'lib/codegraph.rb', line 127 def adds @adds end |
#debug ⇒ Object
Returns the value of attribute debug.
127 128 129 |
# File 'lib/codegraph.rb', line 127 def debug @debug end |
#excludes ⇒ Object
Returns the value of attribute excludes.
127 128 129 |
# File 'lib/codegraph.rb', line 127 def excludes @excludes end |
#funx ⇒ Object
Returns the value of attribute funx.
127 128 129 |
# File 'lib/codegraph.rb', line 127 def funx @funx end |
Instance Method Details
#scan ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/codegraph.rb', line 157 def scan jobqueue = JobQueue.new # scan functions fo all other function names names = @parser.funx.keys + @adds - @excludes @parser.funx.each_pair {|name,body| next unless names.include?(name) jobqueue.push { puts "Add func: #{name}" if @debug # Check if this body is in the funx DB bodyCk = hexencode(body) if @@funxDB.has_key?(bodyCk) and @@funxDB[name] == body edges = @@funxDB[bodyCk] edges.each {|edge| self.edge(*edge)} else edges = [] self.node(name) (names - [name]).each { |func| if/#@@matchBeforFuncName#{Regexp.escape(func)}#@@matchAfterFuncName/.match(body) edge = ["#{name}","#{func}"] self.edge(*edge) edges << edge end } @@lock.synchronize { @@funxDB[bodyCk] = edges @@funxDB[name] = body } end } } jobqueue.run updateFunxDB end |
#showBody(name) ⇒ Object
192 193 194 |
# File 'lib/codegraph.rb', line 192 def showBody(name) @funx[name] end |