org.snapscript.compile.validate.ExecutableValidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snap Show documentation
Show all versions of snap Show documentation
Dynamic scripting for the JVM
package org.snapscript.compile.validate;
import java.util.List;
import org.snapscript.compile.verify.Verifier;
import org.snapscript.core.ContextValidator;
import org.snapscript.core.Context;
import org.snapscript.core.convert.ConstraintMatcher;
import org.snapscript.core.function.index.FunctionIndexer;
import org.snapscript.core.module.Module;
import org.snapscript.core.module.ModuleRegistry;
import org.snapscript.core.type.Type;
import org.snapscript.core.type.TypeExtractor;
public class ExecutableValidator implements ContextValidator {
private final ModuleValidator modules;
private final TypeValidator types;
private final Verifier verifier;
public ExecutableValidator(ConstraintMatcher matcher, TypeExtractor extractor, FunctionIndexer indexer, Verifier verifier) {
this.types = new TypeValidator(matcher, extractor, indexer);
this.modules = new ModuleValidator(types);
this.verifier = verifier;
}
@Override
public void validate(Context context) throws Exception {
ModuleRegistry registry = context.getRegistry();
List modules = registry.getModules();
verifier.verify();
for(Module module : modules) {
validate(module);
}
}
@Override
public void validate(Type type) throws Exception {
types.validate(type);
}
@Override
public void validate(Module module) throws Exception {
modules.validate(module);
}
}