use of ast.ExpCore._void in project L42 by ElvisResearchGroup.
the class HB method visit.
@Override
public ExpCore visit(Block s) {
ExpCore result = null;
for (Block.Dec di : s.getDecs()) {
result = acc(result, di.getInner().accept(this));
}
result = acc(result, s.getInner().accept(this));
if (result == null && onlyAroundHole) {
return null;
}
assert !onlyAroundHole || result instanceof WalkBy : onlyAroundHole + " " + result;
for (Block.Dec dec : s.getDecs()) {
if (xs.contains(dec.getX())) {
throw new ErrorMessage.VariableDeclaredMultipleTimes(dec.getX(), s.getP());
}
this.xs.add(dec.getX());
this.xsRes.add(dec.getX());
}
try {
if (!onlyAroundHole && !s.getOns().isEmpty()) {
for (On on : s.getOns()) {
if (xs.contains(on.getX())) {
throw new ErrorMessage.VariableDeclaredMultipleTimes(on.getX(), s.getP());
}
xs.add(on.getX());
xsRes.add(on.getX());
on.getInner().accept(this);
xs.remove(on.getX());
}
}
return result;
} finally {
for (Block.Dec dec : s.getDecs()) {
this.xs.remove(dec.getX());
}
}
}
use of ast.ExpCore._void in project L42 by ElvisResearchGroup.
the class TsBlock method kTypeCatchAny.
default default TOutK kTypeCatchAny(TIn in, Tr tr, On k) {
Block e = (Block) k.getE();
ExpCore e0 = e.getDecs().get(0).getInner();
TIn in1 = in.removeG(k.getX());
TOut _out = type(in1.withE(e0, Path.Void().toImmNT()));
if (!_out.isOk()) {
return _out.toError();
}
TOk ok = _out.toOk();
if (!ok.exceptions.isEmpty() || !ok.returns.isEmpty()) {
return new TErr(in, "", null, ErrorKind.UnsafeCatchAny);
}
ExpCore newE = e.withDeci(0, e.getDecs().get(0).withInner(ok.annotated));
return new TOkK(tr, k.withE(newE), in.expected);
/*
(catch and rethrow any)// could be sugared as "on throw doAndPropagate e"
Phase |p |G |Tr|-catch throw Any x (e0 throw x) ~> catch throw Any x (e0' throw x): T<=T | Tr
where //Note: e0, e, e0',e' are using the sugar imm Void x=e == e
e0=(e catch error Any z void void)
e0'=(e' catch error Any z void void)
Phase |p |G\x |- e ~> e':_ <=imm Void | empty
catchRethrow(catch throw Any x(e0 throw x))
*/
}
use of ast.ExpCore._void in project L42 by ElvisResearchGroup.
the class Executor method subst.
public static ExpCore subst(ExpCore ctxVal, Redex.Subst r) {
Block e1 = r.getThat();
int i = r.getSubstIndex();
ExpCore val = e1.getDecs().get(i).getInner();
String x = e1.getDecs().get(i).getX();
ArrayList<Block.Dec> decs = new ArrayList<Block.Dec>(e1.getDecs());
decs.remove(i);
Block e2 = new Block(e1.getDoc(), decs, e1.getInner(), e1.getOns(), e1.getP());
ExpCore result = ReplaceX.of(e2, val, x);
return ReplaceCtx.of(ctxVal, result);
}
use of ast.ExpCore._void in project L42 by ElvisResearchGroup.
the class Executor method meta1Prop.
protected ClassB meta1Prop(Program p, ClassB cb, NestedClass m) {
log("---meta1Prop--");
//get cb-->ct
//get p'
Program p1 = p.evilPush(cb);
//extract e
ExpCore e = m.getInner();
//extract cb
Ctx<ClassB> ctxC = ExtractCtxCompiled.of(e);
//run cb1-->cb2
ClassB cb2 = (ClassB) step(new PData(p1), ctxC.hole);
ExpCore e2 = ReplaceCtx.of(ctxC.ctx, cb2);
//compose cb with new member
return cb.withMember(m.withInner(e2));
}
use of ast.ExpCore._void in project L42 by ElvisResearchGroup.
the class TestHelper method getExpCore.
public static ExpCore getExpCore(String source, String _e1) {
Expression code1 = Parser.parse("GeneratedByTestHelper_", _e1);
Expression code2 = Desugar.of(code1);
ExpCore e1 = code2.accept(new InjectionOnCore());
return e1;
}
Aggregations