Package org.openquark.cal.internal.javamodel.JavaExpression

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


            JavaExpression javaBaseRecordExpr = baseRecordExprContextPair.getJavaExpression();
            recordUpdateBlock.addStatement(baseRecordExprContextPair.getContextBlock());

            //the compiler ensures that evaluating baseRecordExpr will result in a RTRecordValue.
            invocationTarget = new CastExpression(JavaTypeNames.RTRECORD_VALUE, javaBaseRecordExpr);
        }

        //the expression {e | field1 := e1, field2 := e2, field3 := e3} is encoded as
        //{{{e | field1 := e1} | field2 := e2} | field3 := e3}
View Full Code Here


            JavaExpression javaBaseRecordExpr = baseRecordExprContextPair.getJavaExpression();
            recordExtensionBlock.addStatement(baseRecordExprContextPair.getContextBlock());

            //the compiler ensures that evaluating baseRecordExpr will result in a RTRecordValue.
            invocationTarget = new CastExpression(JavaTypeNames.RTRECORD_VALUE, javaBaseRecordExpr);
            //invocationType = InvocationType.VIRTUAL;

        } else {
            invocationTarget = null;
        }
View Full Code Here

        JavaExpression javaRecordExpr = recordExprContextPair.getJavaExpression();
        Block recordSelectionBlock = new Block();
        recordSelectionBlock.addStatement(recordExprContextPair.getContextBlock());

        //the compiler ensures that evaluating recordExpr will result in a RTRecordValue.
        javaRecordExpr = new CastExpression(JavaTypeNames.RTRECORD_VALUE, javaRecordExpr);

        MethodInvocation getValueInvocation;
        if (fieldName instanceof FieldName.Textual) {
            getValueInvocation = new MethodInvocation.Instance(javaRecordExpr, "getTextualFieldValue",
                LiteralWrapper.make(fieldName.getCalSourceForm()), JavaTypeName.STRING,
View Full Code Here

        JavaExpression javaConditionExpr = conditionExprContextPair.getJavaExpression();
        recordCaseBlock.addStatement(conditionExprContextPair.getContextBlock());

        //the compiler ensures that evaluating conditionExpr will result in a RTRecordValue.
        javaConditionExpr = new CastExpression(JavaTypeNames.RTRECORD_VALUE, javaConditionExpr);

        LocalVariable conditionVar = new LocalVariable("$recordCase" + nestedCaseLevel, JavaTypeNames.RTRECORD_VALUE);

        LocalVariableDeclaration conditionVarDeclaration = new LocalVariableDeclaration(conditionVar, javaConditionExpr);
        recordCaseBlock.addStatement(conditionVarDeclaration);
View Full Code Here

            JavaExpression arg = createVirtualInvocation(value, "getOpaqueValue", JavaTypeName.OBJECT);
            if (unboxedType.equals(JavaTypeName.OBJECT)) {
                // getOpaqueValue() returns an Object no need to cast.
                return arg;
            } else {
                return new CastExpression(unboxedType, arg);       // cast to argClass
            }
        }
    }
View Full Code Here

        } else
        if (argClass == java.math.BigInteger.class) {
            javaExpression = createMakeKernelIntegerInvocation(definition);
        } else
        if (isCalValueClass(argClass)) {
            javaExpression = new CastExpression (JavaTypeNames.RTVALUE, definition);
        } else
        {
            javaExpression = createMakeKernelOpaqueInvocation(definition);
        }
View Full Code Here

        }

        if (directlyRetrieveUnboxed) {

            ExpressionContextPair ecp = genS_E(dcs.getDCValueExpr(), variableContext);
            JavaExpression target = new CastExpression (JavaTypeNames.RTCONS, ecp.getJavaExpression());

            // Call the unboxed version of getFieldByIndex.
            // In RTCons we declare versions of getFieldByIndex_As_...() for each of the Java primitive types,
            // Object, and java.lang.String.
            // At this point we need to decide which one to call.
View Full Code Here

            JavaExpression caseExpression = pair.getJavaExpression();
            //caseExpression = releaseVarsInSwitchCondition(eswitch, caseExpression, variableContext);

            // We may need to cast the result of the case expression to the type of the local variable.
            caseExpression = (isEnumDataType || caseExpression instanceof ClassInstanceCreationExpression) ? caseExpression : new CastExpression(typeClassName, caseExpression);

            // Assign the result of the switch expression to the local an then get the ordinal value.
            JavaExpression assignLocal = new JavaExpression.Assignment(caseVar, caseExpression);
            JavaExpression getOrdinal = SCJavaDefn.createInvocation(assignLocal, SCJavaDefn.GETORDINALVALUE);
View Full Code Here

            ExpressionContextPair pair = genS_E(eSwitch.getSwitchExpr(), variableContext);
            switchBlock.addStatement(pair.getContextBlock());
            JavaExpression caseExpression = pair.getJavaExpression();

            if (caseVarType.equals(JavaTypeNames.RTCONS)) {
                caseExpression = new CastExpression(JavaTypeNames.RTCONS, caseExpression);
            }

            LocalVariableDeclaration caseVarDeclaration =
                new LocalVariableDeclaration(caseVar, caseExpression);
            switchBlock.addStatement(caseVarDeclaration);
        }

        // Populate the switch statement with case statement groups.

        // Create a new let variable scope to handle the alternate and any let variables it contains.
        variableContext.pushJavaScope();

        Block caseBlock = new Block();

        if (isSwitchingOnDC) {
            caseBlock.addStatement(new LineComment(((DataConstructor)altTag).getName().getQualifiedName()));
        }

        // Get this alternative's variables.  These have to be added to the active list of scope variables
        if (alt.hasVars()) {
            caseBlock.addStatement(new LineComment("Decompose data type to access members."));

            if (caseVar == null) {
                throw new CodeGenerationException ("Null case variable encountered in single alternate switch.");
            }

            // Must be a data constructor tag, since there are field names (see Expression.Switch.SwitchAlt).
            DataConstructor tagDC = (DataConstructor)altTag;

            TypeExpr fieldTypes[] = SCJavaDefn.getFieldTypesForDC(tagDC);

            // Cast the case var to the appropriate type to call getField0, getField1, etc.
            JavaTypeName dcTypeName = CALToJavaNames.createTypeNameFromDC(tagDC, module);
            JavaExpression castExpression = new CastExpression(dcTypeName, caseVar);

            // There is at least one field to be extracted.
            // Declare a local variable that is the casted case var so that we only do the cast once.
            JavaExpression castCaseVar = new LocalVariable("$dcCaseVar" + nestedCaseLevel, dcTypeName);
            LocalVariableDeclaration localVarStmnt = new LocalVariableDeclaration((LocalVariable)castCaseVar, castExpression);
View Full Code Here

TOP

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

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.