Skip to content

Commit

Permalink
For add_int use int instead of long for small values
Browse files Browse the repository at this point in the history
  • Loading branch information
whydoubt committed Aug 17, 2019
1 parent a00dfee commit fc2ad72
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions voc/python/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,18 @@ def add_str(self, value):
)

def add_int(self, value):
self.add_opcodes(
LCONST_val(value),
JavaOpcodes.INVOKESTATIC('org/python/types/Int', 'getInt', args=['J'], returns='Lorg/python/types/Int;'),
)
if -32768 <= value <= 32767:
self.add_opcodes(
ICONST_val(value),
JavaOpcodes.INVOKESTATIC('org/python/types/Int', 'getInt', args=['I'],
returns='Lorg/python/types/Int;'),
)
else:
self.add_opcodes(
LCONST_val(value),
JavaOpcodes.INVOKESTATIC('org/python/types/Int', 'getInt', args=['J'],
returns='Lorg/python/types/Int;'),
)

def add_float(self, value):
self.add_opcodes(
Expand Down

0 comments on commit fc2ad72

Please sign in to comment.