compiler.compileMember(call.getArg(0));
final Type type1 = call.getArg(1).getType();
if (type1 instanceof LevelType) {
final LevelCalc levelCalc =
compiler.compileLevel(call.getArg(1));
return new AbstractMemberCalc(
call, new Calc[] {memberCalc, levelCalc})
{
public Member evaluateMember(Evaluator evaluator) {
Level level = levelCalc.evaluateLevel(evaluator);
Member member = memberCalc.evaluateMember(evaluator);
int distance =
member.getLevel().getDepth() - level.getDepth();
return ancestor(evaluator, member, distance, level);
}
};
} else {
final IntegerCalc distanceCalc =
compiler.compileInteger(call.getArg(1));
return new AbstractMemberCalc(
call, new Calc[] {memberCalc, distanceCalc})
{
public Member evaluateMember(Evaluator evaluator) {
int distance = distanceCalc.evaluateInteger(evaluator);
Member member = memberCalc.evaluateMember(evaluator);