Package org.openquark.gems.client.AutoburnLogic

Examples of org.openquark.gems.client.AutoburnLogic.AutoburnInfo


                } else {
                    autoBurnLastResult = AutoburnLogic.AutoburnAction.IMPOSSIBLE;                  
                }
            } else {

                AutoburnInfo autoburnInfo =
                    GemGraph.isAncestorOfBrokenGemForest(thisGem) ?
                            null :
                                AutoburnLogic.getAutoburnInfo(typeToUnify, thisGem, tableTop.getTypeCheckInfo());

                AutoburnUnifyStatus autoburnUnifyStatus =
                    autoburnInfo != null ?
                            autoburnInfo.getAutoburnUnifyStatus() :
                                AutoburnLogic.AutoburnUnifyStatus.NOT_POSSIBLE;          

                if (autoburnUnifyStatus == AutoburnUnifyStatus.UNAMBIGUOUS_NOT_NECESSARY) {

                    // This means the gems can be connected either by burning them or by
                    // just connecting them without burning. In this case we want to determine
                    // which action is best and do that.

                    int noBurnCloseness = TypeExpr.getTypeCloseness(thisGem.getOutputPart().getType(), typeToUnify, currentModuleTypeInfo);
                    if (autoburnInfo.getMaxTypeCloseness() > noBurnCloseness) {
                        autoburnUnifyStatus = AutoburnUnifyStatus.UNAMBIGUOUS;
                    } else {
                        autoburnUnifyStatus = AutoburnUnifyStatus.NOT_NECESSARY;
                    }

                    // Now resume checking the basic possibilities.
                }

                if (autoburnUnifyStatus == AutoburnUnifyStatus.UNAMBIGUOUS) {

                    autoBurnLastResult = AutoburnLogic.AutoburnAction.BURNED;
                    gemChanged = true;

                    // Set the inputs according to the unambiguous burning. 
                    // This should trigger burn events on listeners, causing the GemGraph to be re-typed.
                    AutoburnLogic.BurnCombination burnCombination = autoburnInfo.getBurnCombinations().get(0);
                    int[] burnArray = burnCombination.getInputsToBurn();
                    doAutoburnUserAction(thisGem, burnArray);

                } else if (autoburnUnifyStatus == AutoburnUnifyStatus.AMBIGUOUS) {
View Full Code Here


            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,
        // burning either argument, or burning both arguments.
        assertEquals(3, autoburnInfo.getBurnCombinations().size());       
        int[] argsToBurn = (autoburnInfo.getBurnCombinations().get(0)).getInputsToBurn();
        assertTrue(Arrays.equals(argsToBurn, new int[] {0}));
        argsToBurn = (autoburnInfo.getBurnCombinations().get(1)).getInputsToBurn();
        assertTrue(Arrays.equals(argsToBurn, new int[] {1}));
        argsToBurn = (autoburnInfo.getBurnCombinations().get(2)).getInputsToBurn();
        assertTrue(Arrays.equals(argsToBurn, new int[] {0, 1}));
    }
View Full Code Here

            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());
        assertEquals(0, autoburnInfo.getBurnCombinations().size());      
    }
View Full Code Here

       
        // 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.
        assertEquals(1, autoburnInfo.getBurnCombinations().size());       
        int[] argsToBurn = (autoburnInfo.getBurnCombinations().get(0)).getInputsToBurn();
        assertTrue(Arrays.equals(argsToBurn, new int[] {1}));
    }   
View Full Code Here

        if (intellicutMode == IntellicutMode.PART_INPUT) {
               
            // Figure out if we should connect the gem by burning it or by just connecting it.
            // We want to perform whatever action results in the highest type closeness.

            AutoburnInfo autoburnInfo = AutoburnLogic.getAutoburnInfo(part.getType(), dGem.getGem(), gemCutter.getTypeCheckInfo());
            AutoburnUnifyStatus burnStatus = autoburnInfo.getAutoburnUnifyStatus();
           
            boolean attemptToConnect = burnStatus.isAutoConnectable();
       
            if (burnStatus == AutoburnUnifyStatus.UNAMBIGUOUS) {

                // Perform the burn if it is unambiguous.
                attemptToConnect = autoburnGem(dGem, autoburnInfo);
               
            } else if (burnStatus == AutoburnUnifyStatus.UNAMBIGUOUS_NOT_NECESSARY) {

                // Only burn it if that is better than not burning it.
                int noBurnTypeCloseness = TypeExpr.getTypeCloseness(part.getType(), dGem.getGem().getOutputPart().getType(), gemCutter.getPerspective().getWorkingModuleTypeInfo());
                if (autoburnInfo.getMaxTypeCloseness() > noBurnTypeCloseness) {
                    attemptToConnect = autoburnGem(dGem, autoburnInfo);
                }
            }
          
            if (attemptToConnect) {
View Full Code Here

TOP

Related Classes of org.openquark.gems.client.AutoburnLogic.AutoburnInfo

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.