Package org.openquark.cal.compiler.io

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


        EntryPointSpec addSpec = EntryPointSpec.make(QualifiedName.make(CAL_Prelude.MODULE_NAME, "add"), new InputPolicy[] {
            InputPolicy.DEFAULT_INPUT_POLICY,
            InputPolicy.DEFAULT_INPUT_POLICY
        }, OutputPolicy.INT_OUTPUT_POLICY);
       
        EntryPoint add = compiler.getEntryPoint(addSpec, CAL_Prelude.MODULE_NAME, messageLogger);
        assertNotNull(add);
        Object addResult = executor.exec(add, new Object[] { new Integer(1), new Integer(2) });
        assertTrue(addResult instanceof Integer);
        assertEquals(new Integer(1 + 2), addResult);
    }
View Full Code Here


        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);

        assertNull(add); //the entry point should not be created as the output type is ambiguous
        assert(messageLogger.getNMessages() > 0);
       
        CompilerMessage error = messageLogger.getFirstError();
View Full Code Here

        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);

        assertNull(add); //the entry point should not be created as the input/output types do not unify
        assert(messageLogger.getNMessages() > 0);
       
        CompilerMessage error = messageLogger.getFirstError();
View Full Code Here

        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);

        //this should output 3 as a CAL internal value
        Object add2Result = executor.exec(add2, new Object[] { addResult, new Integer(2) });
      
       
View Full Code Here

        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);

        //this should add 2 to the CAL internal value representing 3
        Object add2Result = executor.exec(add2, new Object[] { addResult, new Integer(2) });
      
       
View Full Code Here

        int index = 1;
        while (moduleTypeInfo.getFunctionalAgent(targetName) != null) {
            targetName = "target" + index;
            index++;
        }
        EntryPoint entryPoint = compileAdjunct(QualifiedName.make(moduleName, targetName), maybeQualifiedExpressionText);

        if (entryPoint == null) {
            return false;
        }
View Full Code Here

        calLogger.fine("Compiling adjunct..");
        ModuleName targetModule = qualifiedTargetName.getModuleName();

        // Compile it, indicating that this is an adjunct
        EntryPoint targetEntryPoint =
            getProgramModelManager().getCompiler().getEntryPoint(
                    new AdjunctSource.FromText(scDef),
                    EntryPointSpec.make(QualifiedName.make(targetModule, unqualifiedTargetName), new InputPolicy[]{}, OutputPolicy.DEFAULT_OUTPUT_POLICY),
                    targetModule,
                    ml);
View Full Code Here

              
        CompilerMessageLogger messageLogger = new MessageLogger();       
        WorkspaceManager workspaceManager = calServices.getWorkspaceManager();
        Compiler compiler = calServices.getCompiler();  
       
        EntryPoint entryPoint = compiler.getEntryPoint(
            EntryPointSpec.make(QualifiedName.make(CALPlatformTestModuleNames.M2, "getNthPrime")),
            CALPlatformTestModuleNames.M2, messageLogger);
        if (messageLogger.getNMessages() > 0) {
            System.err.println(messageLogger.toString());
        }
View Full Code Here

        //allPrimesAdjunct = (Prelude.output # List.toJIterator) M1.allPrimes;           

        EntryPointSpec allPrimesEntryPointSpec =
            EntryPointSpec.make(QualifiedName.make(CALPlatformTestModuleNames.M1, "allPrimes"), null, OutputPolicy.ITERATOR_OUTPUT_POLICY);       
       
        EntryPoint allPrimesEntryPoint =
            compiler.getEntryPoint(allPrimesEntryPointSpec, CALPlatformTestModuleNames.M1, messageLogger);
       
        if (messageLogger.getNMessages() > 0) {
            System.err.println(messageLogger.toString());
        }
View Full Code Here

        List<EntryPoint> entryPoints =
            compiler.getEntryPoints(entryPointSpecs, CALPlatformTestModuleNames.M2, messageLogger);
        if (messageLogger.getNMessages() > 0) {
            System.err.println(messageLogger.toString());
        }       
        EntryPoint allPrimesEntryPoint = entryPoints.get(0);
        EntryPoint stringListEntryPoint = entryPoints.get(1);       
       
        try {
            Iterator<?> primesIterator = (Iterator<?>)executor.exec(allPrimesEntryPoint, null);
            Iterator<?> namesIterator = (Iterator<?>)executor.exec(stringListEntryPoint, null);    
                          
View Full Code Here

TOP

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

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.