operator - method
dynamic
operator -(
- Object o
)
Implementation
operator -(Object o){
switch(o){
case NamedLine n:
return this - n.expression;
case (double, PxUnit) ldouble:
return this - ExpressionOld.literal(ldouble);
case (int, PxUnit) lint:
return this - ExpressionOld.literal(pxIntToDouble(lint));
// case (double, PxUnit) l:
// return this - Expression.literal(l);
case LiteralGetter lg:
return this - ExpressionOld.literalGetter(lg);
case double p:
return this - ExpressionOld.percent(p);
case PercentGetter pg:
return this - ExpressionOld.percentGetter(pg);
case ExpressionOld e:
if(literal != null || e.literal != null){
return ExpressionOld((Size size)=>percentGetter(size) - e.percentGetter(size), (Size size){
final a = literal?.call(size);
final b = e.literal?.call(size);
if(a?.$2 == b?.$2 || a == null || b == null){
return (((a?.$1 ?? 0) - (b?.$1 ?? 0)), (a?.$2 ?? b?.$2)!);
/// 单位里有 wpc 和 hpc 的统一到[w,h]pc
}if(a.$2 == PxUnit.wpc){
return (a.$1 - pxUnitDoubleWidthPercentGetter(b)(size), PxUnit.wpc);
}else
if(a.$2 == PxUnit.hpc){
return (a.$1 - pxUnitDoubleHeightPercentGetter(b)(size), PxUnit.hpc);
}else
if(b.$2 == PxUnit.wpc){
return (pxUnitDoubleWidthPercentGetter(a)(size) - b.$1, PxUnit.wpc);
}else
if(b.$2 == PxUnit.hpc){
return (pxUnitDoubleWidthPercentGetter(a)(size) - b.$1, PxUnit.hpc);
/// 单位里没有 wpc 和 hpc 的统一到 px
}else{
return (pxUnitDoubleGetter(a)(size) - pxUnitDoubleGetter(b)(size), PxUnit.px);
}
});
}else{
return ExpressionOld((Size size)=>percentGetter(size) - e.percentGetter(size), null);
}
}
}