Package org.openquark.cal.internal.javamodel

Examples of org.openquark.cal.internal.javamodel.JavaStatement$IfThenElseStatement


                    JavaOperator.NOT_EQUALS_OBJECT,
                    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);
View Full Code Here


                        JavaOperator.NOT_EQUALS_OBJECT,
                        resultField,
                        LiteralWrapper.NULL)
                        ;

                JavaStatement thenStatement =
                    new ReturnStatement(
                        new MethodInvocation.Instance(
                            null,
                            "debug_getChild",
                            JavaTypeNames.RTFULLAPP,
View Full Code Here

                    JavaOperator.NOT_EQUALS_OBJECT,
                    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),
View Full Code Here

                    JavaOperator.NOT_EQUALS_OBJECT,
                    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);
View Full Code Here

                        JavaOperator.NOT_EQUALS_OBJECT,
                        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);
View Full Code Here

            //notice that for non-RTValue fields, we need to box

            //$ec.isBreakpointEnabled($functionNameField)
            JavaExpression isDebuggingNeededCheck = new MethodInvocation.Instance(SCJavaDefn.EXECUTION_CONTEXT_VAR, "isDebugProcessingNeeded", LiteralWrapper.make(dc.getName().getQualifiedName()), JavaTypeName.STRING, JavaTypeName.BOOLEAN, MethodInvocation.InvocationType.VIRTUAL);
            JavaStatement.Block debuggingNeededThenBlock = new Block();
            JavaStatement isDebuggingNeededIfStatement =
                new JavaStatement.IfThenElseStatement(isDebuggingNeededCheck, debuggingNeededThenBlock);

            final int arity = dc.getArity();

            //new RTValue[]{CAL_Int.make(take$nElements$1), take$list$2}
View Full Code Here

            javaMethod.addStatement(sw);

            JavaExpression exception =
                new JavaExpression.ClassInstanceCreationExpression(JavaTypeName.INDEX_OUT_OF_BOUNDS_EXCEPTION);
            JavaStatement s =
                new JavaStatement.ThrowStatement (exception);
            javaMethod.addStatement(s);
            return javaMethod;
        }
View Full Code Here

                new OperatorExpression.Binary(
                    JavaOperator.EQUALS_OBJECT,
                    new JavaExpression.JavaField.This(className),
                    new JavaExpression.JavaField.Static(className, "$instance", className));

            JavaStatement returnStatement =
                new JavaStatement.ReturnStatement(conditionExpr);

            javaMethod.addStatement(returnStatement);
        }
View Full Code Here

                //    }

                JavaExpression conditionExpr =
                    new MethodInvocation.Instance(null, "isFunctionSingleton", JavaTypeName.BOOLEAN, MethodInvocation.InvocationType.VIRTUAL);

                JavaStatement thenStatement =
                    new JavaStatement.ThrowStatement(
                        new JavaExpression.ClassInstanceCreationExpression(JavaTypeName.INDEX_OUT_OF_BOUNDS_EXCEPTION));

                JavaStatement.IfThenElseStatement ifThenStatement =
                    new JavaStatement.IfThenElseStatement (conditionExpr, thenStatement);
View Full Code Here

                    JavaTypeName.VOID,
                    JavaExpression.MethodInvocation.InvocationType.VIRTUAL)));
       
        configCheckFailureBody.addStatement(new JavaStatement.ReturnStatement());
       
        final JavaStatement configCheck =
            new JavaStatement.IfThenElseStatement(
                new JavaExpression.OperatorExpression.Unary(
                    JavaOperator.LOGICAL_NEGATE,
                    new JavaExpression.MethodInvocation.Instance(
                        generatedCodeInfoLocalVar,
                        "isCompatibleWithCurrentConfiguration",
                        JavaTypeName.BOOLEAN,
                        JavaExpression.MethodInvocation.InvocationType.VIRTUAL)),
                configCheckFailureBody);
       
        mainMethod.addStatement(configCheck);
       
        ////
        /// Generate code to obtain the class loader which loaded this main class.
        ///
        /// It is necessary to obtain this class loader and pass it into the execution context and the resource access
        /// because the class loader which loaded the CAL Platform classes may be an *ancestor* of the one which loaded
        /// the standalone JAR (e.g. the bootstrap class loader), and thus may not have access to the foreign classes
        /// and localized resources necessary for the standalone JAR to run.
        //
       
        // Code fragment:
        //
        // ClassLoader classloader = {MainClassName}.class.getClassLoader();
        //
        final JavaTypeName javaTypeName_ClassLoader = JavaTypeName.make(ClassLoader.class);
       
        final JavaExpression classloaderInit =
            new JavaExpression.MethodInvocation.Instance(
                new JavaExpression.ClassLiteral(mainClassName),
                "getClassLoader",
                javaTypeName_ClassLoader,
                JavaExpression.MethodInvocation.InvocationType.VIRTUAL);
       
        final JavaExpression.LocalVariable classloaderLocalVar = new JavaExpression.LocalVariable("classloader", javaTypeName_ClassLoader);
       
        final JavaStatement classloaderDecl = new JavaStatement.LocalVariableDeclaration(classloaderLocalVar, classloaderInit);
       
        mainMethod.addStatement(classloaderDecl);
       
        ////
        /// Generate code to set up the execution context to have access to a standalone-JAR-specific
        /// ResourceAccess implementation.
        //

        // Code fragment:
        //       
        // RTExecutionContext executionContext = new RTExecutionContext(
        //     new ExecutionContextProperties.Builder().toProperties(),
        //     new StandaloneRuntimeEnvironment(
        //         classloader,
        //         new StandaloneJarResourceAccess(classloader)));       
        //
        final JavaTypeName javaTypeName_ExecutionContextProperties = JavaTypeName.make(ExecutionContextProperties.class);
        final JavaTypeName javaTypeName_ResourceAccess = JavaTypeName.make(ResourceAccess.class);
       
        final JavaExpression newRuntimeEnvironment =
            new JavaExpression.ClassInstanceCreationExpression(
                JavaTypeNames.STANDALONE_RUNTIME_ENVIRONMENT,
                new JavaExpression[] {
                    classloaderLocalVar,
                    new JavaExpression.ClassInstanceCreationExpression(
                        JavaTypeName.make(StandaloneJarResourceAccess.class),
                        classloaderLocalVar,
                        javaTypeName_ClassLoader)},
                new JavaTypeName[] {
                    javaTypeName_ClassLoader,
                    javaTypeName_ResourceAccess}                                  
                );
       
        final JavaExpression executionContextInit =
            new JavaExpression.ClassInstanceCreationExpression(
                JavaTypeNames.RTEXECUTION_CONTEXT,
                new JavaExpression[] {
                    new JavaExpression.MethodInvocation.Instance(
                        new JavaExpression.ClassInstanceCreationExpression(JavaTypeName.make(ExecutionContextProperties.Builder.class)),
                        "toProperties",
                        javaTypeName_ExecutionContextProperties,
                        JavaExpression.MethodInvocation.InvocationType.VIRTUAL),
                    newRuntimeEnvironment                  
                },
                new JavaTypeName[] {
                    javaTypeName_ExecutionContextProperties,
                    JavaTypeNames.RUNTIME_ENIVONMENT
                });
       
        final JavaExpression.LocalVariable executionContextLocalVar = new JavaExpression.LocalVariable(EXECUTION_CONTEXT_USER_FRIENDLY_NAME, JavaTypeNames.RTEXECUTION_CONTEXT);
        final JavaStatement executionContextDecl = new JavaStatement.LocalVariableDeclaration(executionContextLocalVar, executionContextInit, true);
       
        mainMethod.addStatement(executionContextDecl);
       
        ////
        /// Generate code to run the entry point.
View Full Code Here

TOP

Related Classes of org.openquark.cal.internal.javamodel.JavaStatement$IfThenElseStatement

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.