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.call;
|
|
11
|
|
12 import com.oracle.truffle.api.*;
|
|
13 import com.oracle.truffle.api.frame.*;
|
|
14 import com.oracle.truffle.ruby.runtime.*;
|
|
15 import com.oracle.truffle.ruby.runtime.core.*;
|
|
16 import com.oracle.truffle.ruby.runtime.methods.*;
|
|
17 import com.oracle.truffle.ruby.runtime.objects.*;
|
|
18
|
|
19 /**
|
|
20 * A node in the dispatch chain that does no caching and looks up methods from scratch each time it
|
|
21 * is called.
|
|
22 */
|
|
23 public class GeneralBoxedDispatchNode extends BoxedDispatchNode {
|
|
24
|
|
25 private final String name;
|
|
26
|
|
27 public GeneralBoxedDispatchNode(RubyContext context, SourceSection sourceSection, String name) {
|
|
28 super(context, sourceSection);
|
|
29
|
|
30 assert name != null;
|
|
31
|
|
32 this.name = name;
|
|
33 }
|
|
34
|
|
35 @Override
|
|
36 public Object dispatch(VirtualFrame frame, RubyBasicObject receiverObject, RubyProc blockObject, Object[] argumentsObjects) {
|
|
37 /*
|
|
38 * TODO(CS): we should probably have some kind of cache here - even if it's just a hash map.
|
|
39 * MRI and JRuby do and might avoid some pathological cases.
|
|
40 */
|
|
41
|
|
42 final RubyMethod method = lookup(frame, receiverObject, name);
|
|
43 return method.call(frame.pack(), receiverObject, blockObject, argumentsObjects);
|
|
44 }
|
|
45
|
|
46 }
|