Package org.openquark.cal.internal.javamodel

Examples of org.openquark.cal.internal.javamodel.JavaTypeName


                for (FieldName fn : typeConstructorInfo.commonFieldNames) {
                    Set<JavaTypeName> javaTypeNames = typeConstructorInfo.allFieldTypeNames.get(fn);
                    assert(javaTypeNames.size() == 1);
                   
                    Iterator<JavaTypeName> types = javaTypeNames.iterator();
                    JavaTypeName type = types.next();
       
                    String fieldName = (String)typeConstructorInfo.fieldJavaNames.get(fn);
                    String argName = fieldName+"$";
       
                    argNames[i] = argName;
View Full Code Here


            this.targetPackage = targetPackage;
        }

        JavaClassRep generateClassForType () {
           
            JavaTypeName typeConstructorClassName =
                JavaTypeName.make(targetPackage + "." + typeConstructorInfo.javaClassName, false);
   
            TypeConstructor typeConstructor = typeConstructorInfo.typeConstructor;
           
            JavaClassRep outerTypeDefinition =
View Full Code Here

            thenBlock.addStatement(new ExpressionStatement (assignResult));
           
            // Now get the contribution from each dc field.
            for (FieldName fn : fieldNames) {
                String javaFieldName = typeConstructorInfo.fieldJavaNames.get (fn);
                JavaTypeName fieldType = fieldNameToType.get (fn);
                JavaField field = new JavaField.Instance(null, javaFieldName, fieldType);
               
                JavaExpression fieldExpression;
                if (fieldType instanceof JavaTypeName.Primitive) {
                    if (fieldType instanceof JavaTypeName.Primitive.Boolean) {
View Full Code Here

           
            if (fieldNames != null && fieldNames.size() > 0) {
                // Now we need to compare equality for the various fields.
                Iterator<FieldName> fields = fieldNames.iterator();
                FieldName fn = fields.next ();
                JavaTypeName fieldType = (JavaTypeName)fieldNameToType.get(fn);
                JavaExpression compare = makeFieldComparison (fn, fieldType, localVar);
               
                while (fields.hasNext()) {
                    fn = fields.next ();
                    fieldType = (JavaTypeName)fieldNameToType.get(fn);
View Full Code Here

                        getDCName,
                        LiteralWrapper.make("\n"));
           
            for (FieldName fn : fieldNames) {
                // There will only be one field type.
                JavaTypeName fieldType = (JavaTypeName)fieldTypes.get(fn);
                String javaFieldName = (String)typeConstructorInfo.fieldJavaNames.get(fn);
                JavaExpression field =
                    new JavaField.Instance(null, javaFieldName, fieldType);
               
                JavaExpression fieldString;
                if (fieldType instanceof JavaTypeName.Primitive ||
                        fieldType.equals(JavaTypeName.STRING)) {
                    fieldString = field;
                } else {
                    fieldString =
                        new MethodInvocation.Instance(field, "toString", JavaTypeName.STRING, MethodInvocation.InvocationType.VIRTUAL);
                }
View Full Code Here

   
                int classModifiers = Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL;
               
                DataConstructorInfo dcInfo = (DataConstructorInfo)typeConstructorInfo.dataConstructorInfo.get(dc);
               
                JavaTypeName dcClassTypeName =
                    JavaTypeName.make(
                            typeConstructorClassName.getFullJavaSourceName() + "$" + dcInfo.innerClassName, false);
               
                JavaClassRep dcClass =
                    new JavaClassRep(
                            dcClassTypeName,
                            typeConstructorClassName,
                            classModifiers,
                            IO_Source_Generator.EMPTY_TYPE_NAME_ARRAY);
   
                JavaDocComment jdc =
                    new JavaDocComment ("This class represents instances of the CAL data constructor " + dc.getName() + ".");
                dcClass.setJavaDoc(jdc);
               
                createFields (dcClass, dc, typeConstructorInfo);
               
                dcClass.addConstructor(createConstructor(dc, typeConstructorInfo, dcClassTypeName));
               
                dcClass.addMethod(createMethod_getDCName(dc.getName().getUnqualifiedName()));
   
                for (FieldName fieldName : dcInfo.fieldTypeNames.keySet()) {
                    if (typeConstructorInfo.commonFieldNames.contains(fieldName)) {
                        continue;
                    }
                    JavaTypeName fieldType = (JavaTypeName)dcInfo.fieldTypeNames.get(fieldName);
                    String javaFieldName = (String)typeConstructorInfo.fieldJavaNames.get(fieldName);
                   
                    String accessorName = (String)typeConstructorInfo.fieldJavaAccessorMethodNames.get(fieldName);
                    JavaMethod getter = createMethod_getField(accessorName, javaFieldName, fieldType, true);
                   
View Full Code Here

                Block constructorBody = new Block();
               
                for (int i = 0, n = dc.getArity(); i < n; ++i) {
                    FieldName fn = (FieldName)dc.getNthFieldName(i);
                   
                    JavaTypeName type = (JavaTypeName)dci.fieldTypeNames.get(fn);
                    String fieldName = (String)typeConstructorInfo.fieldJavaNames.get(fn);
                    String argName = fieldName+"$";
       
                    argNames[i] = argName;
                    argTypes[i] = type;

                    if (!typeConstructorInfo.commonFieldNames.contains(fn)) {
                        JavaExpression.JavaField.Instance field =
                            new JavaExpression.JavaField.Instance(null, fieldName, type);
                        JavaExpression assign = new Assignment (field, new MethodVariable(argName));
                        constructorBody.addStatement(new ExpressionStatement(assign));
                    }
                }
               
                String constructorName = dcClassTypeName.getUnqualifiedJavaSourceName();
                int index = constructorName.lastIndexOf('.');
                if (index > -1) {
                    constructorName = constructorName.substring(index + 1);
                }
               
                JavaConstructor constructor;
                if (typeConstructorInfo.commonFieldNames.size() > 0) {
                    JavaExpression superArgValues[] = new JavaExpression[typeConstructorInfo.commonFieldNames.size()];
                    JavaTypeName superArgTypes[] = new JavaTypeName[superArgValues.length];
                    int i = 0;
                    for (FieldName superFieldName : typeConstructorInfo.commonFieldNames) {
                        JavaTypeName fieldType = (JavaTypeName)dci.fieldTypeNames.get(superFieldName);
                        String fieldName = (String)typeConstructorInfo.fieldJavaNames.get(superFieldName);
                        String argName = fieldName+"$";
                        JavaExpression superArgValue = new MethodVariable(argName);
                        superArgValues[i] = superArgValue;
                        superArgTypes[i] = fieldType;
View Full Code Here

                    FieldName fieldName = dc.getNthFieldName(i);
                    if (typeConstructorInfo.commonFieldNames.contains(fieldName)) {
                        continue;
                    }
                   
                    JavaTypeName type = (JavaTypeName)dci.fieldTypeNames.get(fieldName);
                    String javaFieldName = (String)typeConstructorInfo.fieldJavaNames.get(fieldName);
       
                    int modifiers = Modifier.FINAL | Modifier.PRIVATE;
                   
                    JavaFieldDeclaration fieldDec = new JavaFieldDeclaration (modifiers, type, javaFieldName, null);
View Full Code Here

                // Fall back on calling fNS.

                Block body = new Block();

                JavaExpression argValues[] = new JavaExpression[getArity() + 1];
                JavaTypeName argTypes[] = new JavaTypeName[argValues.length];

                argValues[argValues.length-1] = SCJavaDefn.EXECUTION_CONTEXT_VAR;

                Arrays.fill(argTypes, JavaTypeNames.RTVALUE);
                argTypes[argTypes.length-1] = JavaTypeNames.RTEXECUTION_CONTEXT;
View Full Code Here

        if (mf.getArity() != chain.length -1 || mf.getArity() == 0) {
            return null;
        }

        // We don't 'unbox' our internal type.
        JavaTypeName calledReturnType = SCJavaDefn.typeExprToTypeName(mf.getResultType());
        if (calledReturnType.equals(JavaTypeNames.RTVALUE) ||
            calledReturnType.equals(JavaTypeName.CAL_VALUE)) {
            return null;
        }

        // If the primitiveness of the called function result type is not the same
        // as the primitiveness of the desired unboxed type we can't do a direct call.
View Full Code Here

TOP

Related Classes of org.openquark.cal.internal.javamodel.JavaTypeName

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.