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

Examples of org.openquark.cal.internal.runtime.lecc.RTRecordValue$EmptyRecord


   * This method implements the function logic of the CAL function Cal.Collections.IntMap.fromList$ins$2
   */
  public final RTValue f2S(RTValue t, RTValue p, RTExecutionContext $ec) throws CALExecutorException {
    // Top level supercombinator logic

    RTRecordValue $recordCase1 =
      ((RTRecordValue)(java.lang.Object)p.getValue());
    RTValue k = $recordCase1.getOrdinalFieldValue(1);
    RTValue x = $recordCase1.getOrdinalFieldValue(2);

    return
      Insert.$instance.f3S(
        k.evaluate($ec).getOrdinalValue(),
        x,
View Full Code Here


   * This method implements the function logic of the CAL function Cal.Utilities.DirectedGraph.flattenComponents$insertEdge$8
   */
  public final RTValue f2S(RTValue edges, RTValue edgePair, RTExecutionContext $ec) throws CALExecutorException {
    // Top level supercombinator logic

    RTRecordValue $recordCase1 =
      ((RTRecordValue)(java.lang.Object)edgePair.getValue());
    RTValue startVertexNum = $recordCase1.getOrdinalFieldValue(1);
    RTValue endVertexNum = $recordCase1.getOrdinalFieldValue(2);

    return
      Insert_With.$instance.f4S(
        new RTPartialApp._3._1(
          Union.$instance,
View Full Code Here

        RTValue xs = $case1.get_tail();
        RTValue letVar_pattern_tail1_tail2 =
          Unzip.$pattern_tail1_tail2$6$def_Lazy(xs, $ec);


        RTRecordValue $recordCase2 =
          ((RTRecordValue)(java.lang.Object)x.evaluate($ec));
        RTValue x1 = $recordCase2.getOrdinalFieldValue(1);
        RTValue x2 = $recordCase2.getOrdinalFieldValue(2);

        return
          RTRecordValue.makeTupleRecord(
            new RTValue[] {new TYPE_List.CAL_Cons(x1, Unzip.tail1$4$def_Lazy(letVar_pattern_tail1_tail2, $ec)), new TYPE_List.CAL_Cons(x2, Unzip.tail2$5$def_Lazy(letVar_pattern_tail1_tail2, $ec))});
      }
View Full Code Here

   * This method implements the function logic of the CAL function Cal.Utilities.DirectedGraph.$lambda$showDirectedGraph$1
   */
  public final RTValue f4S(RTValue $dictvarCal_Core_Debug_Show_33, RTValue graph, RTValue accum, RTValue vertexNum, RTExecutionContext $ec) throws CALExecutorException {
    // Top level supercombinator logic

    RTRecordValue $recordCase1 =
      ((RTRecordValue)(java.lang.Object)accum.evaluate($ec));
    RTValue indent = $recordCase1.getOrdinalFieldValue(1);
    RTValue text = $recordCase1.getOrdinalFieldValue(2);

    return
      RTRecordValue.makeTupleRecord(
        new RTValue[] {new RTFullApp.General._2._L(Add_Int.$instance, indent, new RTFullApp.General._1._S(Show_Directed_Graph__indent_Diff__3.$instance, _dict___Num___Int.$instance)), new RTFullApp.General._2._L(Append_String.$instance, text, new RTFullApp.General._2._L(Append_String.$instance, new RTFullApp.General._1._S(Show_Directed_Graph__make_Indent_String__4.$instance, indent), new RTFullApp.General._2._L(Append_String.$instance, $dictvarCal_Core_Debug_Show_33.apply(new RTFullApp.General._2._S(Get_Vertex.$instance, graph, vertexNum)), _lambda__show_Directed_Graph__1.$L1_String_N)))});
  }
View Full Code Here

   * This method implements the function logic of the CAL function Cal.Utilities.DirectedGraph.$lambda$showDirectedGraph$2
   */
  public final RTValue f4S(RTValue $dictvarCal_Core_Debug_Show_33, RTValue graph, RTValue accum, RTValue vertexNum, RTExecutionContext $ec) throws CALExecutorException {
    // Top level supercombinator logic

    RTRecordValue $recordCase1 =
      ((RTRecordValue)(java.lang.Object)accum.evaluate($ec));
    RTValue indent = $recordCase1.getOrdinalFieldValue(1);
    RTValue text = $recordCase1.getOrdinalFieldValue(2);

    if (indent.evaluate($ec).getOrdinalValue() ==
    Show_Directed_Graph__base_Indent__2.$instance.f1S(
      _dict___Num___Int.$instance,
      $ec).evaluate(
View Full Code Here

      // Top level supercombinator logic
      if (Is_Empty.$instance.fUnboxed1S(candidateSet.evaluate($ec), $ec)) {
        return Reverse.$instance.f1S(reversedList.evaluate($ec), $ec);
      } else {

        RTRecordValue $recordCase2 =
          ((RTRecordValue)(java.lang.Object)
            Delete_Find_Min.$instance.f1S(
              candidateSet.evaluate($ec),
              $ec).evaluate(
              $ec));
        RTValue min = $recordCase2.getOrdinalFieldValue(1);
        RTValue candidateSetWithoutMin =
          $recordCase2.getOrdinalFieldValue(2);

        RTValue letVar_newSatisfiedSet =
          Stable_Topological_Sort__sort_Helper__5.newSatisfiedSet$14$def_Lazy(
            min,
            satisfiedSet,
View Full Code Here

   * This method implements the function logic of the CAL function Cal.Utilities.DirectedGraph.findCycleInternal$finishVertexFn$5
   */
  public final RTValue f2S(RTValue accum, RTValue vertexNum, RTExecutionContext $ec) throws CALExecutorException {
    // Top level supercombinator logic

    RTRecordValue $recordCase1 =
      ((RTRecordValue)(java.lang.Object)accum.evaluate($ec));
    RTValue path = $recordCase1.getOrdinalFieldValue(1);
    RTValue isCycle = $recordCase1.getOrdinalFieldValue(2);

    if (isCycle.evaluate($ec).getBooleanValue()) {
      return accum;
    } else {
      return
View Full Code Here

        /*
         * loop through each element in the input record and apply the coarbitrary
         * method to vary the input generator so that the resulting generator will be
         * dependant on each of the fields in the input record.
         */
        final RTRecordValue recordDict = (RTRecordValue)recordDictionary;
        final RTRecordValue inputRecord = (RTRecordValue) record;
        RTValue result = generator;
        for (int i = 0, nFields = recordDict.getNFields(); i < nFields; ++i) {
            RTValue elem = inputRecord.getNthValue(i);
            RTValue fieldDict = recordDict.getNthValue(i);
            result = fieldDict.apply( indexOfCoArbitraryClassMethod, elem, result).evaluate($ec);
       }

        return result;
View Full Code Here

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

        RTRecordValue recordDict = (RTRecordValue)recordDictionary;

        int numOrdinalFields = recordDict.getNOrdinalFields();
        int numTextualFields = recordDict.getNTextualFields();

        RTValue ordinalValues[] = (numOrdinalFields > 0) ? new RTValue[numOrdinalFields] : null;
        RTValue textualValues[] = (numTextualFields > 0) ? new RTValue[numTextualFields] : null;

        for (int i = 0, nFields = numTextualFields + numOrdinalFields; i < nFields; ++i) {

            // update the genParams so that each field has an independent generator
            genParams = independent.apply(RTData.CAL_Int.make(i), genParams);
            RTValue fieldDict = recordDict.getNthValue(i);

            //generate an arbitrary instance of the field
            RTValue v = fieldDict.apply(indexOfGenerateClassMethod, genParams).evaluate($ec);

            if (i < recordDict.getNOrdinalFields()) {
                ordinalValues[i] = v;
            } else {
                textualValues[i - numOrdinalFields] = v;
            }
        }

        return recordDict.makeFromValues(ordinalValues, textualValues);
    }
View Full Code Here

        //inputRecord 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 != inputMap.size()) {
            throw new IllegalArgumentException("A Java map of size " + inputMap.size() + " cannot be input to a record with " + nFields + " fields.");
        }

        //inputMap, but with the keys sorted in FieldName order.
        final SortedMap<?, ?> fieldNameSortedInputMap;

        //In the case when inputMap is in fact a SortedMap that is using the comparator on the keys, then we can just use it directly.
        //We still need to verify that the keys are in fact FieldNames, but that will be done later.
        //Otherwise we need to copy the map to get a proper iteration order.
        if (inputMap instanceof SortedMap && ((SortedMap<?, ?>)inputMap).comparator() == null) {
            fieldNameSortedInputMap = (SortedMap<?, ?>)inputMap;
        } else {
            fieldNameSortedInputMap = new TreeMap<Object, Object>(inputMap);
        }

        if (nOrdinalFields > 0) {

            final Iterator<?> inputEntrySetIterator = fieldNameSortedInputMap.entrySet().iterator();

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

                final Map.Entry<?, ?> inputEntry = (Map.Entry<?, ?>)inputEntrySetIterator.next();
                final FieldName fieldName = (FieldName)inputEntry.getKey();
                if (!(fieldName instanceof FieldName.Ordinal)
                    || ((FieldName.Ordinal)fieldName).getOrdinal() != recordDict.getNthOrdinalFieldName(i)) {
                    throw new IllegalArgumentException("The field names of the input map and target record must match exactly.");
                }

                final RTValue fieldDict = recordDict.getNthOrdinalValue(i);
                final RTValue fieldValue = RTData.CAL_Opaque.make(inputEntry.getValue());

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

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

            if (nTextualFields > 0) {

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

                    final Map.Entry<?, ?> inputEntry = (Map.Entry<?, ?>)inputEntrySetIterator.next();
                    final FieldName fieldName = (FieldName)inputEntry.getKey();
                    if (!(fieldName instanceof FieldName.Textual)
                        || (fieldName.getCalSourceForm() != recordDict.getNthTextualFieldName(i))) {
                        throw new IllegalArgumentException("The field names of the input map and target record must match exactly.");
                    }

                    final RTValue fieldDict = recordDict.getNthTextualValue(i);
                    final RTValue fieldValue = RTData.CAL_Opaque.make(inputEntry.getValue());

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

                return recordDict.makeFromValues(ordinalValues, textualValues);
            }

            return recordDict.makeFromValues(ordinalValues, null);
        }

        if (nTextualFields > 0) {

            final Iterator<?> inputEntrySetIterator = fieldNameSortedInputMap.entrySet().iterator();

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

                final Map.Entry<?, ?> inputEntry = (Map.Entry<?, ?>)inputEntrySetIterator.next();
                final FieldName fieldName = (FieldName)inputEntry.getKey();
                if (!(fieldName instanceof FieldName.Textual)
                    || !(fieldName.getCalSourceForm().equals(recordDict.getNthTextualFieldName(i)))) {
                    throw new IllegalArgumentException("The field names of the input map and target record must match exactly.");
                }

                final RTValue fieldDict = recordDict.getNthTextualValue(i);
                final RTValue fieldValue = RTData.CAL_Opaque.make(inputEntry.getValue());

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

            return recordDict.makeFromValues(null, textualValues);
        }

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

TOP

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

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.