Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/template/TemplateMethod.java @ 8245:703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Wed, 06 Mar 2013 18:32:33 +0100 |
parents | ac4e8c16ffdf |
children | cb70ed101b5f |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/template/TemplateMethod.java Wed Mar 06 18:27:57 2013 +0100 +++ b/graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/template/TemplateMethod.java Wed Mar 06 18:32:33 2013 +0100 @@ -22,19 +22,25 @@ */ package com.oracle.truffle.codegen.processor.template; +import java.util.*; + import javax.lang.model.element.*; +import javax.lang.model.type.*; + +import com.oracle.truffle.codegen.processor.*; public class TemplateMethod { - private final String id; + private String id; private final Template template; private final MethodSpec specification; private final ExecutableElement method; private final AnnotationMirror markerAnnotation; private final ActualParameter returnType; - private final ActualParameter[] parameters; + private final List<ActualParameter> parameters; - public TemplateMethod(String id, Template template, MethodSpec specification, ExecutableElement method, AnnotationMirror markerAnnotation, ActualParameter returnType, ActualParameter[] parameters) { + public TemplateMethod(String id, Template template, MethodSpec specification, ExecutableElement method, AnnotationMirror markerAnnotation, ActualParameter returnType, + List<ActualParameter> parameters) { this.template = template; this.specification = specification; this.method = method; @@ -54,6 +60,10 @@ this(method.id, method.template, method.specification, method.method, method.markerAnnotation, method.returnType, method.parameters); } + public void setId(String id) { + this.id = id; + } + public String getId() { return id; } @@ -70,7 +80,7 @@ return returnType; } - public ActualParameter[] getParameters() { + public List<ActualParameter> getParameters() { return parameters; } @@ -83,15 +93,27 @@ return null; } + public List<ActualParameter> getReturnTypeAndParameters() { + List<ActualParameter> allParameters = new ArrayList<>(getParameters().size() + 1); + allParameters.add(getReturnType()); + allParameters.addAll(getParameters()); + return Collections.unmodifiableList(allParameters); + } + public ActualParameter findParameter(ParameterSpec spec) { for (ActualParameter param : getParameters()) { - if (param.getSpecification() == spec) { + if (param.getSpecification().getName().equals(spec.getName())) { return param; } } return null; } + public boolean canBeAccessedByInstanceOf(TypeMirror type) { + TypeMirror methodType = Utils.findNearestEnclosingType(getMethod()).asType(); + return Utils.isAssignable(type, methodType) || Utils.isAssignable(methodType, type); + } + public ExecutableElement getMethod() { return method; } @@ -106,7 +128,7 @@ @Override public String toString() { - return getClass().getSimpleName() + " [method = " + method + "]"; + return "id = " + getId() + ", " + getClass().getSimpleName() + " [method = " + getMethod() + "]"; } public ActualParameter getPreviousParam(ActualParameter searchParam) {