use of ast.Ast.Type in project L42 by ElvisResearchGroup.
the class Desugar method visit.
public Expression visit(ClassB s) {
Position pos = s.getP();
assert !(s.getH() instanceof ConcreteHeader);
if (!s.getFields().isEmpty()) {
List<Member> ms = s.getFields().stream().flatMap(f -> Desugar.field(pos, f)).collect(Collectors.toList());
ms.addAll(s.getMs());
s = s.withMs(ms).withH(new Ast.TraitHeader());
}
Set<String> oldUsedVars = this.usedVars;
HashMap<String, Type> oldVarEnv = this.varEnv;
try {
s = (ClassB) super.visit(s);
s = FlatFirstLevelLocalNestedClasses.of(s, this);
s = DesugarCatchDefault.of(s);
return s;
} finally {
this.usedVars = oldUsedVars;
this.varEnv = oldVarEnv;
}
}
use of ast.Ast.Type in project L42 by ElvisResearchGroup.
the class Desugar method visit.
public MethodImplemented visit(MethodImplemented mi) {
this.usedVars = new HashSet<String>();
this.varEnv = new HashMap<String, Type>();
String mName = desugarName(mi.getS().nameToS());
mi = mi.withS(mi.getS().withName(mName));
for (String name : mi.getS().getNames()) {
usedVars.add(name);
List<Ast.MethodSelectorX> msxsi = new ArrayList<>();
msxsi.add(new Ast.MethodSelectorX(mi.getS(), name));
varEnv.put(name, null);
}
usedVars.add("this");
List<Ast.MethodSelectorX> msxsi = new ArrayList<>();
msxsi.add(new Ast.MethodSelectorX(mi.getS(), "this"));
//varEnv.put("this",new Ast.HistoricType(Path.outer(0),msxsi,Doc.empty()));
List<Ast.MethodSelectorX> msxs = new ArrayList<>();
msxs.add(new Ast.MethodSelectorX(mi.getS(), ""));
usedVars.addAll(CollectDeclaredVars.of(mi.getInner()));
//final restrictions
final MethodImplemented mi2 = mi;
return withExpectedType(null, () -> super.visit(mi2));
//well... this is an issue> method desugaring for method implemented does not know its return type?
}
use of ast.Ast.Type in project L42 by ElvisResearchGroup.
the class DesugarW method castT.
private VarDecXE castT(Position pos, Type t, String y, String x) {
assert t instanceof Type;
Type nt = t;
String z = Functions.freshName("casted", usedVars);
List<Catch> ks = new ArrayList<>();
Type t2 = new Type(nt.getMdf(), Path.Any(), Doc.empty());
ks.add(new //case return captured
Expression.Catch1(//case return captured
pos, //case return captured
SignalKind.Return, //case return captured
t, //case return captured
z, //return it
new X(pos, z)));
ks.add(new //else
Expression.Catch1(//else
pos, //else
SignalKind.Return, //else
t2, //else
z, // exception void
new Signal(SignalKind.Exception, Expression._void.instance)));
RoundBlock block = Desugar.getBlock(pos, new Signal(SignalKind.Return, new X(pos, x)), ks, Desugar.errorMsg("CastT-Should be unreachable code"));
return new VarDecXE(false, Optional.of(t), y, block);
}
use of ast.Ast.Type in project L42 by ElvisResearchGroup.
the class DesugarW method withDesugarGetDefaultCatch.
private Catch withDesugarGetDefaultCatch(Position pos, SignalKind kind, Expression eClose) {
String propagated1 = Functions.freshName("propagated", usedVars);
Expression blockPropagate1 = Desugar.getBlock(pos, eClose, new Signal(kind, new X(pos, propagated1)));
Type t = Type.immAny;
Expression.Catch1 k1 = new Expression.Catch1(pos, kind, t, propagated1, blockPropagate1);
return new DesugarCatchDefault.CatchToComplete(k1);
}
use of ast.Ast.Type in project L42 by ElvisResearchGroup.
the class CloneVisitor method visit.
public Expression visit(ClassB s) {
Header h = liftH(s.getH());
List<FieldDec> fs = Map.of(this::liftF, s.getFields());
List<Type> superT = Map.of(this::liftT, s.getSupertypes());
List<Member> ms = Map.of(this::liftM, s.getMs());
return new ClassB(liftDoc(s.getDoc1()), h, fs, superT, ms, s.getP());
}
Aggregations