Package org.openquark.cal.internal.javamodel.JavaStatement

Examples of org.openquark.cal.internal.javamodel.JavaStatement.ReturnStatement


            if (!mf.isTailRecursive()) {
                then.addStatement(new ExpressionStatement(new MethodInvocation.Instance(null, "clearMembers", JavaTypeName.VOID, MethodInvocation.InvocationType.VIRTUAL)));
            }

            reduce.addStatement(new IfThenElseStatement(condition, then));
            reduce.addStatement(new ReturnStatement(resultField));

            return reduce;
        }
View Full Code Here


            MethodInvocation fn = new MethodInvocation.Instance (functionField, fMethodName, args, argTypes, JavaTypeNames.RTVALUE, MethodInvocation.InvocationType.VIRTUAL);
            MethodInvocation setResult = new MethodInvocation.Instance (null, "setResult", fn, JavaTypeNames.RTVALUE, JavaTypeName.VOID,  MethodInvocation.InvocationType.VIRTUAL);
            then.addStatement(new ExpressionStatement(setResult));

            reduce.addStatement(new IfThenElseStatement(condition, then));
            reduce.addStatement(new ReturnStatement(resultField));

            return reduce;
        }
View Full Code Here

                    resultField,
                    LiteralWrapper.NULL)
                    ;

            JavaStatement thenStatement =
                new ReturnStatement(
                    new MethodInvocation.Instance(
                        null,
                        "debug_getNChildren",
                        JavaTypeNames.RTFULLAPP,
                        JavaExpression.EMPTY_JAVA_EXPRESSION_ARRAY,
                        JavaExpression.EMPTY_TYPE_NAME_ARRAY,
                        JavaTypeName.INT,
                        MethodInvocation.InvocationType.SPECIAL));

            JavaStatement elseStatement =
                new ReturnStatement(LiteralWrapper.make(Integer.valueOf(memberFields.length)));

            JavaStatement.IfThenElseStatement ifThenElseStatement =
                new JavaStatement.IfThenElseStatement (conditionExpr, thenStatement, elseStatement);

            method.addStatement(ifThenElseStatement);
View Full Code Here

                        resultField,
                        LiteralWrapper.NULL)
                        ;

                JavaStatement thenStatement =
                    new ReturnStatement(
                        new MethodInvocation.Instance(
                            null,
                            "debug_getChild",
                            JavaTypeNames.RTFULLAPP,
                            new JavaExpression[]{childNVar},
                            new JavaTypeName[] {JavaTypeName.INT},
                            JavaTypeName.CAL_VALUE,
                            MethodInvocation.InvocationType.SPECIAL));

                JavaStatement.IfThenElseStatement ifThenStatement =
                    new JavaStatement.IfThenElseStatement (conditionExpr, thenStatement);

                method.addStatement(ifThenStatement);
            }

            SwitchStatement switchStatement =
                new SwitchStatement(childNVar);

            for (int i = 0, nFields = memberFields.length; i < nFields; ++i) {

                JavaField javaField = memberFields[i];
                String javaFieldName = javaField.getFieldName();
                JavaTypeName javaFieldType = javaField.getFieldType();
                JavaExpression javaFieldExpr = new JavaExpression.JavaField.Instance(null, javaFieldName, javaFieldType);
                if (!javaFieldType.equals(JavaTypeNames.RTVALUE)) {
                    javaFieldExpr = SCJavaDefn.boxExpression(javaFieldType, javaFieldExpr);
                }
                switchStatement.addCase(
                    new SwitchStatement.IntCaseGroup(i, new ReturnStatement(javaFieldExpr)));
            }

            switchStatement.addCase(
                new SwitchStatement.DefaultCase(
                    new JavaStatement.ThrowStatement(
View Full Code Here

                    resultField,
                    LiteralWrapper.NULL)
                    ;

            JavaStatement thenStatement =
                new ReturnStatement(
                     new MethodInvocation.Instance(
                         null,
                         "debug_getNodeStartText",
                         JavaTypeNames.RTFULLAPP,
                         JavaExpression.EMPTY_JAVA_EXPRESSION_ARRAY,
                         JavaExpression.EMPTY_TYPE_NAME_ARRAY,
                         JavaTypeName.STRING,
                         MethodInvocation.InvocationType.SPECIAL));

            JavaStatement elseStatement =
                new ReturnStatement(
                    new JavaExpression.OperatorExpression.Binary(JavaOperator.STRING_CONCATENATION,
                        LiteralWrapper.make("("),
                        new MethodInvocation.Instance(
                            new JavaExpression.JavaField.Instance(null, "function", className),
                            "getQualifiedName", JavaTypeName.STRING, MethodInvocation.InvocationType.VIRTUAL)));
View Full Code Here

                    resultField,
                    LiteralWrapper.NULL)
                    ;

            JavaStatement thenStatement =
                new ReturnStatement(
                    new MethodInvocation.Instance(
                        null,
                        "debug_getNodeEndText",
                        JavaTypeNames.RTFULLAPP,
                        JavaExpression.EMPTY_JAVA_EXPRESSION_ARRAY,
                        JavaExpression.EMPTY_TYPE_NAME_ARRAY,
                        JavaTypeName.STRING,
                        MethodInvocation.InvocationType.SPECIAL));

            JavaStatement elseStatement =
                new ReturnStatement(LiteralWrapper.make(")"));

            JavaStatement.IfThenElseStatement ifThenElseStatement =
                new JavaStatement.IfThenElseStatement (conditionExpr, thenStatement, elseStatement);

            method.addStatement(ifThenElseStatement);
View Full Code Here

                        resultField,
                        LiteralWrapper.NULL)
                        ;

                JavaStatement thenStatement =
                    new ReturnStatement(
                        new MethodInvocation.Instance(
                            null,
                            "debug_getChildPrefixText",
                            JavaTypeNames.RTFULLAPP,
                            new JavaExpression[]{childNVar},
                            new JavaTypeName[]{JavaTypeName.INT},
                            JavaTypeName.STRING,
                            MethodInvocation.InvocationType.SPECIAL));

                JavaStatement.IfThenElseStatement ifThenStatement =
                    new JavaStatement.IfThenElseStatement (conditionExpr, thenStatement);

                method.addStatement(ifThenStatement);
            }

            {
                //    if (childN >= 0 && childN < 2) {
                //        return " ";
                //    }

                JavaExpression conditionExpr =
                    new OperatorExpression.Binary(
                        JavaOperator.CONDITIONAL_AND,
                        new OperatorExpression.Binary(
                            JavaOperator.GREATER_THAN_EQUALS_INT,
                            childNVar,
                            LiteralWrapper.make(Integer.valueOf(0))),
                        new OperatorExpression.Binary(
                            JavaOperator.LESS_THAN_INT,
                            childNVar,
                            LiteralWrapper.make(Integer.valueOf(memberFields.length))));

                JavaStatement thenStatement =
                    new ReturnStatement(LiteralWrapper.make(" "));

                JavaStatement.IfThenElseStatement ifThenStatement =
                    new JavaStatement.IfThenElseStatement (conditionExpr, thenStatement);

                method.addStatement(ifThenStatement);
View Full Code Here

            int modifiers = Modifier.PROTECTED | Modifier.FINAL;
            JavaMethod javaMethod = new JavaMethod (modifiers, JavaTypeName.STRING, "ordinal", JavaTypeName.INT, false, "getFieldNameByOrdinal");
            SwitchStatement sw = new SwitchStatement (METHODVAR_ORDINAL);
            for (int i = 0, nFields = dc.getArity(); i < nFields; ++i) {
                String fieldName = dc.getNthFieldName(i).toString();
                sw.addCase(new SwitchStatement.IntCaseGroup(i, new ReturnStatement(LiteralWrapper.make(fieldName))));
            }

            javaMethod.addStatement(sw);

            JavaExpression exception =
View Full Code Here

        private JavaMethod createDCFieldSelectionClass_method_getDCName () {
            int modifiers = Modifier.PROTECTED | Modifier.FINAL;
            JavaMethod javaMethod = new JavaMethod (modifiers, JavaTypeName.STRING, "getDCName");

            javaMethod.addStatement(new ReturnStatement (JavaExpression.LiteralWrapper.make (dc.getName().getQualifiedName())));
            return javaMethod;
        }
View Full Code Here

            // Add the method to the class.
            JavaMethod javaMethod = new JavaMethod(modifiers, returnType, "getArity");
            javaClassRep.addMethod(javaMethod);

            // Add the body..
            javaMethod.addStatement(new ReturnStatement(LiteralWrapper.make(Integer.valueOf(dc.getArity()))));

            //LiteralWrapper zeroWrapper = LiteralWrapper.make(JavaPrimitives.makeInteger(0));
//            if (arity == 0) {
                // return 0;
//                javaMethod.addStatement(new ReturnStatement(zeroWrapper));
View Full Code Here

TOP

Related Classes of org.openquark.cal.internal.javamodel.JavaStatement.ReturnStatement

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.