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);
}
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);
}
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());
}
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);
}
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);
}
Aggregations