Search in sources :

Example 1 with PathMwt

use of ast.Util.PathMwt in project L42 by ElvisResearchGroup.

the class Translator method useFrom.

//this should take a class, strip out nested and 'from' it so that it is as at top level
static ClassB useFrom(ClassB ct, Path p) {
    ArrayList<Member> ms = new ArrayList<Member>();
    for (Member m : ct.getMs()) {
        m.match(nc -> null, mi -> {
            throw Assertions.codeNotReachable();
        }, mt -> ms.add(From.from(mt, p)));
    }
    //for(PathMwt pmwt:ct.getStage().getInherited()){
    for (PathMwt pmwt : Collections.<PathMwt>emptyList()) {
        if (Functions.getIfInDom(ms, pmwt.getMwt().getMs()).isPresent()) {
            continue;
        }
        ms.add(From.from(pmwt.getMwt(), p));
    }
    List<Path> sup = tools.Map.of(ti -> (Path) From.fromP(ti.getPath(), p), ct.getSupertypes());
    //tools.Map.of(pi->(Path)From.fromP(pi,p),ct.getStage().getInheritedPaths());
    List<Path> supAll = sup;
    ClassB res = ct.withMs(ms).withSupertypes(tools.Map.of(pi -> pi.toImmNT(), sup));
    return res;
}
Also used : Path(ast.Ast.Path) From(coreVisitors.From) Stage(ast.Ast.Stage) Arrays(java.util.Arrays) Program(programReduction.Program) Ast(ast.Ast) Configuration(facade.Configuration) Type(ast.Ast.Type) HashMap(java.util.HashMap) Assertions(tools.Assertions) ArrayList(java.util.ArrayList) CompilationError(platformSpecific.inMemoryCompiler.InMemoryJavaCompiler.CompilationError) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) ClassB(ast.ExpCore.ClassB) InterfaceHeader(ast.Ast.InterfaceHeader) Map(java.util.Map) Facade(reduction.Facade) PathMwt(ast.Util.PathMwt) MapClassLoader(platformSpecific.inMemoryCompiler.InMemoryJavaCompiler.MapClassLoader) Method(java.lang.reflect.Method) IsCompiled(coreVisitors.IsCompiled) NestedClass(ast.ExpCore.ClassB.NestedClass) Files(java.nio.file.Files) Path(ast.Ast.Path) Doc(ast.Ast.Doc) Phase(ast.ExpCore.ClassB.Phase) IOException(java.io.IOException) ExpCore(ast.ExpCore) Member(ast.ExpCore.ClassB.Member) Functions(auxiliaryGrammar.Functions) InvocationTargetException(java.lang.reflect.InvocationTargetException) Util(ast.Util) Consumer(java.util.function.Consumer) List(java.util.List) EmptyProgram(programReduction.Program.EmptyProgram) Paths(java.nio.file.Paths) Optional(java.util.Optional) SourceFile(platformSpecific.inMemoryCompiler.InMemoryJavaCompiler.SourceFile) Timer(profiling.Timer) InMemoryJavaCompiler(platformSpecific.inMemoryCompiler.InMemoryJavaCompiler) Collections(java.util.Collections) L42(facade.L42) ArrayList(java.util.ArrayList) Member(ast.ExpCore.ClassB.Member) PathMwt(ast.Util.PathMwt) ClassB(ast.ExpCore.ClassB)

Aggregations

Ast (ast.Ast)1 Doc (ast.Ast.Doc)1 InterfaceHeader (ast.Ast.InterfaceHeader)1 Path (ast.Ast.Path)1 Stage (ast.Ast.Stage)1 Type (ast.Ast.Type)1 ExpCore (ast.ExpCore)1 ClassB (ast.ExpCore.ClassB)1 Member (ast.ExpCore.ClassB.Member)1 NestedClass (ast.ExpCore.ClassB.NestedClass)1 Phase (ast.ExpCore.ClassB.Phase)1 Util (ast.Util)1 PathMwt (ast.Util.PathMwt)1 Functions (auxiliaryGrammar.Functions)1 From (coreVisitors.From)1 IsCompiled (coreVisitors.IsCompiled)1 Configuration (facade.Configuration)1 L42 (facade.L42)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1