InstructionList body = new InstructionList();
Name scale9Grid = new Name("scale9Grid");
body.addInstruction(ABCConstants.OP_getlocal0);
body.addInstruction(ABCConstants.OP_getproperty, scale9Grid);
Label trueLabel = new Label();
body.addInstruction(ABCConstants.OP_iftrue, trueLabel);
Name edgeMetrics = ReferenceFactory.packageQualifiedReference(workspace, CORE_PACKAGE + ".EdgeMetrics").getMName();
body.addInstruction(ABCConstants.OP_getlex, edgeMetrics);
body.addInstruction(ABCConstants.OP_getproperty, new Name("EMPTY"));
body.addInstruction(ABCConstants.OP_returnvalue);
body.labelNext(trueLabel);
body.addInstruction(ABCConstants.OP_findpropstrict, edgeMetrics);
body.addInstruction(ABCConstants.OP_getlocal0);
body.addInstruction(ABCConstants.OP_getproperty, scale9Grid);
body.addInstruction(ABCConstants.OP_getproperty, new Name("left"));
body.addInstruction(ABCConstants.OP_getlocal0);
body.addInstruction(ABCConstants.OP_getproperty, scale9Grid);
body.addInstruction(ABCConstants.OP_getproperty, new Name("top"));
Name math = new Name("Math");
body.addInstruction(ABCConstants.OP_getlex, math);
body.addInstruction(ABCConstants.OP_getlocal0);
body.addInstruction(ABCConstants.OP_getproperty, new Name("measuredWidth"));
body.addInstruction(ABCConstants.OP_getlocal0);
body.addInstruction(ABCConstants.OP_getproperty, scale9Grid);
body.addInstruction(ABCConstants.OP_getproperty, new Name("right"));
body.addInstruction(ABCConstants.OP_subtract);
Object[] ceil = new Object[] {new Name("ceil"), 1};
body.addInstruction(ABCConstants.OP_callproperty, ceil);
body.addInstruction(ABCConstants.OP_getlex, math);
body.addInstruction(ABCConstants.OP_getlocal0);
body.addInstruction(ABCConstants.OP_getproperty, new Name("measuredHeight"));
body.addInstruction(ABCConstants.OP_getlocal0);
body.addInstruction(ABCConstants.OP_getproperty, scale9Grid);
body.addInstruction(ABCConstants.OP_getproperty, new Name("bottom"));
body.addInstruction(ABCConstants.OP_subtract);
body.addInstruction(ABCConstants.OP_callproperty, ceil);
body.addInstruction(ABCConstants.OP_constructprop, new Object[] {edgeMetrics, 4});
body.addInstruction(ABCConstants.OP_returnvalue);
classGen.addITraitsGetter(new Name("borderMetrics"), edgeMetrics, body);
}
if (skinClassInfo.needsIFlexDisplayObject)
{
// generate:
// public function get measuredWidth():Number
// {
// return _measuredWidth;
// }
if (skinClassInfo.needsMeasuredWidth)
{
InstructionList body = new InstructionList();
body.addInstruction(ABCConstants.OP_getlocal0);
body.addInstruction(ABCConstants.OP_getproperty, _measuredWidth);
body.addInstruction(ABCConstants.OP_returnvalue);
classGen.addMemberVariable(_measuredWidth, numberName);
classGen.addITraitsGetter(new Name("measuredWidth"), numberName, body);
}
// generate:
// public function get measuredHeight():Number
// {
// return _measuredHeight;
// }
if (skinClassInfo.needsMeasuredHeight)
{
InstructionList body = new InstructionList();
body.addInstruction(ABCConstants.OP_getlocal0);
body.addInstruction(ABCConstants.OP_getproperty, _measuredHeight);
body.addInstruction(ABCConstants.OP_returnvalue);
classGen.addMemberVariable(_measuredHeight, numberName);
classGen.addITraitsGetter(new Name("measuredHeight"), numberName, body);
}
// generate:
// public function move(x:Number, y:Number):void
// {
// this.x = x;
// this.y = y;
// }
if (skinClassInfo.needsMove)
{
InstructionList body = new InstructionList();
body.addInstruction(ABCConstants.OP_getlocal0);
body.addInstruction(ABCConstants.OP_getlocal1);
body.addInstruction(ABCConstants.OP_setproperty, new Name("x"));
body.addInstruction(ABCConstants.OP_getlocal0);
body.addInstruction(ABCConstants.OP_getlocal2);
body.addInstruction(ABCConstants.OP_setproperty, new Name("y"));
body.addInstruction(ABCConstants.OP_returnvoid);
Collection<Name> paramTypes = new ImmutableList.Builder<Name>()
.add(numberName)
.add(numberName)
.build();
classGen.addITraitsMethod(new Name("move"), paramTypes, new Name("void"), Collections.<Object>emptyList(), false, false, false, body);
}
// generate:
// public function setActualSize(newWidth:Number, newHeight:Number):void
// {
// if (width != newWidth)
// {
// width = newWidth;
// }
// if (height != newHeight)
// {
// height = newHeight;
// }
// }
if (skinClassInfo.needsSetActualSize)
{
InstructionList body = new InstructionList();
Name width = new Name("width");
body.addInstruction(ABCConstants.OP_getlocal0);
body.addInstruction(ABCConstants.OP_getproperty, width);
body.addInstruction(ABCConstants.OP_getlocal1);
Label trueLabel = new Label();
body.addInstruction(ABCConstants.OP_ifeq, trueLabel);
body.addInstruction(ABCConstants.OP_findproperty, width);
body.addInstruction(ABCConstants.OP_getlocal1);
body.addInstruction(ABCConstants.OP_setproperty, width);
body.labelNext(trueLabel);
Name height = new Name("height");
body.addInstruction(ABCConstants.OP_getlocal0);
body.addInstruction(ABCConstants.OP_getproperty, height);
body.addInstruction(ABCConstants.OP_getlocal2);
trueLabel = new Label();
body.addInstruction(ABCConstants.OP_ifeq, trueLabel);
body.addInstruction(ABCConstants.OP_findproperty, height);
body.addInstruction(ABCConstants.OP_getlocal2);
body.addInstruction(ABCConstants.OP_setproperty, height);