Mercurial > hg > graal-compiler
diff graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/template/ParameterSpec.java @ 8595:8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 01 Apr 2013 21:43:20 +0200 |
parents | ce6e8672f798 |
children | 97ad6d3e7557 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/template/ParameterSpec.java Mon Apr 01 12:19:15 2013 +0200 +++ b/graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/template/ParameterSpec.java Mon Apr 01 21:43:20 2013 +0200 @@ -27,6 +27,7 @@ import javax.lang.model.type.*; import com.oracle.truffle.codegen.processor.*; +import com.oracle.truffle.codegen.processor.template.MethodSpec.TypeDef; public class ParameterSpec { @@ -38,9 +39,7 @@ private final List<TypeMirror> allowedTypes; /** Cardinality one or multiple. */ - private Cardinality cardinality; - /** Type is optional can be dismissed. */ - private boolean optional; + private Cardinality cardinality = Cardinality.ONE; /** Type is part of the method signature. Relevant for comparisons. */ private boolean signature; /** Type must be indexed when parsing. */ @@ -48,6 +47,8 @@ /** Type is bound to local final variable. */ private boolean local; + private TypeDef typeDefinition; + public ParameterSpec(String name, TypeMirror... allowedTypes) { this(name, Arrays.asList(allowedTypes)); } @@ -57,8 +58,12 @@ this.allowedTypes = allowedTypes; } - public void setOptional(boolean optional) { - this.optional = optional; + void setTypeDefinition(TypeDef typeDefinition) { + this.typeDefinition = typeDefinition; + } + + TypeDef getTypeDefinition() { + return typeDefinition; } public void setSignature(boolean signature) { @@ -93,10 +98,6 @@ return name; } - public boolean isOptional() { - return optional; - } - public Cardinality getCardinality() { return cardinality; } @@ -114,4 +115,25 @@ return false; } + @Override + public String toString() { + return toSignatureString(false); + } + + public String toSignatureString(boolean typeOnly) { + StringBuilder builder = new StringBuilder(); + if (typeDefinition != null) { + builder.append("<" + typeDefinition.getName() + ">"); + } else if (getAllowedTypes().size() >= 1) { + builder.append(Utils.getSimpleName(getAllowedTypes().get(0))); + } else { + builder.append("void"); + } + if (!typeOnly) { + builder.append(" "); + builder.append(getName()); + } + return builder.toString(); + } + }