Mercurial > hg > truffle
comparison graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/template/TemplateMethod.java @ 7291:a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Fri, 21 Dec 2012 10:44:31 -0800 |
parents | |
children | 6343a09b2ec1 |
comparison
equal
deleted
inserted
replaced
7290:a81db08fe930 | 7291:a748e4d44694 |
---|---|
1 /* | |
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.oracle.truffle.codegen.processor.template; | |
24 | |
25 import javax.lang.model.element.*; | |
26 | |
27 public class TemplateMethod { | |
28 | |
29 private final MethodSpec specification; | |
30 private final ExecutableElement method; | |
31 private final AnnotationMirror markerAnnotation; | |
32 private final ActualParameter returnType; | |
33 private final ActualParameter[] parameters; | |
34 | |
35 public TemplateMethod(MethodSpec specification, ExecutableElement method, AnnotationMirror markerAnnotation, ActualParameter returnType, ActualParameter[] parameters) { | |
36 this.specification = specification; | |
37 this.method = method; | |
38 this.markerAnnotation = markerAnnotation; | |
39 this.returnType = returnType; | |
40 this.parameters = parameters; | |
41 } | |
42 | |
43 public TemplateMethod(TemplateMethod method) { | |
44 this.specification = method.specification; | |
45 this.method = method.method; | |
46 this.markerAnnotation = method.markerAnnotation; | |
47 this.returnType = method.returnType; | |
48 this.parameters = method.parameters; | |
49 } | |
50 | |
51 | |
52 public MethodSpec getSpecification() { | |
53 return specification; | |
54 } | |
55 | |
56 public ActualParameter getReturnType() { | |
57 return returnType; | |
58 } | |
59 | |
60 public ActualParameter[] getParameters() { | |
61 return parameters; | |
62 } | |
63 | |
64 public ActualParameter findParameter(String valueName) { | |
65 for (ActualParameter param : getParameters()) { | |
66 if (param.getSpecification().getName().equals(valueName)) { | |
67 return param; | |
68 } | |
69 } | |
70 return null; | |
71 } | |
72 | |
73 public ActualParameter findParameter(ParameterSpec spec) { | |
74 for (ActualParameter param : getParameters()) { | |
75 if (param.getSpecification() == spec) { | |
76 return param; | |
77 } | |
78 } | |
79 return null; | |
80 } | |
81 | |
82 public ExecutableElement getMethod() { | |
83 return method; | |
84 } | |
85 | |
86 public String getMethodName() { | |
87 return getMethod().getSimpleName().toString(); | |
88 } | |
89 | |
90 public AnnotationMirror getMarkerAnnotation() { | |
91 return markerAnnotation; | |
92 } | |
93 | |
94 @Override | |
95 public String toString() { | |
96 return getClass().getSimpleName() + " [method = " + method + "]"; | |
97 } | |
98 } |