Skip to content

Commit

Permalink
Use existing JPype conversion between Python lists and Java lists
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoeilers committed Oct 24, 2024
1 parent 63e6f5f commit 52c5c67
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/nagini_translation/lib/viper_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def getconst(name):
self.Perm = getconst('Perm')
self.sourcefile = sourcefile
self.none = getobject(java, scala, 'None')
self.converters = getobject(java, scala.jdk.javaapi, 'CollectionConverters')

def is_available(self) -> bool:
"""
Expand All @@ -94,18 +95,10 @@ def append(self, list, to_append):
list.append(lsttoappend)

def to_seq(self, list):
arr = self.jvm.get_array(self.java.lang.Object, len(list))
result = self.scala.collection.mutable.ArraySeq.make(arr)
for index in range(0, len(list)):
result.update(index, list[index])
return result.toList()
return self.converters.asScala(self.java.util.ArrayList(list)).toSeq()

def to_list(self, seq):
result = []
iterator = seq.toIterator()
while iterator.hasNext():
result.append(iterator.next())
return result
return list(self.converters.asJava(seq))

def to_map(self, dict):
result = self.scala.collection.immutable.HashMap()
Expand Down

0 comments on commit 52c5c67

Please sign in to comment.