use of ast.Ast.Path in project L42 by ElvisResearchGroup.
the class MethodPathCloneVisitor method visit.
public ExpCore visit(MCall s) {
Program ep = p;
for (ClassB cbi : this.getLocator().getCbs()) {
if (cbi != null) {
ep = ep.evilPush(cbi);
}
}
MethodSelector ms = s.getS();
Path guessed = null;
try {
TIn in = TIn.top(Phase.Typed, ep, s.getInner());
in = in.withG(varEnv.entrySet().stream().collect(Collectors.toMap(me -> me.getKey(), me -> new java.util.AbstractMap.SimpleEntry<>(false, me.getValue()))));
Type tGuessed = newTypeSystem.GuessTypeCore._of(in.p, in, s.getInner());
if (tGuessed == null) {
return super.visit(s);
}
guessed = tGuessed.getPath();
assert guessed != null;
} catch (NormImpossible ignored) {
return super.visit(s);
}
MethodSelector ms2 = visitMS(ms, guessed);
if (ms2.equals(ms)) {
return super.visit(s);
}
s = new MCall(s.getInner(), ms2, s.getDoc(), s.getEs(), s.getP());
return super.visit(s);
}
use of ast.Ast.Path in project L42 by ElvisResearchGroup.
the class Plugin method Mredirect£xthat£xsrc£xdest.
@ActionType({ ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.TypeAny })
public Object Mredirect£xthat£xsrc£xdest(Object _that, Object _src, Object _dest) {
ClassB that = ensureExtractClassB(_that);
List<Ast.C> src = PathAux.parseValidCs(ensureExtractStringU(_src));
Path dest = ensureExtractPathFromJava(_dest);
assert dest.isCore() || dest.isPrimitive() : dest;
//TODO: see if extractPath should be changed
if (dest.isCore()) {
dest = dest.setNewOuter(dest.outerNumber() + 1);
}
return Redirect.redirect(Resources.getP(), that, Path.outer(0, src), dest);
}
use of ast.Ast.Path 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.Ast.Path in project L42 by ElvisResearchGroup.
the class Redirect method plusEqual.
private static void plusEqual(List<PathSPath> ambiguities, Path pif, List<Path> extPs) {
assert ambiguitiesOk(ambiguities);
try {
assert !extPs.isEmpty();
assert !extPs.contains(null);
assert !pif.isPrimitive() && pif.outerNumber() == 0;
for (PathSPath psp : ambiguities) {
if (psp.getPath().equals(pif)) {
psp.setPathsSet(new HashSet<>(psp.getPathsSet()));
assert !psp.getPathsSet().isEmpty();
Path forErr = psp.getPathsSet().iterator().next();
psp.getPathsSet().retainAll(extPs);
if (psp.getPathsSet().isEmpty()) {
List<Path> psErr = Arrays.asList(forErr, extPs.get(0));
throw Errors42.errorIncoherentRedirectMapping(Redirect.verifiedForErrorMsg, ambiguities, psp.getPath(), psErr);
}
return;
}
}
ambiguities.add(new PathSPath(pif, new HashSet<>(extPs)));
} finally {
assert ambiguitiesOk(ambiguities);
}
}
use of ast.Ast.Path in project L42 by ElvisResearchGroup.
the class ToAst method visitUsing.
@Override
public Expression visitUsing(UsingContext ctx) {
Path path = Ast.Path.sugarParse(nameU(ctx.Path()));
Expression inner = ctx.eTop().accept(this);
String name = nameL(ctx.mCall().m());
Parameters parameters = this.parseMParameters(ctx.mCall().round().ps());
Doc docs = parseDoc(ctx.mCall().round().docsOpt());
return new Expression.Using(path, name, docs, parameters, inner);
}
Aggregations