13514
|
1 /*
|
|
2 * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. This
|
|
3 * code is released under a tri EPL/GPL/LGPL license. You can use it,
|
|
4 * redistribute it and/or modify it under the terms of the:
|
|
5 *
|
|
6 * Eclipse Public License version 1.0
|
|
7 * GNU General Public License version 2
|
|
8 * GNU Lesser General Public License version 2.1
|
|
9 */
|
|
10 package com.oracle.truffle.ruby.nodes.literal.array;
|
|
11
|
|
12 import com.oracle.truffle.api.*;
|
|
13 import com.oracle.truffle.api.frame.*;
|
|
14 import com.oracle.truffle.api.nodes.*;
|
|
15 import com.oracle.truffle.ruby.nodes.*;
|
|
16 import com.oracle.truffle.ruby.runtime.*;
|
|
17 import com.oracle.truffle.ruby.runtime.core.array.*;
|
|
18
|
|
19 @NodeInfo(shortName = "object-array-literal")
|
|
20 public class ObjectArrayLiteralNode extends ArrayLiteralNode {
|
|
21
|
|
22 public ObjectArrayLiteralNode(RubyContext context, SourceSection sourceSection, RubyNode[] values) {
|
|
23 super(context, sourceSection, values);
|
|
24 }
|
|
25
|
|
26 @ExplodeLoop
|
|
27 @Override
|
|
28 public RubyArray executeArray(VirtualFrame frame) {
|
|
29 final Object[] executedValues = new Object[values.length];
|
|
30
|
|
31 for (int n = 0; n < values.length; n++) {
|
|
32 executedValues[n] = values[n].execute(frame);
|
|
33 }
|
|
34
|
|
35 return new RubyArray(getContext().getCoreLibrary().getArrayClass(), new ObjectArrayStore(executedValues));
|
|
36 }
|
|
37
|
|
38 @ExplodeLoop
|
|
39 @Override
|
|
40 public void executeVoid(VirtualFrame frame) {
|
|
41 for (int n = 0; n < values.length; n++) {
|
|
42 values[n].executeVoid(frame);
|
|
43 }
|
|
44 }
|
|
45
|
|
46 @Override
|
|
47 public Object execute(VirtualFrame frame) {
|
|
48 return executeArray(frame);
|
|
49 }
|
|
50
|
|
51 }
|