Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.TypeConsApp


     * @param argName
     * @param argType
     * @return the JavaExpression which wraps the unboxed value.
     */
    static private JavaExpression wrapArgument (String argName, TypeExpr argType) throws UnableToResolveForeignEntityException {
        TypeConsApp typeConsApp = argType.rootTypeConsApp();
        if (typeConsApp != null && typeConsApp.getNArgs() == 0) {
           
            // boolean
            if (typeConsApp.isNonParametricType(CAL_Prelude.TypeConstructors.Boolean)) {               
                JavaExpression makeBoolean =
                    new MethodInvocation.Static(
                            SOURCE_MODEL_EXPR_TYPE_NAME,
                            "makeBooleanValue",
                            new MethodVariable(argName),
                            JavaTypeName.BOOLEAN,
                            SOURCE_MODEL_EXPR_TYPE_NAME);
               
                return makeBoolean;
            }

            if(typeConsApp.getForeignTypeInfo() != null) {
                ForeignTypeInfo fti = typeConsApp.getForeignTypeInfo();
                Class<?> foreignClass = fti.getForeignType();
               
                // We handle the primitive Java types, excluding void.
                if(foreignClass.isPrimitive() && foreignClass != void.class) {
                    MethodVariable mv = new MethodVariable(argName);
View Full Code Here


     * Translate a TypeExpr to the corresponding JavaTypeName.
     * @param argType
     * @return the JavaTypeName.
     */
    private final static JavaTypeName typeExprToTypeName (TypeExpr argType) throws UnableToResolveForeignEntityException {
        TypeConsApp typeConsApp = argType.rootTypeConsApp();
        if (typeConsApp != null && typeConsApp.getNArgs() == 0) {
            if (typeConsApp.isNonParametricType(CAL_Prelude.TypeConstructors.Boolean)) {
                return JavaTypeName.BOOLEAN;
            }

            if(typeConsApp.getForeignTypeInfo() != null) {
                ForeignTypeInfo fti = typeConsApp.getForeignTypeInfo();
                Class<?> foreignClass = fti.getForeignType();
                if(foreignClass.isPrimitive() && foreignClass != void.class) {
                    if (foreignClass == boolean.class) {
                        return JavaTypeName.BOOLEAN;
                    } else if (foreignClass == byte.class) {
View Full Code Here

        /**
         * Notify this info object that the given type is supported.
         * @param typeExpr the type in question.
         */
        public void markSupported(TypeExpr typeExpr) {
            TypeConsApp typeConsApp = typeExpr.rootTypeConsApp();
            if (typeConsApp != null) {
                supportedTypeConstructors.add(typeConsApp.getName());
            }
        }
View Full Code Here

         * Ask this info object whether the given type has been marked as supported by previous callers.
         * @param typeExpr the type in question
         * @return whether the given type has been marked as supported by previous callers.
         */
        public boolean isSupported(TypeExpr typeExpr) {
            TypeConsApp typeConsApp = typeExpr.rootTypeConsApp();
            return typeConsApp != null && supportedTypeConstructors.contains(typeConsApp.getName());
        }
View Full Code Here

        /**
         * {@inheritDoc}
         */
        @Override
        public boolean canHandleValue(ValueNode valueNode, SupportInfo providerSupportInfo) {
            TypeConsApp typeConsApp = valueNode.getTypeExpr().rootTypeConsApp();
            return typeConsApp != null && getPerspective().isEnumDataType(typeConsApp.getName());
        }
View Full Code Here

    static boolean doesTypeUnboxToObjectDerivative (TypeExpr typeExpr) throws CodeGenerationException {
        if (typeExpr == null) {
            return false;
        }

        TypeConsApp typeCons = typeExpr.rootTypeConsApp();

        if (typeCons != null && typeCons.getNArgs() == 0) {
            if (typeCons.isNonParametricType(CAL_Prelude.TypeConstructors.Boolean)) {
                return false;
            }

            // Zero arity data constructors are treated as int.
            if (LECCMachineConfiguration.TREAT_ENUMS_AS_INTS) {
                if (isEnumDataType (typeCons)) {
                    return false;
                }
            }

            if(typeCons.getForeignTypeInfo() != null) {
                Class<?> foreignClass = SCJavaDefn.getForeignType(typeCons.getForeignTypeInfo());

                // If the class is CalValue or one of the Java primitives we don't treat
                // this as corresponding to an unboxed Object type.
                if (isCalValueClass(foreignClass)|| foreignClass.isPrimitive()) {
                    return false;
View Full Code Here

     * @return String
     * @param typeExpr
     */
    public String getTypeIconName(TypeExpr typeExpr) {

        TypeConsApp typeConsApp = typeExpr.rootTypeConsApp();

        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 {
View Full Code Here

        int fixedWidth = 0;
               
       
        if (typeExpr instanceof TypeConsApp) {
           
            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.";
View Full Code Here

       
        ValueEditorProvider.SupportInfo supportInfo = new ValueEditorProvider.SupportInfo();
       
        for (final TypeConstructor typeCons : entities) {

            TypeConsApp typeConsApp = getValueNodeBuilderHelper().getTypeConstructorForEntity(typeCons);

            if (typeConsApp != null) {
      
                ValueNode valueNode = valueNodeBuilderHelper.getValueNodeForTypeExpr(typeConsApp);
               
View Full Code Here

     * general than text editability, since it could just mean the up/down arrow keys can change the
     * value, as opposed to freeform typing of a value.
     */
    public boolean isFieldEditable(TypeExpr typeExpr) {

        TypeConsApp typeConsApp = typeExpr.rootTypeConsApp();
       
        return isTextEditable(typeExpr) ||           
        typeExpr.isNonParametricType(CAL_RelativeTime.TypeConstructors.RelativeDate) ||
        typeExpr.isNonParametricType(CAL_RelativeTime.TypeConstructors.RelativeTime) ||
        typeExpr.isNonParametricType(CAL_RelativeTime.TypeConstructors.RelativeDateTime) ||
        typeConsApp != null && getPerspective().isEnumDataType(typeConsApp.getName());
    }
View Full Code Here

TOP

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

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.