Search in sources :

Example 1 with Branch

use of org.whole.lang.scheme.model.Branch in project whole by wholeplatform.

the class SchemeInterpreterVisitor method visit.

public void visit(CondExpression entity) {
    boolean prune = false;
    Branches branches = (Branches) entity.getBranches();
    if (!branches.wGetEntityDescriptor().equals(SchemeEntityDescriptorEnum.Branches))
        throw new VisitException("expected a " + SchemeEntityDescriptorEnum.Branches);
    for (int i = 0; i < branches.wSize() && !prune; i++) {
        Branch branch = (Branch) entity.wGet(i);
        if (booleanValue(branch.getTest())) {
            branch.getBody().accept(this);
            return;
        }
    }
    entity.getElseBody().accept(this);
}
Also used : Branches(org.whole.lang.scheme.model.Branches) Branch(org.whole.lang.scheme.model.Branch) VisitException(org.whole.lang.visitors.VisitException)

Example 2 with Branch

use of org.whole.lang.scheme.model.Branch in project whole by wholeplatform.

the class BranchPart method getModelSpecificChildren.

protected List<IEntity> getModelSpecificChildren() {
    List<IEntity> list = new ArrayList<IEntity>(2);
    Branch entity = getModelEntity();
    list.add(entity.getTest());
    list.add(entity.getBody());
    return list;
}
Also used : IEntity(org.whole.lang.model.IEntity) Branch(org.whole.lang.scheme.model.Branch) ArrayList(java.util.ArrayList)

Aggregations

Branch (org.whole.lang.scheme.model.Branch)2 ArrayList (java.util.ArrayList)1 IEntity (org.whole.lang.model.IEntity)1 Branches (org.whole.lang.scheme.model.Branches)1 VisitException (org.whole.lang.visitors.VisitException)1