public MethodDefinitionBuilder resultType(Method method, int flags) { if (Decl.isMpl(method)) { // Create a String with the TypeInfo StringBuilder sb = new StringBuilder(); // It's a bunch of nested callables (# of param lists - 1) for (int i = 1; i < method.getParameterLists().size(); i++) { sb.append("ceylon.language::Callable<"); } // Then the return type as defined originally sb.append(method.getType().getProducedTypeQualifiedName()); // And then the parameter types of each nested callable for (int i = method.getParameterLists().size() - 1; i > 0; i--) { ParameterList plist = method.getParameterLists().get(i); for (Parameter p : plist.getParameters()) { sb.append(','); sb.append(p.getType().getProducedTypeQualifiedName()); } sb.append('>'); } return resultType( gen.makeAtType(sb.toString(), false), gen.makeJavaType(gen.functionalReturnType(method), flags)); } else { ProducedTypedReference typedRef = gen.getTypedReference(method); ProducedTypedReference nonWideningTypedRef = gen.nonWideningTypeDecl(typedRef); ProducedType nonWideningType = gen.nonWideningType(typedRef, nonWideningTypedRef); return resultType( makeResultType(nonWideningTypedRef.getDeclaration(), nonWideningType, flags), method); } }
public MethodDefinitionBuilder resultTypeNonWidening( ProducedTypedReference typedRef, ProducedType returnType, int flags) { ProducedTypedReference nonWideningTypedRef = gen.nonWideningTypeDecl(typedRef); returnType = gen.nonWideningType(typedRef, nonWideningTypedRef); return resultType( makeResultType(nonWideningTypedRef.getDeclaration(), returnType, flags), typedRef.getDeclaration()); }
private AttributeDefinitionBuilder( AbstractTransformer owner, TypedDeclaration attrType, String javaClassName, String attrName, String fieldName, boolean toplevel) { int typeFlags = 0; ProducedTypedReference typedRef = owner.getTypedReference(attrType); ProducedTypedReference nonWideningTypedRef = owner.nonWideningTypeDecl(typedRef); ProducedType nonWideningType = owner.nonWideningType(typedRef, nonWideningTypedRef); if (!CodegenUtil.isUnBoxed(nonWideningTypedRef.getDeclaration())) { typeFlags |= AbstractTransformer.JT_NO_PRIMITIVES; } this.attrType = owner.makeJavaType(nonWideningType, typeFlags); this.attrTypeRaw = owner.makeJavaType(nonWideningType, AbstractTransformer.JT_RAW); this.owner = owner; this.javaClassName = javaClassName; this.attrName = attrName; this.fieldName = fieldName; this.toplevel = toplevel; // Make sure we use the declaration for building the getter/setter names, as we might be trying // to // override a JavaBean property with an "isFoo" getter, or non-Ceylon casing, and we have to // respect that. getterBuilder = MethodDefinitionBuilder.method2(owner, Naming.getGetterName(attrType)) .block(generateDefaultGetterBlock()) .isOverride(attrType.isActual()) .annotations(owner.makeAtAnnotations(attrType.getAnnotations())) .resultType(this.attrType, attrType); setterBuilder = MethodDefinitionBuilder.method2(owner, Naming.getSetterName(attrType)) .block(generateDefaultSetterBlock()) // only actual if the superclass is also variable .isOverride( attrType.isActual() && ((TypedDeclaration) attrType.getRefinedDeclaration()).isVariable()) .parameter( Flags.FINAL, attrName, attrType, nonWideningTypedRef.getDeclaration(), nonWideningType, 0); }
public MethodDefinitionBuilder parameter(Parameter param, int flags) { String paramName = param.getName(); String aliasedName = paramName; MethodOrValue mov = CodegenUtil.findMethodOrValueForParam(param); int mods = 0; if (!(mov instanceof Value) || !mov.isVariable() || mov.isCaptured()) { mods |= FINAL; } if (mov instanceof Method || mov instanceof Value && mov.isVariable() && mov.isCaptured()) { aliasedName = Naming.getAliasedParameterName(param); } TypedDeclaration nonWideningDecl; ProducedType nonWideningType; if (mov instanceof Value) { ProducedTypedReference typedRef = gen.getTypedReference(mov); ProducedTypedReference nonWideningTypedRef = gen.nonWideningTypeDecl(typedRef); nonWideningType = gen.nonWideningType(typedRef, nonWideningTypedRef); nonWideningDecl = nonWideningTypedRef.getDeclaration(); } else { nonWideningType = param.getType(); nonWideningDecl = param; } return parameter(mods, paramName, aliasedName, param, nonWideningDecl, nonWideningType, flags); }
public AppliedAttribute( @Ignore TypeDescriptor $reifiedContainer, @Ignore TypeDescriptor $reifiedGet, @Ignore TypeDescriptor $reifiedSet, FreeValue declaration, ProducedTypedReference typedReference, ceylon.language.meta.model.Type<? extends Object> container) { super( $reifiedContainer, TypeDescriptor.klass(ceylon.language.meta.model.Value.class, $reifiedGet, $reifiedSet), container); this.declaration = declaration; this.typedReference = typedReference; this.closedType = Metamodel.getAppliedMetamodel(typedReference.getType()); this.$reifiedGet = $reifiedGet; this.$reifiedSet = $reifiedSet; }