Examples of ModuleEnvironment


Examples of org.rascalmpl.interpreter.env.ModuleEnvironment

    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

Examples of org.rascalmpl.interpreter.env.ModuleEnvironment

      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

Examples of org.rascalmpl.interpreter.env.ModuleEnvironment

    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);
View Full Code Here

Examples of org.rascalmpl.interpreter.env.ModuleEnvironment

    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);
View Full Code Here

Examples of org.rascalmpl.interpreter.env.ModuleEnvironment

  }
 
  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);
View Full Code Here

Examples of org.rascalmpl.interpreter.env.ModuleEnvironment

  private static ASTBuilder getBuilder() {
    return new ASTBuilder();
  }

  private static void addImportToCurrentModule(ISourceLocation src, String name, IEvaluator<Result<IValue>> eval) {
    ModuleEnvironment module = eval.getHeap().getModule(name);
    if (module == null) {
      throw new UndeclaredModule(name, src);
    }
    ModuleEnvironment current = eval.getCurrentModuleEnvironment();
    current.addImport(name, module);
    current.setSyntaxDefined(current.definesSyntax() || module.definesSyntax());
  }
View Full Code Here

Examples of org.rascalmpl.interpreter.env.ModuleEnvironment

      String name = Modules.getName(top);

      // create the current module if it does not exist yet
      GlobalEnvironment heap = eval.getHeap();
      ModuleEnvironment env = heap.getModule(name);
      if(env == null){
        env = new ModuleEnvironment(name, heap);
        // do not add the module to the heap here.
      }
      env.setBootstrap(needBootstrapParser(data));

      // make sure all the imported and extended modules are loaded
      // since they may provide additional syntax definitions\
      Environment old = eval.getCurrentEnvt();
      try {
        eval.setCurrentEnvt(env);
        env.setInitialized(true);

        eval.event("defining syntax");
        ISet rules = Modules.getSyntax(top);
        for (IValue rule : rules) {
          evalImport(eval, (IConstructor) rule);
        }

        eval.event("importing modules");
        ISet imports = Modules.getImports(top);
        for (IValue mod : imports) {
          evalImport(eval, (IConstructor) mod);
        }

        eval.event("extending modules");
        ISet extend = Modules.getExtends(top);
        for (IValue mod : extend) {
          evalImport(eval, (IConstructor) mod);
        }

        eval.event("generating modules");
        ISet externals = Modules.getExternals(top);
        for (IValue mod : externals) {
          evalImport(eval, (IConstructor) mod);
        }
      }
      finally {
        eval.setCurrentEnvt(old);
      }

      // parse the embedded concrete syntax fragments of the current module
      IConstructor result = tree;
      if (!eval.getHeap().isBootstrapper() && (needBootstrapParser(data) || (env.definesSyntax() && containsBackTick(data, 0)))) {
        eval.event("parsing concrete syntax");
        result = parseFragments(eval, tree, location, env);
      }

      if (!eval.getSuspendTriggerListeners().isEmpty()) {
View Full Code Here

Examples of org.rascalmpl.interpreter.env.ModuleEnvironment

    return evaluator;
  }

  public JavaToRascal(PrintWriter stdout, PrintWriter stderr) {
    this.evaluator = new Evaluator(vf, stderr, stdout,
        new ModuleEnvironment(ModuleEnvironment.SHELL_MODULE, heap), heap);
  }
View Full Code Here

Examples of org.rascalmpl.interpreter.env.ModuleEnvironment

  public boolean isVariableInModule(String moduleName, String variableName,
      String... variableType) {
    Environment old = evaluator.getCurrentEnvt();
    try {
      evaluator.doImport(null, moduleName);
      ModuleEnvironment env = evaluator.getCurrentEnvt().getImport(
          moduleName);
      Result<IValue> simpleVariable = env.getSimpleVariable(variableName);
      if (simpleVariable == null)
        return false;
      for (String vt : variableType) {
        Type tp = getType(env, vt);
        if (tp == null)
View Full Code Here

Examples of org.rascalmpl.interpreter.env.ModuleEnvironment

  public boolean isProcedureInModule(String moduleName, String procedureName,
      String procedureResultType, int arity) {
    Environment old = evaluator.getCurrentEnvt();
    try {
      evaluator.doImport(null, moduleName);
      ModuleEnvironment env = evaluator.getCurrentEnvt().getImport(
          moduleName);
      ArrayList<AbstractFunction> funcs = new ArrayList<AbstractFunction>();
      Type typ = getType(env, procedureResultType);
      if (typ == null)
        return false;
      env.getAllFunctions(typ, procedureName, funcs);
      for (AbstractFunction f : funcs) {
        if (f.getArity() == arity) {
          return true;
        }
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.