Package com.asakusafw.utils.java.model.syntax

Examples of com.asakusafw.utils.java.model.syntax.Expression


            if (data == null) {
                environment.error("{0}のデータモデルを解析できませんでした", type);
                data = new DataClass.Unresolved(factory, type);
            }
            Type domType = importer.toType(type);
            Expression cache = addField(
                    domType,
                    "cache",
                    data.createNewInstance(domType));
            return new DataObjectMirror(factory, cache, data);
        }
View Full Code Here


            Type elementType = importer.toType(type);
            Class<?> bufferType = inputBufferTypeFromKind(bufferKind);
            Type listType = importer.resolve(factory.newParameterizedType(
                    Models.toType(factory, bufferType),
                    Collections.singletonList(elementType)));
            Expression list = addField(
                    listType,
                    "list",
                    new TypeBuilder(factory, listType)
                        .newObject()
                        .toExpression());
View Full Code Here

        assert context != null;
        ModelFactory f = context.getModelFactory();
        OperatorDescription desc = context.getOperatorDescription();
        FlowElementPortDescription master = desc.getInputPorts().get(0);

        Expression hasMaster = context.createField(boolean.class, "sawMaster");
        DataObjectMirror masterCache = context.createModelCache(master.getDataType());
        context.addBegin(new ExpressionBuilder(f, hasMaster)
            .assignFrom(Models.toLiteral(f, false))
            .toStatement());
        context.addProcess(master, f.newIfStatement(
View Full Code Here

        FlowElementPortDescription master = desc.getInputPorts().get(0);
        FlowElementPortDescription tx = desc.getInputPorts().get(1);

        ListBufferMirror list = context.createListBuffer(master.getDataType(), InputBuffer.EXPAND);
        context.addBegin(list.createBegin());
        Expression proc = context.getProcessInput(master);
        context.addProcess(master, list.createAdvance(proc));
        context.addEnd(list.createEnd());

        List<Expression> arguments = Lists.create();
        arguments.add(list.get());
        arguments.add(context.getProcessInput(tx));
        for (OperatorDescription.Parameter param : desc.getParameters()) {
            arguments.add(Models.toLiteral(f, param.getValue()));
        }
        assert selector.getParameterTypes().size() <= arguments.size();
        if (selector.getParameterTypes().size() <= arguments.size()) {
            arguments = arguments.subList(0, selector.getParameterTypes().size());
        }

        context.addProcess(tx, list.createEnd());
        Expression impl = context.createImplementation();
        SimpleName selected = context.createName("selected");
        context.addProcess(tx, new ExpressionBuilder(f, impl)
            .method(selector.getName(), arguments)
            .toLocalVariableDeclaration(
                    context.convert(master.getDataType()),
View Full Code Here

    private void processMasterFirst(LineEndProcessor.Context context) {
        assert context != null;
        ModelFactory f = context.getModelFactory();

        Expression lookup = createLookup(context, f);

        this.hasMasterExpresion = new ExpressionBuilder(f, lookup)
            .method("isEmpty")
            .apply(InfixOperator.EQUALS, Models.toLiteral(f, false))
            .toExpression();
View Full Code Here

            LineEndProcessor.Context context,
            OperatorHelper selector) {
        assert context != null;
        assert selector != null;
        ModelFactory f = context.getModelFactory();
        Expression lookup = createLookup(context, f);
        Expression selected = context.createLocalVariable(
                resource.getMasterDataClass().getType(),
                Models.toNullLiteral(f));
        List<Expression> arguments = Lists.create();
        arguments.add(lookup);
        arguments.add(context.getInput());
        for (OperatorDescription.Parameter param : context.getOperatorDescription().getParameters()) {
            arguments.add(Models.toLiteral(f, param.getValue()));
        }
        assert selector.getParameterTypes().size() <= arguments.size();
        if (selector.getParameterTypes().size() <= arguments.size()) {
            arguments = arguments.subList(0, selector.getParameterTypes().size());
        }
        Expression impl = context.createImplementation();
        context.add(f.newIfStatement(
                new ExpressionBuilder(f, lookup)
                    .apply(InfixOperator.NOT_EQUALS, Models.toNullLiteral(f))
                    .toExpression(),
                f.newBlock(new ExpressionBuilder(f, selected)
View Full Code Here

    }

    private Expression createLookup(LineEndProcessor.Context context, ModelFactory f) {
        assert context != null;
        assert f != null;
        Expression lookup = context.createLocalVariable(
                context.simplify(new TypeBuilder(f, Models.toType(f, List.class))
                    .parameterize(Models.toType(f, resource.getMasterDataClass().getType()))
                    .toType()),
                new ExpressionBuilder(f, context.getResource(resource))
                    .method("find", context.getInput())
View Full Code Here

        ModelFactory f = context.getModelFactory();

        FlowElementPortDescription input = context.getInputPort(Summarize.ID_INPUT);
        FlowElementPortDescription output = context.getOutputPort(Summarize.ID_OUTPUT);

        Expression init = context.createField(boolean.class, "initialized");
        context.addBegin(new ExpressionBuilder(f, init)
            .assignFrom(Models.toLiteral(f, false))
            .toStatement());

        DataObjectMirror cache = context.createModelCache(output.getDataType());
View Full Code Here

        assert context != null;
        assert folding != null;
        assert summarizing != null;
        assert outputCache != null;
        Property property = summarizing.findProperty(folding.destination());
        Expression input = context.getProcessInput(context.getInputPort(Summarize.ID_INPUT));
        ModelFactory f = context.getModelFactory();
        // TODO for only DMDL
        switch (folding.aggregator()) {
        case MAX:
            return new ExpressionBuilder(f, property.createGetter(outputCache))
View Full Code Here

            List<Statement> statements = Lists.create();
            statements.add(new TypeBuilder(factory, t(ArrayList.class, t(StageOutput.class)))
                .newObject()
                .toLocalVariableDeclaration(t(List.class, t(StageOutput.class)), list));
            for (ResolvedSlot slot : slots) {
                Expression valueType = factory.newClassLiteral(t(slot.getValueClass().getType()));
                Class<?> outputFormatType = slot.getSource().getOutputFormatType();
                statements.add(new ExpressionBuilder(factory, list)
                    .method("add", new TypeBuilder(factory, t(StageOutput.class))
                        .newObject(
                                Models.toLiteral(factory, slot.getSource().getOutputName()),
View Full Code Here

TOP

Related Classes of com.asakusafw.utils.java.model.syntax.Expression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.