use of org.whole.lang.visitors.VisitException in project whole by wholeplatform.
the class SchemeInterpreterVisitor method visit.
@Override
public void visit(Definitions entity) {
super.visit(entity);
IEntity mainDefine = getBindings().wGet("main");
if (mainDefine == null)
throw new VisitException("expected the definition of: main");
stagedVisit(mainDefine);
}
use of org.whole.lang.visitors.VisitException 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);
}
use of org.whole.lang.visitors.VisitException in project whole by wholeplatform.
the class SchemeInterpreterVisitor method visit.
public void visit(OrExpression entity) {
IEntity exprs = entity.getExpressions();
if (!exprs.wGetEntityDescriptor().equals(SchemeEntityDescriptorEnum.SchemeExpressions))
throw new VisitException("expected a " + SchemeEntityDescriptorEnum.SchemeExpressions);
boolean result = true;
for (int i = 0; i < exprs.wSize(); i++) result = result || booleanValue(((SchemeExpression) exprs.wGet(i)));
setResult(SchemeEntityFactory.instance.createBooleanValue(result));
}
use of org.whole.lang.visitors.VisitException in project whole by wholeplatform.
the class SchemeInterpreterVisitor method visit.
public void visit(ApplyExpression entity) {
IEntity exprs = entity.getExpressions();
if (!exprs.wGetEntityDescriptor().equals(SchemeEntityDescriptorEnum.SchemeExpressions))
throw new VisitException("expected a " + SchemeEntityDescriptorEnum.SchemeExpressions);
if (exprs.wIsEmpty())
throw new VisitException("empty application");
ConstExpression head = (ConstExpression) evaluate((SchemeExpression) exprs.wGet(0));
ConstExpression[] args = new ConstExpression[exprs.wSize() - 1];
for (int i = 1; i < exprs.wSize(); i++) args[i - 1] = (ConstExpression) evaluate(((SchemeExpression) exprs.wGet(i)));
apply(head, args);
}
use of org.whole.lang.visitors.VisitException in project whole by wholeplatform.
the class PojoArtifactsGeneratorVisitor method visit.
@Override
public void visit(Library library) {
Name libraryName = library.getName();
if (!EntityUtils.isNotResolver(libraryName))
throw new VisitException("No library name");
String modelFileName = DataTypeUtils.getAsPersistenceString(libraryName) + "Model";
Model model = PojoMappingUtils.getModel(library);
env().wDefValue("modelFileName", modelFileName);
env().wDef("modelFileContent", model);
IEntity ws = ModelsArtifactsTemplateManager.instance().create("ModelFileArtifact");
Matcher.substitute(ws, env(), false);
ArtifactsUtils.moveArtifactsIntoWorkspace(ws, env());
}
Aggregations