Search in sources :

Example 1 with Declare1ParameterFunExpr

use of suite.jdk.gen.FunExprK.Declare1ParameterFunExpr in project suite by stupidsing.

the class FunFactory method parameter1.

public FunExpr parameter1(Iterate<FunExpr> doFun) {
    PlaceholderFunExpr parameter = new PlaceholderFunExpr();
    Declare1ParameterFunExpr expr = new Declare1ParameterFunExpr();
    expr.parameter = parameter;
    expr.do_ = doFun.apply(parameter);
    return expr;
}
Also used : Declare1ParameterFunExpr(suite.jdk.gen.FunExprK.Declare1ParameterFunExpr) PlaceholderFunExpr(suite.jdk.gen.FunExprK.PlaceholderFunExpr)

Example 2 with Declare1ParameterFunExpr

use of suite.jdk.gen.FunExprK.Declare1ParameterFunExpr in project suite by stupidsing.

the class FunExpand method expand_.

private FunExpr expand_(FunExpr e0, int depth) {
    return // 
    e0.<// 
    FunExpr>switch_().applyIf(ApplyFunExpr.class, e1 -> {
        FunExpr object0 = e1.object;
        FunExpr object1 = object0 instanceof CastFunExpr ? ((CastFunExpr) object0).expr : object0;
        if (object1 instanceof Declare0ParameterFunExpr) {
            Declare0ParameterFunExpr object_ = (Declare0ParameterFunExpr) object1;
            return expand(object_.do_, depth);
        } else if (object1 instanceof Declare1ParameterFunExpr) {
            Declare1ParameterFunExpr object_ = (Declare1ParameterFunExpr) object1;
            return expand(replace(object_.do_, object_.parameter, e1.parameters.get(0)), depth);
        } else if (object1 instanceof Declare2ParameterFunExpr) {
            Declare2ParameterFunExpr object_ = (Declare2ParameterFunExpr) object1;
            FunExpr do0 = object_.do_;
            FunExpr do1 = replace(do0, object_.p0, e1.parameters.get(0));
            FunExpr do2 = replace(do1, object_.p1, e1.parameters.get(1));
            return expand(do2, depth);
        } else
            return null;
    }).applyIf(DeclareLocalFunExpr.class, e1 -> {
        return expand(replace(e1.do_, e1.var, e1.value), depth);
    }).applyIf(InvokeLambdaFunExpr.class, e1 -> {
        if (Boolean.FALSE) {
            LambdaInstance<?> l_inst = e1.lambda;
            LambdaImplementation<?> l_impl = l_inst.lambdaImplementation;
            if (e1.isExpand || weight(l_impl.expr) <= 5) {
                LambdaInterface<?> l_iface = l_impl.lambdaInterface;
                FunExpr fe = l_impl.expr;
                for (String fieldName : l_impl.fieldTypes.keySet()) fe = replaceFieldInject(fe, fieldName, object(l_inst.fieldValues.get(fieldName), l_impl.fieldTypes.get(fieldName)));
                return expand(fe.cast_(l_iface.interfaceClass).apply(e1.parameters), depth - 1);
            } else
                return null;
        } else
            return null;
    }).applyIf(If1FunExpr.class, e1 -> {
        FunExpr if_ = e1.if_;
        if (if_ instanceof ConstantFunExpr) {
            ConstantFunExpr e2 = (ConstantFunExpr) if_;
            if (e2.type == Type.INT)
                return ((Integer) e2.constant).intValue() != 0 ? e1.then : e1.else_;
            else
                return null;
        } else
            return null;
    }).result();
}
Also used : DeclareLocalFunExpr(suite.jdk.gen.FunExprL.DeclareLocalFunExpr) Read(suite.streamlet.Read) Singleton(suite.node.util.Singleton) Inspect(suite.inspect.Inspect) ConstantFunExpr(suite.jdk.gen.FunExprM.ConstantFunExpr) If1FunExpr(suite.jdk.gen.FunExprM.If1FunExpr) InvokeLambdaFunExpr(suite.jdk.gen.FunExprL.InvokeLambdaFunExpr) Declare2ParameterFunExpr(suite.jdk.gen.FunExprK.Declare2ParameterFunExpr) ApplyFunExpr(suite.jdk.gen.FunExprL.ApplyFunExpr) LambdaImplementation(suite.jdk.lambda.LambdaImplementation) FieldInjectFunExpr(suite.jdk.gen.FunExprL.FieldInjectFunExpr) Obj_Int(suite.primitive.IntPrimitives.Obj_Int) String_(suite.util.String_) Declare0ParameterFunExpr(suite.jdk.gen.FunExprK.Declare0ParameterFunExpr) Declare1ParameterFunExpr(suite.jdk.gen.FunExprK.Declare1ParameterFunExpr) Rethrow(suite.util.Rethrow) LambdaInstance(suite.jdk.lambda.LambdaInstance) Type(org.apache.bcel.generic.Type) CastFunExpr(suite.jdk.gen.FunExprM.CastFunExpr) FunExpr(suite.jdk.gen.FunExpression.FunExpr) FunFactory(suite.jdk.gen.FunFactory) LambdaInterface(suite.jdk.lambda.LambdaInterface) Declare1ParameterFunExpr(suite.jdk.gen.FunExprK.Declare1ParameterFunExpr) CastFunExpr(suite.jdk.gen.FunExprM.CastFunExpr) Declare2ParameterFunExpr(suite.jdk.gen.FunExprK.Declare2ParameterFunExpr) ConstantFunExpr(suite.jdk.gen.FunExprM.ConstantFunExpr) If1FunExpr(suite.jdk.gen.FunExprM.If1FunExpr) Declare0ParameterFunExpr(suite.jdk.gen.FunExprK.Declare0ParameterFunExpr) DeclareLocalFunExpr(suite.jdk.gen.FunExprL.DeclareLocalFunExpr) DeclareLocalFunExpr(suite.jdk.gen.FunExprL.DeclareLocalFunExpr) ConstantFunExpr(suite.jdk.gen.FunExprM.ConstantFunExpr) If1FunExpr(suite.jdk.gen.FunExprM.If1FunExpr) InvokeLambdaFunExpr(suite.jdk.gen.FunExprL.InvokeLambdaFunExpr) Declare2ParameterFunExpr(suite.jdk.gen.FunExprK.Declare2ParameterFunExpr) ApplyFunExpr(suite.jdk.gen.FunExprL.ApplyFunExpr) FieldInjectFunExpr(suite.jdk.gen.FunExprL.FieldInjectFunExpr) Declare0ParameterFunExpr(suite.jdk.gen.FunExprK.Declare0ParameterFunExpr) Declare1ParameterFunExpr(suite.jdk.gen.FunExprK.Declare1ParameterFunExpr) CastFunExpr(suite.jdk.gen.FunExprM.CastFunExpr) FunExpr(suite.jdk.gen.FunExpression.FunExpr)

Aggregations

Declare1ParameterFunExpr (suite.jdk.gen.FunExprK.Declare1ParameterFunExpr)2 Type (org.apache.bcel.generic.Type)1 Inspect (suite.inspect.Inspect)1 Declare0ParameterFunExpr (suite.jdk.gen.FunExprK.Declare0ParameterFunExpr)1 Declare2ParameterFunExpr (suite.jdk.gen.FunExprK.Declare2ParameterFunExpr)1 PlaceholderFunExpr (suite.jdk.gen.FunExprK.PlaceholderFunExpr)1 ApplyFunExpr (suite.jdk.gen.FunExprL.ApplyFunExpr)1 DeclareLocalFunExpr (suite.jdk.gen.FunExprL.DeclareLocalFunExpr)1 FieldInjectFunExpr (suite.jdk.gen.FunExprL.FieldInjectFunExpr)1 InvokeLambdaFunExpr (suite.jdk.gen.FunExprL.InvokeLambdaFunExpr)1 CastFunExpr (suite.jdk.gen.FunExprM.CastFunExpr)1 ConstantFunExpr (suite.jdk.gen.FunExprM.ConstantFunExpr)1 If1FunExpr (suite.jdk.gen.FunExprM.If1FunExpr)1 FunExpr (suite.jdk.gen.FunExpression.FunExpr)1 FunFactory (suite.jdk.gen.FunFactory)1 LambdaImplementation (suite.jdk.lambda.LambdaImplementation)1 LambdaInstance (suite.jdk.lambda.LambdaInstance)1 LambdaInterface (suite.jdk.lambda.LambdaInterface)1 Singleton (suite.node.util.Singleton)1 Obj_Int (suite.primitive.IntPrimitives.Obj_Int)1