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

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


                for (Term term : segment.getTerms()) {
                    if (term.getArrangement() != Arrangement.GROUPING) {
                        continue;
                    }
                    String name = ShuffleEmiterUtil.getPropertyName(segment, term);
                    Expression rhs = term.getSource().createValueDiff(
                            new ExpressionBuilder(factory, o1)
                                .field(name)
                                .toExpression(),
                            new ExpressionBuilder(factory, o2)
                                .field(name)
                                .toExpression());
                    cases.add(new ExpressionBuilder(factory, diff)
                        .assignFrom(rhs)
                        .toStatement());
                    cases.add(createDiff(diff));
                }
                cases.add(factory.newBreakStatement());
            }
            cases.add(factory.newSwitchDefaultLabel());
            cases.add(createAssertionError());

            statements.add(factory.newSwitchStatement(segmentId1, cases));

            statements.add(new ExpressionBuilder(factory, diff)
                .assignFrom(new ExpressionBuilder(factory, factory.newThis())
                    .method(ShuffleEmiterUtil.COMPARE_INT,
                            segmentId1,
                            segmentId2)
                    .toExpression())
                .toStatement());
            statements.add(createDiff(diff));

            cases = Lists.create();
            for (Segment segment : model.getSegments()) {
                cases.add(factory.newSwitchCaseLabel(v(segment.getPortId())));
                for (Term term : segment.getTerms()) {
                    if (term.getArrangement() == Arrangement.GROUPING) {
                        continue;
                    }
                    String name = ShuffleEmiterUtil.getPropertyName(segment, term);
                    Expression rhs = term.getSource().createValueDiff(
                            new ExpressionBuilder(factory, o1)
                                .field(name)
                                .toExpression(),
                            new ExpressionBuilder(factory, o2)
                                .field(name)
View Full Code Here


        }

        private MethodDeclaration createWriteMethod() {
            SimpleName out = factory.newSimpleName("out");

            Expression segmentId = new ExpressionBuilder(factory, factory.newThis())
                .field(PORT_ID_FIELD_NAME)
                .toExpression();

            List<Statement> cases = Lists.create();
            for (Segment segment : model.getSegments()) {
View Full Code Here

        }

        private MethodDeclaration createReadFieldsMethod() {
            SimpleName in = factory.newSimpleName("in");

            Expression segmentId = new ExpressionBuilder(factory, factory.newThis())
                .field(PORT_ID_FIELD_NAME)
                .toExpression();

            List<Statement> statements = Lists.create();
            statements.add(new ExpressionBuilder(factory, segmentId)
View Full Code Here

        if (sourceType == null || sinkType == null) {
            return;
        }

        context.add(cache.createReset());
        Expression inputObject = context.getInput();
        Expression outputObject = cache.get();
        for (DataClass.Property sourceProperty : sourceType.getProperties()) {
            Property sinkProperty = sinkType.findProperty(sourceProperty.getName());
            if (sinkProperty == null) {
                getEnvironment().error(
                        "{0}において、{2}.{3}に対応するプロパティが{1}に定義されていません",
View Full Code Here

            return statement;
        }

        @Override
        public Expression createNewInstance(Type type) {
            Expression expression = Models.toNullLiteral(factory);
            expression.putModelTrait(CommentEmitTrait.class, new CommentEmitTrait(Arrays.asList(
                    MessageFormat.format(
                            "Failed to resolve in \"createNewInstance\": {0}",
                            runtimeType)
            )));
            return expression;
View Full Code Here

        Joined annotation = TypeUtil.erase(joinedPort.getDataType()).getAnnotation(Joined.class);
        Set<String> saw = Sets.create();
        for (Joined.Term term : annotation.terms()) {
            DataClass inputType = getEnvironment().getDataClasses().load(term.source());
            Expression input;
            if (term.source().equals(context.getInputPort(MasterJoin.ID_INPUT_MASTER).getDataType())) {
                input = masterAnalyzer.getGetRawMasterExpression();
            } else {
                input = context.getProcessInput(tx);
            }
View Full Code Here

        if (sourceType == null || sinkType == null) {
            return;
        }

        context.add(cache.createReset());
        Expression inputObject = context.getInput();
        Expression outputObject = cache.get();
        for (DataClass.Property sinkProperty : sinkType.getProperties()) {
            Property sourceProperty = sourceType.findProperty(sinkProperty.getName());
            if (sourceProperty == null) {
                getEnvironment().error(
                        "{0}において、{2}.{3}に対応するプロパティが{1}に定義されていません",
View Full Code Here

        OperatorDescription desc = context.getOperatorDescription();

        FlowElementPortDescription input = context.getInputPort(Fold.ID_INPUT);
        FlowElementPortDescription output = context.getOutputPort(Fold.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());
        Expression impl = context.createImplementation();
        Expression proc = context.getProcessInput(input);
        List<Expression> arguments = Lists.create();
        arguments.add(cache.get());
        arguments.add(proc);
        for (OperatorDescription.Parameter param : desc.getParameters()) {
            arguments.add(Models.toLiteral(f, param.getValue()));
View Full Code Here

            statements.add(new ExpressionBuilder(factory, builderName)
                .method("addInput", arguments)
                .toStatement());
        }
        for (OperatorPortDeclaration var : descriptor.getOutputPorts()) {
            Expression type = toExpression(var);
            statements.add(new ExpressionBuilder(factory, builderName)
                .method("addOutput", util.v(var.getName()), type)
                .toStatement());
        }
        for (OperatorPortDeclaration var : descriptor.getParameters()) {
            Expression type = toExpression(var);
            statements.add(new ExpressionBuilder(factory, builderName)
                .method("addParameter",
                        util.v(var.getName()),
                        type,
                        factory.newSimpleName(var.getName()))
                .toStatement());
        }
        for (Expression attr : descriptor.getAttributes()) {
            statements.add(new ExpressionBuilder(factory, builderName)
                .method("addAttribute", attr)
                .toStatement());
        }
        Expression resolver = new ExpressionBuilder(factory, factory.newThis())
            .field(RESOLVER_FIELD_NAME)
            .toExpression();
        statements.add(new ExpressionBuilder(factory, resolver)
            .assignFrom(new ExpressionBuilder(factory, builderName)
                .method("toResolver")
View Full Code Here

        }
        return statements;
    }

    private Expression toExpression(OperatorPortDeclaration var) throws AssertionError {
        Expression type;
        switch (var.getType().getKind()) {
        case DIRECT:
            type = factory.newClassLiteral(util.t(environment.getErasure(var.getType().getDirect())));
            break;
        case REFERENCE:
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.