Search in sources :

Example 1 with ClassB

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

the class InjectionOnSugar method visit.

@Override
public Expression visit(ClassB s) {
    Doc doc1 = s.getDoc1();
    Header h = (s.isInterface()) ? new Ast.InterfaceHeader() : new Ast.TraitHeader();
    List<Type> supertypes = s.getSupertypes();
    List<Member> members = new ArrayList<>();
    for (ast.ExpCore.ClassB.Member mi : s.getMs()) {
        members.add(mi.match(nc -> new Expression.ClassB.NestedClass(nc.getDoc(), nc.getName(), lift(nc.getInner()), nc.getP()), mimpl -> new Expression.ClassB.MethodImplemented(mimpl.getDoc(), mimpl.getS(), lift(mimpl.getInner()), mimpl.getP()), mwt -> {
            Doc idoc = mwt.getDoc();
            MethodSelector is = mwt.getMs();
            MethodType mt = mwt.getMt();
            return new Expression.ClassB.MethodWithType(idoc, is, mt, lift(mwt.get_inner()), mwt.getP());
        }));
    }
    return new Expression.ClassB(doc1, h, Collections.emptyList(), supertypes, members, s.getP());
}
Also used : VarDecXE(ast.Ast.VarDecXE) UpdateVar(ast.ExpCore.UpdateVar) Ast(ast.Ast) Header(ast.Ast.Header) MCall(ast.ExpCore.MCall) Type(ast.Ast.Type) Member(ast.Expression.ClassB.Member) WellFormedness(auxiliaryGrammar.WellFormedness) MethodType(ast.Ast.MethodType) Loop(ast.ExpCore.Loop) MethodSelector(ast.Ast.MethodSelector) ArrayList(java.util.ArrayList) Visitor(coreVisitors.Visitor) ClassB(ast.ExpCore.ClassB) WalkBy(ast.ExpCore.WalkBy) Mdf(ast.Ast.Mdf) X(ast.ExpCore.X) VarDec(ast.Ast.VarDec) Path(ast.Ast.Path) Signal(ast.ExpCore.Signal) Match(tools.Match) Doc(ast.Ast.Doc) ExpCore._void(ast.ExpCore._void) ExpCore(ast.ExpCore) Block(ast.ExpCore.Block) Expression(ast.Expression) List(java.util.List) Position(ast.Ast.Position) Using(ast.ExpCore.Using) Optional(java.util.Optional) Collections(java.util.Collections) MethodType(ast.Ast.MethodType) MethodSelector(ast.Ast.MethodSelector) Ast(ast.Ast) ArrayList(java.util.ArrayList) Type(ast.Ast.Type) MethodType(ast.Ast.MethodType) Header(ast.Ast.Header) Expression(ast.Expression) Doc(ast.Ast.Doc) Member(ast.Expression.ClassB.Member) ClassB(ast.ExpCore.ClassB)

Example 2 with ClassB

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

the class UsedPaths method collectPaths.

Void collectPaths(List<Path> ps, MethodImplemented mi) {
    ps.addAll(CollectPaths0.of(mi.getInner()));
    List<ClassB> cbs = CollectClassBs0.of(mi.getInner());
    for (ClassB cb : cbs) {
        ps.addAll(Functions.remove1OuterAndPrimitives(of(cb)));
    }
    return null;
}
Also used : ClassB(ast.ExpCore.ClassB)

Example 3 with ClassB

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

the class UsedPathsPlus method collectPaths.

Void collectPaths(List<Path> ps, NestedClass nc) {
    if (!(nc.getInner() instanceof ClassB)) {
        return null;
    }
    ClassB cb = (ClassB) nc.getInner();
    assert IsCompiled.of(cb);
    //assert Configuration.typeExtraction.isCt(cb);
    ps.addAll(nc.getDoc().getPaths());
    ps.addAll(Functions.remove1OuterAndPrimitives(of(cb)));
    return null;
}
Also used : ClassB(ast.ExpCore.ClassB)

Example 4 with ClassB

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

the class TsLibrary method libraryWellTyped.

default default TOut libraryWellTyped(TIn in) {
    //   (library well typed)
    //   Phase |- p ~> L' //In implementation, if p.top().Phase>=Phase, L'=p.Top()
    ClassB top = in.p.top();
    assert //   Phase in {Typed,Coherent}
    in.phase.subtypeEq(Phase.Typed) : "";
    if (top.getPhase().subtypeEq(in.phase)) {
        return new TOk(in, top, Path.Library().toImmNT());
    }
    //   L0={interface? implements Ps M1..Mn Phase'}=norm(p)
    //   L'={interface? implements Ps M1'..Mn' max(Phase',Phase)}
    ClassB L0 = normTopL(in);
    List<MethodWithType> mwts = L0.mwts();
    List<NestedClass> ns = L0.ns();
    List<NestedClass> newNs = new ArrayList<>();
    //   forall i in 1..n
    //     Phase| p| Ps |- Mi ~> Mi'
    TIn inNested = in.withP(in.p.updateTop(L0));
    List<MethodWithType> newMwts;
    if (in.phase == Phase.Coherent && top.getPhase() == Phase.Typed) {
        newMwts = new ArrayList<>(mwts);
    } else {
        newMwts = new ArrayList<>();
        for (MethodWithType mwt : mwts) {
            TOutM out = memberMethod(inNested, L0.getSupertypes(), mwt);
            if (!out.isOk()) {
                return out.toError();
            }
            newMwts.add((MethodWithType) out.toOkM().inner);
        }
    }
    for (NestedClass nt : ns) {
        TOutM out = memberNested(inNested, nt);
        if (!out.isOk()) {
            return out.toError();
        }
        newNs.add((NestedClass) out.toOkM().inner);
    }
    Phase maxPhase = L0.getPhase();
    if (in.phase.subtypeEq(maxPhase)) {
        maxPhase = in.phase;
    }
    ClassB L1 = new ClassB(L0.getDoc1(), L0.isInterface(), L0.getSupertypes(), newMwts, newNs, L0.getP(), maxPhase, L0.getUniqueId());
    if (in.phase == Phase.Coherent) {
        boolean isCoh = coherent(in.p.updateTop(L1), true);
        if (!isCoh) {
            return new TErr(in, "", Path.Library().toImmNT(), ErrorKind.LibraryNotCoherent);
        }
    }
    //   //or error not coherent set of abstr. methods:list
    return new TOk(in, L1, Path.Library().toImmNT());
}
Also used : Phase(ast.ExpCore.ClassB.Phase) ArrayList(java.util.ArrayList) NestedClass(ast.ExpCore.ClassB.NestedClass) MethodWithType(ast.ExpCore.ClassB.MethodWithType) ClassB(ast.ExpCore.ClassB)

Example 5 with ClassB

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

the class ErrorFormatter method reportPlaceOfMetaError.

private static String reportPlaceOfMetaError(Program p, ErrorMessage msg) {
    ErrorMessage.MalformedFinalResult _msg = (ErrorMessage.MalformedFinalResult) msg;
    ClassB cb = _msg.getFinalRes();
    //String path=_msg.getReason();
    String path = reportPlaceOfMetaError(p, cb);
    return path + "\n-----\n" + _msg.getReason();
}
Also used : ErrorMessage(ast.ErrorMessage) ClassB(ast.ExpCore.ClassB)

Aggregations

ClassB (ast.ExpCore.ClassB)107 ArrayList (java.util.ArrayList)33 Path (ast.Ast.Path)30 ExpCore (ast.ExpCore)25 Member (ast.ExpCore.ClassB.Member)25 EncodingHelper.ensureExtractClassB (auxiliaryGrammar.EncodingHelper.ensureExtractClassB)20 Program (programReduction.Program)20 Ast (ast.Ast)19 MethodWithType (ast.ExpCore.ClassB.MethodWithType)19 MethodSelector (ast.Ast.MethodSelector)18 NestedClass (ast.ExpCore.ClassB.NestedClass)18 List (java.util.List)17 ActionType (platformSpecific.fakeInternet.ActionType)16 Doc (ast.Ast.Doc)12 Type (ast.Ast.Type)12 ErrorMessage (ast.ErrorMessage)12 Optional (java.util.Optional)10 C (ast.Ast.C)9 MethodType (ast.Ast.MethodType)8 Phase (ast.ExpCore.ClassB.Phase)8