use of org.eclipse.ceylon.model.typechecker.model.Value in project ceylon by eclipse.
the class InterfaceVisitor method visit.
@Override
public void visit(Tree.ObjectDefinition that) {
Value model = that.getDeclarationModel();
// locals and toplevels get a type generated for them
if (!model.isMember() && !model.isToplevel()) {
Set<String> old = localCompanionClasses;
localCompanionClasses = new HashSet<String>();
super.visit(that);
localCompanionClasses = old;
} else {
super.visit(that);
}
}
use of org.eclipse.ceylon.model.typechecker.model.Value in project ceylon by eclipse.
the class NamedArgumentInvocation method bindAttributeArgument.
private void bindAttributeArgument(Tree.AttributeArgument attrArg, Parameter declaredParam, Naming.SyntheticName argName) {
ListBuffer<JCStatement> statements;
final Value model = attrArg.getDeclarationModel();
final String name = model.getName();
String className = Naming.getAttrClassName(model, 0);
final List<JCTree> attrClass = gen.gen().transformAttribute(model, name, className, null, attrArg.getBlock(), attrArg.getSpecifierExpression(), null, null);
TypedReference typedRef = gen.getTypedReference(model);
TypedReference nonWideningTypedRef = gen.nonWideningTypeDecl(typedRef);
Type nonWideningType = gen.nonWideningType(typedRef, nonWideningTypedRef);
Type type = parameterType(declaredParam, model.getType(), 0);
final BoxingStrategy boxType = getNamedParameterBoxingStrategy(declaredParam);
JCExpression initValue = gen.make().Apply(null, gen.makeSelect(gen.makeUnquotedIdent(className), Naming.getGetterName(model)), List.<JCExpression>nil());
initValue = gen.expressionGen().applyErasureAndBoxing(initValue, nonWideningType, !CodegenUtil.isUnBoxed(nonWideningTypedRef.getDeclaration()), boxType, type);
JCTree.JCVariableDecl var = gen.make().VarDef(gen.make().Modifiers(FINAL, List.<JCAnnotation>nil()), argName.asName(), gen.makeJavaType(type, boxType == BoxingStrategy.BOXED ? JT_NO_PRIMITIVES : 0), initValue);
statements = toStmts(attrArg, attrClass).append(var);
bind(declaredParam, argName, gen.makeJavaType(type, boxType == BoxingStrategy.BOXED ? JT_NO_PRIMITIVES : 0), statements.toList());
}
use of org.eclipse.ceylon.model.typechecker.model.Value in project ceylon by eclipse.
the class DefiniteAssignmentVisitor method visit.
public void visit(Tree.SpecifierStatement stmt) {
Tree.Term bme = stmt.getBaseMemberExpression();
if (bme instanceof Tree.MemberOrTypeExpression) {
Declaration decl = ((Tree.MemberOrTypeExpression) bme).getDeclaration();
if (// non-variable and deferred
tracked.containsKey(decl) && // specification is in a for/else
forBlock != null && !forBlock.equals(tracked.get(decl))) {
// not declared in *this* for/else
if (elseBlock == null) {
((Value) decl).setSpecifiedInForElse(true);
}
ControlBlock assigningBlock = elseBlock != null ? elseBlock : forBlock;
addSpecified(decl, assigningBlock);
}
}
super.visit(stmt);
}
use of org.eclipse.ceylon.model.typechecker.model.Value in project ceylon by eclipse.
the class SmallDeclarationVisitor method visit.
@Override
public void visit(Tree.AttributeSetterDefinition that) {
Value getter = that.getDeclarationModel().getGetter();
if (getter != null && getter.isSmall()) {
// Setter parameter is small if getter is small
smallDeclaration(that.getDeclarationModel().getParameter().getModel());
}
super.visit(that);
}
use of org.eclipse.ceylon.model.typechecker.model.Value in project ceylon by eclipse.
the class SmallDeclarationVisitor method setSmallType.
protected static void setSmallType(FunctionOrValue f) {
Type t = smallUnderlyingType(f.getType());
f.setType(t);
if (f instanceof Value) {
Setter s = ((Value) f).getSetter();
if (s != null) {
s.getParameter().getModel().setType(t);
}
}
}
Aggregations