Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/NodeFactoryBase.java @ 16751:4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 11 Aug 2014 15:53:05 +0200 |
parents | |
children | e6d15134ca86 |
rev | line source |
---|---|
16751
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 package com.oracle.truffle.api.dsl.internal; |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 import java.util.*; |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 import com.oracle.truffle.api.dsl.*; |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 import com.oracle.truffle.api.nodes.*; |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 /** |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This is NOT public API. Do not use directly. This code may change without notice. |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 */ |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 public abstract class NodeFactoryBase<T> implements NodeFactory<T> { |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 private final Class<T> nodeClass; |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 private final Class<?>[][] nodeSignatures; |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 private final Class<? extends Node>[] executionSignatures; |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 @SuppressWarnings("unchecked") |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 public NodeFactoryBase(Class<T> nodeClass, Class<?>[] executionSignatures, Class<?>[][] nodeSignatures) { |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 this.nodeClass = nodeClass; |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 this.nodeSignatures = nodeSignatures; |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 this.executionSignatures = (Class<? extends Node>[]) executionSignatures; |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 } |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 public abstract T createNode(Object... arguments); |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 public final Class<T> getNodeClass() { |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
27 return nodeClass; |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
28 } |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
29 |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
30 public final List<List<Class<?>>> getNodeSignatures() { |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
31 List<List<Class<?>>> signatures = new ArrayList<>(); |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
32 for (int i = 0; i < nodeSignatures.length; i++) { |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
33 signatures.add(Arrays.asList(nodeSignatures[i])); |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
34 } |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
35 return signatures; |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
36 } |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
37 |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
38 public final List<Class<? extends Node>> getExecutionSignature() { |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
39 return Arrays.asList(executionSignatures); |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
40 } |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
41 |
4f589fa69b9c
Truffle-DSL: added shared code required for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
42 } |