Search in sources :

Example 1 with Garbage

use of ast.Redex.Garbage in project L42 by ElvisResearchGroup.

the class IsRedex method visit.

public static Redex visit(Program p, MCall s) {
    if (!IsValue.of(p, s.getInner())) {
        return Redex.invalid();
    }
    for (ExpCore ei : s.getEs()) {
        if (!IsValue.of(p, ei)) {
            return Redex.invalid();
        }
    }
    //after the first approximation//TODO: it is really slow, can we use this idea to redo the whole ctxExtract?, note, it is only needed for garbage
    Garbage g = IsValue.nestedGarbage(s.getInner());
    if (g != null) {
        return new Garbage(s.withInner(g.getThatLessGarbage()));
    }
    List<ExpCore> newEs = esNestedGarbage(s.getEs());
    if (newEs != null) {
        return new Garbage(s.withEs(newEs));
    }
    return new Redex.MethCall(s);
/*MethodWithType mwt=p.method(path, ms);
    if(!IsValue.isAtom(s.getReceiver())){
      return Optional.of(new Redex.PrimCallRec(s));
      }
    for(int i=0;i<s.getEs().size();i++){
      if(!IsValue.isAtom(s.getEs().get(i))){
        return Optional.of(new Redex.PrimCallArg(s,i));
        }}
    return Optional.of(new Redex.);*/
}
Also used : Garbage(ast.Redex.Garbage) ExpCore(ast.ExpCore)

Aggregations

ExpCore (ast.ExpCore)1 Garbage (ast.Redex.Garbage)1