Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.TypeExpr


               
                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


    public static RecordType getRecordTypeForRenamedField(TypeExpr typeExpr, FieldName oldFieldName, FieldName newFieldName) {

        Map<FieldName, TypeExpr> fieldNamesToTypeMap = new HashMap<FieldName, TypeExpr>();
        List<FieldName> existingFields = typeExpr.rootRecordType().getHasFieldNames();
        for (final FieldName existingFieldName : existingFields) {
            TypeExpr existingFieldType = typeExpr.rootRecordType().getHasFieldType(existingFieldName);

            fieldNamesToTypeMap.put(existingFieldName, existingFieldType);
        }
       
        TypeExpr fieldTypeExpr = fieldNamesToTypeMap.remove(oldFieldName);
        fieldNamesToTypeMap.put(newFieldName, fieldTypeExpr);

        return TypeExpr.makeNonPolymorphicRecordType(fieldNamesToTypeMap);
    }
View Full Code Here

        super(valueEntryPanel);
       
        ValueNode valueNode = valueEntryPanel.getValueNode();
       
        TypeExpr typeExpr = valueNode.getTypeExpr();

        if (typeExpr.isNonParametricType(CAL_RelativeTime.TypeConstructors.RelativeTime)) {

            m_timeOrDateType = RELATIVETIME;

        } else if (typeExpr.isNonParametricType(CAL_RelativeTime.TypeConstructors.RelativeDate)) {

            m_timeOrDateType = RELATIVEDATE;

        } else if (typeExpr.isNonParametricType(CAL_RelativeTime.TypeConstructors.RelativeDateTime)) {

            m_timeOrDateType = RELATIVEDATETIME;

        } else if(typeExpr.isNonParametricType(CAL_Time.TypeConstructors.Time)) {
            m_timeOrDateType = JTIME;
        } else {

            throw new IllegalArgumentException("Error in constructor DateTimeValueEntryField:\nThe param valueNode is not of type Date/Time/DateTime.");
        }
View Full Code Here

        public void stateChanged(ChangeEvent evt) {

            ValueNode oldValue = getValueNode();
            Integer newValue = new Integer(slider.getValue());

            TypeExpr typeExpr = getValueNode().getTypeExpr();
            replaceValueNode(new LiteralValueNode(newValue, typeExpr), true);

            label.setText(String.valueOf(slider.getValue()));
            label.setToolTipText(String.valueOf(slider.getValue()));
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    public boolean select(GemEntity gemEntity) {

         TypeExpr gemType = gemEntity.getTypeExpr();
         if (gemType.getArity() != 1) {
             return false;
         }
               
         TypeExpr[] filterTypePieces = new TypeExpr[]{inputType, outputType};
        
         TypeExpr[] gemTypePieces = gemType.getTypePieces();
       
         // See if unification/pattern matching works.
         if (selectMoreGeneralized) {
             return TypeExpr.canUnifyTypePieces(gemTypePieces, filterTypePieces, currentModuleTypeInfo);
         } else {
View Full Code Here

     * @param sortGems  If true, then the gems will be sorted alphabetically.
     * @return a set of the matching gems
     */
    public Set<GemEntity> findGemsOfType(ModuleName scopeModule, String typeName, boolean sortGems) {
        // Get the type expression for the type name.
        final TypeExpr typeExpr = getTypeFromString(scopeModule, typeName);
        if (typeExpr == null) {
            return Collections.emptySet();
        }

        // Find all gems matching this type.
        final ModuleTypeInfo targetModuleTypeInfo = getModuleTypeInfo(scopeModule);
        GemFilter filter = new GemFilter() {
            @Override
            public boolean select(GemEntity gemEntity) {
                TypeExpr gemType = gemEntity.getTypeExpr();
                return TypeExpr.canPatternMatch(gemType, typeExpr, targetModuleTypeInfo);
            }
        };
        return getMatchingGems(filter, sortGems);
    }
View Full Code Here

     * @param sortGems        If true, then the gems will be sorted alphabetically.
     * @return (Set of GemEntity) a set of the matching gems
     */
    public Set<GemEntity> findGemsByReturnType(ModuleName scopeModule, String returnTypeName, boolean sortGems) {
        // Get the type expression for the type name.
        final TypeExpr returnTypeExpr = getTypeFromString(scopeModule, returnTypeName);
        if (returnTypeExpr == null) {
            return Collections.emptySet();
        }

        // Find all gems matching this type.
        final ModuleTypeInfo targetModuleTypeInfo = getModuleTypeInfo(scopeModule);
        GemFilter filter = new GemFilter() {
            @Override
            public boolean select(GemEntity gemEntity) {
                TypeExpr gemResultType = gemEntity.getTypeExpr().getResultType();
                return TypeExpr.canPatternMatch(gemResultType, returnTypeExpr, targetModuleTypeInfo);
            }
        };
        return getMatchingGems(filter, sortGems);
    }
View Full Code Here

    public void setOwnerValueNode(ValueNode newValueNode) {
        super.setOwnerValueNode(newValueNode);
       
        Time timeValue = (Time)getJTimeValueNode().getValue();
        Date dateTimeValue = timeValue.toDate();
        TypeExpr dateType = valueEditorManager.getValueNodeBuilderHelper().getTypeConstructorForName(CAL_RelativeTime.TypeConstructors.RelativeDate);
        TypeExpr timeType = valueEditorManager.getValueNodeBuilderHelper().getTypeConstructorForName(CAL_RelativeTime.TypeConstructors.RelativeTime);
       
        dateValueEditor.setOwnerValueNode(new RelativeDateValueNode(dateTimeValue, dateType));
        timeValueEditor.setOwnerValueNode(new RelativeTimeValueNode(dateTimeValue, timeType));
    }
View Full Code Here

        if (listEntry != null) {
           
            GemEntity gemEntity = (GemEntity) listEntry.getData();
            ModuleTypeInfo currentModuleInfo = valueEditorManager.getPerspective().getWorkingModuleTypeInfo();
            TypeExpr valueNodeType = getValueNode().getTypeExpr();
            TypeExpr functionType = gemEntity.getTypeExpr();
            TypeExpr unifiedType;
           
            try {
                unifiedType = TypeExpr.unify(valueNodeType, functionType, currentModuleInfo);
            } catch (TypeException e) {
                throw new IllegalStateException(e.getMessage());
View Full Code Here

    /**
     * @param mf
     * @return - true if this SC has strict arguments of an unboxable type.
     */
    private boolean hasStrictUnboxableArguments (MachineFunction mf) throws CodeGenerationException {
        TypeExpr paramTypes[] = mf.getParameterTypes();
        boolean paramStrictness[] = mf.getParameterStrictness();

        for (int i = 0, n = paramTypes.length; i < n; ++i) {
            if (SCJavaDefn.canTypeBeUnboxed(paramTypes[i]) && paramStrictness[i]) {
                return true;
View Full Code Here

TOP

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

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.