use of com.redhat.ceylon.model.typechecker.model.Parameter in project ceylon-compiler by ceylon.
the class ExpressionTransformer method transform.
public JCExpression transform(Tree.InvocationExpression ce) {
JCExpression ret = checkForInvocationExpressionOptimisation(ce);
if (ret != null)
return ret;
Tree.Term primary = Decl.unwrapExpressionsUntilTerm(ce.getPrimary());
Declaration primaryDeclaration = null;
Reference producedReference = null;
if (primary instanceof Tree.MemberOrTypeExpression) {
producedReference = ((Tree.MemberOrTypeExpression) primary).getTarget();
primaryDeclaration = ((Tree.MemberOrTypeExpression) primary).getDeclaration();
}
Invocation invocation;
if (ce.getPositionalArgumentList() != null) {
if ((isIndirectInvocation(ce) || isWithinDefaultParameterExpression(primaryDeclaration.getContainer())) && !Decl.isJavaStaticOrInterfacePrimary(ce.getPrimary())) {
// indirect invocation
invocation = new IndirectInvocation(this, primary, primaryDeclaration, ce);
} else {
// direct invocation
java.util.List<Parameter> parameters = ((Functional) primaryDeclaration).getFirstParameterList().getParameters();
invocation = new PositionalInvocation(this, primary, primaryDeclaration, producedReference, ce, parameters);
}
} else if (ce.getNamedArgumentList() != null) {
invocation = new NamedArgumentInvocation(this, primary, primaryDeclaration, producedReference, ce);
} else {
return makeErroneous(ce, "no arguments");
}
return transformInvocation(invocation);
}
use of com.redhat.ceylon.model.typechecker.model.Parameter in project ceylon-compiler by ceylon.
the class ClassTransformer method overloads.
private Iterable<java.util.List<Parameter>> overloads(Functional f) {
java.util.List<java.util.List<Parameter>> result = new ArrayList<java.util.List<Parameter>>();
result.add(f.getFirstParameterList().getParameters());
int ii = 0;
for (Parameter p : f.getFirstParameterList().getParameters()) {
if (p.isDefaulted() || (p.isSequenced() && !p.isAtLeastOne())) {
result.add(f.getFirstParameterList().getParameters().subList(0, ii));
}
ii++;
}
return result;
}
use of com.redhat.ceylon.model.typechecker.model.Parameter in project ceylon-compiler by ceylon.
the class ClassTransformer method addRefinedThrowerInstantiatorMethod.
private void addRefinedThrowerInstantiatorMethod(ClassDefinitionBuilder classBuilder, String message, ClassOrInterface classModel, Class formalClass, Reference unrefined) {
MethodDefinitionBuilder mdb = MethodDefinitionBuilder.systemMethod(this, naming.getInstantiatorMethodName(formalClass));
mdb.modifiers(transformClassDeclFlags(formalClass) & ~ABSTRACT);
for (TypeParameter tp : formalClass.getTypeParameters()) {
mdb.typeParameter(tp);
mdb.reifiedTypeParameter(tp);
}
for (Parameter formalP : formalClass.getParameterList().getParameters()) {
ParameterDefinitionBuilder pdb = ParameterDefinitionBuilder.systemParameter(this, formalP.getName());
pdb.sequenced(formalP.isSequenced());
pdb.defaulted(formalP.isDefaulted());
pdb.type(makeJavaType(unrefined.getTypedParameter(formalP).getType()), null);
mdb.parameter(pdb);
}
mdb.resultType(makeJavaType(unrefined.getType()), null);
mdb.body(makeThrowUnresolvedCompilationError(message));
classBuilder.method(mdb);
}
use of com.redhat.ceylon.model.typechecker.model.Parameter in project ceylon-compiler by ceylon.
the class MethodDefinitionBuilder method resultType.
public MethodDefinitionBuilder resultType(Function method, int flags) {
if (method.isParameter()) {
if (Decl.isUnboxedVoid(method) && !Strategy.useBoxedVoid(method)) {
return resultType(gen.makeJavaTypeAnnotations(method, false), gen.make().Type(gen.syms().voidType));
} else {
Parameter parameter = method.getInitializerParameter();
Type resultType = parameter.getType();
for (int ii = 1; ii < method.getParameterLists().size(); ii++) {
resultType = gen.typeFact().getCallableType(resultType);
}
return resultType(gen.makeJavaType(resultType, CodegenUtil.isUnBoxed(method) ? 0 : AbstractTransformer.JT_NO_PRIMITIVES), method);
}
}
TypedReference typedRef = gen.getTypedReference(method);
TypedReference nonWideningTypedRef = gen.nonWideningTypeDecl(typedRef);
Type nonWideningType = gen.nonWideningType(typedRef, nonWideningTypedRef);
if (method.isActual() && CodegenUtil.hasTypeErased(method))
flags |= AbstractTransformer.JT_RAW;
return resultType(makeResultType(nonWideningTypedRef.getDeclaration(), nonWideningType, flags), method);
}
use of com.redhat.ceylon.model.typechecker.model.Parameter in project ceylon-compiler by ceylon.
the class NamedArgumentInvocation method appendVarsForNamedArguments.
private void appendVarsForNamedArguments(java.util.List<Tree.NamedArgument> namedArguments, java.util.List<Parameter> declaredParams) {
// Assign vars for each named argument given
for (Tree.NamedArgument namedArg : namedArguments) {
gen.at(namedArg);
Parameter declaredParam = namedArg.getParameter();
Naming.SyntheticName argName = argName(declaredParam);
if (namedArg instanceof Tree.SpecifiedArgument) {
bindSpecifiedArgument((Tree.SpecifiedArgument) namedArg, declaredParam, argName);
} else if (namedArg instanceof Tree.MethodArgument) {
bindMethodArgument((Tree.MethodArgument) namedArg, declaredParam, argName);
} else if (namedArg instanceof Tree.ObjectArgument) {
bindObjectArgument((Tree.ObjectArgument) namedArg, declaredParam, argName);
} else if (namedArg instanceof Tree.AttributeArgument) {
bindAttributeArgument((Tree.AttributeArgument) namedArg, declaredParam, argName);
} else {
throw BugException.unhandledNodeCase(namedArg);
}
}
}
Aggregations