Search in sources :

Example 31 with Expression

use of ast.Expression 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;
}
Also used : ExpCore(ast.ExpCore) Expression(ast.Expression) InjectionOnCore(sugarVisitors.InjectionOnCore)

Example 32 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class TestHelper method getProgram.

public static Program getProgram(/*List<Path> paths,*/
String[] code) {
    Program p0 = Program.emptyLibraryProgram();
    Integer outerCount = code.length;
    for (String s : code) {
        Expression e = Parser.parse("This" + outerCount, s);
        --outerCount;
        ClassB ec = (ClassB) Desugar.of(e).accept(new InjectionOnCore());
        p0 = p0.evilPush(ec);
    }
    return p0;
}
Also used : Program(programReduction.Program) Expression(ast.Expression) ClassB(ast.ExpCore.ClassB) InjectionOnCore(sugarVisitors.InjectionOnCore)

Example 33 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class TestHelper method getClassB.

public static ClassB getClassB(String source, String e1) {
    Expression code1 = Parser.parse("GeneratedByTestHelper_" + source, e1);
    auxiliaryGrammar.WellFormedness.checkAll(code1);
    Expression code2 = Desugar.of(code1);
    assert auxiliaryGrammar.WellFormedness.checkAll(code2);
    ExpCore.ClassB code3 = (ExpCore.ClassB) code2.accept(new InjectionOnCore());
    assert coreVisitors.CheckNoVarDeclaredTwice.of(code3);
    return code3;
}
Also used : ExpCore(ast.ExpCore) Expression(ast.Expression) ClassB(ast.ExpCore.ClassB) ClassB(ast.ExpCore.ClassB) InjectionOnCore(sugarVisitors.InjectionOnCore)

Example 34 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class InjectionOnSugar method visit.

@Override
public Expression visit(Using s) {
    List<String> xs = s.getS().getNames();
    List<ast.ExpCore> es1 = s.getEs();
    List<ast.Expression> es = new ArrayList<ast.Expression>();
    for (ast.ExpCore e : es1) {
        es.add(lift(e));
    }
    ast.Ast.Parameters ps = new ast.Ast.Parameters(Optional.<ast.Expression>empty(), xs, es);
    return new Expression.Using(s.getPath(), s.getS().nameToS(), s.getDoc(), ps, lift(s.getInner()));
}
Also used : ExpCore(ast.ExpCore) Ast(ast.Ast) Using(ast.ExpCore.Using) ArrayList(java.util.ArrayList) ExpCore(ast.ExpCore) Expression(ast.Expression)

Example 35 with Expression

use of ast.Expression in project L42 by ElvisResearchGroup.

the class InjectionOnSugar method visit.

@Override
public Expression visit(ClassB s) {
    Doc doc1 = s.getDoc1();
    Header h = (s.isInterface()) ? new Ast.InterfaceHeader() : new Ast.TraitHeader();
    List<Type> supertypes = s.getSupertypes();
    List<Member> members = new ArrayList<>();
    for (ast.ExpCore.ClassB.Member mi : s.getMs()) {
        members.add(mi.match(nc -> new Expression.ClassB.NestedClass(nc.getDoc(), nc.getName(), lift(nc.getInner()), nc.getP()), mimpl -> new Expression.ClassB.MethodImplemented(mimpl.getDoc(), mimpl.getS(), lift(mimpl.getInner()), mimpl.getP()), mwt -> {
            Doc idoc = mwt.getDoc();
            MethodSelector is = mwt.getMs();
            MethodType mt = mwt.getMt();
            return new Expression.ClassB.MethodWithType(idoc, is, mt, lift(mwt.get_inner()), mwt.getP());
        }));
    }
    return new Expression.ClassB(doc1, h, Collections.emptyList(), supertypes, members, s.getP());
}
Also used : VarDecXE(ast.Ast.VarDecXE) UpdateVar(ast.ExpCore.UpdateVar) Ast(ast.Ast) Header(ast.Ast.Header) MCall(ast.ExpCore.MCall) Type(ast.Ast.Type) Member(ast.Expression.ClassB.Member) WellFormedness(auxiliaryGrammar.WellFormedness) MethodType(ast.Ast.MethodType) Loop(ast.ExpCore.Loop) MethodSelector(ast.Ast.MethodSelector) ArrayList(java.util.ArrayList) Visitor(coreVisitors.Visitor) ClassB(ast.ExpCore.ClassB) WalkBy(ast.ExpCore.WalkBy) Mdf(ast.Ast.Mdf) X(ast.ExpCore.X) VarDec(ast.Ast.VarDec) Path(ast.Ast.Path) Signal(ast.ExpCore.Signal) Match(tools.Match) Doc(ast.Ast.Doc) ExpCore._void(ast.ExpCore._void) ExpCore(ast.ExpCore) Block(ast.ExpCore.Block) Expression(ast.Expression) List(java.util.List) Position(ast.Ast.Position) Using(ast.ExpCore.Using) Optional(java.util.Optional) Collections(java.util.Collections) MethodType(ast.Ast.MethodType) MethodSelector(ast.Ast.MethodSelector) Ast(ast.Ast) ArrayList(java.util.ArrayList) Type(ast.Ast.Type) MethodType(ast.Ast.MethodType) Header(ast.Ast.Header) Expression(ast.Expression) Doc(ast.Ast.Doc) Member(ast.Expression.ClassB.Member) ClassB(ast.ExpCore.ClassB)

Aggregations

Expression (ast.Expression)66 ArrayList (java.util.ArrayList)24 VarDec (ast.Ast.VarDec)14 X (ast.Expression.X)13 Type (ast.Ast.Type)11 VarDecXE (ast.Ast.VarDecXE)11 ExpCore (ast.ExpCore)11 Catch (ast.Expression.Catch)11 RoundBlock (ast.Expression.RoundBlock)11 VarDecE (ast.Ast.VarDecE)10 Doc (ast.Ast.Doc)8 Position (ast.Ast.Position)8 MethodSelectorX (ast.Ast.MethodSelectorX)7 Parameters (ast.Ast.Parameters)7 MethodWithType (ast.Expression.ClassB.MethodWithType)7 MethodType (ast.Ast.MethodType)6 ClassB (ast.ExpCore.ClassB)6 InjectionOnCore (sugarVisitors.InjectionOnCore)6 Ast (ast.Ast)5 Path (ast.Ast.Path)4