Search in sources :

Example 46 with MethodType

use of ast.Ast.MethodType in project L42 by ElvisResearchGroup.

the class Test212_or_170_MethodTypes method testMapAll.

@Test
public void testMapAll() {
    List<Map<MethodType, String>> maps = new ArrayList<>();
    for (MethodType mt : dataSet) {
        maps.add(fixMap(mt));
    }
    maps.stream().sorted((m1, m2) -> m1.size() - m2.size()).forEach(map -> {
        System.out.println(mapToS(map));
    });
}
Also used : TestProgram(programReduction.TestProgram) WellFormednessCore(auxiliaryGrammar.WellFormednessCore) Arrays(java.util.Arrays) Program(programReduction.Program) Path(ast.Ast.Path) Collection(java.util.Collection) Type(ast.Ast.Type) Set(java.util.Set) HashMap(java.util.HashMap) Test(org.junit.Test) MethodType(ast.Ast.MethodType) Collectors(java.util.stream.Collectors) Functions(auxiliaryGrammar.Functions) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) List(java.util.List) Map(java.util.Map) Assert(org.junit.Assert) Collections(java.util.Collections) AlternativeMethodTypes(newTypeSystem.AlternativeMethodTypes) Mdf(ast.Ast.Mdf) MethodType(ast.Ast.MethodType) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 47 with MethodType

use of ast.Ast.MethodType in project L42 by ElvisResearchGroup.

the class SumMethods method mtU.

static MethodType mtU(int index, MethodType mt1, MethodType mt2) {
    Mdf mdfU = mdfU(mt1.getMdf(), mt2.getMdf());
    if (mdfU == null) {
        return null;
    }
    Type removed = mt2.getTs().get(index);
    boolean isRemovedPh = !Functions.isComplete(removed);
    List<Type> totTypes;
    if (isRemovedPh) {
        totTypes = new ArrayList<>(mt1.getTs());
    } else {
        totTypes = mt1.getTs().stream().map(t -> TypeManipulation.noFwd(t)).collect(Collectors.toList());
    }
    totTypes.addAll(mt2.getTs());
    int toRemove = mt1.getTs().size() + index;
    totTypes.remove(toRemove);
    List<Type> exU = new ArrayList<>(mt1.getExceptions());
    exU.addAll(mt2.getExceptions());
    MethodType mtU = new MethodType(false, mdfU, totTypes, mt2.getReturnType(), exU);
    return mtU;
}
Also used : MethodType(ast.Ast.MethodType) Type(ast.Ast.Type) MethodType(ast.Ast.MethodType) MethodWithType(ast.ExpCore.ClassB.MethodWithType) Mdf(ast.Ast.Mdf)

Example 48 with MethodType

use of ast.Ast.MethodType in project L42 by ElvisResearchGroup.

the class MakeKs method prototypeK.

//can not reuse the desugar one, here we create ExpCore stuff, also , the sugar one may disappear
private static MethodWithType prototypeK(Doc doc, List<String> fieldNames, List<Type> fieldTypes, Position pos) {
    MethodSelector ms = MethodSelector.of("", fieldNames);
    Type resT = Type.mutThis0;
    MethodType mt = new MethodType(false, ast.Ast.Mdf.Class, fieldTypes, resT, Collections.emptyList());
    return new MethodWithType(doc, ms, mt, Optional.empty(), pos);
}
Also used : MethodType(ast.Ast.MethodType) MethodSelector(ast.Ast.MethodSelector) Type(ast.Ast.Type) MethodType(ast.Ast.MethodType)

Aggregations

MethodType (ast.Ast.MethodType)48 Type (ast.Ast.Type)32 MethodWithType (ast.ExpCore.ClassB.MethodWithType)25 Mdf (ast.Ast.Mdf)14 MethodSelector (ast.Ast.MethodSelector)14 ArrayList (java.util.ArrayList)14 Path (ast.Ast.Path)10 ExpCore (ast.ExpCore)9 List (java.util.List)9 Collections (java.util.Collections)8 Functions (auxiliaryGrammar.Functions)7 Test (org.junit.Test)7 Doc (ast.Ast.Doc)6 MethodWithType (ast.Expression.ClassB.MethodWithType)6 HashMap (java.util.HashMap)6 Program (programReduction.Program)6 Ast (ast.Ast)5 ClassB (ast.ExpCore.ClassB)5 Member (ast.ExpCore.ClassB.Member)5 Optional (java.util.Optional)5