Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.TypeExpr


     * @param dc
     * @return an array of TypeExpr
     */
    private final TypeExpr[] getFieldTypesForDC (DataConstructor dc) {
        TypeExpr[] fieldTypes = new TypeExpr[dc.getArity()];
        TypeExpr dcType = dc.getTypeExpr();
        TypeExpr[] tft = dcType.getTypePieces(dc.getArity());
        System.arraycopy(tft, 0, fieldTypes, 0, fieldTypes.length);

        return fieldTypes;
    }
View Full Code Here


     */
    @Override
    public void setInitialValue() {
       
        DataConstructorValueNode valueNode = getDataConstructorValueNode();
        TypeExpr valueNodeTypeExpr = valueNode.getTypeExpr();
       
        QualifiedName typeConstructorName = valueNode.getTypeExpr().rootTypeConsApp().getName();
        DataConstructor[] dataConsList = valueEditorManager.getPerspective().getDataConstructorsForType(typeConstructorName);

        DataConstructor currentDataCons = valueNode.getDataConstructor();
View Full Code Here

     */
    private Map<ValueNode, TypeExpr> getValueNodeToUnconstrainedTypeMap() {
       
        Map<ValueNode, TypeExpr> returnMap = new HashMap<ValueNode, TypeExpr>();

        TypeExpr leastConstrainedType = getContext().getLeastConstrainedTypeExpr();
        if (leastConstrainedType.rootTypeVar() != null) {
            leastConstrainedType = getDataConstructor().getTypeExpr().getResultType();
        }
       
        returnMap.put(getValueNode(), leastConstrainedType);
               
View Full Code Here

        return new ValueEditorContext() {

            public TypeExpr getLeastConstrainedTypeExpr() {

                DataConstructor dataConstructor = getDataConstructor();
                TypeExpr leastConstrainedParentType = parentEditor.getContext().getLeastConstrainedTypeExpr();
       
                if (leastConstrainedParentType instanceof TypeVar) {
           
                    // The parent is parametric, that means the child can be whatever it wants.
                    return dataConstructor.getTypeExpr().getTypePieces()[argNum];
View Full Code Here

        for (int i = 0; i < editorPanels.length; i++) {

            ValueNode argValueNode = editorPanels[i].getValueEntryPanel().getOwnerValueNode();

            TypeExpr argType = TypeExpr.getComponentTypeExpr(leastConstrainedType, i, dataCons);

            returnMap.put(argValueNode, argType);
        }

        return returnMap;
View Full Code Here

         * Updates the text and tooltip of the placeholder label.
         * @param polymorphicVarContext used for toString'ing the argument TypeExpr
         */
        public void refreshDisplay(PolymorphicVarContext polymorphicVarContext) {
           
            TypeExpr leastConstrainedType = valueEntryPanel.getContext().getLeastConstrainedTypeExpr();
            TypeExpr actualType = valueEntryPanel.getValueNode().getTypeExpr();
           
            // Show the more specialized of the two types..
            if (actualType instanceof TypeVar) {
                placeHolderLabel.setText(leastConstrainedType.toString(polymorphicVarContext, namingPolicy));
            } else {
                placeHolderLabel.setText(actualType.toString(polymorphicVarContext, namingPolicy));
            }
           
            if (getBorder() instanceof LineBorder) {
                setBorder(BorderFactory.createLineBorder(valueEntryPanel.getBackground(), 1));
            }
View Full Code Here

        TypeExpr[] sourceTypes = new TypeExpr[] {
            TypeExpr.makeParametricType()// first argument
            TypeExpr.makeParametricType()// second argument
            TypeExpr.makeParametricType()   // output type
        };
        TypeExpr destType = calServices.getTypeFromString(testModule, "a -> b");
       
        AutoburnInfo autoburnInfo = AutoburnLogic.getAutoburnInfo(destType, sourceTypes, calServices.getTypeCheckInfo(testModule));
        assertEquals(AutoburnLogic.AutoburnUnifyStatus.AMBIGUOUS_NOT_NECESSARY, autoburnInfo.getAutoburnUnifyStatus());
       
        // Every possible burn combination is valid here, ie leaving both arguments unburned,
View Full Code Here

        // Make the source a function of type a -> b, and the destination a gem of type [a].
        TypeExpr[] sourceTypes = new TypeExpr[] {           
            TypeExpr.makeParametricType()// second argument
            TypeExpr.makeParametricType()   // output type
        };
        TypeExpr destType = calServices.getTypeFromString(testModule, "[a]");
       
        AutoburnInfo autoburnInfo = AutoburnLogic.getAutoburnInfo(destType, sourceTypes, calServices.getTypeCheckInfo(testModule));

        // The only possibility here is to leave the argument unburned.
        assertEquals(AutoburnLogic.AutoburnUnifyStatus.NOT_NECESSARY, autoburnInfo.getAutoburnUnifyStatus());
View Full Code Here

     */
    public void testAutoburnGemEntity() {
       
        // We'll use List.map for the source entity and [a] -> [b] for the destination
        GemEntity gemEntity = calServices.getCALWorkspace().getGemEntity(CAL_List.Functions.map);
        TypeExpr destType = calServices.getTypeFromString(testModule, "[a] -> [b]");
       
        AutoburnInfo autoburnInfo = AutoburnLogic.getAutoburnInfo(destType, gemEntity, calServices.getTypeCheckInfo(testModule));
        assertEquals(AutoburnLogic.AutoburnUnifyStatus.UNAMBIGUOUS, autoburnInfo.getAutoburnUnifyStatus());
       
        // The only way to connect these two types together is by burning the second argument.
View Full Code Here

        Set<TypeExpr> matchingTypes = new HashSet<TypeExpr>();
        ModuleTypeInfo currentModuleTypeInfo = valueEditorManager.getPerspective().getWorkingModuleTypeInfo();
       
        if (currentModuleTypeInfo != null) {
           
            TypeExpr valueNodeTypeExpr = getValueNode().getTypeExpr();
       
            for (final TypeExpr typeExpr : dataTypes) {
   
                if (TypeExpr.canPatternMatch(typeExpr, valueNodeTypeExpr, currentModuleTypeInfo)) {
                    matchingTypes.add(typeExpr);
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.