Package org.openquark.cal.internal.runtime.lecc

Examples of org.openquark.cal.internal.runtime.lecc.RTRecordValue$OrdinalData$Tuple


        //must iterate in a deterministic order over the field names (as specified by FieldName.CalSourceFormComparator)
        //so that the function is well-defined in the presence of side effects.
        //If f is a field, then recordDictionary.f is the dictionary for use when calling the class method Prelude.notEquals on
        //the values x.f and y.f.

        final RTRecordValue recordDict = (RTRecordValue)recordDictionary;
        final RTRecordValue xRecord = (RTRecordValue)x;
        final RTRecordValue yRecord = (RTRecordValue)y;

        for (int i = 0, nFields = recordDict.getNFields(); i < nFields; ++i) {

            final RTValue fieldDict = recordDict.getNthValue(i);
            final RTValue xField = xRecord.getNthValue(i);
            final RTValue yField = yRecord.getNthValue(i);

            //compute "Prelude.notEquals fieldDict xField yField"
            //this is just (after inlining Prelude.notEquals d = d indexOfNotEqualsClassMethod"
            //fieldDict indexOfNotEqualsClassMethod xField yField
View Full Code Here


        //must iterate in a deterministic order over the field names (as specified by FieldName.CalSourceFormComparator)
        //so that the function is well-defined in the presence of side effects.
        //If f is a field, then recordDictionary.f is the dictionary for use when calling the class method Prelude.notEquals on
        //the values x.f and y.f.

        final RTRecordValue recordDict = (RTRecordValue)recordDictionary;
        final RTRecordValue xRecord = (RTRecordValue)x;
        final RTRecordValue yRecord = (RTRecordValue)y;

        for (int i = 0, nFields = recordDict.getNFields(); i < nFields; ++i) {

            final RTValue fieldDict = recordDict.getNthValue(i);
            final RTValue xField = xRecord.getNthValue(i);
            final RTValue yField = yRecord.getNthValue(i);

            //compute "Prelude.notEquals fieldDict xField yField"
            //this is just (after inlining Prelude.notEquals d = d indexOfNotEqualsClassMethod"
            //fieldDict indexOfNotEqualsClassMethod xField yField
View Full Code Here

        //must iterate in a deterministic order over the field names (as specified by FieldName.CalSourceFormComparator)
        //so that the function is well-defined in the presence of side effects.
        //If f is a field, then recordDictionary.f is the dictionary for use when calling the class method Prelude.output on
        //the value x.f.

        RTRecordValue recordDict = (RTRecordValue)recordDictionary;
        RTRecordValue xRecord = (RTRecordValue)x;

        int nFields = recordDict.getNFields();

        List<Object> resultList;
View Full Code Here

        /*
         * Loops through all fields in the record dictionary and invokes the
         * dictionary function and adds them to the result list
         */
        RTRecordValue recordDict = (RTRecordValue)recordDictionary;
        RTRecordValue recordValue = (RTRecordValue)record;

        RTValue index = RTData.CAL_Int.make(indexValue);
       
        int numOrdinalFields = recordDict.getNOrdinalFields();
        int numTextualFields = recordDict.getNTextualFields();
       
        int nParams = recordValue.getNOrdinalFields() + recordValue.getNTextualFields();
        //create the list of parameter sources
        ArrayList<RecordParamHelper> paramSources = new ArrayList<RecordParamHelper>(nParams);
        for(int i=0; i<nParams; i++) {
            paramSources.add(RecordParamHelper.create(recordValue.getNthValue(i), $ec));
        }
       
        List<Object> res= new ArrayList<Object>(numOrdinalFields + numTextualFields);
           
        for (int i = 0, nFields = numTextualFields + numOrdinalFields; i < nFields; ++i) {
View Full Code Here

        /*
         * Loops through all fields in the record dictionary and invokes the
         * class method to construct each record field
         */

        RTRecordValue recordDict = (RTRecordValue)recordDictionary;
        RTRecordValue recordValue = (RTRecordValue) args;

        RTValue indexValue = RTData.CAL_Int.make(index);
       
        int numOrdinalFields = recordDict.getNOrdinalFields();
        int numTextualFields = recordDict.getNTextualFields();
       
        RTValue ordinalValues[] = (numOrdinalFields > 0) ? new RTValue[numOrdinalFields] : null;
        RTValue textualValues[] = (numTextualFields > 0) ? new RTValue[numTextualFields] : null;

        int nParams = recordValue.getNOrdinalFields() + recordValue.getNTextualFields();
        //create the list of parameter sources
        ArrayList<RecordParamHelper> paramSources = new ArrayList<RecordParamHelper>(nParams);
        for(int i=0; i<nParams; i++) {
            paramSources.add(RecordParamHelper.create(recordValue.getNthValue(i), $ec));
        }
       
        for (int i = 0, nFields = numTextualFields + numOrdinalFields; i < nFields; ++i) {
           
            RTValue fieldDict = recordDict.getNthValue(i);           
View Full Code Here

        //recordFromJListPrimitive recordDict inputList.
        //we iterate in FieldName order over the field names so that the function is well-defined in the presence of side effects.
        //If f is the nth field in the recordDictionary, then recordDictionary.f is the dictionary for use when calling the
        //class method Prelude.input on the nth element of the input list.

        final RTRecordValue recordDict = (RTRecordValue)recordDictionary;

        final int nOrdinalFields = recordDict.getNOrdinalFields();
        final int nTextualFields = recordDict.getNTextualFields();

        final int nFields = nOrdinalFields + nTextualFields;
        //check that the number of fields in the inputList is the same as the number of fields in the record.
        //without this check it is possible that inputList could have more elements than the size of the record and still succeed.
        //This would still "work" but this check is useful to alert clients to potential bugs in their code.
        if (nFields != inputList.size()) {
            throw new IllegalArgumentException("A Java list of size " + inputList.size() + " cannot be input to a record with " + nFields + " fields.");
        }

        if (nOrdinalFields > 0) {

            //we use an iterator since inputList may be a non-random access list such as a java.util.LinkedList.
            Iterator<?> inputListIterator = inputList.iterator();

            RTValue[] ordinalValues = new RTValue[nOrdinalFields];
            for (int i = 0; i < nOrdinalFields; ++i) {

                RTValue fieldDict = recordDict.getNthOrdinalValue(i);
                RTValue listElement = RTData.CAL_Opaque.make(inputListIterator.next());

                //compute "Prelude.input fieldDict listElement"
                //this is just (after inlining Prelude.input d = d)
                //fieldDict listElement

                ordinalValues[i] = fieldDict.apply(listElement);
            }

            if (nTextualFields > 0) {

                RTValue [] textualValues = new RTValue[nTextualFields];
                for (int i = 0; i < nTextualFields; ++i) {

                    RTValue fieldDict = recordDict.getNthTextualValue(i);
                    RTValue listElement = RTData.CAL_Opaque.make(inputListIterator.next());

                    textualValues[i] = fieldDict.apply(listElement);
                }

                return recordDict.makeFromValues(ordinalValues, textualValues);
            }

            return recordDict.makeFromValues(ordinalValues, null);
        }

        if (nTextualFields > 0) {

            //we use an iterator since inputList may be a non-random access list such as a java.util.LinkedList.
            Iterator<?> inputListIterator = inputList.iterator();

            RTValue [] textualValues = new RTValue[nTextualFields];
            for (int i = 0; i < nTextualFields; ++i) {

                RTValue fieldDict = recordDict.getNthTextualValue(i);
                RTValue listElement = RTData.CAL_Opaque.make(inputListIterator.next());

                textualValues[i] = fieldDict.apply(listElement);
            }

            return recordDict.makeFromValues(null, textualValues);
        }

        //empty record
        return RTRecordValue.EMPTY_RECORD;
    }
View Full Code Here

        //the compiler ensures that the 3 record arguments all have the same fields.
        //we iterate in FieldName order over the field names so that the function is well-defined in the presence of side effects.
        //If f is a field, then recordDictionary.f is the dictionary for use when calling the class method Prelude.equals on
        //the values x.f and y.f.

        final RTRecordValue recordDict = (RTRecordValue)recordDictionary;
        final RTRecordValue xRecord = (RTRecordValue)x;
        final RTRecordValue yRecord = (RTRecordValue)y;

        for (int i = 0, nFields = recordDict.getNFields(); i < nFields; ++i) {

            final RTValue fieldDict = recordDict.getNthValue(i);
            final RTValue xField = xRecord.getNthValue(i);
            final RTValue yField = yRecord.getNthValue(i);

            //compute "Prelude.equals fieldDict xField yField"
            //this is just (after inlining Prelude.equals d = d indexOfEqualsClassMethod"
            //fieldDict indexOfEqualsClassMethod xField yField
View Full Code Here

        //the compiler ensures that the 3 record arguments all have the same fields.
        //we iterate in FieldName order over the field names so that the function is well-defined in the presence of side effects.
        //If f is a field, then recordDictionary.f is the dictionary for use when calling the class method Prelude.equals on
        //the values x.f and y.f.

        final RTRecordValue recordDict = (RTRecordValue)recordDictionary;
        final RTRecordValue xRecord = (RTRecordValue)x;
        final RTRecordValue yRecord = (RTRecordValue)y;

        for (int i = 0, nFields = recordDict.getNFields(); i < nFields; ++i) {

            RTValue fieldDict = recordDict.getNthValue(i);
            RTValue xField = xRecord.getNthValue(i);
            RTValue yField = yRecord.getNthValue(i);

            //compute "Prelude.equals fieldDict xField yField"
            //this is just (after inlining Prelude.equals d = d indexOfEqualsClassMethod"
            //fieldDict indexOfEqualsClassMethod xField yField
View Full Code Here

        //must iterate in a deterministic order over the field names (as specified by FieldName.CalSourceFormComparator)
        //so that the function is well-defined in the presence of side effects.
        //If f is a field, then recordDictionary.f is the dictionary for use when calling the class method Prelude.output on
        //the value x.f.

        final RTRecordValue recordDict = (RTRecordValue)recordDictionary;
        final RTRecordValue xRecord = (RTRecordValue)x;

        final RecordValue resultMap = RecordValueImpl.make();
        final int nFields = recordDict.getNFields();

        for (int i = 0; i < nFields; ++i) {
            final FieldName fieldName = recordDict.getNthFieldName(i);
            //RTValue fieldDict = recordDictionary.getNthValue(i);
            //RTValue xField = xRecord.getNthValue(i);

            //compute "Prelude.output fieldDict xField"
            //this is just (after inlining Prelude.output d = d"
            //fieldDict xField
            final Object fieldValue = recordDict.getNthValue(i).apply(xRecord.getNthValue(i)).evaluate($ec).getOpaqueValue();
            resultMap.put(fieldName, fieldValue);
        }

        return resultMap;
    }
View Full Code Here

        $ec.incrementNMethodCalls();
        if (LECCMachineConfiguration.generateDebugCode() && $ec.isDebugProcessingNeeded(getQualifiedName())) {
            $ec.debugProcessing(getQualifiedName(), new RTValue[]{record});
        }

        final RTRecordValue recordValue = (RTRecordValue)record;

        for (int i = 0, nFields = recordValue.getNFields(); i < nFields; ++i) {
           final RTValue fieldValue = recordValue.getNthValue(i);
           final RTValue evaluatedFieldValue = fieldValue.evaluate($ec);
           if (fieldValue != evaluatedFieldValue) {
               //called for the side effect of collapsing any indirections. This is important for freeing up space.
               recordValue.getNthValue(i);
           }
        }

        return recordValue;
    }
View Full Code Here

TOP

Related Classes of org.openquark.cal.internal.runtime.lecc.RTRecordValue$OrdinalData$Tuple

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.