diff --git a/runEO/pom.xml b/runEO/pom.xml
index 4f3edabca..7869a5764 100644
--- a/runEO/pom.xml
+++ b/runEO/pom.xml
@@ -7,7 +7,7 @@
0.0.1
UTF-8
- 0.23.3
+ 0.23.4
11
11
diff --git a/transpiler/src/main/eo/my-array.eo b/transpiler/src/main/eo/my-array.eo
new file mode 100644
index 000000000..6f7f958c0
--- /dev/null
+++ b/transpiler/src/main/eo/my-array.eo
@@ -0,0 +1,52 @@
++package org.eolang
++alias cage org.eolang.gray.cage
++alias goto org.eolang.gray.goto
++junit
+
+[] > test-my-array
+ [x] > mkCopy
+ x' > copy
+ copy.< > @
+ [result] > return
+ [] > xclass
+ 3 > xid
+ [] > xmyArray
+ [initValue] > apply
+ [stackUp] > @
+ cage > pResult
+ [] > result
+ cage > value
+
+ [] > xlength
+ [self] > apply
+ [stackUp] > @
+ seq > @
+ stackUp.forward (return (self.value.length))
+ 123
+
+ [] > xget
+ [self i] > apply
+ [stackUp] > @
+ seq > @
+ stackUp.forward (return (self.value.get i))
+ 123
+
+ [] > xappend
+ [self x] > apply
+ [stackUp] > @
+ seq > @
+ mkCopy (self.value) > tmp
+ self.value.write (tmp.copy.append x)
+ stackUp.forward (return 0)
+
+ seq > @
+ result.value.write initValue
+ pResult.write result
+ stackUp.forward (return pResult)
+
+ (goto ((xmyArray.apply (*)).@)).result > a
+ seq > @
+ (goto ((a.xappend.apply a 2).@)).result
+ and.
+ ((goto ((a.xlength.apply a).@)).result.eq 1)
+ (goto ((a.xget.apply a 0).@)).result.eq 2
diff --git a/transpiler/src/main/scala/org/polystat/py2eo/transpiler/PrintEO.scala b/transpiler/src/main/scala/org/polystat/py2eo/transpiler/PrintEO.scala
index 05b2f51f3..dc03b6e65 100644
--- a/transpiler/src/main/scala/org/polystat/py2eo/transpiler/PrintEO.scala
+++ b/transpiler/src/main/scala/org/polystat/py2eo/transpiler/PrintEO.scala
@@ -53,7 +53,8 @@ object PrintEO {
def printExpr(value : T) : String = {
def e = printExpr _
value match {
- case CollectionCons(kind, l, _) => "(* " + l.map(e).mkString(space) + crb
+ case CollectionCons(kind, l, _) =>
+ "(*" + l.map(x => " " + e(x)).mkString + crb
case NoneLiteral(_) => "\"None: is there a None literal in the EO language?\"" // todo: see <<-- there
case IntLiteral(value, _) => value.toString()
case FloatLiteral(value, _) => value.toString
diff --git a/transpiler/src/main/scala/org/polystat/py2eo/transpiler/PrintLinearizedMutableEOWithCage.scala b/transpiler/src/main/scala/org/polystat/py2eo/transpiler/PrintLinearizedMutableEOWithCage.scala
index 94f0e6b20..75601b7ad 100644
--- a/transpiler/src/main/scala/org/polystat/py2eo/transpiler/PrintLinearizedMutableEOWithCage.scala
+++ b/transpiler/src/main/scala/org/polystat/py2eo/transpiler/PrintLinearizedMutableEOWithCage.scala
@@ -238,7 +238,8 @@ object PrintLinearizedMutableEOWithCage {
def printTest(testName : String, st : Statement.T) : Text = {
HackName.count = 0 // todo: imperative style suddenly
println(s"doing $testName")
- val mkCopy = List(
+ val mkCopy = {
+ List(
"[x] > mkCopy",
" x' > copy",
" copy.< > @",
@@ -264,7 +265,38 @@ object PrintLinearizedMutableEOWithCage {
" [] > xclass",
" 0 > xid",
"cage > xcurrent-exception"
- )
+ ) ++
+ """|[] > xmyArray
+ | [initValue] > apply
+ | [stackUp] > @
+ | cage > pResult
+ | [] > result
+ | cage > value
+ | [] > xlength
+ | [self] > apply
+ | [stackUp] > @
+ | seq > @
+ | stackUp.forward (return (self.value.length))
+ | 123
+ | [] > xget
+ | [self i] > apply
+ | [stackUp] > @
+ | seq > @
+ | stackUp.forward (return (self.value.get i))
+ | 123
+ | [] > xappend
+ | [self x] > apply
+ | [stackUp] > @
+ | seq > @
+ | mkCopy (self.value) > tmp
+ | self.value.write (tmp.copy.append x)
+ | stackUp.forward (return 0)
+ | seq > @
+ | result.value.write initValue
+ | pResult.write result
+ | stackUp.forward (return pResult)"""
+ .stripMargin.split("\n")
+ }
val theTest@FuncDef(_, _, _, _, _, _, _, _, _, _) =
SimpleAnalysis.computeAccessibleIdents(FuncDef(testName, List(), None, None, None, st, Decorators(List()),
HashMap(), isAsync = false, st.ann.pos))
diff --git a/transpiler/src/main/scala/org/polystat/py2eo/transpiler/SimplePass.scala b/transpiler/src/main/scala/org/polystat/py2eo/transpiler/SimplePass.scala
index e3f2b2ce6..8400dc8dd 100644
--- a/transpiler/src/main/scala/org/polystat/py2eo/transpiler/SimplePass.scala
+++ b/transpiler/src/main/scala/org/polystat/py2eo/transpiler/SimplePass.scala
@@ -799,6 +799,14 @@ object SimplePass {
}
}
+ def addExplicitConstructorOfCollection(e : T) : T = {
+ e match {
+ case CollectionCons(kind, l, ann) =>
+ CallIndex(true, Ident("xmyArray", e.ann.pos), List((None, e)), e.ann.pos)
+ case _ => e
+ }
+ }
+
def xPrefixInStatement(x : Statement.T, ns : NamesU) : (Statement.T, NamesU) = {
def pref(s : String) = s"x$s"
(
diff --git a/transpiler/src/main/scala/org/polystat/py2eo/transpiler/Transpile.scala b/transpiler/src/main/scala/org/polystat/py2eo/transpiler/Transpile.scala
index e94d97496..f6fd3ef04 100644
--- a/transpiler/src/main/scala/org/polystat/py2eo/transpiler/Transpile.scala
+++ b/transpiler/src/main/scala/org/polystat/py2eo/transpiler/Transpile.scala
@@ -33,7 +33,9 @@ object Transpile {
debugPrinter(y00._1, "afterSimplifyFor")
val y1 = SimplePass.procStatement(SimplePass.xPrefixInStatement)(y00._1, y00._2)
val y2 = SimplePass.simpleProcExprInStatement(Expression.map(SimplePass.concatStringLiteral))(y1._1, y1._2)
- val y = SimplePass.simpleProcExprInStatement(Expression.map(SimplePass.xPrefixInExpr))(y2._1, y2._2)
+ val y = SimplePass.simpleProcExprInStatement(Expression.map(
+ x => SimplePass.addExplicitConstructorOfCollection(SimplePass.xPrefixInExpr(x))
+ ))(y2._1, y2._2)
try {
val rmExcepts = SimplePass.procStatement(SimplePass.simplifyExcepts)(y._1, y._2)
diff --git a/transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/list/list-1.yaml b/transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/list/list-1.yaml
index 8bc56fb3e..88cbe0fcd 100644
--- a/transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/list/list-1.yaml
+++ b/transpiler/src/test/resources/org/polystat/py2eo/transpiler/simple-tests/list/list-1.yaml
@@ -1,5 +1,6 @@
-enabled: False
+enabled: True
python: |
def test():
+ def len(list): return list.length()
list = [1,2, 3]
return len(list) == 3
\ No newline at end of file