Search in sources :

Example 11 with ClassB

use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.

the class MethodPathCloneVisitor method visit.

public ExpCore visit(MCall s) {
    Program ep = p;
    for (ClassB cbi : this.getLocator().getCbs()) {
        if (cbi != null) {
            ep = ep.evilPush(cbi);
        }
    }
    MethodSelector ms = s.getS();
    Path guessed = null;
    try {
        TIn in = TIn.top(Phase.Typed, ep, s.getInner());
        in = in.withG(varEnv.entrySet().stream().collect(Collectors.toMap(me -> me.getKey(), me -> new java.util.AbstractMap.SimpleEntry<>(false, me.getValue()))));
        Type tGuessed = newTypeSystem.GuessTypeCore._of(in.p, in, s.getInner());
        if (tGuessed == null) {
            return super.visit(s);
        }
        guessed = tGuessed.getPath();
        assert guessed != null;
    } catch (NormImpossible ignored) {
        return super.visit(s);
    }
    MethodSelector ms2 = visitMS(ms, guessed);
    if (ms2.equals(ms)) {
        return super.visit(s);
    }
    s = new MCall(s.getInner(), ms2, s.getDoc(), s.getEs(), s.getP());
    return super.visit(s);
}
Also used : Path(ast.Ast.Path) From(coreVisitors.From) GuessTypeCore(newTypeSystem.GuessTypeCore) Program(programReduction.Program) Ast(ast.Ast) MCall(ast.ExpCore.MCall) Map(tools.Map) Type(ast.Ast.Type) Configuration(facade.Configuration) HashMap(java.util.HashMap) Assertions(tools.Assertions) MethodWithType(ast.ExpCore.ClassB.MethodWithType) MethodSelector(ast.Ast.MethodSelector) ArrayList(java.util.ArrayList) ClassB(ast.ExpCore.ClassB) NormImpossible(ast.ErrorMessage.NormImpossible) Norm(programReduction.Norm) On(ast.ExpCore.Block.On) Path(ast.Ast.Path) Doc(ast.Ast.Doc) Phase(ast.ExpCore.ClassB.Phase) MethodSelectorX(ast.Ast.MethodSelectorX) ExpCore(ast.ExpCore) Member(ast.ExpCore.ClassB.Member) Collectors(java.util.stream.Collectors) Block(ast.ExpCore.Block) Functions(auxiliaryGrammar.Functions) List(java.util.List) TIn(newTypeSystem.TIn) Optional(java.util.Optional) Dec(ast.ExpCore.Block.Dec) Collections(java.util.Collections) MethodImplemented(ast.ExpCore.ClassB.MethodImplemented) MethodSelector(ast.Ast.MethodSelector) Type(ast.Ast.Type) MethodWithType(ast.ExpCore.ClassB.MethodWithType) Program(programReduction.Program) MCall(ast.ExpCore.MCall) TIn(newTypeSystem.TIn) NormImpossible(ast.ErrorMessage.NormImpossible) ClassB(ast.ExpCore.ClassB)

Example 12 with ClassB

use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.

the class Plugin method MmoveImplementation£xthat£xpath£xsrc£xdest.

@ActionType({ ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library })
public Object MmoveImplementation£xthat£xpath£xsrc£xdest(Object _that, Object _path, Object _sel1, Object _sel2) {
    try {
        ClassB that = ensureExtractClassB(_that);
        //assert that.getStage().isInheritedComputed();
        List<Ast.C> path = PathAux.parseValidCs(ensureExtractStringU(_path));
        MethodSelector sel1 = MethodSelector.parse(ensureExtractStringU(_sel1));
        MethodSelector sel2 = MethodSelector.parse(ensureExtractStringU(_sel2));
        return Abstract.toAbstract(Resources.getP(), that, path, sel1, sel2);
    } catch (RuntimeException rte) {
        //to put breakpoint
        throw rte;
    }
}
Also used : MethodSelector(ast.Ast.MethodSelector) ClassB(ast.ExpCore.ClassB) EncodingHelper.ensureExtractClassB(auxiliaryGrammar.EncodingHelper.ensureExtractClassB) ActionType(platformSpecific.fakeInternet.ActionType)

Example 13 with ClassB

use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.

the class Plugin method Mredirect£xthat£xsrc£xdest.

@ActionType({ ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.TypeAny })
public Object Mredirect£xthat£xsrc£xdest(Object _that, Object _src, Object _dest) {
    ClassB that = ensureExtractClassB(_that);
    List<Ast.C> src = PathAux.parseValidCs(ensureExtractStringU(_src));
    Path dest = ensureExtractPathFromJava(_dest);
    assert dest.isCore() || dest.isPrimitive() : dest;
    //TODO: see if extractPath should be changed
    if (dest.isCore()) {
        dest = dest.setNewOuter(dest.outerNumber() + 1);
    }
    return Redirect.redirect(Resources.getP(), that, Path.outer(0, src), dest);
}
Also used : Path(ast.Ast.Path) ClassB(ast.ExpCore.ClassB) EncodingHelper.ensureExtractClassB(auxiliaryGrammar.EncodingHelper.ensureExtractClassB) ActionType(platformSpecific.fakeInternet.ActionType)

Example 14 with ClassB

use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.

the class Plugin method MmakeMethod£xthat£xpath£xselector£xmdfs£xexceptionN.

@ActionType({ ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library })
public Object MmakeMethod£xthat£xpath£xselector£xmdfs£xexceptionN(Object _lib, Object _path, Object _selector, Object _mdfs, Object _execptionN) {
    ClassB lib = ensureExtractClassB(_lib);
    List<Ast.C> path = PathAux.parseValidCs(ensureExtractStringU(_path));
    MethodSelector selector = MethodSelector.parse(ensureExtractStringU(_selector));
    String mdfs = ensureExtractStringU(_mdfs);
    int exceptionN = ensureExtractInt32(_execptionN);
    return MakeMethod.addMethod(lib, path, selector, mdfs, exceptionN);
}
Also used : MethodSelector(ast.Ast.MethodSelector) ClassB(ast.ExpCore.ClassB) EncodingHelper.ensureExtractClassB(auxiliaryGrammar.EncodingHelper.ensureExtractClassB) ActionType(platformSpecific.fakeInternet.ActionType)

Example 15 with ClassB

use of ast.ExpCore.ClassB in project L42 by ElvisResearchGroup.

the class Plugin method MaddKs£xthat£xpath£xfields£xmutK£xlentK£xreadK£ximmK£xisFwd.

@ActionType({ ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library })
public Object MaddKs£xthat£xpath£xfields£xmutK£xlentK£xreadK£ximmK£xisFwd(Object _that, Object _path, Object _fields, Object _mutK, Object _lentK, Object _readK, Object _immK, Object _fwd) {
    ClassB that = ensureExtractClassB(_that);
    List<Ast.C> path = PathAux.parseValidCs(ensureExtractStringU(_path));
    String[] fieldNames = ensureExtractStringU(_fields).split(",");
    String mutK = ensureExtractStringU(_mutK);
    String lentK = ensureExtractStringU(_lentK);
    String readK = ensureExtractStringU(_readK);
    String immK = ensureExtractStringU(_immK);
    boolean fwd = ensureExtractInt32(_fwd) == 0 ? false : true;
    return MakeKs.makeKs(that, path, Arrays.asList(fieldNames), mutK, lentK, readK, immK, fwd);
}
Also used : ClassB(ast.ExpCore.ClassB) EncodingHelper.ensureExtractClassB(auxiliaryGrammar.EncodingHelper.ensureExtractClassB) ActionType(platformSpecific.fakeInternet.ActionType)

Aggregations

ClassB (ast.ExpCore.ClassB)107 ArrayList (java.util.ArrayList)33 Path (ast.Ast.Path)30 ExpCore (ast.ExpCore)25 Member (ast.ExpCore.ClassB.Member)25 EncodingHelper.ensureExtractClassB (auxiliaryGrammar.EncodingHelper.ensureExtractClassB)20 Program (programReduction.Program)20 Ast (ast.Ast)19 MethodWithType (ast.ExpCore.ClassB.MethodWithType)19 MethodSelector (ast.Ast.MethodSelector)18 NestedClass (ast.ExpCore.ClassB.NestedClass)18 List (java.util.List)17 ActionType (platformSpecific.fakeInternet.ActionType)16 Doc (ast.Ast.Doc)12 Type (ast.Ast.Type)12 ErrorMessage (ast.ErrorMessage)12 Optional (java.util.Optional)10 C (ast.Ast.C)9 MethodType (ast.Ast.MethodType)8 Phase (ast.ExpCore.ClassB.Phase)8