Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.RecordType


            if (typeExpr.isListType()) {
                if (typeExpr.rootTypeConsApp() == null) {
                    ((TypeApp)typeExpr).getOperandType();
                }
            } else if (typeExpr.isTupleType()) {
                RecordType rt = (RecordType)typeExpr;
                Map<FieldName, TypeExpr> hasFieldsMap = rt.getHasFieldsMap();
                for (Iterator<TypeExpr> it = hasFieldsMap.values().iterator(); it.hasNext();) {
                    updateInputableImports(it.next());
                }
            } else if (!typeExpr.isFunctionType()) {
                if (tca != null) {
View Full Code Here


                    dumpCompilerMessages(logger);
                } else if (qualifiedTypeClassName != null) {
                    ClassInstanceIdentifier id;
                    if (instanceTypeExpr instanceof RecordType) {
                       
                        RecordType recordType = (RecordType)instanceTypeExpr;
                        if (recordType.isRecordPolymorphic()) {
                            id = new UniversalRecordInstance(qualifiedTypeClassName);
                        } else {
                            throw new IllegalArgumentException();
                        }
                    } else if (instanceTypeExpr instanceof TypeConsApp) {
View Full Code Here

                    dumpCompilerMessages(logger);
                } else if (qualifiedTypeClassName != null) {
                    ClassInstanceIdentifier id;
                    if (instanceTypeExpr instanceof RecordType) {
                       
                        RecordType recordType = (RecordType)instanceTypeExpr;
                        if (recordType.isRecordPolymorphic()) {
                            id = new UniversalRecordInstance(qualifiedTypeClassName);
                        } else {
                            throw new IllegalArgumentException();
                        }
                    } else if (instanceTypeExpr instanceof TypeConsApp) {
View Full Code Here

        RecordFieldSelectionGemFieldNameEditor editor = new RecordFieldSelectionGemFieldNameEditor(recordFieldSelectionGem, tableTop);
       
        //create the appropriate editor type
        if (inputTypeExpr instanceof RecordType) {
            RecordType inputType = (RecordType)inputTypeExpr;
           
            Set<FieldName> disallowedFields = new HashSet<FieldName>(inputType.getLacksFieldsSet());
            disallowedFields.removeAll(inputType.getHasFieldNames());
           
            List<FieldName> possibleFields = RecordFieldSelectionGem.possibleFieldNames(inputType, outputTypeExpr, tableTop.getCurrentModuleTypeInfo());
                 
            if (inputType.isRecordPolymorphic()) {
                if (possibleFields.isEmpty()) {
                    fieldEditor = editor.createTextFieldEditor(disallowedFields);
                } else {
                    fieldEditor = editor.createComboFieldEditor(possibleFields, editor.createTextFieldEditor(disallowedFields));
                }
View Full Code Here

        if (tupleValue == null) {
            throw new NullPointerException();
        }
       
        RecordType recordType = typeExprParam.rootRecordType();
        Map<FieldName, TypeExpr> hasFieldsMap = recordType.getHasFieldsMap();
       
        // Set the number of pieces in this tuple so that we know when we're completed
        this.numPieces = hasFieldsMap.size();
       
        if (tupleValue.size() != numPieces) {
View Full Code Here

        // If we don't need to change type expressions... Then we just basically copy the value
        if (getClass().equals(handlerClass)) {
           
            int currentTupleSize = getTupleSize();
            RecordType newRecordType = newTypeExpr.rootRecordType();
            Map<FieldName, TypeExpr> newRecordHasFieldsMap = newRecordType.getHasFieldsMap();
           
            List<ValueNode> newComponentList = new ArrayList<ValueNode>();

            int i = 0;
            for (final TypeExpr componentTypeExpr : newRecordHasFieldsMap.values()) {
View Full Code Here

            }
           
            if (value == null) {

                List<ValueNode> tupleValue = new ArrayList<ValueNode>();
                RecordType recordType = typeExpr.rootRecordType();
                  
                Map<FieldName, TypeExpr> hasFieldsMap = recordType.getHasFieldsMap();
                for (final TypeExpr fieldType : hasFieldsMap.values()) {
               
                    ValueNode newVN = getValueNodeBuilderHelper().getValueNodeForTypeExpr(fieldType);
                   
                    // Return null if a child value node couldn't be built.
View Full Code Here

    public ValueNode transmuteValueNode(ValueNodeBuilderHelper valueNodeBuilderHelper, ValueNodeTransformer valueNodeTransformer, TypeExpr newTypeExpr) {
        Class<? extends ValueNode> handlerClass = valueNodeBuilderHelper.getValueNodeClass(newTypeExpr);

        if ((getClass().equals(handlerClass))) {
           
            RecordType recordType = newTypeExpr.rootRecordType();
            List<FieldName> newFieldNames = recordType.getHasFieldNames();
            List<ValueNode> newFieldNodes = new ArrayList<ValueNode>(newFieldNames.size());
           
            // Transmute all fields which have equal names, and create those which do not
            for (final FieldName newFieldName : newFieldNames) {
                ValueNode newFieldNode;
               
                TypeExpr newFieldType = recordType.getHasFieldType(newFieldName);
                int nameIndex = fieldNames.indexOf(newFieldName);
                if (nameIndex != -1) {
                   
                    // The record field in the new type is contained in our record
                    ValueNode oldFieldNode = this.fieldNodes.get(nameIndex);
View Full Code Here

         * {@inheritDoc}
         */
        @Override
        public RecordValueNode getNodeInstance(Object value, DataConstructor dataConstructor, TypeExpr typeExpr) {

            RecordType recordType = typeExpr.rootRecordType();
           
            if (recordType == null) {
                // This expression is not a record type, so this provides does not handle it
                return null;
            }
           
            List<FieldName> fieldNames = recordType.getHasFieldNames();
           
            // value is either a List of ValueNode or null
            List<ValueNode> listValue = UnsafeCast.asTypeOf(value, Collections.<ValueNode>emptyList());

            if (listValue == null) {
                // Create default value nodes for the fields
               
                int arity = fieldNames.size();
                listValue = new ArrayList<ValueNode>(arity);
                for (int i = 0 ; i < arity; i++) {
               
                    TypeExpr argType = recordType.getHasFieldType(fieldNames.get(i));
                    ValueNode valueNode = getValueNodeBuilderHelper().getValueNodeForTypeExpr(argType);
                    if (valueNode == null) {
                        // Cannot create a node represented, thus cannot create this node
                        return null;
                    }
View Full Code Here

     * @return RecordValueNode with the field renamed
     */
    public AbstractRecordValueNode renameField(FieldName fieldName, FieldName newFieldName, ValueNodeBuilderHelper builderHelper, ValueNodeTransformer transformer) {

        // Create the new record type.
        RecordType newRecordType = getRecordTypeForRenamedField(getTypeExpr(), fieldName, newFieldName);
       
        // Create new record value node by transmuting ourselves to the new record type
       
        AbstractRecordValueNode newRecordNode = (RecordValueNode)this.transmuteValueNode(builderHelper, transformer, newRecordType);
       
View Full Code Here

TOP

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

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.