Package org.rascalmpl.interpreter.env

Examples of org.rascalmpl.interpreter.env.GlobalEnvironment


  private final IValueFactory vf;
  private static final String packageName = "org.rascalmpl.java.parser.object";
  private static final boolean debug = false;

  public ParserGenerator(IRascalMonitor monitor, PrintWriter out, List<ClassLoader> loaders, IValueFactory factory, Configuration config) {
    GlobalEnvironment heap = new GlobalEnvironment();
    ModuleEnvironment scope = new ModuleEnvironment("___parsergenerator___", heap);
    this.evaluator = new Evaluator(ValueFactoryFactory.getValueFactory(), out, out, scope,heap);
    this.evaluator.getConfiguration().setRascalJavaClassPathProperty(config.getRascalJavaClassPathProperty());
    evaluator.addRascalSearchPathContributor(StandardLibraryContributor.getInstance());   
    this.evaluator.setBootstrapperProperty(true);
View Full Code Here


    return mod;
  }

  private Evaluator getSharedEvaluator(IEvaluatorContext ctx) {
    if (this.eval == null) {
      GlobalEnvironment heap = new GlobalEnvironment();
      ModuleEnvironment root = new ModuleEnvironment("___EVAL___", heap);
      this.eval = new Evaluator(ctx.getValueFactory(), ctx.getStdErr(), ctx.getStdOut(), root, heap, ctx.getEvaluator().getClassLoaders(), ctx.getEvaluator().getRascalResolver());
      this.eval.getConfiguration().setRascalJavaClassPathProperty(ctx.getConfiguration().getRascalJavaClassPathProperty());
    }
   
View Full Code Here

  private final IValueFactory vf;
  private static final String packageName = "org.rascalmpl.java.parser.object";
  private static final boolean debug = false;

  public ParserGenerator(IRascalMonitor monitor, PrintWriter out, List<ClassLoader> loaders, IValueFactory factory, Configuration config) {
    GlobalEnvironment heap = new GlobalEnvironment();
    ModuleEnvironment scope = new ModuleEnvironment("___parsergenerator___", heap);
    this.evaluator = new Evaluator(ValueFactoryFactory.getValueFactory(), out, out, scope,heap);
    evaluator.addRascalSearchPathContributor(StandardLibraryContributor.getInstance());    this.evaluator.setBootstrapperProperty(true);
    this.bridge = new JavaBridge(loaders, factory, config);
    this.vf = factory;
View Full Code Here

  private boolean checkerEnabled;
  private boolean initialized;
  private boolean loaded;
 
  public StaticChecker(PrintWriter stderr, PrintWriter stdout) {
    GlobalEnvironment heap = new GlobalEnvironment();
    ModuleEnvironment root = heap.addModule(new ModuleEnvironment("___static_checker___", heap));
    eval = new Evaluator(ValueFactoryFactory.getValueFactory(), stderr, stdout, root, heap);
    eval.addRascalSearchPathContributor(StandardLibraryContributor.getInstance());
    checkerEnabled = false;
    initialized = false;
    loaded = false;
View Full Code Here

    this.eval = new org.rascalmpl.library.util.Eval(values);
  }
 
  private Evaluator createEvaluator(IEvaluatorContext ctx) {
    if (this.evaluator == null) {
      GlobalEnvironment heap = new GlobalEnvironment();
      ModuleEnvironment root = new ModuleEnvironment("___SCREEN___", heap);
      errString = new StringWriter();
      outString = new StringWriter();
      err = new PrintWriter(errString);
      out = new PrintWriter(outString);
View Full Code Here

  private String getCoursesLocation() {
    return System.getProperty("rascal.courses");
  }
 
  public RascalTutor() {
    GlobalEnvironment heap = new GlobalEnvironment();
    ModuleEnvironment root = heap.addModule(new ModuleEnvironment("___TUTOR___", heap));
    PrintWriter stderr = new PrintWriter(System.err);
    PrintWriter stdout = new PrintWriter(System.out);
    eval = new Evaluator(ValueFactoryFactory.getValueFactory(), stderr, stdout, root, heap);
   
    URIResolverRegistry reg = eval.getResolverRegistry();
View Full Code Here

    if (cachedEvaluator == null || robin++ > maxCacheRounds) {
      robin = 0;
      IEvaluator<?> callingEval = ctx.getEvaluator();
     
     
      GlobalEnvironment heap = new GlobalEnvironment();
      ModuleEnvironment root = heap.addModule(new ModuleEnvironment("___full_module_parser___", heap));
      cachedEvaluator = new Evaluator(callingEval.getValueFactory(), callingEval.getStdErr(), callingEval.getStdOut(), root, heap);
      cachedEvaluator.getResolverRegistry().copyResolverRegistries(ctx.getResolverRegistry());
     
      // Update the classpath so it is the same as in the context interpreter.
      cachedEvaluator.getConfiguration().setRascalJavaClassPathProperty(ctx.getConfiguration().getRascalJavaClassPathProperty());
View Full Code Here

      return nothing();
    }
  }

  public static void importModule(String name, ISourceLocation src, IEvaluator<Result<IValue>> eval) {
    GlobalEnvironment heap = eval.__getHeap();
   
    if (!heap.existsModule(name)) {
      //System.err.println("importModule: " + name);
      // deal with a fresh module that needs initialization
      heap.addModule(new ModuleEnvironment(name, heap));
      loadModule(src, name, eval);
    }
    else if (eval.getCurrentEnvt() == eval.__getRootScope()) {
      // in the root scope we treat an import as a "reload"
      heap.resetModule(name);
      loadModule(src, name, eval);
    }
   
    addImportToCurrentModule(src, name, eval);
   
    if (heap.getModule(name).isDeprecated()) {
      eval.getStdErr().println(src + ":" + name + " is deprecated, " + heap.getModule(name).getDeprecatedMessage());
    }
   
    return;
  }
View Full Code Here

   
    return;
  }
 
  public static void extendCurrentModule(ISourceLocation x, String name, IEvaluator<Result<IValue>> eval) {
    GlobalEnvironment heap = eval.__getHeap();
    ModuleEnvironment other = heap.getModule(name);;
   
    if (other == null) {
      // deal with a fresh module that needs initialization
      heap.addModule(new ModuleEnvironment(name, heap));
      other = loadModule(x, name, eval);
    }
    else if (eval.getCurrentEnvt() == eval.__getRootScope()) {
      // in the root scope we treat an extend as a "reload"
      heap.resetModule(name);
      other = loadModule(x, name, eval);
    }
   
    // now simply extend the current module
    eval.getCurrentModuleEnvironment().extend(other); //heap.getModule(name));
View Full Code Here

    // now simply extend the current module
    eval.getCurrentModuleEnvironment().extend(other); //heap.getModule(name));
  }
 
  public static ModuleEnvironment loadModule(ISourceLocation x, String name, IEvaluator<Result<IValue>> eval) {
    GlobalEnvironment heap = eval.getHeap();
   
    ModuleEnvironment env = heap.getModule(name);
    if (env == null) {
      env = new ModuleEnvironment(name, heap);
      heap.addModule(env);
    }
   
    try {
      Module module = buildModule(name, env, eval);

      if (isDeprecated(module)) {
        eval.getStdErr().println("WARNING: deprecated module " + name + ":" + getDeprecatedMessage(module));
      }
     
      if (module != null) {
        String internalName = org.rascalmpl.semantics.dynamic.Module.getModuleName(module);
        if (!internalName.equals(name)) {
          throw new ModuleNameMismatch(internalName, name, x);
        }
        heap.setModuleURI(name, module.getLocation().getURI());
       
        module.interpret(eval);
       
        return env;
      }
    } catch (StaticError e) {
      heap.removeModule(env);
      throw e;
    } catch (Throw e) {
      heap.removeModule(env);
      throw e;
    } catch (IOException e) {
      heap.removeModule(env);
      throw new ModuleImport(name, e.getMessage(), x);
    }

    heap.removeModule(env);
    throw new ImplementationError("Unexpected error while parsing module " + name + " and building an AST for it ", x);
  }
View Full Code Here

TOP

Related Classes of org.rascalmpl.interpreter.env.GlobalEnvironment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.