Package org.openquark.cal.internal.javamodel

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


       
        // Code fragment:
        //
        // ClassLoader classloader = {MainClassName}.class.getClassLoader();
        //
        final JavaTypeName javaTypeName_ClassLoader = JavaTypeName.make(ClassLoader.class);
       
        final JavaExpression classloaderInit =
            new JavaExpression.MethodInvocation.Instance(
                new JavaExpression.ClassLiteral(mainClassName),
                "getClassLoader",
                javaTypeName_ClassLoader,
                JavaExpression.MethodInvocation.InvocationType.VIRTUAL);
       
        final JavaExpression.LocalVariable classloaderLocalVar = new JavaExpression.LocalVariable("classloader", javaTypeName_ClassLoader);
       
        final JavaStatement classloaderDecl = new JavaStatement.LocalVariableDeclaration(classloaderLocalVar, classloaderInit);
       
        mainMethod.addStatement(classloaderDecl);
       
        ////
        /// Generate code to set up the execution context to have access to a standalone-JAR-specific
        /// ResourceAccess implementation.
        //

        // Code fragment:
        //       
        // RTExecutionContext executionContext = new RTExecutionContext(
        //     new ExecutionContextProperties.Builder().toProperties(),
        //     new StandaloneRuntimeEnvironment(
        //         classloader,
        //         new StandaloneJarResourceAccess(classloader)));       
        //
        final JavaTypeName javaTypeName_ExecutionContextProperties = JavaTypeName.make(ExecutionContextProperties.class);
        final JavaTypeName javaTypeName_ResourceAccess = JavaTypeName.make(ResourceAccess.class);
       
        final JavaExpression newRuntimeEnvironment =
            new JavaExpression.ClassInstanceCreationExpression(
                JavaTypeNames.STANDALONE_RUNTIME_ENVIRONMENT,
                new JavaExpression[] {
View Full Code Here


        final String methodName = sanitizeMethodNameForJava(functionalAgent.getName().getUnqualifiedName(), methodNameMapping);
       
        // Special handling of unit return type in CAL - it gets mapped to a void return type in Java
        final boolean isUnitResultType = functionalAgentType.getResultType().isNonParametricType(CAL_Prelude.TypeConstructors.Unit);
       
        final JavaTypeName methodReturnTypeName;
        if (isUnitResultType) {
            methodReturnTypeName = JavaTypeName.VOID;
        } else {
            methodReturnTypeName = returnType.getExposedTypeName();
        }
View Full Code Here

        //     {directPrimopCalls},
        //     {ignoringStrictnessAnnotations},
        //     {noninterruptibleRuntime});
        //
        final StandaloneJarGeneratedCodeInfo currentConfigGeneratedCodeInfo = StandaloneJarGeneratedCodeInfo.makeFromCurrentConfiguration();
        final JavaTypeName javaTypeName_StandaloneJarGeneratedCodeInfo = JavaTypeName.make(StandaloneJarGeneratedCodeInfo.class);
       
        final JavaExpression generatedCodeInfoInit =
            new JavaExpression.ClassInstanceCreationExpression(
                javaTypeName_StandaloneJarGeneratedCodeInfo,
                new JavaExpression[] {
View Full Code Here

       
        if (machineFunction == null) {
            throw new NullPointerException ("Invalid MachineFunction in getStartPointInstanceJavaExpression() for " + className + ".");
        }
       
        final JavaTypeName javaTypeName = JavaTypeName.make(className, false);
       
        if (machineFunction.isDataConstructor()) {
            // This is a data constructor.
            // Get the static 'make' method.
            return new JavaExpression.MethodInvocation.Static(
View Full Code Here

     * @return the java expression for creating an instance of the class.
     *
     * @see CALClassLoader#getTagDCStartPointInstance
     */
    private static JavaExpression getTagDCStartPointInstanceJavaExpression(final String className, final int ordinal) {
        final JavaTypeName javaTypeName = JavaTypeName.make(className, false);
        final JavaTypeName javaTypeName_TagDC = JavaTypeName.make(className + "$TagDC", false);
       
        return new JavaExpression.MethodInvocation.Static(
            javaTypeName,
            "getTagDC",
            JavaExpression.LiteralWrapper.make(new Integer(ordinal)),
View Full Code Here

        private static ClassTypeInfo make(final Class<?> classType) {
            if (classType == null) {
                return makeNonForeign();
            }
           
            final JavaTypeName rtValueTypeName;
            final String unmarshallingMethodName;
           
            if (classType == char.class) {
                rtValueTypeName = JavaTypeNames.RTDATA_CHAR;
                unmarshallingMethodName = "getCharValue";
View Full Code Here

                argTypes[i] = JavaTypeNames.RTVALUE;
            }
        }
        argTypes[calledArity] = JavaTypeNames.RTEXECUTION_CONTEXT;

        JavaTypeName returnType = JavaTypeNames.RTVALUE;

        // Get the method name to call.
        String functionName = CALToJavaNames.makeLetVarDefFunctionJavaName(mf.getQualifiedName(), module);
        if (scheme == Scheme.E_SCHEME) {
            functionName = functionName + "_Strict";
View Full Code Here

            }
            if (!isArgStrict(varToCast.getName()) || !isArgUnboxable(varToCast.getName())) {
                throw new CodeGenerationException("Expression.Cast is applied to a non-strict or non-primitive argument.");
            }

            JavaTypeName castType = JavaTypeName.make (getCastType(cast));

            JavaExpression returnVal = boxExpression(castType, new JavaExpression.CastExpression(castType, variableContext.getUnboxedReference(varToCast.getName())));
            return generateReturn(returnVal, variableContext);

        }
View Full Code Here

        // This is a DC field selection expression in a lazy scheme.  Do a lazy compilation of the
        // DC expression and then pass the resulting graph as an argument to an RTDataConsFieldSelection
        // sub class.
        ExpressionContextPair ecp = genS_C (dcSelection.getDCValueExpr(), variableContext);

        JavaTypeName fieldSelectionClassTypeName =
            CALToJavaNames.createFieldSelectionClassTypeNameFromDC(dcSelection.getDataConstructor(), module);

        JavaExpression cice =
            new ClassInstanceCreationExpression (fieldSelectionClassTypeName,
                                                 new JavaExpression[]{ecp.getJavaExpression(),
View Full Code Here

                    }
                }
            }
        }

        JavaTypeName fieldType = type;

        JavaField field;
        field =new JavaField.Static(thisTypeName, fieldName, fieldType);
        sharedValues.add (new ReferencedDCInfo(field, type, dc));
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.