Package org.openquark.cal.compiler.io

Examples of org.openquark.cal.compiler.io.EntryPointSpec


     * a polymorphic function without supplying the type
     */
    public void testAmbiguousError_Test() {
        //policies can be used there.
        CompilerMessageLogger messageLogger = new MessageLogger();
        EntryPointSpec addSpec = EntryPointSpec.make(QualifiedName.make(CAL_Prelude.MODULE_NAME, "add"), new InputPolicy[] {
            InputPolicy.DEFAULT_INPUT_POLICY,
            InputPolicy.DEFAULT_INPUT_POLICY
        }, OutputPolicy.DEFAULT_OUTPUT_POLICY);
       
        EntryPoint add = compiler.getEntryPoint(addSpec, CAL_Prelude.MODULE_NAME, messageLogger);
View Full Code Here


     * with un-unifiable types.
     */
    public void testTypeIncompatabilityError_Test() {
        //policies can be used there.
        CompilerMessageLogger messageLogger = new MessageLogger();
        EntryPointSpec addSpec = EntryPointSpec.make(QualifiedName.make(CAL_Prelude.MODULE_NAME, "add"), new InputPolicy[] {
            InputPolicy.DOUBLE_INPUT_POLICY,
            InputPolicy.DOUBLE_INPUT_POLICY
        }, OutputPolicy.INT_OUTPUT_POLICY);
       
        EntryPoint add = compiler.getEntryPoint(addSpec, CAL_Prelude.MODULE_NAME, messageLogger);
View Full Code Here

     * Test output and input of typed CAL values
     */
    public void testCALInputOutput_Test() throws CALExecutorException {
        //policies can be used there.
        CompilerMessageLogger messageLogger = new MessageLogger();
        EntryPointSpec addSpec = EntryPointSpec.make(QualifiedName.make(CAL_Prelude.MODULE_NAME, "add"), new InputPolicy[] {
            InputPolicy.DEFAULT_INPUT_POLICY,
            InputPolicy.DEFAULT_INPUT_POLICY
        }, OutputPolicy.makeTypedCalValueOutputPolicy(SourceModel.TypeExprDefn.TypeCons.make(CAL_Prelude.TypeConstructors.Int)));
       
        EntryPoint add = compiler.getEntryPoint(addSpec, CAL_Prelude.MODULE_NAME, messageLogger);

        //this should output 3 as a CAL internal value
        Object addResult = executor.exec(add, new Object[] { new Integer(1), new Integer(2) });
       
        EntryPointSpec addSpec2 = EntryPointSpec.make(QualifiedName.make(CAL_Prelude.MODULE_NAME, "add"), new InputPolicy[] {
            InputPolicy.makeTypedCalValueInputPolicy(SourceModel.TypeExprDefn.TypeCons.make(CAL_Prelude.TypeConstructors.Int)),
            InputPolicy.INT_INPUT_POLICY
        }, OutputPolicy.INT_OUTPUT_POLICY);     

        EntryPoint add2 = compiler.getEntryPoint(addSpec2, CAL_Prelude.MODULE_NAME, messageLogger);
View Full Code Here

     * Test output and input of untyped CAL values
     */
    public void testUnTypedCALInputOutput_Test() throws CALExecutorException {
        //policies can be used there.
        CompilerMessageLogger messageLogger = new MessageLogger();
        EntryPointSpec addSpec = EntryPointSpec.make(QualifiedName.make(CAL_Prelude.MODULE_NAME, "add"), new InputPolicy[] {
            InputPolicy.INT_INPUT_POLICY,
            InputPolicy.DEFAULT_INPUT_POLICY
        }, OutputPolicy.CAL_VALUE_OUTPUT_POLICY);
       
        EntryPoint add = compiler.getEntryPoint(addSpec, CAL_Prelude.MODULE_NAME, messageLogger);

        //this should output 3 as a CAL internal value
        Object addResult = executor.exec(add, new Object[] { new Integer(1), new Integer(2) });
       
        EntryPointSpec addSpec2 = EntryPointSpec.make(QualifiedName.make(CAL_Prelude.MODULE_NAME, "add"), new InputPolicy[] {
            InputPolicy.CAL_VALUE_INPUT_POLICY,
            InputPolicy.DEFAULT_INPUT_POLICY
        }, OutputPolicy.INT_OUTPUT_POLICY);     

        EntryPoint add2 = compiler.getEntryPoint(addSpec2, CAL_Prelude.MODULE_NAME, messageLogger);
View Full Code Here

        //explicit input and output policies.
       
        //allPrimesAdjunct :: Prelude.JObject;
        //allPrimesAdjunct = (Prelude.output # List.toJIterator) M1.allPrimes;          
       
        EntryPointSpec allPrimesEntryPointSpec =
            EntryPointSpec.make(QualifiedName.make(CALPlatformTestModuleNames.M1, "allPrimes"), null, OutputPolicy.ITERATOR_OUTPUT_POLICY);
        EntryPointSpec stringListEntryPointSpec =
            EntryPointSpec.make(QualifiedName.make(CALPlatformTestModuleNames.M2, "stringList"), null, OutputPolicy.ITERATOR_OUTPUT_POLICY);      
                     
        entryPointSpecs.add(allPrimesEntryPointSpec);
        entryPointSpecs.add(stringListEntryPointSpec);       
        compiler.getEntryPoints(entryPointSpecs, CALPlatformTestModuleNames.M2, messageLogger);
View Full Code Here

        //        (takeN
        //            ((\x -> (Prelude.unsafeCoerce ((Prelude.input x) :: Prelude.CalValue)) :: [Prelude.Int]) list)
        //            ((Prelude.input :: Prelude.JObject -> Prelude.Int) nToTake)
        //         );
       
        EntryPointSpec allPrimesEntryPointSpec =
            EntryPointSpec.make(QualifiedName.make(CALPlatformTestModuleNames.M1, "allPrimes"), new InputPolicy[] {}, OutputPolicy.CAL_VALUE_OUTPUT_POLICY);
        EntryPointSpec stringListEntryPointSpec =
            EntryPointSpec.make(QualifiedName.make(CALPlatformTestModuleNames.M2, "stringList"), new InputPolicy[] {}, OutputPolicy.CAL_VALUE_OUTPUT_POLICY);
       
        String Prelude_Int = CAL_Prelude.TypeConstructors.Int.getQualifiedName();
        String Prelude_CalValue = CAL_Prelude.TypeConstructors.CalValue.getQualifiedName();
        String Prelude_String = CAL_Prelude.TypeConstructors.String.getQualifiedName();
        String Prelude_unsafeCoerce = CAL_Prelude.Functions.unsafeCoerce.getQualifiedName();
        String Prelude_output = CAL_Prelude.Functions.output.getQualifiedName();
       
        SourceModel.TypeExprDefn listOfIntType = SourceModel.TypeExprDefn.List.make(SourceModel.TypeExprDefn.TypeCons.make(CAL_Prelude.TypeConstructors.Int));
        EntryPointSpec takeNListOfInt =
            EntryPointSpec.make(QualifiedName.make(CALPlatformTestModuleNames.M2, "takeN"), new InputPolicy[] {
            InputPolicy.makeTypedCalValueInputPolicy(listOfIntType),
            InputPolicy.DEFAULT_INPUT_POLICY
            }, OutputPolicy.make("(\\x -> " + Prelude_output + " ((" + Prelude_unsafeCoerce + " x) :: ([" + Prelude_Int + "], " + Prelude_CalValue + ")))"));

       
        SourceModel.TypeExprDefn listOfStringType = SourceModel.TypeExprDefn.List.make(SourceModel.TypeExprDefn.TypeCons.make(CAL_Prelude.TypeConstructors.String));
        EntryPointSpec takeNListOfString =
            EntryPointSpec.make(QualifiedName.make(CALPlatformTestModuleNames.M2, "takeN"), new InputPolicy[] {
            InputPolicy.makeTypedCalValueInputPolicy(listOfStringType),
            InputPolicy.DEFAULT_INPUT_POLICY
        }, OutputPolicy.make("(\\x -> " + Prelude_output + " ((" + Prelude_unsafeCoerce + " x) :: ([" + Prelude_String + "], " + Prelude_CalValue + ")))"));       
                     
View Full Code Here

                SourceModel.FunctionDefn functionDefn = SourceModel.FunctionDefn.Algebraic.make(RUN_TARGET_NAME,
                                                                                                Scope.PUBLIC,
                                                                                                new SourceModel.Parameter[0],
                                                                                                code);
               
                EntryPointSpec entryPointSpec = calServices.addNewModuleWithFunction(TARGET_MODULE_NAME, functionDefn);
                Object result = calServices.runFunction(entryPointSpec, executionContext, arguments);
   
                return result;
            }
            catch (CALExecutorException e) {
View Full Code Here

    }
   
    private static boolean isWellFormed(String path) throws Exception {
        BasicCALServices cal = getCALServices();

        EntryPointSpec isWellFormedEntrySpec =
            EntryPointSpec.make(QualifiedName.make(ModuleName.make("Cal.Test.Experimental.Utilities.XmlParserEngine_Tests"),
                    "isWellFormed"));
       
        Object result = cal.runFunction(isWellFormedEntrySpec, new Object[] { path });
       
View Full Code Here

   }
   
    private static void parseAndWriteSecondXmlCanonicalForm(String inPath, String outPath) throws Exception {
        BasicCALServices cal = getCALServices();
       
        EntryPointSpec parseAndWriteSecondXmlCanonicalFormEntrySpec =
            EntryPointSpec.make(QualifiedName.make(ModuleName.make("Cal.Test.Experimental.Utilities.XmlParserEngine_Tests"),
                    "parseAndWriteSecondXmlCanonicalForm"));
       
        cal.runFunction(parseAndWriteSecondXmlCanonicalFormEntrySpec, new Object[] { inPath, outPath });
    }
View Full Code Here

        try {
            GemFactory gemFactory = new GemFactory(calServices);
            SourceModel.FunctionDefn.Algebraic gemSource = factorialGemGraph(gemFactory, calServices).getCALSource();
   
            EntryPointSpec entryPointSpec = calServices.addNewModuleWithFunction(RUN_MODULE, gemSource);
           
            try {
                BigInteger result;
   
                result = (BigInteger)calServices.runFunction(entryPointSpec, new Object[] { BigInteger.valueOf(7) });
View Full Code Here

TOP

Related Classes of org.openquark.cal.compiler.io.EntryPointSpec

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.