Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.TypeExpr


        // If the gem can't have inputs check if it is connectable.
        int numArgs = thisGem.getNInputs();
        if (numArgs == 0 || thisGem instanceof CollectorGem) {
           
            TypeExpr gemType = thisGem.getOutputPart().getType();
            if (TypeExpr.canUnifyType(gemType, typeToUnify, currentModuleTypeInfo)) {
                return AutoburnLogic.AutoburnAction.NOTHING;   
            } else {
                return AutoburnLogic.AutoburnAction.IMPOSSIBLE;
            }
View Full Code Here


     *
     * @param gemEntity
     * @return Returns true iff the signature of the gem is suitable. In practice, this means that the gem returns Boolean.
     */
    protected boolean checkSignature (GemEntity gemEntity) {
        TypeExpr gemTypeExpr = gemEntity.getTypeExpr();
       
        return gemTypeExpr.getResultType().isNonParametricType(CAL_Prelude.TypeConstructors.Boolean);
    }
View Full Code Here

     * @param envEntity the FunctionalAgent being documented. Can be null if the comment is not for an FunctionalAgent.
     * @param scopedEntityNamingPolicy the naming policy to use for generating qualified/unqualified names.
     * @return a plain text representation for the comment.
     */
    public static String getTextFromCALDocComment(final CALDocComment caldoc, final FunctionalAgent envEntity, final ScopedEntityNamingPolicy scopedEntityNamingPolicy) {
        TypeExpr typeExpr;
        if (envEntity == null) {
            typeExpr = null;
        } else {
            typeExpr = envEntity.getTypeExpr();
        }
View Full Code Here

     * @param caldoc the associated CALDoc. Can be null.
     * @param envEntity the associated entity. Can be null.
     * @param scopedEntityNamingPolicy the naming policy to use for generating qualified/unqualified names.
     */
    public static String getTextForArgumentsAndReturnValue(final CALDocComment caldoc, final FunctionalAgent envEntity, final ScopedEntityNamingPolicy scopedEntityNamingPolicy) {
        TypeExpr typeExpr;
        if (envEntity == null) {
            typeExpr = null;
        } else {
            typeExpr = envEntity.getTypeExpr();
        }
View Full Code Here

        }
    }
   
    private QualifiedName qualifyTypeClass(String typeClassName) {
        CompilerMessageLogger logger = new MessageLogger();
        TypeExpr typeExpr = getTypeChecker().getTypeFromString(typeClassName + " a => a", targetModule, logger);
       
        if (logger.getNErrors() > 0) {
            dumpCompilerMessages(logger);
            return null;
        }
       
        String typeString = typeExpr.toString(ScopedEntityNamingPolicy.FULLY_QUALIFIED);
       
        String qualifiedTypeClassName = typeString.substring(0, typeString.indexOf(' '));
       
        if (qualifiedTypeClassName.indexOf('.') != -1) {
            return QualifiedName.makeFromCompoundName(qualifiedTypeClassName);
View Full Code Here

                String typeClassName = args.substring(0, nextSpace);
                String instanceTypeString = args.substring(nextSpace).trim();
               
                QualifiedName qualifiedTypeClassName = resolveTypeClassName(typeClassName);
                CompilerMessageLogger logger = new MessageLogger();
                TypeExpr instanceTypeExpr = getTypeChecker().getTypeFromString(instanceTypeString, targetModule, logger);
               
                if (logger.getNErrors() > 0) {
                    dumpCompilerMessages(logger);
                } else if (qualifiedTypeClassName != null) {
                    ClassInstanceIdentifier id;
View Full Code Here

                String typeClassName = args.substring(0, nextSpace);
                String instanceTypeString = args.substring(nextSpace).trim();
               
                QualifiedName qualifiedTypeClassName = resolveTypeClassName(typeClassName);
                CompilerMessageLogger logger = new MessageLogger();
                TypeExpr instanceTypeExpr = getTypeChecker().getTypeFromString(instanceTypeString, targetModule, logger);
               
                if (logger.getNErrors() > 0) {
                    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) {
                        id = new TypeConstructorInstance(qualifiedTypeClassName, ((TypeConsApp)instanceTypeExpr).getName());
                    } else {
                        throw new IllegalArgumentException();       
                    }
                   
                    ModuleTypeInfo typeInfo = workspaceManager.getModuleTypeInfo(targetModule);
                    if (typeInfo == null) {
                        iceLogger.log(Level.INFO, "The module " + targetModule + " does not exist.");
                    } else {
                        ClassInstance instance = typeInfo.getVisibleClassInstance(id);
                       
                        if (instance == null) {
                            iceLogger.log(Level.INFO, "The instance " + id + " does not exist.");
                        } else {
                            ScopedEntityNamingPolicy scopedEntityNamingPolicy = new ScopedEntityNamingPolicy.UnqualifiedUnlessAmbiguous(typeInfo);
                           
                            TypeExpr instanceMethodTypeExpr = instance.getInstanceMethodType(methodName);
                           
                            iceLogger.log(Level.INFO, methodName + " :: " + instanceMethodTypeExpr.toString(scopedEntityNamingPolicy) + "\n");
                           
                            ClassMethod classMethod = instance.getTypeClass().getClassMethod(methodName);
                           
                            try {
                                CALDocComment comment = instance.getMethodCALDocComment(methodName);
View Full Code Here

            }
           
            String scDef = qualificationResults.getQualifiedCode();
            scDef = targetName + " = \n" + scDef + "\n;";
           
            TypeExpr te = getTypeChecker().checkFunction(new AdjunctSource.FromText(scDef), targetModule, logger);
            if (te == null) {
                iceLogger.log(Level.INFO, "Attempt to type expression has failed because of errors: ");
                dumpCompilerMessages(logger);
                return;
            }
           
            //we want to display the type using fully qualified type constructor names, but also making use of
            //preferred names of type are record variables
            iceLogger.log(Level.INFO, "  " + te.toString(true, ScopedEntityNamingPolicy.FULLY_QUALIFIED) + "\n");
        }
    }
View Full Code Here

        InputListItem item = getSelectedInputListItem ();

        propertyCombo.removeAllItems ();

        if (item != null) {
            TypeExpr inputTypeExpr = item.typeExpr;

            int inputDataType = typeExprToDataType (inputTypeExpr);

            propertyCombo.initialise(jobDescription.getMessagePropertyDescriptions (), inputDataType);
        }
View Full Code Here

            BasicCALServices calServices = MonitorApp.getInstance().getCalServices();
            //for all message properties consider which metrics are suitable
            Collection<MessagePropertyDescription> msgProperties = jobDescription.getMessagePropertyDescriptions();
            for (final MessagePropertyDescription propertyInfo : msgProperties) {
                TypeExpr propertyType = propertyInfo.getCalType(calServices);
                              
                Set<GemEntity> gemEntities = new MetricGemFilter(propertyType, inputItem.typeExpr).getMatchingGems();
                for (final GemEntity gemEntity : gemEntities) {
                    metricCombo.addItem(new MetricComboItem (new MetricDescription(gemEntity.getName(), propertyInfo )));
                                           
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.