Package org.rascalmpl.interpreter

Examples of org.rascalmpl.interpreter.Evaluator


  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);
    this.bridge = new JavaBridge(loaders, factory, config);
    this.vf = factory;
View Full Code Here


  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());
    }
   
    return this.eval;
  }
View Full Code Here

  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;
   
    monitor.startJob("Loading parser generator", 100, 139);
View Full Code Here

  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

      ModuleEnvironment root = new ModuleEnvironment("___SCREEN___", heap);
      errString = new StringWriter();
      outString = new StringWriter();
      err = new PrintWriter(errString);
      out = new PrintWriter(outString);
      this.evaluator = new Evaluator(values, err, out, root, heap, ctx.getEvaluator().getClassLoaders(), ctx.getEvaluator().getRascalResolver());
      this.evaluator.getConfiguration().setRascalJavaClassPathProperty(ctx.getConfiguration().getRascalJavaClassPathProperty());
    }
   
    return this.evaluator;
  }
View Full Code Here

  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();
   
    if (isEditMode()) {
       FileURIResolver fileURIResolver = new FileURIResolver() {
View Full Code Here

    return evaluator.parseCommands(evaluator.getMonitor(), str.getValue(), loc.getURI());
  }
 
  public IValue parseModule(ISourceLocation loc, IEvaluatorContext ctx) {
    try {
      Evaluator ownEvaluator = getPrivateEvaluator(ctx);
      return ownEvaluator.parseModule(ownEvaluator.getMonitor(), loc.getURI());
    }
    catch (IOException e) {
      throw RuntimeExceptionFactory.io(values.string(e.getMessage()), null, null);
    }
    catch (Throwable e) {
View Full Code Here

      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());
      // clone the classloaders
View Full Code Here

   
    return cachedEvaluator;
  }
 
  public IValue parseModule(IString str, ISourceLocation loc, IEvaluatorContext ctx) {
    Evaluator ownEvaluator = getPrivateEvaluator(ctx);
    return ownEvaluator.parseModule(ownEvaluator.getMonitor(), str.getValue().toCharArray(), loc.getURI());
  }
View Full Code Here

    Evaluator ownEvaluator = getPrivateEvaluator(ctx);
    return ownEvaluator.parseModule(ownEvaluator.getMonitor(), str.getValue().toCharArray(), loc.getURI());
  }
 
  public IValue parseModule(ISourceLocation loc, final IList searchPath, IEvaluatorContext ctx) {
    final Evaluator ownEvaluator = getPrivateEvaluator(ctx);
    final URIResolverRegistry otherReg = ctx.getResolverRegistry();
    URIResolverRegistry ownRegistry = ownEvaluator.getResolverRegistry();
   
    // bridge the resolvers that are not defined in the new Evaluator, but needed here
    for (IValue l : searchPath) {
      String scheme = ((ISourceLocation) l).getURI().getScheme();
      if (!ownRegistry.supportsInputScheme(scheme)) {
        ownRegistry.registerInput(new ResolverBridge(scheme, otherReg));
      }
    }
   
    // add the given locations to the search path
    SourceLocationListContributor contrib = new SourceLocationListContributor("reflective", searchPath);
    ownEvaluator.addRascalSearchPathContributor(contrib);
   
    try {
      return ownEvaluator.parseModule(ownEvaluator.getMonitor(), loc.getURI());
    } catch (IOException e) {
      throw RuntimeExceptionFactory.io(values.string(e.getMessage()), null, null);
    }
    catch (Throwable e) {
      throw RuntimeExceptionFactory.javaException(e, null, null);
    }
    finally {
      ownEvaluator.removeSearchPathContributor(contrib);
    }
  }
View Full Code Here

TOP

Related Classes of org.rascalmpl.interpreter.Evaluator

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.