All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.snapscript.compile.validate.ExecutableValidator Maven / Gradle / Ivy

There is a newer version: 1.4.6
Show newest version
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);
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy