Examples of ModuleEnvironment


Examples of org.rascalmpl.interpreter.env.ModuleEnvironment

    @Override
    public Result<IValue> interpret(IEvaluator<Result<IValue>> eval) {
      String name = getModuleName(this);
      GlobalEnvironment heap = eval.__getHeap();
      ModuleEnvironment env = heap.getModule(name);

      if (env == null) {
        env = new ModuleEnvironment(name, heap);
        heap.addModule(env);
      }

      Environment oldEnv = eval.getCurrentEnvt();
      eval.setCurrentEnvt(env); // such that declarations end up in
      // the module scope
      try {
        // the header is already evaluated at parse time,
        // including imports and extends and syntax definitions
//        getHeader().interpret(eval);

        List<Toplevel> decls = this.getBody().getToplevels();
        eval.__getTypeDeclarator().evaluateDeclarations(decls, eval.getCurrentEnvt());

        for (Toplevel l : decls) {
          l.interpret(eval);
        }
      }
      catch (RuntimeException e) {
        env.setInitialized(false);
        throw e;
      }
      finally {
        eval.setCurrentEnvt(oldEnv);
      }
View Full Code Here

Examples of org.rascalmpl.interpreter.env.ModuleEnvironment

 
  // REFLECT -- copy in PreludeCompiled
  public IValue readTextValueString(IValue type, IString input, IEvaluatorContext ctx) {
//    TypeStore store = ctx.getCurrentEnvt().getStore();
    TypeStore store = new TypeStore();
    ModuleEnvironment pt = ctx.getHeap().getModule("ParseTree");
    if(pt != null){
      store.importStore(pt.getStore());
    }
    Type start = tr.valueToType((IConstructor) type, store);
   
    StringReader in = new StringReader(input.getValue());
    try {
View Full Code Here

Examples of org.rascalmpl.interpreter.env.ModuleEnvironment

      QualifiedName sort = this.getSort();
      String name = org.rascalmpl.interpreter.utils.Names.typeName(sort);

      if (org.rascalmpl.interpreter.utils.Names.isQualified(sort)) {
        GlobalEnvironment heap = env.getHeap();
        ModuleEnvironment mod = heap
            .getModule(org.rascalmpl.interpreter.utils.Names
                .moduleName(sort));

        if (mod == null) {
          throw new UndeclaredModule(
              org.rascalmpl.interpreter.utils.Names
                  .moduleName(sort), sort);
        }

        adt = mod.lookupAbstractDataType(name);
      } else {
        adt = env.lookupAbstractDataType(name);
      }

      if (adt == null) {
View Full Code Here

Examples of org.rascalmpl.interpreter.env.ModuleEnvironment

  public IValue call(IRascalMonitor monitor, String module, String name, IValue... args) {
    IRascalMonitor old = setMonitor(monitor);
    Environment oldEnv = getCurrentEnvt();
   
    try {
      ModuleEnvironment modEnv = getHeap().getModule(module);
      setCurrentEnvt(modEnv);
      return call(name, (Map<String,IValue>) null, args);
    }
    finally {
      setMonitor(old);
View Full Code Here

Examples of org.rascalmpl.interpreter.env.ModuleEnvironment

  public IValue main(IRascalMonitor monitor, String module, String function, String[] commandline) {
    IRascalMonitor old = setMonitor(monitor);
    Environment oldEnv = getCurrentEnvt();
   
    try {
      ModuleEnvironment modEnv = getHeap().getModule(module);
      setCurrentEnvt(modEnv);
     
      Name name = Names.toName(function, modEnv.getLocation());
      OverloadedFunction func = (OverloadedFunction) getCurrentEnvt().getVariable(name);
     
      if (func == null) {
        throw new UndeclaredVariable(function, name);
      }
View Full Code Here

Examples of org.rascalmpl.interpreter.env.ModuleEnvironment

  public IValue call(String name, String module, Map<String, IValue> kwArgs, IValue... args) {
    IRascalMonitor old = setMonitor(monitor);
    Environment oldEnv = getCurrentEnvt();
   
    try {
      ModuleEnvironment modEnv = getHeap().getModule(module);
      setCurrentEnvt(modEnv);
      return call(name, kwArgs, args);
    }
    finally {
      setMonitor(old);
View Full Code Here

Examples of org.rascalmpl.interpreter.env.ModuleEnvironment

    return org.rascalmpl.semantics.dynamic.Import.getParser(this, (ModuleEnvironment) getCurrentEnvt().getRoot(), loc, false);
  }

  @Override
  public IConstructor getGrammar(Environment env) {
    ModuleEnvironment root = (ModuleEnvironment) env.getRoot();
    return getParserGenerator().getGrammar(monitor, root.getName(), root.getSyntaxDefinition());
  }
View Full Code Here

Examples of org.rascalmpl.interpreter.env.ModuleEnvironment

  public IConstructor getGrammar(IRascalMonitor monitor, URI uri) {
    IRascalMonitor old = setMonitor(monitor);
    try {
      ParserGenerator pgen = getParserGenerator();
      String main = uri.getAuthority();
      ModuleEnvironment env = getHeap().getModule(main);
      return pgen.getGrammar(monitor, main, env.getSyntaxDefinition());
    }
    finally {
      setMonitor(old);
    }
  }
View Full Code Here

Examples of org.rascalmpl.interpreter.env.ModuleEnvironment

  public IConstructor getExpandedGrammar(IRascalMonitor monitor, URI uri) {
    IRascalMonitor old = setMonitor(monitor);
    try {
      ParserGenerator pgen = getParserGenerator();
      String main = uri.getAuthority();
      ModuleEnvironment env = getHeap().getModule(main);
      monitor.startJob("Expanding Grammar");
      return pgen.getExpandedGrammar(monitor, main, env.getSyntaxDefinition());
    }
    finally {
      monitor.endJob(true);
      setMonitor(old);
    }
View Full Code Here

Examples of org.rascalmpl.interpreter.env.ModuleEnvironment

      dependingImports.addAll(getImportingModules(names));
      dependingExtends.addAll(getExtendingModules(names));

      monitor.startJob("Reconnecting importers of affected modules");
      for (String mod : dependingImports) {
        ModuleEnvironment env = heap.getModule(mod);
        Set<String> todo = new HashSet<String>(env.getImports());
        for (String imp : todo) {
          if (names.contains(imp)) {
            env.unImport(imp);
            ModuleEnvironment imported = heap.getModule(imp);
            if (imported != null) {
              env.addImport(imp, imported);
            }
          }

        }
        monitor.event("Reconnected " + mod, 1);
      }

      monitor.event("Reconnecting extenders of affected modules");
      for (String mod : dependingExtends) {
        ModuleEnvironment env = heap.getModule(mod);
        Set<String> todo = new HashSet<String>(env.getExtends());
        for (String ext : todo) {
          if (names.contains(ext)) {
            env.unExtend(ext);
            ModuleEnvironment extended = heap.getModule(ext);
            if (extended != null) {
              env.addExtend(ext);
            }
          }
        }
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.