Examples of TypeExprDefn


Examples of org.openquark.cal.compiler.SourceModel.TypeExprDefn

    private static TypeSignature getTypeSignature(Class<?>[] paramTypes, Class<?> returnType, Class<?> instanceMemberClass, GenerationInfo generationInfo) {
       
        // Build the type expr from right to left..
       
        // The typeExpr defn ends with the return type.
        TypeExprDefn typeExprDefn = getTypeExprForClass(returnType, generationInfo);
       
        // Add the argument types in reverse order.
        if (paramTypes != null) {

            Class<?>[] methodArgTypes = paramTypes;
            for (int i = methodArgTypes.length - 1; i >= 0; i--) {
               
                Class<?> methodArgType = methodArgTypes[i];
               
                TypeExprDefn argTypeCalNameTypeExprDefn = getTypeExprForClass(methodArgType, generationInfo);
                typeExprDefn = TypeExprDefn.Function.make(argTypeCalNameTypeExprDefn, typeExprDefn);
            }
        }
       
        // If a method is not static, the class CAL type has to precede the argument list.
        if (instanceMemberClass != null) {
           
            TypeExprDefn argTypeCalNameTypeExprDefn = getTypeExprForClass(instanceMemberClass, generationInfo);
            typeExprDefn = TypeExprDefn.Function.make(argTypeCalNameTypeExprDefn, typeExprDefn);
        }
       
        // Finally, create and return the type signature.
        return TypeSignature.make(typeExprDefn);
View Full Code Here

Examples of org.openquark.cal.compiler.SourceModel.TypeExprDefn

                JavaTypeName fieldType,
                String foreignFieldTypeString,
                DataConstructor dc,
                List<TopLevelSourceElement> topLevelDefns) {

            TypeExprDefn jInstanceClassTypeExpr = TypeExprDefn.TypeCons.make(Name.TypeCons.makeUnqualified(instanceForeignTypeName));

            Name.TypeCons typeConsName;
            if (foreignFieldTypeString.indexOf('.') > -1) {
                typeConsName = Name.TypeCons.make(QualifiedName.makeFromCompoundName(foreignFieldTypeString));
            } else {
                typeConsName = Name.TypeCons.makeUnqualified(foreignFieldTypeString);
            }
           
            TypeExprDefn fieldTypeForGetter = TypeExprDefn.TypeCons.make(typeConsName);

            String functionName =
                (String)(typeConstructorInfo.calFieldAccessorFunctionNames.get(fn)).get(dc);
            String methodName =
                (String)typeConstructorInfo.fieldJavaAccessorMethodNames.get(fn);
View Full Code Here

Examples of org.openquark.cal.compiler.SourceModel.TypeExprDefn

            String inputFunctionArgName = "j" + typeConstructorInfo.calForeignTypeName.substring(1);
            Expr.Var inputFunctionArg = Expr.Var.make(Name.Function.makeUnqualified(inputFunctionArgName));

            // Do the function type declaration.
            // JCube -> Cube
            TypeExprDefn inputFunctionType =
                TypeExprDefn.Function.make(
                        TypeExprDefn.TypeCons.make(Name.TypeCons.makeUnqualified(typeConstructorInfo.calForeignTypeName)),
                        TypeExprDefn.TypeCons.make(Name.TypeCons.makeUnqualified(typeConstructorName.getUnqualifiedName())));
           
            SourceModel.CALDoc.Comment.Function inputFunctionComment;
View Full Code Here

Examples of org.openquark.cal.compiler.SourceModel.TypeExprDefn

            //     output (outputCube dcInstance);
            String outputFunctionName =
                "output" + typeConstructor.getName().getUnqualifiedName();

            // Do the function type declaration.
            TypeExprDefn outputFunctionType =
                TypeExprDefn.Function.make(
                        TypeExprDefn.TypeCons.make(Name.TypeCons.makeUnqualified(typeConstructorInfo.typeConstructor.getName().getUnqualifiedName())),
                        TypeExprDefn.TypeCons.make(Name.TypeCons.makeUnqualified(typeConstructorInfo.calForeignTypeName)));
           
            SourceModel.CALDoc.Comment.Function outputFunctionComment;
            {
                SourceModel.CALDoc.TextSegment.Plain textSegment =
                    SourceModel.CALDoc.TextSegment.Plain.make(
                            "\nOutput an instance of " + typeConstructor.getName().getUnqualifiedName() + ".\n" +
                            "Translates an instance of " + typeConstructor.getName().getUnqualifiedName() + " to\n" +
                            "an instance of "+ typeConstructorInfo.calForeignTypeName + ".");
               
                SourceModel.CALDoc.TextBlock textBlock =
                    SourceModel.CALDoc.TextBlock.make(new SourceModel.CALDoc.TextSegment.TopLevel[]{textSegment});
                   
                outputFunctionComment =
                    SourceModel.CALDoc.Comment.Function.make(
                            textBlock,
                            null);
            }
           
            SourceModel.FunctionTypeDeclaration outputFunctionTypeDecl =
                FunctionTypeDeclaration.make(
                        outputFunctionComment,
                        outputFunctionName,
                        TypeSignature.make(outputFunctionType));
           
            topLevelDefnsList.add(outputFunctionTypeDecl);
           
            SourceModel.FunctionDefn.Algebraic outputFunction =
                FunctionDefn.Algebraic.make(
                        outputFunctionName,
                        Scope.PUBLIC,
                        new SourceModel.Parameter[]{Parameter.make("dcInstance", true)},
                        outputFunctionBody);
            topLevelDefnsList.add(outputFunction);
           
            // Now create the conversion function.  i.e. a private function that outputs to a JObject.
            String conversionFunctionName = outputFunctionName + "ToJObject";
            // Do the function type declaration.
            TypeExprDefn conversionFunctionType =
                TypeExprDefn.Function.make(
                        TypeExprDefn.TypeCons.make(Name.TypeCons.makeUnqualified(typeConstructorInfo.typeConstructor.getName().getUnqualifiedName())),
                        JOBJECT_TYPE_EXPR_DEFN);
           
            SourceModel.CALDoc.Comment.Function conversionFunctionComment;
View Full Code Here

Examples of org.openquark.cal.compiler.SourceModel.TypeExprDefn

           
            if (nArgs == 0) {
                return SourceModel.Expr.Var.makeUnqualified(calConstructorName);
            }
           
            TypeExprDefn argTypes[] = new TypeExprDefn[nArgs];
            for (int i = 0; i < nArgs; ++i) {
                argTypes[i] = getTypeExprDefn(new JavaTypeName[]{javaConstructor.getParamType(i)});
            }

            SourceModel.Expr applicationExpressions[] = new SourceModel.Expr[nArgs+ 1];
View Full Code Here

Examples of org.openquark.cal.compiler.SourceModel.TypeExprDefn

                }
               
                TypeExpr fieldTypeExpr = dcFieldTypes[i];
                updateInputableImports(fieldTypeExpr);
               
                TypeExprDefn fieldTypeForGetter = getTypeExprDefn(new JavaTypeName[]{fieldType});
                String fieldTypeForGetterTypeConsName = ((TypeExprDefn.TypeCons)fieldTypeForGetter).getTypeConsName().toString();
                String dcFieldTypeConsName = "";
                TypeConsApp typeConsApp = fieldTypeExpr.rootTypeConsApp();
                if (typeConsApp != null) {
                    TypeConstructor tc = typeConsApp.getRoot();
View Full Code Here

Examples of org.openquark.cal.compiler.SourceModel.TypeExprDefn

            for (int i = 0; i < nArgs; ++i) {
                argTypes[i] = constructor.getParamType(i);
            }
            argTypes[nArgs] = javaClass.getClassName();
               
            TypeExprDefn argTypeDef = getTypeExprDefn(argTypes);
            TypeSignature declaredType = TypeSignature.make(argTypeDef);
           
            SourceModel.CALDoc.Comment.Function constructorFunctionComment;
            {
                SourceModel.CALDoc.TextSegment.Plain textSegment =
View Full Code Here

Examples of org.openquark.cal.compiler.SourceModel.TypeExprDefn

                    String letVarName,
                    String innerForeignTypeName) {
           
            SourceModel.LocalDefn[] localDefns = new SourceModel.LocalDefn[2];

            TypeExprDefn foreignTypeExprDefn =
                TypeExprDefn.TypeCons.make(Name.TypeCons.makeUnqualified(innerForeignTypeName));
           
            SourceModel.CALDoc.TextSegment.Plain textSegment =
                SourceModel.CALDoc.TextSegment.Plain.make(
                        "Cast the " + outerForeignTypeName + " value to a " + innerForeignTypeName);
View Full Code Here

Examples of org.openquark.cal.compiler.SourceModel.TypeExprDefn

                        typeConstructorNames[i] = Name.TypeCons.make(moduleName, "J" + javaTypes[i].getUnqualifiedJavaSourceName());
                    }
                }
            }
           
            TypeExprDefn codomain = TypeExprDefn.TypeCons.make(typeConstructorNames[typeConstructorNames.length - 1]);
          
            for (int i = typeConstructorNames.length - 2; i >= 0; i--) {
                TypeExprDefn domain = TypeExprDefn.TypeCons.make(typeConstructorNames[i]);
                codomain = TypeExprDefn.Function.make(domain, codomain);
            }
           
            return codomain;
        }
View Full Code Here

Examples of org.openquark.cal.compiler.SourceModel.TypeExprDefn

                        inputFunctionName,
                        Scope.PUBLIC,
                        new SourceModel.Parameter[]{Parameter.make(inputArgumentName, false)},
                        body);

            TypeExprDefn inputFunctionType =
                TypeExprDefn.Function.make(
                        TypeExprDefn.TypeCons.make(Name.TypeCons.makeUnqualified(typeConstructorInfo.calForeignTypeName)),
                        TypeExprDefn.TypeCons.make(Name.TypeCons.makeUnqualified(typeConstructor.getName().getUnqualifiedName())));
           
            SourceModel.CALDoc.Comment.Function inputFunctionComment;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.