Search in sources :

Example 26 with ExpCore._void

use of ast.ExpCore._void in project L42 by ElvisResearchGroup.

the class InjectionOnCore method visit.

public ExpCore visit(Expression.ClassB s) {
    Doc doc1 = s.getDoc1();
    List<Ast.Type> supertypes = s.getSupertypes();
    boolean isInterface = false;
    if (s.getH() instanceof Ast.ConcreteHeader) {
        throw Assertions.codeNotReachable();
    }
    if (s.getH() instanceof Ast.InterfaceHeader) {
        isInterface = true;
    }
    List<Member> members = new ArrayList<>();
    for (ast.Expression.ClassB.Member mi : s.getMs()) {
        members.add(mi.match(m -> new ClassB.NestedClass(m.getDoc(), m.getName(), lift(m.getInner()), m.getP()), m -> new ClassB.MethodImplemented(m.getDoc(), m.getS(), lift(m.getInner()), m.getP()), m -> {
            Doc mdoc = m.getDoc();
            Ast.MethodSelector ms = m.getMs();
            MethodType mt = m.getMt();
            return new ClassB.MethodWithType(mdoc, ms, mt, lift(m.getInner()), m.getP());
        }));
    }
    ClassB result = new ClassB(doc1, isInterface, supertypes, members, s.getP(), Phase.None, 0);
    return result;
}
Also used : Ast(ast.Ast) Path(ast.Ast.Path) Catch(ast.Expression.Catch) Match(tools.Match) Doc(ast.Ast.Doc) Type(ast.Ast.Type) Phase(ast.ExpCore.ClassB.Phase) Assertions(tools.Assertions) MethodType(ast.Ast.MethodType) ExpCore(ast.ExpCore) Member(ast.ExpCore.ClassB.Member) MethodSelector(ast.Ast.MethodSelector) Block(ast.ExpCore.Block) Expression(ast.Expression) WalkBy(ast.Expression.WalkBy) ArrayList(java.util.ArrayList) List(java.util.List) SignalKind(ast.Ast.SignalKind) ContextId(ast.Expression.ContextId) Position(ast.Ast.Position) ClassReuse(ast.Expression.ClassReuse) Optional(java.util.Optional) Visitor(sugarVisitors.Visitor) Collections(java.util.Collections) MethodType(ast.Ast.MethodType) MethodSelector(ast.Ast.MethodSelector) ArrayList(java.util.ArrayList) Type(ast.Ast.Type) MethodType(ast.Ast.MethodType) Doc(ast.Ast.Doc) Member(ast.ExpCore.ClassB.Member)

Example 27 with ExpCore._void

use of ast.ExpCore._void in project L42 by ElvisResearchGroup.

the class InjectionOnCore method visit.

public ExpCore visit(Expression.MCall s) {
    assert !s.getPs().getE().isPresent() : s;
    ExpCore receiver = s.getReceiver().accept(this);
    String name = s.getName();
    Doc doc = s.getDoc();
    List<String> xs = s.getPs().getXs();
    List<ExpCore> es = new ArrayList<>();
    for (Expression e : s.getPs().getEs()) {
        es.add(e.accept(this));
    }
    return new MCall(receiver, MethodSelector.of(name, xs), doc, es, s.getP());
}
Also used : ExpCore(ast.ExpCore) Expression(ast.Expression) ArrayList(java.util.ArrayList) Doc(ast.Ast.Doc)

Example 28 with ExpCore._void

use of ast.ExpCore._void in project L42 by ElvisResearchGroup.

the class CtxL method equals.

public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (obj == null)
        return false;
    if (getClass() != obj.getClass())
        return false;
    CtxL other = (CtxL) obj;
    ExpCore oE = other.fillHole(new ExpCore.WalkBy());
    ExpCore thisE = this.fillHole(new ExpCore.WalkBy());
    return thisE.equals(oE);
}
Also used : ExpCore(ast.ExpCore)

Example 29 with ExpCore._void

use of ast.ExpCore._void in project L42 by ElvisResearchGroup.

the class CtxL method _split.

public static CtxL _split(ExpCore.ClassB l) {
    int pos = firstNotCompiled(l.getMs());
    if (pos == l.getMs().size()) {
        return null;
    }
    Member m = l.getMs().get(pos);
    ExpCore inner = m.getInner();
    boolean metaReady = m instanceof NestedClass && IsCompiled.of(m.getInner());
    CtxC innerSplit;
    if (metaReady) {
        innerSplit = CtxC.hole(inner);
    } else {
        innerSplit = CtxC.split(inner);
    }
    return new CtxL(l, pos, innerSplit);
}
Also used : ExpCore(ast.ExpCore) NestedClass(ast.ExpCore.ClassB.NestedClass) Member(ast.ExpCore.ClassB.Member)

Example 30 with ExpCore._void

use of ast.ExpCore._void in project L42 by ElvisResearchGroup.

the class Norm method normMwt.

protected MethodWithType normMwt(Program p, MethodWithType mwt) {
    MethodType mt = mwt.getMt();
    Optional<ExpCore> e = mwt.get_inner().map(e1 -> e1.accept(new CloneVisitor() {

        @Override
        public ExpCore visit(ClassB cb) {
            return norm(p.evilPush(cb));
        }
    }));
    return mwt.withMt(mt).with_inner(e);
}
Also used : MethodType(ast.Ast.MethodType) ExpCore(ast.ExpCore) CloneVisitor(coreVisitors.CloneVisitor) ClassB(ast.ExpCore.ClassB)

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