File tree Expand file tree Collapse file tree 2 files changed +92
-0
lines changed
src/vm/jvm/runtime/org/perl6/nqp/truffle Expand file tree Collapse file tree 2 files changed +92
-0
lines changed Original file line number Diff line number Diff line change
1
+ package org .perl6 .nqp .truffle .nodes .expression ;
2
+
3
+ import com .oracle .truffle .api .CompilerAsserts ;
4
+ import com .oracle .truffle .api .frame .VirtualFrame ;
5
+ import com .oracle .truffle .api .nodes .ExplodeLoop ;
6
+ import com .oracle .truffle .api .nodes .NodeInfo ;
7
+
8
+ import org .perl6 .nqp .truffle .nodes .NQPNode ;
9
+ import org .perl6 .nqp .truffle .nodes .NQPObjNode ;
10
+ import org .perl6 .nqp .truffle .runtime .NQPListStr ;
11
+ import org .perl6 .nqp .dsl .Deserializer ;
12
+
13
+ @ NodeInfo (shortName = "list_s" )
14
+ public final class NQPListStrNode extends NQPObjNode {
15
+ @ Children private final NQPNode [] bodyNodes ;
16
+
17
+ @ Deserializer
18
+ public NQPListStrNode (NQPNode [] bodyNodes ) {
19
+ this .bodyNodes = bodyNodes ;
20
+ }
21
+
22
+ @ Override
23
+ @ ExplodeLoop
24
+ public Object execute (VirtualFrame frame ) {
25
+ NQPListStr list = new NQPListStr ();
26
+
27
+ CompilerAsserts .compilationConstant (bodyNodes .length );
28
+
29
+ for (NQPNode statement : bodyNodes ) {
30
+ list .pushStr (statement .executeStr (frame ));
31
+ }
32
+
33
+ return list ;
34
+ }
35
+ }
Original file line number Diff line number Diff line change
1
+ package org .perl6 .nqp .truffle .runtime ;
2
+
3
+ import java .util .ArrayList ;
4
+
5
+ public final class NQPListStr {
6
+ ArrayList <String > contents ;
7
+
8
+ public NQPListStr () {
9
+ this .contents = new ArrayList <String >();
10
+ }
11
+
12
+ public String pushStr (String element ) {
13
+ contents .add (element );
14
+ return element ;
15
+ }
16
+
17
+ public String popStr () {
18
+ return contents .remove (contents .size () - 1 );
19
+ }
20
+
21
+ public String unshiftStr (String element ) {
22
+ contents .add (0 , element );
23
+ return element ;
24
+ }
25
+
26
+ public String shiftStr () {
27
+ return contents .remove (0 );
28
+ }
29
+
30
+ public String atposStr (long pos ) {
31
+ if (pos < 0 ) {
32
+ pos = pos + contents .size ();
33
+ }
34
+ String value = contents .get ((int )pos );
35
+ if (value == null ) {
36
+ return null ;
37
+ } else {
38
+ return value ;
39
+ }
40
+ }
41
+
42
+ public String bindposStr (long pos , String value ) {
43
+ if (pos >= contents .size ()) {
44
+ for (int i = contents .size (); i < pos ; i ++) {
45
+ contents .add (null );
46
+ }
47
+ contents .add (value );
48
+ return value ;
49
+ } else {
50
+ return contents .set ((int )pos , value );
51
+ }
52
+ }
53
+
54
+ public int elems () {
55
+ return contents .size ();
56
+ }
57
+ }
You can’t perform that action at this time.
0 commit comments