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

org.snapscript.tree.define.AnyInstanceBuilder Maven / Gradle / Ivy

There is a newer version: 1.4.6
Show newest version
package org.snapscript.tree.define;

import static org.snapscript.core.Reserved.DEFAULT_PACKAGE;

import org.snapscript.core.Context;
import org.snapscript.core.Model;
import org.snapscript.core.Module;
import org.snapscript.core.ModuleRegistry;
import org.snapscript.core.Scope;
import org.snapscript.core.Type;
import org.snapscript.core.define.Instance;
import org.snapscript.core.define.PrimitiveInstance;

public class AnyInstanceBuilder {
   
   private Module module;
   
   public AnyInstanceBuilder() {
      super();
   }

   public Instance create(Scope scope, Type real) throws Exception {
      Scope inner = real.getScope();
      Model model = scope.getModel();
      
      if(module == null) {
         Module parent = scope.getModule();
         Context context = parent.getContext();
         ModuleRegistry registry = context.getRegistry();
         
         module = registry.addModule(DEFAULT_PACKAGE);
      }
      return new PrimitiveInstance(module, model, inner, real); 
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy