Package org.openquark.cal.internal.javamodel

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


         * @param fieldNameToStrictness - Map of FieldName -> Boolean
         */
        private void create_Fields (Set<FieldName> fieldNames, Map<FieldName, JavaTypeName> fieldNameToType, Map<FieldName, Boolean> fieldNameToStrictness) {
            for (final FieldName fieldName : fieldNames) {
                boolean strict = fieldNameToStrictness.get(fieldName).booleanValue();
                JavaTypeName type = JavaTypeNames.RTVALUE;
                int modifiers = 0;
                if (strict) {
                    modifiers = Modifier.FINAL;
                    type = fieldNameToType.get(fieldName);
                }
View Full Code Here


         */
        private void createMethod_getTagDC() {
            int modifiers = Modifier.PUBLIC | Modifier.FINAL | Modifier.STATIC;

            // Add the method to the class.
            JavaTypeName tagDCTypeName = CALToJavaNames.createTypeNameForTagDCFromType(typeConstructor, module);
            JavaMethod javaMethod = new JavaMethod(modifiers, tagDCTypeName, "ordinal", JavaTypeName.INT, false, "getTagDC");
            javaClassRep.addMethod(javaMethod);

            // Add the body..
            // switch (ordinal) {
View Full Code Here

        private void createMethod_getBoxedField (String fieldName,
                                                 boolean fieldIsStrict,
                                                 TypeExpr fieldTypeExpr,
                                                 boolean implementAtThisLevel) throws CodeGenerationException {
            int modifiers = Modifier.PUBLIC;
            JavaTypeName fieldType = SCJavaDefn.typeExprToTypeName(fieldTypeExpr);
            boolean primitiveType = !fieldType.equals(JavaTypeNames.RTVALUE);

            // Add the method to the class.
            String methodName = "get" + fieldName;
            JavaMethod javaMethod = new JavaMethod(modifiers, JavaTypeNames.RTVALUE, methodName);
            javaClassRep.addMethod(javaMethod);
View Full Code Here

        private void createMethod_getUnBoxedField (String fieldName,
                                                   TypeExpr fieldTypeExpr,
                                                   boolean isStrict,
                                                   boolean implementAtThisLevel) throws CodeGenerationException {
            int modifiers = Modifier.PUBLIC;
            JavaTypeName fieldType = SCJavaDefn.typeExprToTypeName(fieldTypeExpr);

            // Add the method to the class.
            String methodName = "get" + fieldName + "_As_" + SCJavaDefn.getNameForPrimitive(fieldType);

View Full Code Here

            // No interfaces are implemented
            JavaTypeName[] interfaces = JavaDefinitionBuilder.EMPTY_TYPE_NAME_ARRAY;

            // Now instantiate the java class representation.
            JavaTypeName tagDCTypeName = CALToJavaNames.createTypeNameForTagDCFromType(typeConstructor, module);
            JavaClassRep tagDCClassRep = new JavaClassRep(tagDCTypeName, className, classModifiers, interfaces);

            // Add the body of the class.

            // private final int tag;
            JavaFieldDeclaration tagField = new JavaFieldDeclaration (Modifier.PRIVATE | Modifier.FINAL, JavaTypeName.INT, "tag", null);
            tagDCClassRep.addFieldDeclaration(tagField);

            // public TagDC(int tagVal) {this.tag = tagVal;}
            JavaConstructor javaConstructor = new JavaConstructor(Modifier.PUBLIC, new String[]{"tagVal"}, new JavaTypeName[]{JavaTypeName.INT}, "TagDC");
            tagDCClassRep.addConstructor(javaConstructor);
            Assignment tagAssign = new Assignment (new JavaField.Instance(null, "tag", JavaTypeName.INT), METHODVAR_TAGVAL);
            javaConstructor.addStatement(new ExpressionStatement(tagAssign));



            // public final int getArity() {return 0;}
            int modifiers = Modifier.PUBLIC | Modifier.FINAL;
            JavaTypeName returnType = JavaTypeName.INT;
            JavaMethod javaMethod = new JavaMethod(modifiers, returnType, "getArity");
            tagDCClassRep.addMethod(javaMethod);
            javaMethod.addStatement(new ReturnStatement(LiteralWrapper.make(Integer.valueOf(0))));

            // public final int getOrdinalValue(){return tag;}
View Full Code Here

                    argTypes[i] = javaDefn.getArgumentTypeName(i);
                }
            }

            // Add the method to the class.
            JavaTypeName returnType = JavaTypeNames.RTVALUE;
            if (scheme == Scheme.UNBOX_INTERNAL_SCHEME) {
                returnType = SCJavaDefn.typeExprToTypeName(mf.getResultType());
            }
            JavaMethod javaMethod = new JavaMethod(modifiers, returnType, argNames, argTypes, null, methodName);
View Full Code Here

         */
        private final void generateOuterSCDefinition() throws CodeGenerationException {
            if (this.javaClassRep == null) {

                // Get the fully-qualified superclass and class names;
                JavaTypeName superClassTypeName = JavaTypeNames.RTSUPERCOMBINATOR;
                if (functions.includesCAFs()) {
                    superClassTypeName = JavaTypeNames.RTCAF;
                }


View Full Code Here

            final int modifiers = Modifier.PUBLIC | Modifier.FINAL;

            // Add the method to the class.
            final String argNames[] = new String []{ROOT_NODE, SCJavaDefn.EXECUTION_CONTEXT_NAME};
            final JavaTypeName argTypes[] = new JavaTypeName []{JavaTypeNames.RTRESULT_FUNCTION, JavaTypeNames.RTEXECUTION_CONTEXT};
            final boolean[] argFinal = new boolean[] {true, true};

            String methodName = "f";

            final JavaMethod javaMethod = new JavaMethod(modifiers, JavaTypeNames.RTVALUE, argNames, argTypes, argFinal, methodName);
View Full Code Here

                } else {
                    // This is a zero arity data constructor.  We get the singleton instance by accessing
                    // the DataType class factory method if the data type has more than one zero arity DC.
                    TypeConstructor typeCons = dc.getTypeConstructor();
                    if (SCJavaDefn.isTagDC(dc, module)) {
                        JavaTypeName typeClass = CALToJavaNames.createTypeNameFromType(typeCons, module);
                        JavaTypeName tagDCTypeName = CALToJavaNames.createTypeNameForTagDCFromType(typeCons, module);
                        Integer ordinal = Integer.valueOf(dc.getOrdinal());
                        fieldInitializer = new MethodInvocation.Static(typeClass, "getTagDC", LiteralWrapper.make(ordinal), JavaTypeName.INT, tagDCTypeName);
                    } else {
                        // Just invoke the regular make invocation to get the singleton SC/DC instance.
                        fieldInitializer =
View Full Code Here

            }

            //todoBI it may be better to guard each instance map by synchronizing on it directly. However, currently the ASM bytecode
            //generator does not support synchronization blocks, and so this is adequate.
            final int modifiers = Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL | Modifier.SYNCHRONIZED;
            JavaTypeName returnType = JavaTypeName.VOID;

            // Add the method to the class.
            JavaMethod javaMethod = new JavaMethod(modifiers, returnType, SCJavaDefn.EXECUTION_CONTEXT_NAME, JavaTypeNames.RTEXECUTION_CONTEXT, false, "resetCachedResults");
            javaClassRep.addMethod(javaMethod);
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.