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.core;
|
|
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 /**
|
|
20 * Take the rest of values in an array after an index, without using any method lookup. This isn't a
|
|
21 * call - it's an operation on a core class.
|
|
22 */
|
|
23 @NodeInfo(shortName = "array-rest")
|
|
24 public final class ArrayRestNode extends RubyNode {
|
|
25
|
|
26 final int begin;
|
|
27 @Child protected RubyNode array;
|
|
28
|
|
29 public ArrayRestNode(RubyContext context, SourceSection sourceSection, int begin, RubyNode array) {
|
|
30 super(context, sourceSection);
|
|
31 this.begin = begin;
|
|
32 this.array = adoptChild(array);
|
|
33 }
|
|
34
|
|
35 @Override
|
|
36 public Object execute(VirtualFrame frame) {
|
|
37 final RubyArray arrayObject = (RubyArray) array.execute(frame);
|
|
38 return arrayObject.getRangeExclusive(begin, arrayObject.size());
|
|
39 }
|
|
40
|
|
41 }
|