Class: SmaliMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/dex-oracle/smali_method.rb

Constant Summary collapse

PARAMETER_ISOLATOR =
/\([^\)]+\)/
PARAMETER_INDIVIDUATOR =
/(\[*(?:[BCDFIJSZ]|L[^;]+;))/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(class_name, signature, body = nil) ⇒ SmaliMethod

Returns a new instance of SmaliMethod.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dex-oracle/smali_method.rb', line 8

def initialize(class_name, signature, body = nil)
  @modified = false
  @class = class_name
  @name = signature[/[^\(]+/]
  @body = body
  @return_type = signature[/[^\)$]+$/]
  @descriptor = "#{class_name}->#{signature}"
  @signature = signature
  @parameters = []
  parameter_string = signature[PARAMETER_ISOLATOR]
  return if parameter_string.nil?
  parameter_string.scan(PARAMETER_INDIVIDUATOR).each { |m| @parameters << m.first }
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



2
3
4
# File 'lib/dex-oracle/smali_method.rb', line 2

def body
  @body
end

#classObject (readonly)

Returns the value of attribute class.



3
4
5
# File 'lib/dex-oracle/smali_method.rb', line 3

def class
  @class
end

#descriptorObject (readonly)

Returns the value of attribute descriptor.



3
4
5
# File 'lib/dex-oracle/smali_method.rb', line 3

def descriptor
  @descriptor
end

#modifiedObject

Returns the value of attribute modified.



2
3
4
# File 'lib/dex-oracle/smali_method.rb', line 2

def modified
  @modified
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/dex-oracle/smali_method.rb', line 3

def name
  @name
end

#parametersObject (readonly)

Returns the value of attribute parameters.



3
4
5
# File 'lib/dex-oracle/smali_method.rb', line 3

def parameters
  @parameters
end

#return_typeObject (readonly)

Returns the value of attribute return_type.



3
4
5
# File 'lib/dex-oracle/smali_method.rb', line 3

def return_type
  @return_type
end

#signatureObject (readonly)

Returns the value of attribute signature.



3
4
5
# File 'lib/dex-oracle/smali_method.rb', line 3

def signature
  @signature
end

Instance Method Details

#==(other) ⇒ Object



26
27
28
# File 'lib/dex-oracle/smali_method.rb', line 26

def ==(other)
    other.class == self.class && other.state == state
end

#stateObject



30
31
32
# File 'lib/dex-oracle/smali_method.rb', line 30

def state
    [@name, @class, @descriptor, @parameters, @return_type, @modified, @body]
end

#to_sObject



22
23
24
# File 'lib/dex-oracle/smali_method.rb', line 22

def to_s
  @descriptor
end