Class: SCNR::Introspector::DataFlow

Inherits:
Object
  • Object
show all
Defined in:
lib/scnr/introspector/data_flow.rb,
lib/scnr/introspector/data_flow/sink.rb,
lib/scnr/introspector/data_flow/scope.rb

Defined Under Namespace

Classes: Scope, Sink

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &block) ⇒ DataFlow

Returns a new instance of DataFlow.

Parameters:

  • options (Hash) (defaults to: {})
  • block (Block)

    Code to #trace.

Options Hash (options):

Raises:



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/scnr/introspector/data_flow.rb', line 25

def initialize( options = {}, &block )
  options = options.dup

  if (scope = options.delete(:scope)).is_a? DataFlow::Scope
    @scope = scope
  elsif scope.is_a? Hash
    @scope = DataFlow::Scope.new( scope )
  elsif scope.nil?
    @scope = DataFlow::Scope.new
  else
    fail DataFlow::Scope::Error::Invalid
  end

  @sinks = []
end

Instance Attribute Details

#scopeScope

Returns:



10
11
12
# File 'lib/scnr/introspector/data_flow.rb', line 10

def scope
  @scope
end

#sinksArray<Point> (readonly)

Returns:

  • (Array<Point>)


13
14
15
# File 'lib/scnr/introspector/data_flow.rb', line 13

def sinks
  @sinks
end

Class Method Details

.from_rpc_data(h) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/scnr/introspector/data_flow.rb', line 61

def self.from_rpc_data( h )
  n = self.new

  h.each do |k, v|
    case k
    when 'sinks'
      n.instance_variable_set( "@#{k}", v.map { |pd| Sink.from_rpc_data( pd ) } )

    else
      n.instance_variable_set( "@#{k}", v )
    end
  end

  n
end

Instance Method Details

#to_rpc_dataObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/scnr/introspector/data_flow.rb', line 41

def to_rpc_data
  data = {}
  instance_variables.each do |iv|
    case iv
    when :@sinks
      data['sinks'] = @sinks.map(&:to_rpc_data)

    when :@scope
      next

    else
      v = instance_variable_get( iv )
      next if !v
      data[iv.to_s.gsub('@','')] = v.to_rpc_data

    end
  end
  data
end