use of org.eclipse.ceylon.compiler.typechecker.tree.Tree.AttributeSetterDefinition in project ceylon by eclipse.
the class GenerateJsVisitor method visit.
@Override
public void visit(final Tree.AttributeGetterDefinition that) {
if (errVisitor.hasErrors(that) || !TypeUtils.acceptNative(that))
return;
Value d = that.getDeclarationModel();
if (opts.isOptimize() && d.isClassOrInterfaceMember())
return;
comment(that);
if (AttributeGenerator.defineAsProperty(d)) {
defineAttribute(names.self((TypeDeclaration) d.getContainer()), names.name(d));
AttributeGenerator.getter(that, this, true);
final AttributeSetterDefinition setterDef = associatedSetterDefinition(d);
if (setterDef == null) {
out(",undefined");
} else {
out(",function(", names.name(setterDef.getDeclarationModel().getParameter()), ")");
AttributeGenerator.setter(setterDef, this);
}
out(",");
TypeUtils.encodeForRuntime(that, that.getDeclarationModel(), that.getAnnotationList(), this);
if (setterDef != null) {
out(",");
TypeUtils.encodeForRuntime(setterDef, setterDef.getDeclarationModel(), setterDef.getAnnotationList(), this);
}
out(");");
} else {
out(function, names.getter(d, false), "()");
if (TypeUtils.isNativeExternal(d)) {
out("{");
if (stitchNative(d, that)) {
if (verboseStitcher) {
spitOut("Stitching in native attribute " + d.getQualifiedNameString() + ", ignoring Ceylon declaration");
}
} else {
AttributeGenerator.getter(that, this, false);
}
out("}");
} else {
AttributeGenerator.getter(that, this, true);
}
endLine();
out(names.getter(d, false), ".$crtmm$=");
TypeUtils.encodeForRuntime(that, d, this);
if (!shareGetter(d)) {
out(";");
}
AttributeGenerator.generateAttributeMetamodel(that, true, false, this);
}
}
use of org.eclipse.ceylon.compiler.typechecker.tree.Tree.AttributeSetterDefinition in project ceylon by eclipse.
the class GenerateJsVisitor method addGetterToPrototype.
private void addGetterToPrototype(TypeDeclaration outer, final Tree.AttributeGetterDefinition that) {
Value d = that.getDeclarationModel();
if (!opts.isOptimize() || !d.isClassOrInterfaceMember())
return;
comment(that);
defineAttribute(d.isStatic() ? names.name(outer) + ".$st$" : names.self(outer), names.name(d));
if (TypeUtils.isNativeExternal(d)) {
out("{");
if (stitchNative(d, that)) {
if (verboseStitcher) {
spitOut("Stitching in native getter " + d.getQualifiedNameString() + ", ignoring Ceylon declaration");
}
} else {
AttributeGenerator.getter(that, this, false);
}
out("}");
} else {
AttributeGenerator.getter(that, this, true);
}
final AttributeSetterDefinition setterDef = associatedSetterDefinition(d);
if (setterDef == null) {
out(",undefined");
} else {
out(",function(", names.name(setterDef.getDeclarationModel().getParameter()), ")");
AttributeGenerator.setter(setterDef, this);
}
out(",");
TypeUtils.encodeForRuntime(that, that.getDeclarationModel(), that.getAnnotationList(), this);
if (setterDef != null) {
out(",");
TypeUtils.encodeForRuntime(setterDef, setterDef.getDeclarationModel(), setterDef.getAnnotationList(), this);
}
out(");");
}
Aggregations