use of org.whole.lang.visitors.IVisitor in project whole by wholeplatform.
the class MiscLanguageDeployer method deploy.
public void deploy(ReflectionFactory platform) {
platform.addLanguageKit(new MiscLanguageKit());
platform.addOperationFactory(MiscLanguageKit.URI, GenericBuilderAdapterOperation.ID, new IBuilderFactory() {
public IBuilder create(IBuilder strategy, IEntityContext entityContext) {
return new MiscGenericBuilderAdapter((IMiscBuilder) strategy, entityContext);
}
});
platform.addOperationFactory(MiscLanguageKit.URI, SpecificBuilderAdapterOperation.ID, new IBuilderFactory() {
public IBuilder create(IBuilder strategy, IEntityContext entityContext) {
return new MiscSpecificBuilderAdapter(strategy, entityContext);
}
});
platform.addOperationFactory(MiscLanguageKit.URI, PrettyPrinterOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
return new MiscOperationVisitor();
}
});
platform.addOperationFactory(MiscLanguageKit.URI, InterpreterOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
if (stage == 0)
return new MiscOperationVisitor();
else
return null;
}
});
platform.addOperationFactory(MiscLanguageKit.URI, ValidatorOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
return new MiscOperationVisitor();
}
});
platform.addOperationFactory(MiscLanguageKit.URI, ArtifactsGeneratorOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
return new MiscOperationVisitor();
}
});
platform.addOperationFactory(MiscLanguageKit.URI, NormalizerOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
return new MiscOperationVisitor();
}
});
platform.addOperationFactory(MiscLanguageKit.URI, DynamicCompilerOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
return new MiscDynamicCompilerVisitor();
}
});
}
use of org.whole.lang.visitors.IVisitor in project whole by wholeplatform.
the class MathLanguageDeployer method deploy.
public void deploy(ReflectionFactory platform) {
platform.addLanguageKit(new MathLanguageKit());
platform.addOperationFactory(MathLanguageKit.URI, GenericBuilderAdapterOperation.ID, new IBuilderFactory() {
public IBuilder create(IBuilder strategy, IEntityContext entityContext) {
return new MathGenericBuilderAdapter((IMathBuilder) strategy, entityContext);
}
});
platform.addOperationFactory(MathLanguageKit.URI, SpecificBuilderAdapterOperation.ID, new IBuilderFactory() {
public IBuilder create(IBuilder strategy, IEntityContext entityContext) {
return new MathSpecificBuilderAdapter(strategy, entityContext);
}
});
platform.addOperationFactory(MathLanguageKit.URI, InterpreterOperation.ID, new IVisitorFactory() {
public IVisitor create(IOperation operation, int stage) {
if (stage == 0)
return new MathInterpreterVisitor();
else
return null;
}
});
}
use of org.whole.lang.visitors.IVisitor in project whole by wholeplatform.
the class TestsInterpreterVisitor method visit.
@Override
public void visit(IsUndef entity) {
IVisitor v = GenericTraversalFactory.instance.not(TestsMatcherFactory.instance.defined());
v.withSourceEntity(entity).setBindings(getBindings());
setResultVisitor(v);
}
use of org.whole.lang.visitors.IVisitor in project whole by wholeplatform.
the class TestsInterpreterVisitor method visit.
@Override
public void visit(AnyOf entity) {
int size = entity.wSize();
IVisitor[] visitors = new IVisitor[size];
for (int i = 0; i < size; i++) {
entity.get(i).accept(this);
visitors[i] = getResultVisitor();
}
setResultVisitor(GenericTraversalFactory.instance.one(visitors).withSourceEntity(entity));
}
use of org.whole.lang.visitors.IVisitor in project whole by wholeplatform.
the class TestsInterpreterVisitor method evaluate.
protected void evaluate(SubjectStatement entity) {
ITransactionScope ts = BindingManagerFactory.instance.createTransactionScope();
getBindings().wEnterScope(ts);
try {
IEntity subject = evaluate(entity.getSubject(), true);
if (!EntityUtils.isNull(subject))
subject = applyFilterRule(subject);
IVisitor constraint = evaluate(entity.getConstraint());
boolean result = Matcher.match(constraint, subject);
if (getBindings().wIsSet("thrownException"))
throw (RuntimeException) getBindings().wGetValue("thrownException");
if (!result)
throw new TestsException(entity, subject, constraint, getBindings());
} finally {
ts.rollback();
getBindings().wExitScope();
}
}
Aggregations