@@ -85,6 +85,8 @@ private static Object create(RAbstractVector delegate, Object data, RType target
8585 return new RawClosure (delegate , data , targetType );
8686 case Character :
8787 return new StringClosure (delegate , data , targetType );
88+ case List :
89+ return new ListClosure (delegate , data , targetType );
8890 default :
8991 throw RInternalError .shouldNotReachHere ();
9092 }
@@ -146,10 +148,11 @@ public RandomAccessIterator randomAccessIterator(@CachedLibrary("this.data") Vec
146148 @ ExportMessage
147149 public NACheck getNACheck () {
148150 // the contract is that the check is enabled if the vector may contain NA values,
149- // we cannot say that upfront, because NAs can occur as the result of type conversions
151+ // we cannot say upfront that it does not, because NAs can occur as the result of type
152+ // conversions
150153 // NOTE: this method and "isComplete" can be improved for type conversions that are known to
151154 // never introduce NA values (e.g., int -> double)
152- return NACheck .getDisabled ();
155+ return NACheck .getEnabled ();
153156 }
154157
155158 // Integer
@@ -340,6 +343,37 @@ public String getString(RandomAccessIterator it, int index,
340343 return dataLib .getString (data , it , index );
341344 }
342345
346+ // List
347+
348+ @ ExportMessage
349+ public Object [] getListDataCopy (@ CachedLibrary ("this.data" ) VectorDataLibrary dataLib ) {
350+ assert getTargetType () == RType .List ;
351+ Object [] result = new Object [getLength (dataLib )];
352+ SeqIterator it = dataLib .iterator (data );
353+ while (dataLib .next (data , it )) {
354+ result [it .getIndex ()] = dataLib .getNextElement (data , it );
355+ }
356+ return result ;
357+ }
358+
359+ @ ExportMessage
360+ public Object getElementAt (int index ,
361+ @ CachedLibrary ("this.data" ) VectorDataLibrary dataLib ) {
362+ return dataLib .getElementAt (data , index );
363+ }
364+
365+ @ ExportMessage
366+ public Object getNextElement (SeqIterator it ,
367+ @ CachedLibrary ("this.data" ) VectorDataLibrary dataLib ) {
368+ return dataLib .getNextElement (data , it );
369+ }
370+
371+ @ ExportMessage
372+ public Object getElement (RandomAccessIterator it , int index ,
373+ @ CachedLibrary ("this.data" ) VectorDataLibrary dataLib ) {
374+ return dataLib .getElement (data , it , index );
375+ }
376+
343377 // Support of the RClosure interface
344378
345379 @ Override
@@ -376,7 +410,7 @@ protected VectorDataClosure copyDataClosure() {
376410 }
377411
378412 @ ExportLibrary (VectorDataLibrary .class )
379- static class DoubleClosure extends VectorDataClosure {
413+ static final class DoubleClosure extends VectorDataClosure {
380414 DoubleClosure (RAbstractVector delegate , Object data , RType targetType ) {
381415 super (delegate , data , targetType );
382416 }
@@ -393,7 +427,7 @@ protected VectorDataClosure copyDataClosure() {
393427 }
394428
395429 @ ExportLibrary (VectorDataLibrary .class )
396- static class LogicalClosure extends VectorDataClosure {
430+ static final class LogicalClosure extends VectorDataClosure {
397431 LogicalClosure (RAbstractVector delegate , Object data , RType targetType ) {
398432 super (delegate , data , targetType );
399433 }
@@ -410,7 +444,7 @@ protected VectorDataClosure copyDataClosure() {
410444 }
411445
412446 @ ExportLibrary (VectorDataLibrary .class )
413- static class RawClosure extends VectorDataClosure {
447+ static final class RawClosure extends VectorDataClosure {
414448 RawClosure (RAbstractVector delegate , Object data , RType targetType ) {
415449 super (delegate , data , targetType );
416450 }
@@ -427,7 +461,7 @@ protected VectorDataClosure copyDataClosure() {
427461 }
428462
429463 @ ExportLibrary (VectorDataLibrary .class )
430- static class ComplexClosure extends VectorDataClosure {
464+ static final class ComplexClosure extends VectorDataClosure {
431465 ComplexClosure (RAbstractVector delegate , Object data , RType targetType ) {
432466 super (delegate , data , targetType );
433467 }
@@ -444,7 +478,7 @@ protected VectorDataClosure copyDataClosure() {
444478 }
445479
446480 @ ExportLibrary (VectorDataLibrary .class )
447- static class StringClosure extends VectorDataClosure {
481+ static final class StringClosure extends VectorDataClosure {
448482 StringClosure (RAbstractVector delegate , Object data , RType targetType ) {
449483 super (delegate , data , targetType );
450484 }
@@ -459,4 +493,21 @@ protected VectorDataClosure copyDataClosure() {
459493 return new StringClosure (delegate , data , RType .Character );
460494 }
461495 }
496+
497+ @ ExportLibrary (VectorDataLibrary .class )
498+ static final class ListClosure extends VectorDataClosure {
499+ ListClosure (RAbstractVector delegate , Object data , RType targetType ) {
500+ super (delegate , data , targetType );
501+ }
502+
503+ @ Override
504+ protected RType getTargetType () {
505+ return RType .List ;
506+ }
507+
508+ @ Override
509+ protected VectorDataClosure copyDataClosure () {
510+ return new ListClosure (delegate , data , RType .Integer );
511+ }
512+ }
462513}
0 commit comments