use of ast.ExpCore 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.);*/
}
use of ast.ExpCore in project L42 by ElvisResearchGroup.
the class IsRedex method visit.
public static Redex visit(Program p, Block s) {
for (int i = 0; i < s.getDecs().size(); i++) {
ExpCore ei = s.getDecs().get(i).getInner();
Type ti = s.getDecs().get(i).getT().get();
//if(!(ri instanceof Redex.NoRedex)){return ri;}
if (new IsValue(p).validDv(s.getDecs().get(i))) {
continue;
}
//return ri;
return redexDec(p, s, i, ei, ti);
}
//end of for members
Block s2 = Functions.garbage(s, s.getDecs().size());
if (!s2.equals(s)) {
return new Redex.Garbage(s2);
}
if (!s.getOns().isEmpty()) {
return new Redex.NoThrowRemoveOn(s);
}
return Redex.invalid();
}
use of ast.ExpCore in project L42 by ElvisResearchGroup.
the class IsValue method validRightValue.
public boolean validRightValue(ExpCore ec) {
if (!(ec instanceof MCall))
return false;
MCall s = (MCall) ec;
if (!(s.getInner() instanceof EPath)) {
return false;
}
MethodSelector ms = s.getS();
MethodWithType mwt = (MethodWithType) p.extractClassB(((EPath) s.getInner()).getInner())._getMember(ms);
if (mwt.get_inner().isPresent()) {
return false;
}
if (mwt.getMt().getMdf() != ast.Ast.Mdf.Class) {
return false;
}
for (ExpCore ei : s.getEs()) {
if (!isAtom(ei)) {
return false;
}
}
return true;
}
use of ast.ExpCore in project L42 by ElvisResearchGroup.
the class Move method visit.
public Ctx<List<Block.Dec>> visit(Using s) {
for (ExpCore ei : s.getEs()) {
if (!IsCtx.of(ei)) {
continue;
}
return lift(ei.accept(this), ctx -> {
List<ExpCore> es = new ArrayList<ExpCore>(s.getEs());
es.set(es.indexOf(ei), ctx);
return s.withEs(es);
});
}
return null;
}
use of ast.ExpCore in project L42 by ElvisResearchGroup.
the class PropagatorVisitor method visit.
public Void visit(Using s) {
liftP(s.getPath());
liftMs(s.getS());
liftDoc(s.getDoc());
for (ExpCore e : s.getEs()) {
lift(e);
}
lift(s.getInner());
return null;
}
Aggregations