Package org.openquark.cal.internal.javamodel

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


     *               This is used for obtaining the appropriate {@link LECCModule.ClassNameMapper} for use in mapping names.
     * @return JavaTypeName
     */
    static JavaTypeName createTypeNameFromSC (QualifiedName scName, LECCModule module) {
       
        JavaTypeName primitiveFunctionType = primitiveFunctionsMap.get(scName);
        if (primitiveFunctionType != null) {
            return primitiveFunctionType;
        }
       
        String className = createClassNameFromSC(scName, module);
View Full Code Here


     * @param logger the logger to use for logging error messages.
     */
    private void writeClass(JavaClassRep classRep, byte[] bytecode, CompilerMessageLogger logger) {
           
        // figure out the unqualified name of the class.      
        JavaTypeName typeName = classRep.getClassName();      
        String className = typeName.getUnqualifiedJavaSourceName().replace('.', '$');
       
       
        if (immediateUse) {
            classLoader.defineClass(typeName.getName(), bytecode, forAdjunct);
           
        } else {
           
            // Deflate the class data.
            // Note that it is better to perform deflation on the current thread than to get
View Full Code Here

            //new RTValue[]{CAL_Int.make(take$nElements$1), take$list$2}
            JavaExpression[] argValues = new JavaExpression[arity];
            for (int i = 0; i < arity; ++i) {

                String javaArgName = argNames[i];
                JavaTypeName javaArgType = argTypes[i];

                JavaExpression javaArgValue = new LocalName(javaArgName, javaArgType);
                if (!javaArgType.equals(JavaTypeNames.RTVALUE)) {
                    javaArgValue = SCJavaDefn.boxExpression(javaArgType, javaArgValue);
                }

                argValues[i] = javaArgValue;
            }
View Full Code Here

        private JavaClassRep getDCFieldSelectionClass () {
            int classModifiers = Modifier.FINAL | Modifier.PUBLIC | Modifier.STATIC;

            // No interfaces are implemented
            JavaTypeName[] interfaces = JavaDefinitionBuilder.EMPTY_TYPE_NAME_ARRAY;
            JavaTypeName fieldSelectionTypeName = CALToJavaNames.createFieldSelectionClassTypeNameFromDC(dc, module);
            // Now instantiate the java class representation.
            JavaClassRep fieldSelectionClass = new JavaClassRep(fieldSelectionTypeName, JavaTypeNames.RTDATACONS_FIELD_SELECTION, classModifiers, interfaces);

            // Add the constructor: FieldSelection (RTValue $dataConsExpr, int $fieldOrdinal, ErrorInfo $errorInfo);
            fieldSelectionClass.addConstructor(createDCFieldSelectionClass_constructor ());
View Full Code Here

         * Create a constructor for the static inner FieldSelection class.
         * public FieldSelection (RTValue $dataConsExpr, int $fieldOrdinal, ErrorInfo $errorInfo)
         * @return the constructor for the FieldSelection class.
         */
        private JavaConstructor createDCFieldSelectionClass_constructor () {
            JavaTypeName argTypes[] =
                new JavaTypeName[]{
                    JavaTypeNames.RTVALUE,
                    JavaTypeName.INT,
                    JavaTypeName.INT,
                    JavaTypeName.ERRORINFO};
View Full Code Here

                    if (commonFields.contains(fn)) {
                        // Common fields are implemented in base class.
                        continue;
                    }

                    JavaTypeName fieldType = JavaTypeNames.RTVALUE;
                    int modifiers = Modifier.PRIVATE;
                    if (fieldStrictness[i]) {
                        modifiers = modifiers | Modifier.FINAL;
                        if (SCJavaDefn.canTypeBeUnboxed(fieldTypes[i])) {
                            fieldType = SCJavaDefn.typeExprToTypeName(fieldTypes[i]);
View Full Code Here

            javaClassRep.addConstructor(javaConstructor);

            // Initialize any final fields.
            for (int i = 0; i < dc.getArity(); ++i) {
                if (!commonFields.contains(dc.getNthFieldName(i)) && fieldStrictness[i]) {
                    JavaTypeName fieldType = JavaTypeNames.RTVALUE;
                    if (SCJavaDefn.canTypeBeUnboxed(fieldTypes[i])) {
                        fieldType = SCJavaDefn.typeExprToTypeName(fieldTypes[i]);
                    }

                    LiteralWrapper fieldVal = JavaDefinitionBuilder.getDefaultValueForType(fieldType);
View Full Code Here

                argNames[argNames.length - 1] = SCJavaDefn.EXECUTION_CONTEXT_NAME;
            }

            // Build up the arguments to the superclass constructor.
            JavaExpression superClassConstructorArgValues[] = new JavaExpression [commonFields.size()];
            JavaTypeName   superClassConstructorArgTypes[]  = new JavaTypeName [commonFields.size()];
            int j = 0;
            for (final FieldName fn : commonFields) {
                int fieldIndex = dc.getFieldIndex(fn);
                superClassConstructorArgValues[j] = argVars[fieldIndex];
                superClassConstructorArgTypes[j] = argTypes[fieldIndex];
View Full Code Here

                argNames[argNames.length - 1] = SCJavaDefn.EXECUTION_CONTEXT_NAME;
            }

            // Build up the arguments to the superclass constructor.
            JavaExpression superClassConstructorArgValues[] = new JavaExpression [commonFields.size()];
            JavaTypeName   superClassConstructorArgTypes[]  = new JavaTypeName [commonFields.size()];
            int j = 0;
            for (final FieldName fn : commonFields) {
                int fieldIndex = dc.getFieldIndex(fn);
                superClassConstructorArgValues[j] = argVars[fieldIndex];
                superClassConstructorArgTypes[j] = argTypes[fieldIndex];
                j++;
            }

            // Add the method to the class.
            JavaConstructor javaConstructor = new JavaConstructor(modifiers, argNames, argTypes, CALToJavaNames.createInnerClassNameFromDC(dc, module), superClassConstructorArgValues, superClassConstructorArgTypes);
            javaClassRep.addConstructor(javaConstructor);

            if (LECCMachineConfiguration.generateDebugCode()) {
                javaConstructor.addStatement(generateDebugCode(argNames, argTypes));
            }

            // Assert that object arguments are non-null.
            JavaExpression check = null;
            for (int i = 0, n = dc.getArity(); i < n; ++i) {
                // We only check fields of type RTValue.  It is valid to have an unboxed object value of null.
                if (argTypes[i].equals(JavaTypeNames.RTVALUE)) {
                    JavaExpression newCheck = new OperatorExpression.Binary(JavaOperator.NOT_EQUALS_OBJECT, argVars[i], LiteralWrapper.NULL);
                    if (check == null) {
                        check = newCheck;
                    } else {
                        check = new OperatorExpression.Binary(JavaOperator.CONDITIONAL_AND, check, newCheck);
                    }
                }
            }
            if (check != null) {
                javaConstructor.addStatement(new AssertStatement(check, LiteralWrapper.make("Invalid constructor argument for " + dc.getName().getQualifiedName()), JavaTypeName.STRING));
            }

            // Add the body..
            // We want to assign any of the fields in this class.
            for (int i = 0, n = dc.getArity(); i < n; i++) {
                if (commonFields.contains(dc.getNthFieldName(i))) {
                    // This field is in the containing class so we don't
                    // assign here.
                    continue;
                }
                JavaTypeName fieldType = JavaTypeNames.RTVALUE;
                if (fieldStrictness[i] && SCJavaDefn.canTypeBeUnboxed(fieldTypes[i])) {
                    fieldType = SCJavaDefn.typeExprToTypeName(fieldTypes[i]);
                }

                JavaField field = new JavaField.Instance(null, javaFieldNames[i], fieldType);
View Full Code Here

         * Create the getArity() method.
         *      public final int getArity();
         */
        private void createMethod_getArity() {
            int modifiers = Modifier.PUBLIC | Modifier.FINAL;
            JavaTypeName returnType = JavaTypeName.INT;

            // Add the method to the class.
            JavaMethod javaMethod = new JavaMethod(modifiers, returnType, "getArity");
            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.