Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.TypeExpr


        // is the expression of the type constructor argument (ie: this is 'Double' if
        // the editor value node type is 'Range Double')
        ValueEditorContext context = new ValueEditorContext() {
            public TypeExpr getLeastConstrainedTypeExpr() {

                TypeExpr leastConstrainedParentType = getContext().getLeastConstrainedTypeExpr();
                if (leastConstrainedParentType instanceof TypeVar) {
                    // Range type is parametric (ie: value gem was not bound to connection)
                   
                    // The editors will handle types unifying with "Ord a => a", the valid type for
                    // of the range constructor.
                    TypeExpr ordType = ordRangeType.getArg(0);
                    return ordType;
       
                } else {
                    // The parent is not parametric, so the child must fit the parent constraint.
                    // Here also check and enforce ordering
                   
                    TypeExpr childExpr = ((TypeConsApp)leastConstrainedParentType).getArg(0);
                    TypeExpr newType = null;
                    try {
                        newType = TypeExpr.unify(ordRangeType.getArg(0), childExpr, getValueEditorHierarchyManager().getValueEditorManager().getPerspective().getWorkingModuleTypeInfo());
                    } catch (TypeException e) {
                        throw new IllegalStateException("RangeValueEditor: Failed to unify type '" + childExpr + "' with '" + ordRangeType + "'.");
                    }
View Full Code Here


    private void enforceOrdType() {
       
        // Retrieve the default type expression of the parent editor node.
        // This is retrieved from the type of the supercombinator constructing
        // the range entity, and will be "Ord a => Range a".
        TypeExpr ordParametric = ordRangeType;
       
        // Now, unify this with the current value node type. This will (1) specialize
        // a fully parametric type (ie: Range a) to be an instance of Ord, and (2) check that
        // if the type is already specialized (ex: Range Double), the type is actually orderable
        // (this check is enforced in RangeValueNode).
        TypeExpr newType = null;
        try {
            newType = TypeExpr.unify(ordParametric, getValueNode().getTypeExpr(), getValueEditorHierarchyManager().getValueEditorManager().getPerspective().getWorkingModuleTypeInfo());
        } catch (TypeException e) {
            throw new IllegalStateException("RangeValueEditor: Failed to unify type '" + getValueNode().getTypeExpr() + "' with '" + ordParametric + "'.");
        }
View Full Code Here

       
        Map<ValueNode, TypeExpr> returnMap = new HashMap<ValueNode, TypeExpr>();

        // Calculate the type of the parent value editor node
       
        TypeExpr contextType = getContext().getLeastConstrainedTypeExpr();
        if (contextType.rootTypeVar() != null) {
            // ValueGem is not bound to a context, so the type should be the parametric range type
           
            // Retrieve the default type expression of the parent editor node.
            //
            // This is retrieved from the type of the supercombinator constructing
            // the range entity, and will be "Ord a => Range a".
            contextType = ordRangeType;
        }
                   
        // Populate the map
       
        // With our node and type
        returnMap.put(getValueNode(), contextType);
                   
        // With the child editor nodes and types
        TypeExpr childType = contextType.rootTypeConsApp().getArg(0);
        returnMap.put(leftEditor.getOwnerValueNode(), childType);
        returnMap.put(rightEditor.getOwnerValueNode(), childType);

        return returnMap;
    }
View Full Code Here

     */
    protected JTextComponent getValueField() {
       
        if (ivjValueField == null) {

            TypeExpr typeExpr = getValueNode() != null ? getValueNode().getTypeExpr() : TypeExpr.makeParametricType();
           
            // Date and Time types get a special value field.
            if(typeExpr.isNonParametricType(CAL_RelativeTime.TypeConstructors.RelativeDate) ||
               typeExpr.isNonParametricType(CAL_RelativeTime.TypeConstructors.RelativeTime) ||
               typeExpr.isNonParametricType(CAL_RelativeTime.TypeConstructors.RelativeDateTime) ||
               typeExpr.isNonParametricType(CAL_Time.TypeConstructors.Time)) {
               
                ivjValueField = new DateTimeValueEntryField(this);
   
            } else {
               
View Full Code Here

            remove(oldValueField);
            add(newValueField, BorderLayout.CENTER);
            revalidate();
        }
       
        TypeExpr typeExpr = getValueNode() != null ? getValueNode().getTypeExpr() : TypeExpr.makeParametricType();
       
        // If there's an argument name, pass it on to the value field.
        if (argumentName != null) {
            ((ValueEntryField) ivjValueField).setToolTipPrefix(argumentName + ":  ");
        }
       
        // Check if we should use a border.
        if (!valueEditorManager.useValueEntryPanelBorders()) {
            ivjValueField.setBorder(null);
        }
       
        // Remove the old key listener.
        ivjValueField.removeKeyListener(valueFieldKeyListener);
        valueFieldKeyListener = null;
       
        PreludeTypeConstants typeConstants = valueEditorManager.getValueNodeBuilderHelper().getPreludeTypeConstants();
       
        // Add a special key listener for certain types.
        if (typeExpr.sameType(typeConstants.getCharType())) {
           
            valueFieldKeyListener = new CharTypeKeyListener();
            ivjValueField.addKeyListener(valueFieldKeyListener);
       
        } else if (typeExpr.rootTypeConsApp() != null) {
           
            QualifiedName typeConsName = typeExpr.rootTypeConsApp().getName();
           
            if (valueEditorManager.getPerspective().isEnumDataType(typeConsName)) {
               
                valueFieldKeyListener = new EnumTypeKeyListener();
                ivjValueField.addKeyListener(valueFieldKeyListener);
View Full Code Here

     */
    private void updateDisplayedValue() {

        // Handle this depending on type.
        ValueNode valueNode = getValueNode();
        TypeExpr typeExpr = valueNode.getTypeExpr();

        // Note: if this is set as output, then the value field will not be a
        // DateTimeValueEntryField, but a text field!
        if (typeExpr.isNonParametricType(CAL_RelativeTime.TypeConstructors.RelativeDate)) {

            DateTimeValueEntryField dateTimeVef = (DateTimeValueEntryField) getValueField();
            dateTimeVef.setFormat(DateTimeValueEntryField.RELATIVEDATE);
            dateTimeVef.setDate(((RelativeDateValueNode)valueNode).getDateValue());

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

            DateTimeValueEntryField dateTimeVef = (DateTimeValueEntryField) getValueField();
            dateTimeVef.setFormat(DateTimeValueEntryField.RELATIVETIME);
            dateTimeVef.setDate(((RelativeTimeValueNode)valueNode).getTimeValue());

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

            DateTimeValueEntryField dateTimeVef = (DateTimeValueEntryField) getValueField();
            dateTimeVef.setFormat(DateTimeValueEntryField.RELATIVEDATETIME);
            dateTimeVef.setDate(((RelativeDateTimeValueNode)valueNode).getDateTimeValue());

        } else if (typeExpr.isNonParametricType(CAL_Time.TypeConstructors.Time)) {

            DateTimeValueEntryField dateTimeVef = (DateTimeValueEntryField) getValueField();
            dateTimeVef.setFormat(DateTimeValueEntryField.JTIME);
            dateTimeVef.setDate(((JTimeValueNode)valueNode).getJavaDate());

View Full Code Here

    public void setOwnerValueNode(ValueNode newValueNode) {
       
        ValueNode oldOwnerValueNode = getOwnerValueNode();

        super.setOwnerValueNode(newValueNode);
        TypeExpr typeExpr = getValueNode().getTypeExpr();

        // if the value changed, give it a new value entry field.
        if (oldOwnerValueNode == null || !oldOwnerValueNode.sameValue(newValueNode)) {

            // Set-up this ValueEntryPanel with the data in the ValueNode.
View Full Code Here

     * Position the cursor of the value field based on the type and editability of the value.
     */
    private void positionValueFieldCursor() {

        JTextComponent textField = getValueField();
        TypeExpr typeExpr = getValueNode().getTypeExpr();

        // Just position the cursor at the beginning of the document if the text is not editable.
        // Otherwise highlight all of the text.
        if (!isEditable() || !valueEditorManager.isTextEditable(typeExpr)) {

View Full Code Here

            for (int j = 0, k = module.getNClassInstances(); j < k; ++j) {
                ClassInstance ci = module.getNthClassInstance(j);
                if (ci.getTypeClass().getName().equals(CAL_Prelude.TypeClasses.Inputable) ||
                    ci.getTypeClass().getName().equals(CAL_Prelude.TypeClasses.Outputable)) {
                    // Check the instance type
                    TypeExpr instanceTypeExpr = ci.getType();
                    TypeConsApp tca = instanceTypeExpr.rootTypeConsApp();
                    if (tca != null) {
                        if (tca.getRoot().getName().equals(tc.getName())) {
                            alreadyInputableOutputable = true;
                        }
                    }
View Full Code Here

            String targetPackage) throws UnableToResolveForeignEntityException {
       
        Map<FieldName, String> fieldJavaAccessorMethodNames = new LinkedHashMap<FieldName, String>();
        Map<FieldName, JavaTypeName> fieldTypeNames = new LinkedHashMap<FieldName, JavaTypeName>();
       
        TypeExpr fieldTypes[] = getFieldTypesForDC(dataConstructor);
       
        boolean containsFields = false;
       
        for (int i = 0, n = dataConstructor.getArity(); i < n; ++i) {
            FieldName fn = dataConstructor.getNthFieldName(i);
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.