Package org.openquark.cal.internal.javamodel

Examples of org.openquark.cal.internal.javamodel.JavaExpression


            if (LECCMachineConfiguration.generateStatistics()) {
                MethodInvocation mi = new MethodInvocation.Instance(SCJavaDefn.EXECUTION_CONTEXT_VAR, "incrementNMethodCalls", JavaTypeName.VOID, MethodInvocation.InvocationType.VIRTUAL);
                javaMethod.addStatement(new ExpressionStatement(mi));
            }
            if (LECCMachineConfiguration.generateCallCounts()) {
                JavaExpression args[] = new JavaExpression[2];
                JavaTypeName argTypes[] = new JavaTypeName[2];
                args[0] = LiteralWrapper.make(javaDefn.getModuleName().toSourceText());
                args[1] = LiteralWrapper.make(javaDefn.getFunctionName());
                argTypes[0] = argTypes[1] = JavaTypeName.STRING;
                MethodInvocation mi = new MethodInvocation.Instance(SCJavaDefn.EXECUTION_CONTEXT_VAR, "scCalled", args, argTypes, JavaTypeName.VOID, MethodInvocation.InvocationType.VIRTUAL);
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(javaDefn.getQualifiedName().getQualifiedName()),
                        JavaTypeName.STRING,
                        JavaTypeName.BOOLEAN,
                        MethodInvocation.InvocationType.VIRTUAL);

            JavaStatement.Block debuggingNeededThenBlock = new Block();
            JavaStatement isDebuggingNeededIfStatement =
                new JavaStatement.IfThenElseStatement(isDebuggingNeededCheck, debuggingNeededThenBlock);

            final int arity = javaDefn.getArity();

            //new RTValue[]{CAL_Int.make(take$nElements$1), take$list$2}
            JavaExpression[] argValues = new JavaExpression[arity];
            for (int i = 0; i < arity; ++i) {

                String javaArgName = argNames[i];
                JavaTypeName javaArgType = argTypes[i];

                JavaExpression javaArgValue = new LocalName(javaArgName, javaArgType);
                if (!javaArgType.equals(JavaTypeNames.RTVALUE)) {
                    javaArgValue = SCJavaDefn.boxExpression(javaArgType, javaArgValue);
                }

                argValues[i] = javaArgValue;
            }

            JavaExpression argValueArrayCreation = new JavaExpression.ArrayCreationExpression(JavaTypeNames.RTVALUE, argValues);


            //$ec.debugProcessing("Prelude.take",
            //            new RTValue[]{CAL_Int.make(take$nElements$1), take$list$2}));
            JavaExpression suspend =
                new MethodInvocation.Instance(
                    SCJavaDefn.EXECUTION_CONTEXT_VAR, "debugProcessing",
                    new JavaExpression[] {
                            LiteralWrapper.make(javaDefn.getQualifiedName().getQualifiedName()),
                            argValueArrayCreation },
View Full Code Here

            final JavaField resultField = new JavaField.Instance(null, "result", JavaTypeNames.RTVALUE);

            OperatorExpression condition = new OperatorExpression.Binary (JavaOperator.EQUALS_OBJECT, resultField, LiteralWrapper.NULL);
            Block then = new Block();

            JavaExpression args[] = new JavaExpression[mf.getArity() + 1];
            JavaTypeName[] argTypes = new JavaTypeName[mf.getArity()+1];
            for (int i = 0; i < mf.getArity(); ++i) {
                args[i] = functionArgumentMemberFields[i];
                argTypes[i] = JavaTypeNames.RTVALUE;
                if (mf.getParameterStrictness()[i] && SCJavaDefn.canTypeBeUnboxed(mf.getParameterTypes()[i])) {
View Full Code Here

                new JavaConstructor(Modifier.PUBLIC, argNames, argTypes, constructorName);

            // Add the body of the constructor

            // Check for null argument values via assert.
            JavaExpression argCheck = new OperatorExpression.Binary (JavaOperator.NOT_EQUALS_OBJECT, argVars[0], LiteralWrapper.NULL);
            for (int i = 1; i < argNames.length; ++i) {
                // We only do the null pointer check on arguments of type RTValue.
                // It is valid to have an external object (ex. String) which is null.
                if (argTypes[i].equals(JavaTypeNames.RTVALUE)) {
                    JavaExpression compareArg = new OperatorExpression.Binary(JavaOperator.NOT_EQUALS_OBJECT, new MethodVariable(argNames[i]), LiteralWrapper.NULL);
                    argCheck = new JavaExpression.OperatorExpression.Binary(JavaOperator.CONDITIONAL_AND, argCheck, compareArg);
                }
            }
            javaConstructor.addStatement(
                    new AssertStatement(
View Full Code Here

            final JavaField resultField = new JavaField.Instance(null, "result", JavaTypeNames.RTVALUE);

            OperatorExpression condition = new OperatorExpression.Binary (JavaOperator.EQUALS_OBJECT, resultField, LiteralWrapper.NULL);
            Block then = new Block();

            JavaExpression args[] = new JavaExpression[mf.getArity() + 1];
            JavaTypeName[] argTypes = new JavaTypeName[mf.getArity()+1];
            for (int i = 0; i < mf.getArity(); ++i) {
                args[i] =
                    callLastRef(functionArgumentMemberFields[i], (JavaField)functionArgumentMemberFields[i]);
                argTypes[i] = JavaTypeNames.RTVALUE;
View Full Code Here

            // Add the body of the constructor


            // We check for null argument values via assert.
            JavaExpression argCheck = new OperatorExpression.Binary (JavaOperator.NOT_EQUALS_OBJECT, argVars[0], LiteralWrapper.NULL);
            for (int i = 1; i < argNames.length; ++i) {
                JavaExpression compareArg = new OperatorExpression.Binary(JavaOperator.NOT_EQUALS_OBJECT, argVars[i], LiteralWrapper.NULL);
                argCheck = new JavaExpression.OperatorExpression.Binary(JavaOperator.CONDITIONAL_AND, argCheck, compareArg);
            }
            javaConstructor.addStatement(
                    new AssertStatement(argCheck,
                                        new MethodInvocation.Instance(null, "badConsArgMsg", JavaTypeName.STRING, MethodInvocation.InvocationType.VIRTUAL),
View Full Code Here

            //}

            JavaMethod method = new JavaMethod (Modifier.PUBLIC | Modifier.FINAL, JavaTypeName.INT, "debug_getNChildren");

            JavaField resultField = new JavaField.Instance(null, "result", JavaTypeNames.RTVALUE);
            JavaExpression conditionExpr =
                new JavaExpression.OperatorExpression.Binary(
                    JavaOperator.NOT_EQUALS_OBJECT,
                    resultField,
                    LiteralWrapper.NULL)
                    ;
View Full Code Here

                //    if (result != null) {
                //        return super.debug_getChild(childN);
                //    }

                JavaField resultField = new JavaField.Instance(null, "result", JavaTypeNames.RTVALUE);
                JavaExpression conditionExpr =
                    new OperatorExpression.Binary(
                        JavaOperator.NOT_EQUALS_OBJECT,
                        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)));
View Full Code Here

            //}

            JavaMethod method = new JavaMethod (Modifier.PUBLIC | Modifier.FINAL, JavaTypeName.STRING, "debug_getNodeStartText");

            JavaField resultField = new JavaField.Instance(null, "result", JavaTypeNames.RTVALUE);
            JavaExpression conditionExpr =
                new JavaExpression.OperatorExpression.Binary(
                    JavaOperator.NOT_EQUALS_OBJECT,
                    resultField,
                    LiteralWrapper.NULL)
                    ;
View Full Code Here

            //}

            JavaMethod method = new JavaMethod (Modifier.PUBLIC | Modifier.FINAL, JavaTypeName.STRING, "debug_getNodeEndText");

            JavaField resultField = new JavaField.Instance(null, "result", JavaTypeNames.RTVALUE);
            JavaExpression conditionExpr =
                new JavaExpression.OperatorExpression.Binary(
                    JavaOperator.NOT_EQUALS_OBJECT,
                    resultField,
                    LiteralWrapper.NULL)
                    ;
View Full Code Here

TOP

Related Classes of org.openquark.cal.internal.javamodel.JavaExpression

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.