annotate graal/com.oracle.truffle.api.codegen/src/com/oracle/truffle/api/codegen/NodeFactory.java @ 7855:6e4fb0ccebb1

Generated factories implement the new NodeFactory interface.
author Christian Humer <christian.humer@gmail.com>
date Mon, 25 Feb 2013 13:13:02 +0100
parents
children c4c3f50fa9c2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7855
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
1 /*
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
4 *
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
8 *
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
13 * accompanied this code).
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
14 *
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
18 *
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
21 * questions.
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
22 */
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
23 package com.oracle.truffle.api.codegen;
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
24
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
25 import java.util.*;
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
26
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
27 /**
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
28 * Enables the dynamic creation of generated nodes. It provides an convenient way to instantiate
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
29 * generated node classes without using reflection.
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
30 */
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
31 public interface NodeFactory<T> {
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
32
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
33 /**
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
34 * Instantiates the node using the arguments array. The arguments length and types must suffice
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
35 * one of the returned signatures in {@link #getNodeSignatures()}. If the arguments array does
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
36 * not suffice one of the node signatures an {@link IllegalArgumentException} is thrown.
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
37 *
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
38 * @param arguments the argument values
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
39 * @return the instantiated node
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
40 * @throws IllegalArgumentException
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
41 */
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
42 T createNode(Object... arguments);
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
43
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
44 /**
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
45 * Instantiates a new specialized variant of the node. This is an optional method and throws an
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
46 * {@link UnsupportedOperationException} if not supported.
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
47 *
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
48 * @param thisNode the current node
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
49 * @param specializionClasses
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
50 * @return the specialized node
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
51 */
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
52 T createNodeSpecialized(T thisNode, Class<?>... specializionClasses);
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
53
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
54 /**
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
55 * Returns the node class that will get created by {@link #createNode(Object...)}. The node
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
56 * class does not match exactly to the instantiated object but they are guaranteed to be
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
57 * assignable.
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
58 */
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
59 Class<T> getNodeClass();
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
60
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
61 /**
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
62 * Returns a list of signatures that can be used to invoke {@link #createNode(Object...)}.
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
63 */
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
64 List<List<Class<?>>> getNodeSignatures();
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
65
6e4fb0ccebb1 Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
66 }