Search in sources :

Example 26 with ExpCore

use of ast.ExpCore in project L42 by ElvisResearchGroup.

the class PropagatorVisitor method visit.

public Void visit(MCall s) {
    lift(s.getInner());
    liftMs(s.getS());
    liftDoc(s.getDoc());
    for (ExpCore e : s.getEs()) {
        lift(e);
    }
    return null;
}
Also used : ExpCore(ast.ExpCore)

Example 27 with ExpCore

use of ast.ExpCore in project L42 by ElvisResearchGroup.

the class ExtractCtxCompiled method visit.

public Ctx<ClassB> visit(MCall s) {
    if (!IsCompiled.of(s.getInner())) {
        return lift(s.getInner().accept(this), s::withInner);
    }
    for (ExpCore ei : s.getEs()) {
        if (IsCompiled.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);
        });
    }
    throw Assertions.codeNotReachable();
}
Also used : ExpCore(ast.ExpCore) Assertions(tools.Assertions) ArrayList(java.util.ArrayList)

Example 28 with ExpCore

use of ast.ExpCore in project L42 by ElvisResearchGroup.

the class ExtractCtxUpToX method visit.

public Ctx<Block> 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);
        });
    }
    throw Assertions.codeNotReachable();
}
Also used : ExpCore(ast.ExpCore) ArrayList(java.util.ArrayList)

Example 29 with ExpCore

use of ast.ExpCore in project L42 by ElvisResearchGroup.

the class ExtractCtxVal method visit.

public Ctx<Redex> visit(MCall s) {
    Ctx<Redex> res = checkRedex(s);
    if (res != null) {
        return res;
    }
    if (!IsValue.of(p, s.getInner())) {
        return lift(s.getInner().accept(this), ctx -> s.withInner(ctx));
    }
    for (ExpCore ei : s.getEs()) {
        if (IsValue.of(p, 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;
}
Also used : ExpCore(ast.ExpCore) Redex(ast.Redex) ArrayList(java.util.ArrayList)

Example 30 with ExpCore

use of ast.ExpCore in project L42 by ElvisResearchGroup.

the class ExtractThrow method visit.

public ExpCore visit(Block s) {
    if (!s.getOns().isEmpty()) {
        return new ExpCore.WalkBy();
    }
    for (int i = 0; i < s.getDecs().size(); i++) {
        if (new IsValue(p).validDv(s.getDecs().get(i))) {
            continue;
        }
        //otherwise, i is the first non dv
        ExpCore res = s.getDecs().get(i).getInner().accept(this);
        if (res instanceof ExpCore.WalkBy) {
            return res;
        }
        Signal res_ = (Signal) res;
        List<Block.Dec> decs = s.getDecs().subList(0, i);
        Block newInner = new Block(s.getDoc(), decs, res_.getInner(), Collections.emptyList(), s.getP());
        newInner = Functions.garbage(newInner, i);
        return res_.withInner(newInner);
    }
    ExpCore res = s.getInner().accept(this);
    if (res instanceof ExpCore.WalkBy) {
        return res;
    }
    Signal res_ = (Signal) res;
    Block newInner = s.withInner(res_.getInner());
    return res_.withInner(newInner);
}
Also used : ExpCore(ast.ExpCore) Signal(ast.ExpCore.Signal) Block(ast.ExpCore.Block) WalkBy(ast.ExpCore.WalkBy)

Aggregations

ExpCore (ast.ExpCore)62 ArrayList (java.util.ArrayList)25 ClassB (ast.ExpCore.ClassB)18 Member (ast.ExpCore.ClassB.Member)11 MethodWithType (ast.ExpCore.ClassB.MethodWithType)10 Expression (ast.Expression)10 Block (ast.ExpCore.Block)9 MethodType (ast.Ast.MethodType)8 Doc (ast.Ast.Doc)7 Path (ast.Ast.Path)7 Assertions (tools.Assertions)7 MethodSelector (ast.Ast.MethodSelector)6 Position (ast.Ast.Position)6 Program (programReduction.Program)6 InjectionOnCore (sugarVisitors.InjectionOnCore)6 Ast (ast.Ast)5 Type (ast.Ast.Type)5 ErrorMessage (ast.ErrorMessage)5 CloneVisitor (coreVisitors.CloneVisitor)5 List (java.util.List)5