Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/NodeFactoryBase.java @ 16766:90984ae0eaa8
Truffle-DSL: Fixed headers.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 11 Aug 2014 17:29:24 +0200 |
parents | e6d15134ca86 |
children |
rev | line source |
---|---|
16766
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
1 /* |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
4 * |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
7 * published by the Free Software Foundation. Oracle designates this |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
8 * particular file as subject to the "Classpath" exception as provided |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
9 * by Oracle in the LICENSE file that accompanied this code. |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
10 * |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
15 * accompanied this code). |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
16 * |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
17 * You should have received a copy of the GNU General Public License version |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
20 * |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
22 * or visit www.oracle.com if you need additional information or have any |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
23 * questions. |
90984ae0eaa8
Truffle-DSL: Fixed headers.
Christian Humer <christian.humer@gmail.com>
parents:
16763
diff
changeset
|
24 */ |
16763
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
25 package com.oracle.truffle.api.dsl.internal; |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
26 |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
27 import java.util.*; |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
28 |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
29 import com.oracle.truffle.api.dsl.*; |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
30 import com.oracle.truffle.api.nodes.*; |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
31 |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
32 /** |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
33 * This is NOT public API. Do not use directly. This code may change without notice. |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
34 */ |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
35 public abstract class NodeFactoryBase<T> implements NodeFactory<T> { |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
36 |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
37 private final Class<T> nodeClass; |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
38 private final Class<?>[][] nodeSignatures; |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
39 private final Class<? extends Node>[] executionSignatures; |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
40 |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
41 @SuppressWarnings("unchecked") |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
42 public NodeFactoryBase(Class<T> nodeClass, Class<?>[] executionSignatures, Class<?>[][] nodeSignatures) { |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
43 this.nodeClass = nodeClass; |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
44 this.nodeSignatures = nodeSignatures; |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
45 this.executionSignatures = (Class<? extends Node>[]) executionSignatures; |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
46 } |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
47 |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
48 public abstract T createNode(Object... arguments); |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
49 |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
50 public final Class<T> getNodeClass() { |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
51 return nodeClass; |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
52 } |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
53 |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
54 public final List<List<Class<?>>> getNodeSignatures() { |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
55 List<List<Class<?>>> signatures = new ArrayList<>(); |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
56 for (int i = 0; i < nodeSignatures.length; i++) { |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
57 signatures.add(Arrays.asList(nodeSignatures[i])); |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
58 } |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
59 return signatures; |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
60 } |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
61 |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
62 public final List<Class<? extends Node>> getExecutionSignature() { |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
63 return Arrays.asList(executionSignatures); |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
64 } |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
65 |
e6d15134ca86
Truffle-DSL: fixed formatting problems.
Christian Humer <christian.humer@gmail.com>
parents:
16751
diff
changeset
|
66 } |