Search in sources :

Example 16 with ClassB

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

the class Plugin method MhideClass£xthat£xsrc.

@ActionType({ ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library })
public Object MhideClass£xthat£xsrc(Object _that, Object _src) {
    ClassB that = ensureExtractClassB(_that);
    List<Ast.C> src = PathAux.parseValidCs(ensureExtractStringU(_src));
    List<Ast.C> dest = new ArrayList<>(src);
    dest.set(dest.size() - 1, dest.get(dest.size() - 1).withUniqueNum(L42.freshPrivate()));
    return Rename.renameClass(Resources.getP(), that, src, dest);
}
Also used : ArrayList(java.util.ArrayList) ClassB(ast.ExpCore.ClassB) EncodingHelper.ensureExtractClassB(auxiliaryGrammar.EncodingHelper.ensureExtractClassB) ActionType(platformSpecific.fakeInternet.ActionType)

Example 17 with ClassB

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

the class Plugin method MrenameMethod£xthat£xpath£xsrc£xdest.

@ActionType({ ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library })
public Object MrenameMethod£xthat£xpath£xsrc£xdest(Object _that, Object _path, Object _src, Object _dest) {
    ClassB that = ensureExtractClassB(_that);
    List<Ast.C> path = PathAux.parseValidCs(ensureExtractStringU(_path));
    MethodSelector src = MethodSelector.parse(ensureExtractStringU(_src));
    MethodSelector dest = MethodSelector.parse(ensureExtractStringU(_dest));
    return Rename.renameMethod(Resources.getP(), that, path, src, dest);
}
Also used : MethodSelector(ast.Ast.MethodSelector) ClassB(ast.ExpCore.ClassB) EncodingHelper.ensureExtractClassB(auxiliaryGrammar.EncodingHelper.ensureExtractClassB) ActionType(platformSpecific.fakeInternet.ActionType)

Example 18 with ClassB

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

the class Push method pushOne.

//never wrong
//assumes s well formed class name
static ClassB pushOne(ClassB in, Ast.C s) {
    Path p = Path.outer(1);
    ClassB cb = (ClassB) FromInClass.of(in, p);
    List<Member> ms = Collections.singletonList(new ClassB.NestedClass(Doc.empty(), s, cb, null));
    return ClassB.membersClass(ms, cb.getP(), cb.getPhase());
}
Also used : Path(ast.Ast.Path) Member(ast.ExpCore.ClassB.Member) ClassB(ast.ExpCore.ClassB)

Example 19 with ClassB

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

the class ProgramReduction method step.

static Program step(Program p) {
    //precondition: at top level we have a L not of form LC
    assert !IsCompiled.of(p.top());
    CtxL top = CtxL._split(p.top());
    assert top != null;
    Member m = top.originalCtxM();
    assert !IsCompiled.of(m);
    ExpCore hole = top.originalHole();
    if (hole instanceof ClassB) {
        assert !IsCompiled.of(hole);
        return enter(p, top, m);
    }
    ClassB.NestedClass nc = (NestedClass) m;
    return top(p, nc);
}
Also used : NestedClass(ast.ExpCore.ClassB.NestedClass) ExpCore(ast.ExpCore) NestedClass(ast.ExpCore.ClassB.NestedClass) Member(ast.ExpCore.ClassB.Member) ClassB(ast.ExpCore.ClassB)

Example 20 with ClassB

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

the class UsedPaths method collectNotAnyPaths.

private static List<Ast.Path> collectNotAnyPaths(Program p, ExpCore e) {
    class HeuristicForNotAnyPathsSplit extends PropagatorVisitor {

        public Void visit(ClassB s) {
            return null;
        }

        protected List<Path> paths = new ArrayList<Path>();

        private void add(Path p) {
            this.paths.add(p);
        }

        //non determinism heuristic:
        //**if P.m(_) inside e, P not Any
        public Void visit(MCall s) {
            Path p = justPath(s.getInner());
            if (p != null) {
                add(p);
            }
            return super.visit(s);
        }

        //**if ( _ T x=P _ _) inside e and T!=class Any, P not Any.
        //**if (mdf P x=_ _) inside e, P not Any  
        protected void liftDec(Block.Dec s) {
            if (s.getT().isPresent()) {
                Path pt = s.getT().get().getPath();
                if (!pt.isPrimitive()) {
                    add(pt);
                }
            }
            Path p = justPath(s.getInner());
            if (p != null) {
                add(p);
            }
            super.liftDec(s);
        }

        private Path justPath(ExpCore e) {
            if (e instanceof ExpCore.EPath) {
                if (!((ExpCore.EPath) e).getInner().isPrimitive()) {
                    return ((ExpCore.EPath) e).getInner();
                }
            }
            if (e instanceof ExpCore.Block) {
                return justPath(((ExpCore.Block) e).getInner());
            }
            return null;
        }

        //**if p(Pi).Cache=Typed, Pi is not Any
        @Override
        protected void liftP(Path s) {
            if (s.isPrimitive()) {
                return;
            }
            try {
                if (p.extractClassB(s).getPhase() == Phase.Typed) {
                    super.liftP(s);
                    return;
                }
            } catch (ErrorMessage.PathMetaOrNonExistant pne) {
            /*we do not rise this error while computing the heuristic*/
            }
        }

        //**if using P _ _ inside e, P not Any
        public Void visit(ExpCore.Using s) {
            if (!s.getPath().isPrimitive()) {
                add(s.getPath());
            }
            return super.visit(s);
        }

        //**if catch T inside e, T.P not Any
        protected void liftO(ExpCore.Block.On on) {
            Path pOn = on.getT().getPath();
            if (!pOn.isPrimitive()) {
                add(pOn);
            }
            super.liftO(on);
        }

        List<Path> result(ExpCore e) {
            e.accept(this);
            return this.paths;
        }
    }
    return new HeuristicForNotAnyPathsSplit().result(e);
}
Also used : Path(ast.Ast.Path) ExpCore(ast.ExpCore) PathMetaOrNonExistant(ast.ErrorMessage.PathMetaOrNonExistant) PropagatorVisitor(coreVisitors.PropagatorVisitor) MCall(ast.ExpCore.MCall) Block(ast.ExpCore.Block) ArrayList(java.util.ArrayList) List(java.util.List) 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