Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.FieldName


        } else {
            // Must be matching.
            Map<FieldName, String> fieldNameToVarNameMap = ((SwitchAlt.Matching)alt).getFieldNameToVarNameMap();
            for (final Map.Entry<FieldName, String> entry : fieldNameToVarNameMap.entrySet()) {

                FieldName fieldName = entry.getKey();
                String altVar = entry.getValue();
                int fieldIndex = fromDC.getFieldIndex(fieldName);
                altVarIndexList.add(new AltVarIndexPair(altVar, fieldIndex));
            }
        }
View Full Code Here


     * @param dc
     * @param index
     * @return the java name.
     */
    static String getJavaFieldNameFromDC (DataConstructor dc, int index) {
        FieldName fn = dc.getNthFieldName(index);
        String name = getJavaFieldNameFromFieldName(fn);
        if (name == null) {
            name = "field" + index;
        }
        return name;
View Full Code Here

            }
           
            TypeExpr[] fieldTypes = getFieldTypesForDC(dc);
           
            for (int j = 0, k = dc.getArity(); j < k; ++j) {
                FieldName fn = dc.getNthFieldName(j);
                allFieldNames.add(fn);
               
                JavaTypeName jtn = typeExprToTypeName(fieldTypes[j], typeToClassMappings, moduleToPackageMappings, targetPackage);
                Set<JavaTypeName> javaTypeNames = (Set<JavaTypeName>)allFieldTypes.get(fn);
               
View Full Code Here

        TypeExpr fieldTypes[] = getFieldTypesForDC(dataConstructor);
       
        boolean containsFields = false;
       
        for (int i = 0, n = dataConstructor.getArity(); i < n; ++i) {
            FieldName fn = dataConstructor.getNthFieldName(i);
            if (!typeConstructorInfo.commonFieldNames.contains(fn)) {
                containsFields = true;
            }
           
            JavaTypeName javaType = typeExprToTypeName(fieldTypes[i], typeToClassMappings, moduleToPackageMappings, targetPackage);
View Full Code Here

        int nDCs = typeConstructor.getNDataConstructors();
       
        DataConstructor firstDC = typeConstructor.getNthDataConstructor(0);
        for (int i = 0; i < firstDC.getArity(); ++i) {
            FieldName fn = firstDC.getNthFieldName(i);
            commonFieldNames.add(fn);
        }
       
        for (int i = 1; i < nDCs; ++i) {
            DataConstructor dc = typeConstructor.getNthDataConstructor(i);
View Full Code Here

            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());
View Full Code Here

        //todoBI we should be able to implement hasField more efficiently in the
        //case that the fieldName is given in literal form
        //e.g. hasField r "#2" should be inlined directly at compile-time to
        //hasOrdinalField r 2.       
       
        FieldName fieldName = FieldName.make(calSourceFieldName);
        if (fieldName == null) {
            return false;
        }
       
        if (fieldName instanceof FieldName.Textual) {
View Full Code Here

            int arity = dc.getArity();
            if (arity > 0) {
                // private RTValue field1, field2, etc.
                for (int i = 0; i < arity; ++i) {
                    FieldName fn = dc.getNthFieldName(i);
                    if (commonFields.contains(fn)) {
                        // Common fields are implemented in base class.
                        continue;
                    }
View Full Code Here

                // Now update the field name
                if (index == -1) {
                    return;
                }
               
                FieldName oldFieldName = recordFieldModel.getHasFieldName(index);
                RowHeader.FieldNameCellEditor.CellEditorTextField textField = (RowHeader.FieldNameCellEditor.CellEditorTextField)((RowHeader.FieldNameCellEditor)e.getSource()).getComponent();
                String newFieldNameAsString = textField.getText();
               
                if (!textField.isValidFieldName() || newFieldNameAsString.equals(oldFieldName.getCalSourceForm())) {
                    columnModel.getColumn(index).setHeaderValue(oldFieldName.getCalSourceForm());
                    return;
                }
               
                headerOwner.renameField(oldFieldName, FieldName.make(newFieldNameAsString));
            }
View Full Code Here

            this.commonFieldNames = new LinkedHashSet<FieldName>();
            DataConstructor firstDC = dataConsList.get(0);
            boolean[] fieldStrictness = firstDC.getArgStrictness();
            for (int i = 0; i < firstDC.getArity(); ++i) {
                TypeExpr[] fieldTypes = SCJavaDefn.getFieldTypesForDC(firstDC);
                FieldName fn = firstDC.getNthFieldName(i);
                commonFieldNames.add(fn);
                int index = firstDC.getFieldIndex(fn);
                fieldNameToType.put (fn, SCJavaDefn.typeExprToTypeName(fieldTypes[index]));
                fieldNameToStrictness.put (fn, Boolean.valueOf (fieldStrictness[i]));
            }
View Full Code Here

TOP

Related Classes of org.openquark.cal.compiler.FieldName

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.