Module: Rasm::Java::Accessable

Included in:
Bytecode, FieldInfo
Defined in:
lib/rasm/java/accessable.rb

Constant Summary collapse

ACC_PUBLIC =

class, field, method

0x0001
ACC_PRIVATE =

class, field, method

0x0002
ACC_PROTECTED =

class, field, method

0x0004
ACC_STATIC =

field, method

0x0008
ACC_FINAL =

class, field, method

0x0010
ACC_SUPER =

class

0x0020
ACC_SYNCHRONIZED =

method

0x0020
ACC_VOLATILE =

field

0x0040
ACC_BRIDGE =

method

0x0040
ACC_VARARGS =

method

0x0080
ACC_TRANSIENT =

field

0x0080
ACC_NATIVE =

method

0x0100
ACC_INTERFACE =

class

0x0200
ACC_ABSTRACT =

class, method

0x0400
ACC_STRICT =

method

0x0800
ACC_SYNTHETIC =

class, field, method

0x1000
ACC_ANNOTATION =

class

0x2000
ACC_ENUM =

class(?) field inner

0x4000
ACC_DEPRECATED =

class, field, method

0x20000
TYPES =
{
  Z: 'boolean',
  B: 'byte',
  C: 'char',
  S: 'short',
  I: 'int',
  F: 'float',
  J: 'long',
  D: 'double',
  L: lambda{|ref| "#{ref}"},
  '['.to_sym => lambda{|type| "#{type}[]"}
}
TYPEPATTERN =
/^([ZBCSIFJDL\[])([^;<]*(<[^>]+>)?);?$/

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_flagsObject

Returns the value of attribute access_flags.



73
74
75
# File 'lib/rasm/java/accessable.rb', line 73

def access_flags
  @access_flags
end

#nameObject

Returns the value of attribute name.



73
74
75
# File 'lib/rasm/java/accessable.rb', line 73

def name
  @name
end

Instance Method Details

#access_descObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/rasm/java/accessable.rb', line 55

def access_desc
  access = access_flags & ~ ACC_SUPER
  str = ''
  str << 'public ' if ((access & ACC_PUBLIC) != 0)
  str << 'private ' if ((access & ACC_PRIVATE) != 0)
  str << 'protected ' if ((access & ACC_PROTECTED) != 0)
  str << 'final ' if ((access & ACC_FINAL) != 0)
  str << 'static ' if ((access & ACC_STATIC) != 0)
  str << 'synchronized ' if ((access & ACC_SYNCHRONIZED) != 0)
  str << 'volatile ' if ((access & ACC_VOLATILE) != 0)
  str << 'transient ' if ((access & ACC_TRANSIENT) != 0)
  str << 'abstract ' if ((access & ACC_ABSTRACT) != 0)
  str << 'strictfp ' if ((access & ACC_STRICT) != 0)
  str << 'synthetic ' if ((access & ACC_SYNTHETIC) != 0)
  str << 'enum ' if ((access & ACC_ENUM) != 0)
  str
end

#typeof(decriptor) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rasm/java/accessable.rb', line 42

def typeof(decriptor)
  if m = TYPEPATTERN.match(decriptor)
    type = TYPES[m[1].to_sym]
    if type.respond_to? :call
      type.call(typeof(m[2]))
    else
      type
    end
  else
    decriptor
  end
end