Search in sources :

Example 76 with ClassB

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

the class _Sum method matchNC.

private static Void matchNC(Program p, ClassB topA, ClassB topB, NestedClass nca, List<Member> ms, NestedClass ncb, List<Ast.C> current) {
    List<Ast.C> innerCurrent = new ArrayList<>(current);
    innerCurrent.add(nca.getName());
    ClassB newInner = normalizedSum(p, topA, topB, (ClassB) nca.getInner(), (ClassB) ncb.getInner(), innerCurrent);
    Doc doc = nca.getDoc().sum(ncb.getDoc());
    ms.add(nca.withInner(newInner).withDoc(doc));
    return null;
}
Also used : ArrayList(java.util.ArrayList) Doc(ast.Ast.Doc) ClassB(ast.ExpCore.ClassB)

Example 77 with ClassB

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

the class Lib method navigate.

Lib navigate(List<Ast.C> cs) {
    if (cs.isEmpty()) {
        return this;
    }
    if (this.isBinded) {
        //TODO: need from?
        ClassB cb = this.inner.getClassB(cs);
        return new Lib(true, cb, Collections.emptyList(), cb);
    }
    List<Ast.C> top = Collections.singletonList(cs.get(0));
    List<Ast.C> tail = cs.subList(1, cs.size());
    Lib nextStep = new Lib(false, root, Functions.push(path, cs.get(0)), inner.getClassB(top), this);
    return nextStep.navigate(tail);
}
Also used : ClassB(ast.ExpCore.ClassB)

Example 78 with ClassB

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

the class Type method refTo.

default default TypeRefTo refTo(PData pData) {
    Path path = type().getPath();
    Path whereP = Path.outer(0, locationLib().path);
    path = From.fromP(path, whereP);
    if (path.outerNumber() == 0) {
        return new TypeRefTo.Lib(locationLib().root(), path);
    }
    Program p = pData.p.evilPush(locationLib().root().inner);
    //will be evilPush
    try {
        ClassB cb = p.extractClassB(path);
        //if(coreVisitors.IsCompiled.of(cb)){
        if (cb.getPhase() != Phase.None) {
            //norm,typed,coherent
            return new TypeRefTo.Binded(path);
        }
        //TODO: borderline ok?
        return new TypeRefTo.Unavailable();
    } catch (ErrorMessage.PathMetaOrNonExistant pne) {
        if (pne.isMeta()) {
            return new TypeRefTo.Unavailable();
        }
        return new TypeRefTo.Missing();
    }
}
Also used : Path(ast.Ast.Path) Program(programReduction.Program) ErrorMessage(ast.ErrorMessage) ClassB(ast.ExpCore.ClassB)

Example 79 with ClassB

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

the class PlgWrapperGenerator method isOkAsReturn.

private static void isOkAsReturn(Program p, Path csTop, Type ti) throws ClassUnfit, MethodUnfit {
    Path pi = ti.getPath();
    if (pi.equals(Path.Void())) {
        return;
    }
    //We will need to generate a simpler returning expression
    if (pi.equals(Path.Library())) {
        return;
    }
    Path op = _pathForOutside(csTop.getCBar().size(), pi);
    if (op == null) {
        checkForInside(p.top(), csTop, pi);
        return;
    }
    ClassB l = p.extractClassB(op);
    boolean hasIt = hasFrom(l);
    boolean phOk = Functions.isComplete(ti);
    if (ti.getMdf() == Mdf.Class && !ti.equals(Type.classAny)) {
        throw new RefactorErrors.MethodUnfit().msg("Return type can be 'class' only if is exactly 'class any'");
    }
    if (!hasIt) {
        throw new RefactorErrors.ClassUnfit().msg("Class " + op + " has no method #from(binaryRepr)");
    }
    if (!phOk) {
        //TODO: why this limitation?
        throw new RefactorErrors.MethodUnfit().msg("Return type can not be fwd");
    }
}
Also used : Path(ast.Ast.Path) ClassUnfit(is.L42.connected.withSafeOperators.pluginWrapper.RefactorErrors.ClassUnfit) MethodUnfit(is.L42.connected.withSafeOperators.pluginWrapper.RefactorErrors.MethodUnfit) ClassB(ast.ExpCore.ClassB)

Example 80 with ClassB

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

the class PlgWrapperGenerator method checkForInside.

private static void checkForInside(ClassB lTop, Path csTop, Path originalPath) throws ClassUnfit, MethodUnfit {
    if (originalPath.isPrimitive()) {
        throw new RefactorErrors.MethodUnfit().msg("Method signature not supported:\n parameters can not be Void/Any/fwd.\n" + "returns can not be Any/fwd\n" + "exceptions can not be Any/Void/Library");
    }
    Path cs = From.fromP(originalPath, csTop);
    assert cs.outerNumber() == 0;
    List<Ast.C> cBar = cs.getCBar();
    ClassB lPointed = lTop.getClassB(cBar);
    Doc d = lPointed.getDoc1();
    if (d._getParameterForPlugin() == null || d._getParameterForPluginPart() == null) {
        throw new RefactorErrors.ClassUnfit().msg("Class " + cBar + " doesnot have @pluginPart annotation");
    }
}
Also used : Path(ast.Ast.Path) Doc(ast.Ast.Doc) ClassUnfit(is.L42.connected.withSafeOperators.pluginWrapper.RefactorErrors.ClassUnfit) MethodUnfit(is.L42.connected.withSafeOperators.pluginWrapper.RefactorErrors.MethodUnfit) 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