Package frege.prelude.PreludeBase

Examples of frege.prelude.PreludeBase.TList


 
  public class FregeModelVisitor /* extends AbstractVisitor */ {   
   
    public boolean visit(TGlobal g, TTree env, boolean top) {
      final TList syms = Utilities.symbols(env).<TList>forced();
      // do one category after the other according to the predefined order
      for (int cat : order) {
        if (!top) { // avoid unneeded list traversals
          if (cat != func && cat != dcon) continue;
        }
        else if (cat == dcon) continue;
       
        // go through the list of symbols and do the ones that equal the current category
        TList.DCons elem = syms._Cons();
        boolean found = false;
        while (elem != null) {
          final TSymbolT sym = Delayed.<TSymbolT>forced( elem.mem1 );
          elem = (elem.mem2.<TList>forced())._Cons();
          if (sym._constructor() != cat) continue;
View Full Code Here


      return true;
    }
   
    public boolean visit(TGlobal g, TExprT expr) {
      // System.err.println("visiting: " + g.toString() + ", " + expr.toString());
      TList symbols = (TList) FregeParseController.funSTG(
          Utilities.exprSymbols(expr), g);
      TList.DCons node = symbols._Cons();
      while (node != null) {
        TSymbolT sym = Delayed.<TSymbolT>forced( node.mem1);
        visit(g, sym);
        node = (node.mem2.<TList>forced())._Cons();
      }
View Full Code Here

      final TSubSt sub = TGlobal.sub(g);
      final String pack = TSubSt.thisPack(sub);
     
      pushSubItem(new PackageItem(pack, TSubSt.thisPos(sub)));
      if  (! "".equals(pack)) {
        final TList pnps =  Utilities.imports(g).<TList>forced();
        DCons elem = pnps._Cons();
        while (elem != null) {
          final TTuple3 tuple = Delayed.<TTuple3>forced( elem.mem1 );
          elem = (elem.mem2.<TList>forced())._Cons();
          final TPosition pos = Delayed.<TPosition>forced(tuple.mem1);
          final String ns     = Delayed.<String>forced(tuple.mem2);
View Full Code Here

            + ", tokenID=" + idprev + id
            + ", value=\"" + val + '"'
            + ", direct=" + direct
            + ", inside=" + inside);
       
      TList ps = null;
      boolean first = true;
      /*
      if (token != null && (TToken.tokid(token) == TTokenID.IMPORT
          || TToken.tokid(tprev) == TTokenID.IMPORT)) {
        pref = token != null && TToken.tokid(token) != TTokenID.IMPORT
              ? TToken.value(token)
              : "";
           
        List<String> packs = parser.getFD().getAllSources(pref);
        for (String p: packs) {
          result.add(new SourceProposal(p, pref, offset));
        }
        first = result.size() == 0;
      }
      else */ {
        ps = Utilities.proposeContent(g, parser.ourRoot(), offset, tokens, inx);
        while (true) {
          final TList.DCons node = ps._Cons();
          if (node == null) break;
          TProposal p = Delayed.<TProposal>forced(node.mem1);
          if (first) {
            first = false;
            pref = TProposal.prefix(p);
View Full Code Here

      final String[] srcs = fd.getSp().split(System.getProperty("path.separator"));
      final String contents = BuilderUtils.getFileContents(file);
     
      getPlugin().writeInfoMsg(
          "Collecting dependencies from frege file: " + fromPath);
      TList packs = frege.compiler.Scanner.dependencies(contents).<TList>forced();
      packs = Utilities.correctDependenciesFor(packs, fromPath);
     
      while (true) {
        final DCons cons = packs._Cons();
        if (cons == null) break;
        packs = cons.mem2.<TList>forced();
        final String pack = Delayed.<String>forced(cons.mem1);
        final IFile known = fPackages.get(pack);
        if (known != null) {
View Full Code Here

        final String target = Main.targetPath(result, ".java");
       
        getPlugin().writeInfoMsg("built: " + target);
        // get the frege path and build path
        final String bp = TOptions.dir( TGlobal.options(result) );
        final TList ourPath = frege.compiler.Utilities.ourPath(TGlobal.options(result));
        final String fp = Delayed.<String>forced(
            PreludeText.joined(
                              System.getProperty("path.separator"),
                              ourPath
                ));
        final TList srcPath = TOptions.sourcePath(TGlobal.options(result));
        final String sp = Delayed.<String>forced(
            PreludeText.joined(
                          System.getProperty("path.separator"),
                          srcPath
            ));
View Full Code Here

      IProgressMonitor monitor) {
   
    long t0 = System.nanoTime();
    long te = 0;
    long t1 = 0;
    TList passes = null;
    DCons pass = null;
    int index;
   
    {
     
      if (monitor.isCanceled()) return global;
   
      if (contents.length() == leng && contents.hashCode() == hash) {
        return global;      // nothing really updated here
      }
   
   
      msgHandler.clearMessages();
   
      final IProgressMonitor myMonitor = monitor;
      Lambda cancel = new Fun1<Boolean>() {     
        public Boolean eval(Object realworld) {
          return myMonitor.isCanceled()
        }
      };
   
      global = TGlobal.upd$sub(global,  TSubSt.upd$cancelled(
        TGlobal.sub(global),
        cancel));
      global = TGlobal.upd$sub(global, TSubSt.upd$numErrors(TGlobal.sub(global), 0));
      global = TGlobal.upd$sub(global, TSubSt.upd$resErrors(TGlobal.sub(global), 0));
   
      passes = frege.compiler.Main.passes.<TList>forced();
     
      monitor.beginTask(this.getClass().getName() + " parsing",
          1 + IListView__lbrack_rbrack.length(passes));

      index = 0;

      while (!monitor.isCanceled()
          && (pass = passes._Cons()) != null
          && errors(global) == 0
          && index < 2) {    // do lexer and parser synchronized
        t1 = System.nanoTime();
        index++;
        passes = pass.mem2.<TList>forced();
        final TTuple2 adx = Delayed.<TTuple2>forced( pass.mem1 );
        final Lazy action = index == 1 ? Main.lexPassIDE(contents) : Delayed.delayed(adx.mem1);
        final String   desc   = Delayed.<String>forced(adx.mem2);
        final TGlobal g = runSTIO(action, global);
        te = System.nanoTime();
        System.err.println(desc + " took "
          + (te-t1)/1000000 + "ms, cumulative "
          + (te-t0)/1000000 + "ms");
       
        monitor.worked(1);
        global = runSTG(Utilities.passDone, g);
      }
      if (achievement(global) >= achievement(goodglobal))
        goodglobal = global;      // when opening a file with errors
      else {
        // update token array in goodglobal
        TToken[] toks = TSubSt.toks(TGlobal.sub(global));
        goodglobal = TGlobal.upd$sub(goodglobal, TSubSt.upd$toks(
            TGlobal.sub(goodglobal), toks));
      }
//      Array gtoks = TSubSt.toks(TGlobal.sub(global));
//      System.err.println("global.toks==good.toks is " + (toks == gtoks));
    }
   
    int needed = (int) ((te-t0) / 1000000);
       
    if (scanOnly && timeout - needed > 0 && errors(global) == 0 && !monitor.isCanceled())
      try { Thread.sleep(timeout - needed); } catch (InterruptedException e) {}
    t0 = System.nanoTime() - (te-t0);

   
    while (!monitor.isCanceled()
          && errors(global) == 0
          && (pass = passes._Cons()) != null) {      // do the rest unsynchronized
        t1 = System.nanoTime();
        passes = pass.mem2.<TList>forced();
        index++;
        final TTuple2 adx = Delayed.<TTuple2>forced( pass.mem1 );
        final Lazy action = Delayed.delayed(adx.mem1);
View Full Code Here

    // Hence, if we do not have one, we just scan&parse, otherwise we do a full compile
    TGlobal g = parse(input, mcwb == null, monitor);
    int u = TGlobal.unique(g);
    System.err.printf("frege parse: done, unique=%d, adding errors ", u);
    tokensIteratorDone = false;
    TList msgs = PreludeList.reverse(TSubSt.messages(TGlobal.sub(g)));
    int maxmsgs = 9;
    
    while (!monitor.isCanceled() && maxmsgs > 0) {
      TList.DCons node = msgs._Cons();
      if (node == null) break;
      msgs = node.mem2.<TList>forced();
      TMessage msg = Delayed.<TMessage>forced( node.mem1 );
      if (mcwb != null) {
        // do also warnings and hints
View Full Code Here

TOP

Related Classes of frege.prelude.PreludeBase.TList

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.