Package com.asakusafw.compiler.operator

Examples of com.asakusafw.compiler.operator.OperatorPortDeclaration


        List<? extends DocElement> documentation = analyzer.getDocument(aClass);
        List<OperatorPortDeclaration> inputPorts = Lists.create();
        List<OperatorPortDeclaration> outputPorts = Lists.create();
        List<OperatorPortDeclaration> parameters = Lists.create();
        for (int i = 0, n = analyzer.countParameters(); i < n; i++) {
            OperatorPortDeclaration port = analyzePort(analyzer, i);
            if (port == null) {
                continue;
            } else if (port.getKind() == OperatorPortDeclaration.Kind.INPUT) {
                inputPorts.add(port);
            } else if (port.getKind() == OperatorPortDeclaration.Kind.OUTPUT) {
                outputPorts.add(port);
            } else {
                parameters.add(port);
            }
        }
View Full Code Here


        assert outputPorts != null;
        assert parameters != null;
        List<OperatorPortDeclaration> inferred = Lists.create();
        for (OperatorPortDeclaration output : outputPorts) {
            if (output.getType().getRepresentation().getKind() != TypeKind.TYPEVAR) {
                inferred.add(new OperatorPortDeclaration(
                        output.getKind(),
                        output.getDocumentation(),
                        output.getName(),
                        PortTypeDescription.direct(output.getType().getRepresentation()),
                        output.getParameterPosition(),
                        null));
            } else {
                OperatorPortDeclaration outputType = inferOutputType(output, inputPorts, parameters);
                if (outputType != null) {
                    inferred.add(outputType);
                } else {
                    analyzer.error(
                            output.getParameterPosition(),
View Full Code Here

        assert parameters != null;
        Types types = environment.getTypeUtils();
        TypeMirror outputType = output.getType().getRepresentation();
        for (OperatorPortDeclaration input : inputPorts) {
            if (types.isSameType(outputType, input.getType().getRepresentation())) {
                return new OperatorPortDeclaration(
                        output.getKind(),
                        output.getDocumentation(),
                        output.getName(),
                        PortTypeDescription.reference(outputType, input.getName()),
                        output.getParameterPosition(),
                        null);
            }
        }
        DeclaredType classType = environment.getDeclaredType(Class.class);
        for (OperatorPortDeclaration param : parameters) {
            // check is form of M<T>
            TypeMirror paramType = param.getType().getRepresentation();
            if (paramType.getKind() != TypeKind.DECLARED) {
                continue;
            }
            DeclaredType declParamType = (DeclaredType) paramType;
            if (declParamType.getTypeArguments().size() != 1) {
                continue;
            }
            // check is <: Class<?>
            if (types.isSameType(environment.getErasure(paramType), classType) == false) {
                continue;
            }
            if (types.isSameType(declParamType.getTypeArguments().get(0), outputType)) {
                return new OperatorPortDeclaration(
                        output.getKind(),
                        output.getDocumentation(),
                        output.getName(),
                        PortTypeDescription.reference(outputType, param.getName()),
                        output.getParameterPosition(),
View Full Code Here

        TypeConstraint dataType = type.getTypeArgument();
        if (dataType.isModel() == false) {
            analyzer.error(index, "モデルオブジェクト型以外は入出力に指定できません");
            return null;
        }
        return new OperatorPortDeclaration(
                kind,
                analyzer.getParameterDocument(index),
                analyzer.getParameterName(index),
                PortTypeDescription.reference(dataType.getType(), analyzer.getParameterName(index)),
                index,
View Full Code Here

        assert type != null;
        if (type.isOperator()) {
            analyzer.error(index, "演算子オブジェクトは引数に直接指定できません");
            return null;
        }
        return new OperatorPortDeclaration(
                OperatorPortDeclaration.Kind.CONSTANT,
                analyzer.getParameterDocument(index),
                analyzer.getParameterName(index),
                PortTypeDescription.direct(type.getType()),
                index,
View Full Code Here

                FlowPartClass aClass = results.get(0);
                assertThat(aClass.getInputPorts().size(), is(1));
                assertThat(aClass.getOutputPorts().size(), is(1));
                assertThat(aClass.getParameters().size(), is(0));

                OperatorPortDeclaration in = find("in", aClass.getInputPorts());
                OperatorPortDeclaration out = find("out", aClass.getOutputPorts());

                assertTypeEquals(env, in.getType().getRepresentation(), MockHoge.class);
                assertThat(in.getParameterPosition(), is(0));

                assertTypeEquals(env, out.getType().getRepresentation(), MockHoge.class);
                assertThat(out.getParameterPosition(), is(1));
            }
        });
    }
View Full Code Here

                FlowPartClass aClass = results.get(0);
                assertThat(aClass.getInputPorts().size(), is(2));
                assertThat(aClass.getOutputPorts().size(), is(2));
                assertThat(aClass.getParameters().size(), is(2));

                OperatorPortDeclaration in1 = find("in1", aClass.getInputPorts());
                OperatorPortDeclaration in2 = find("in2", aClass.getInputPorts());
                OperatorPortDeclaration out1 = find("out1", aClass.getOutputPorts());
                OperatorPortDeclaration out2 = find("out2", aClass.getOutputPorts());
                OperatorPortDeclaration param1 = find("param1", aClass.getParameters());
                OperatorPortDeclaration param2 = find("param2", aClass.getParameters());

                assertTypeEquals(env, in1.getType().getRepresentation(), MockHoge.class);
                assertThat(in1.getParameterPosition(), is(0));
                assertTypeEquals(env, out1.getType().getRepresentation(), MockHoge.class);
                assertThat(out1.getParameterPosition(), is(1));
                assertThat(param1.getType().getRepresentation().getKind(), is(TypeKind.INT));
                assertThat(param1.getParameterPosition(), is(2));

                assertTypeEquals(env, in2.getType().getRepresentation(), MockFoo.class);
                assertThat(in2.getParameterPosition(), is(3));
                assertTypeEquals(env, out2.getType().getRepresentation(), MockFoo.class);
                assertThat(out2.getParameterPosition(), is(4));
                assertTypeEquals(env, param2.getType().getRepresentation(), String.class);
                assertThat(param2.getParameterPosition(), is(5));
            }
        });
    }
View Full Code Here

                FlowPartClass aClass = results.get(0);
                assertThat(aClass.getInputPorts().size(), is(1));
                assertThat(aClass.getOutputPorts().size(), is(1));
                assertThat(aClass.getParameters().size(), is(0));

                OperatorPortDeclaration in = find("in", aClass.getInputPorts());
                OperatorPortDeclaration out = find("out", aClass.getOutputPorts());

                assertThat("input/output are same", env.getTypeUtils().isSameType(
                        in.getType().getRepresentation(),
                        out.getType().getRepresentation()),
                        is(true));

                assertThat("input/output use type variable",
                        in.getType().getRepresentation().getKind(),
                        is(TypeKind.TYPEVAR));

                assertThat(in.getParameterPosition(), is(0));
                assertThat(out.getParameterPosition(), is(1));
            }
        });
    }
View Full Code Here

                FlowPartClass aClass = results.get(0);
                assertThat(aClass.getInputPorts().size(), is(1));
                assertThat(aClass.getOutputPorts().size(), is(1));
                assertThat(aClass.getParameters().size(), is(1));

                OperatorPortDeclaration in = find("in", aClass.getInputPorts());
                OperatorPortDeclaration out = find("out", aClass.getOutputPorts());
                OperatorPortDeclaration param = aClass.getParameters().get(0);

                assertThat("param is <: Class<?>", env.getTypeUtils().isSameType(
                        env.getErasure(param.getType().getRepresentation()),
                        env.getDeclaredType(Class.class)),
                        is(true));
                assertThat("output/param are same", env.getTypeUtils().isSameType(
                        out.getType().getRepresentation(),
                        ((DeclaredType) param.getType().getRepresentation()).getTypeArguments().get(0)),
                        is(true));

                assertThat("input/output use type variable",
                        in.getType().getRepresentation().getKind(),
                        is(TypeKind.TYPEVAR));

                assertThat(in.getParameterPosition(), is(0));
                assertThat(out.getParameterPosition(), is(1));
                assertThat(param.getParameterPosition(), is(2));
            }
        });
    }
View Full Code Here

TOP

Related Classes of com.asakusafw.compiler.operator.OperatorPortDeclaration

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.