Skip to content

Commit

Permalink
Ignore Code attributes outside of methods (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
Storyyeller committed Dec 31, 2016
1 parent e0999e0 commit 3c1102d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Krakatau/assembler/disassembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def method(a, m):
a.val('.method'), a.flags(m.access, RFLAGS_M), a.utfref(m.name), a.val(':'), a.utfref(m.desc), a.eol()
a.indentlevel += 1
for attr in m.attributes:
a.attribute(attr)
a.attribute(attr, in_method=True)
a.indentlevel -= 1
a.val('.end method'), a.eol()

Expand Down Expand Up @@ -526,7 +526,7 @@ def instruction(a, r):

###########################################################################
### Attributes ############################################################
def attribute(a, attr):
def attribute(a, attr, in_method=False):
name = a.pool.getutf(attr.name)
if not a.roundtrip and name in (b'BootstrapMethods', b'StackMapTable'):
return
Expand All @@ -545,7 +545,7 @@ def attribute(a, attr):
a.val('.annotationdefault'), a.element_value(r)
elif name == b'BootstrapMethods':
a.val('.bootstrapmethods')
elif name == b'Code':
elif name == b'Code' and in_method:
a.code(r)
elif name == b'ConstantValue':
a.val('.constantvalue'), a.ldcrhs(r.u16())
Expand Down

0 comments on commit 3c1102d

Please sign in to comment.