use of ast.ExpCore.Block.On in project L42 by ElvisResearchGroup.
the class PropagatorVisitor method visit.
public Void visit(Block s) {
liftDoc(s.getDoc());
liftDecs(s.getDecs());
lift(s.getInner());
for (On o : s.getOns()) {
liftO(o);
}
return null;
}
use of ast.ExpCore.Block.On in project L42 by ElvisResearchGroup.
the class FreeVariables method visitK.
private void visitK(List<On> k) {
for (On on : k) {
inScope.add(on.getX());
on.getInner().accept(this);
inScope.remove(on.getX());
}
}
use of ast.ExpCore.Block.On in project L42 by ElvisResearchGroup.
the class PlgWrapperGenerator method updateTemplateUsing.
private static MethodWithType updateTemplateUsing(UsingInfo ui, MethodWithType mwt) {
MCall e = templateUsingExc;
MethodType mt = mwt.getMt();
ExpCore.Block b = (Block) e.getEs().get(0);
if (mwt.getMt().getExceptions().isEmpty()) {
b = b.withOns(Collections.emptyList());
}
ExpCore.Using u = (Using) b.getDecs().get(0).getInner();
//parameter expressions
ExpCore.MCall p0 = (MCall) u.getEs().get(0);
//e#mcall.inner<-mwt.retType.path
e = e.withInner(ExpCore.EPath.wrap(mt.getReturnType().getPath()));
//u=u.withS(ui.usingMs);
List<ExpCore> ues = new ArrayList<>();
if (mt.getMdf() != Mdf.Class) {
ues.add(p0.withInner(new ExpCore.X(mwt.getP(), "this")));
}
{
int i = -1;
for (String x : mwt.getMs().getNames()) {
i++;
ExpCore pi = new ExpCore.X(mwt.getP(), x);
boolean needAddBinaryRepr = true;
Type ti = mwt.getMt().getTs().get(i);
if (ti.equals(Type.immLibrary)) {
needAddBinaryRepr = false;
}
if (ti.getMdf() == Mdf.Class) {
needAddBinaryRepr = false;
}
if (needAddBinaryRepr) {
pi = p0.withInner(pi);
}
ues.add(pi);
}
}
u = new Using(u.getPath(), ui.usingMs, u.getDoc(), ues, u.getInner());
String errorS = "plugin string: " + ui.plgInfo.plgString + "\n" + "plugin part: " + ui.plgInfo.plgName + "\n" + "method name: " + mwt.getMs() + "\n" + "java method: " + ui.plgInfo.plgClass.getName() + "." + ui.usingMs + "\n";
//u.inner#mcall.es(0)<-EncodingHelper.wrapStringU()
List<ExpCore> errorEs = Collections.singletonList(EncodingHelper.wrapStringU(errorS));
Signal tmpS = (Signal) u.getInner();
MCall tmpMc = ((MCall) tmpS.getInner()).withEs(errorEs);
u = u.withInner(tmpS.withInner(tmpMc));
b = b.withDecs(Collections.singletonList(b.getDecs().get(0).withInner(u)));
//--
if (!mwt.getMt().getExceptions().isEmpty()) {
On on = b.getOns().get(0);
Dec k0 = ((Block) on.getInner()).getDecs().get(0);
List<Dec> ks = new ArrayList<>();
{
int i = -1;
for (Type ti : mt.getExceptions()) {
i++;
MCall mci = ((MCall) k0.getInner()).withInner(ExpCore.EPath.wrap(ti.getPath()));
ks.add(k0.withInner(mci).withX(k0.getX() + i));
}
}
on = on.withInner(((Block) on.getInner()).withDecs(ks));
b = b.withOns(Collections.singletonList(on));
//k0=b.k(0).inner#block.decs(0)
//k0 add more on need
//ki.inner#mcall.inner<-Pi
}
if (ui.isVoid) {
b = b.withDecs(Collections.singletonList(b.getDecs().get(0).withT(Optional.of(Type.immVoid))));
}
if (!ui.isVoid && !mwt.getMt().getReturnType().equals(Type.immLibrary)) {
e = e.withEs(Collections.singletonList(b));
mwt = mwt.withInner(e);
} else {
mwt = mwt.withInner(b);
}
return mwt;
}
use of ast.ExpCore.Block.On in project L42 by ElvisResearchGroup.
the class MethodPathCloneVisitor method visit.
public ExpCore visit(Block s) {
HashMap<String, Ast.Type> aux = new HashMap<>(this.varEnv);
try {
for (Dec d : s.getDecs()) {
if (d.getT().isPresent()) {
this.varEnv.put(d.getX(), d.getT().get());
}
//TODO:??? GuessTypeCore._of(this.varEnv,d.getInner());
}
List<Dec> newDecs = liftDecs(s.getDecs());
List<On> newOns = new ArrayList<>();
for (On on : s.getOns()) {
this.varEnv.put(on.getX(), on.getT());
newOns.add(liftO(on));
this.varEnv.remove(on.getX());
}
return new Block(s.getDoc(), newDecs, lift(s.getInner()), newOns, s.getP());
} finally {
this.varEnv = aux;
}
}
Aggregations