Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.QualifiedName


        for (int i = 0; i < getArity(); ++i) {
            if (args[i].asLiteral() != null) {
                needTemp[i] = 1;
            } else
            if (args[i].asVar() != null) {
                QualifiedName newVarName = args[i].asVar().getName();
                // If the argument is being passed unchanged to the tail recursive call we can skip the assignment.
                if (newVarName.equals(QualifiedName.make(currentModuleName, argumentNames[i])) &&
                        variableContext.isFunctionArgument(newVarName)) {
                        // The argument passed to the function is being passed unchanged in the tail recursive call.
                        needTemp[i] = 2;
                } else
                // If the var is a local or an sc do a simple assignment
                if (!variableContext.isLocalVariable(newVarName) ||
                    variableContext.isDCField(newVarName) ||
                    variableContext.isRecordField(newVarName)) {
                    needTemp[i] = 1;
                } else
                // If the assignment is to a following argument it is safe to do a simple assignment.
                if (variableContext.isFunctionArgument(newVarName)) {
                    for (int j = i + 1; j < getArity(); ++j) {
                        if (argumentNames[j].equals(newVarName.getUnqualifiedName())) {
                            needTemp[i] = 1;
                        }
                    }
                }

            } else {
                boolean dependent = false;
                for (int j = 0; j < i; j++) {
                    QualifiedName argName = QualifiedName.make(currentModuleName, argumentNames[j]);
                    if (needTemp[j] != 2 && args[i].isDependentOn(argName)) {
                        dependent = true;
                        break;
                    }
                }
View Full Code Here


        String iconName = "/Resources/sometype.gif";

        if (typeConsApp != null) {
           
            QualifiedName typeIde = typeConsApp.getName();

            // Note: The bool check should come before the enumerated check.  Since bool can count as an enumerated type.
            if (typeIde.equals(CAL_Prelude.TypeConstructors.Boolean)) {
                iconName = "/Resources/bool.gif";

            } else if (typeIde.equals(CAL_Prelude.TypeConstructors.Double) ||
                       typeIde.equals(CAL_Prelude.TypeConstructors.Float) ||
                       typeIde.equals(CAL_Prelude.TypeConstructors.Decimal)) {
                iconName = "/Resources/float.gif";

            } else if (typeIde.equals(CAL_Prelude.TypeConstructors.Int) ||
                       typeIde.equals(CAL_Prelude.TypeConstructors.Integer) ||
                       typeIde.equals(CAL_Prelude.TypeConstructors.Byte) ||
                       typeIde.equals(CAL_Prelude.TypeConstructors.Short) ||
                       typeIde.equals(CAL_Prelude.TypeConstructors.Long)) {
                iconName = "/Resources/integer.gif";

            } else if (typeIde.equals(CAL_Prelude.TypeConstructors.Char)) {
                iconName = "/Resources/char.gif";

            } else if (typeIde.equals(CAL_RelativeTime.TypeConstructors.RelativeDate)) {
                iconName = "/Resources/date.gif";

            } else if (typeIde.equals(CAL_RelativeTime.TypeConstructors.RelativeTime)) {
                iconName = "/Resources/time.gif";

            } else if (typeIde.equals(CAL_RelativeTime.TypeConstructors.RelativeDateTime) ||
                       typeIde.equals(CAL_Time.TypeConstructors.Time)) {
                iconName = "/Resources/datetime.gif";

            } else if (typeIde.equals(CAL_Color.TypeConstructors.Color)) {
                iconName = "/Resources/colour.gif";

            } else if (typeIde.equals(CAL_File.TypeConstructors.FileName)) {
                iconName = "/Resources/file.gif";

            } else if (typeIde.equals(CAL_Prelude.TypeConstructors.String)) {
                iconName = "/Resources/string.gif";
               
            } else if (typeIde.equals(CAL_Prelude.TypeConstructors.List)) {
              
                TypeExpr elementTypeExpr = typeConsApp.getArg(0);

                TypeConsApp elementTypeConsApp = elementTypeExpr.rootTypeConsApp();

                if (elementTypeConsApp != null) {

                    QualifiedName elementIde = elementTypeConsApp.getName();

                    if (elementIde.equals(CAL_Prelude.TypeConstructors.Char)) {
                        iconName = "/Resources/string.gif";

                    } else {
                        iconName = "/Resources/list.gif";
                    }
View Full Code Here

                    // Variable name will be in the form $dictvarModule.Class#N where N is an integer
                    // number and where dictvarModule may contain zero or more dots.
                    String name = chain[0].asVar().getName().getUnqualifiedName();
                    name = name.substring(8);

                    QualifiedName qualifiedClassName = QualifiedName.makeFromCompoundName(name.substring(0, name.indexOf("#")));

                    codeGenerationStats.incrementOptimizedDictionaryApplication(qualifiedClassName);
                }

                // First generate the java expressions for the CAL expressions.
View Full Code Here

    /**
     * @param dc
     * @return true for the data constructors Prelude.True or Prelude.False.
     */
    private static boolean isTrueOrFalseDataCons(DataConstructor dc) {
        QualifiedName qn = dc.getName();
        return qn.equals(CAL_Prelude.DataConstructors.True) || qn.equals(CAL_Prelude.DataConstructors.False);
    }
View Full Code Here

           
            TypeConsApp typeConsApp = typeExpr.rootTypeConsApp();

            // Estimate a reasonable preferred width for the various types.
                       
            QualifiedName typeConsName = typeConsApp.getName();

            if (typeConsName.equals(CAL_Prelude.TypeConstructors.Double) ||
                typeConsName.equals(CAL_Prelude.TypeConstructors.Float) ||
                typeConsName.equals(CAL_Prelude.TypeConstructors.Byte) ||
                typeConsName.equals(CAL_Prelude.TypeConstructors.Int) ||
                typeConsName.equals(CAL_Prelude.TypeConstructors.Integer) ||
                typeConsName.equals(CAL_Prelude.TypeConstructors.Decimal) ||
                typeConsName.equals(CAL_Prelude.TypeConstructors.Long) ||
                typeConsName.equals(CAL_Prelude.TypeConstructors.Short)) {
               
                baseline = "999.99";

            } else if (typeConsName.equals(CAL_Prelude.TypeConstructors.Char)) {
                baseline = "W";

            } else if (typeConsName.equals(CAL_Prelude.TypeConstructors.String)) {
                baseline = "A reasonably long string value.";
               
            } else if (typeConsName.equals(CAL_RelativeTime.TypeConstructors.RelativeDate)) {
                baseline = "Wednesday, September 30, 1970";
               
            } else if (typeConsName.equals(CAL_RelativeTime.TypeConstructors.RelativeTime)) {
                baseline = "12:00:00 AM";

            } else if (typeConsName.equals(CAL_RelativeTime.TypeConstructors.RelativeDateTime)) {
                baseline = "Wednesday, September 30, 1970 12:00:00 AM";
           
            } else if (typeConsName.equals(CAL_Time.TypeConstructors.Time)) {
                baseline = "Wednesday, September 30, 1970 12:00:00 AM UTC";

            } else if (typeConsName.equals(CAL_Color.TypeConstructors.Color)) {
                fixedWidth = 30;

            } else if (typeConsName.equals(CAL_File.TypeConstructors.FileName)) {
                baseline = "/home/frank/depots/Quark/CAL";
               
            } else if (typeConsName.equals(CAL_Prelude.TypeConstructors.Function)) {
                baseline = "Prelude.FunctionName";

            } else if (typeConsName.equals(CAL_Prelude.TypeConstructors.List)) {

                TypeExpr elementTypeExpr = typeConsApp.getArg(0);
                TypeConsApp elementTypeConsApp = elementTypeExpr.rootTypeConsApp();

                if (elementTypeConsApp != null) {

                    QualifiedName elementTypeConsName = elementTypeConsApp.getName();

                    if (elementTypeConsName.equals(CAL_Prelude.TypeConstructors.Char)) {
                        // This is just a String, so use same width.
                        baseline = "A reasonably long string value.";

                    } else {
                        fixedWidth = getTypePreferredWidth(elementTypeExpr, fontMetrics);
View Full Code Here

            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

                            typeSignature);
                allTopLevelElements.add(castFunction);
            }

            for (Map.Entry<QualifiedName, TypeConstructor>entry : additionalForeignTypeDeclarations.entrySet()) {
                QualifiedName typeConstructorName = (QualifiedName)entry.getKey();
                TypeConstructor typeConstructor = (TypeConstructor)entry.getValue();
               
                // Declare the java class as a foreign type.
                // ex. data foreign unsafe import jvm "org.olap.CubeType" public JCubeType;
                SourceModel.TypeConstructorDefn.ForeignType foreignType =
                    TypeConstructorDefn.ForeignType.make(
                            typeConstructorName.getUnqualifiedName(),
                            Scope.PRIVATE,
                            ForeignTypeInfo.getCalSourceName(typeConstructor.getForeignTypeInfo().getForeignType()),
                            Scope.PRIVATE,
                            null);
                allTopLevelElements.add(foreignType);
View Full Code Here

     * @see #factorialDefn
     */
    public static void runFactorialDemo(BasicCALServices calServices) {
            
        /**This is the name of the factional gem defined in {@link #factorialDefn()}*/
        QualifiedName factorial = QualifiedName.make(TEST_MODULE_NAME, "factorial");
       
        try {
            //This calls the factorial function by name and passes a single BigInteger argument - 5.
            //The EntryPointSpec specifies the function to call.
            //Other EntryPointSpec factory methods allow us to specify how values are marshaled between CAL and Java.
View Full Code Here

     * @see #positiveOutlierDetectorDefn
     */
    public static void runPositiveOutlierDetectorDemo(BasicCALServices calServices) {

        /**This is the name of the positiveOutlierDetector gem defined in {@link #positiveOutlierDetectorDefn()}*/
        QualifiedName positiveOutlierDetector = QualifiedName.make(TEST_MODULE_NAME, "positiveOutlierDetector");
       
        try {
            ////
            /// A Java java.util.List can be passed in as an argument to a CAL function that expects a
            /// CAL list as an argument.
View Full Code Here

        //
        // test list = demoMap factorial list;
        //
       
        //this will be the name of the newly defined function.
        QualifiedName demoMapFactorial = QualifiedName.make(RUN_MODULE_NAME, "test");
       
        try {
           
        calServices.addNewModuleWithFunction(
            RUN_MODULE_NAME,
            SourceModel.FunctionDefn.Algebraic.make(
                demoMapFactorial.getUnqualifiedName(),
                Scope.PUBLIC,
                new SourceModel.Parameter[] { SourceModel.Parameter.make("list", false) },
               
                SourceModel.Expr.Application.make(
                    new SourceModel.Expr[] {
View Full Code Here

TOP

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

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.