Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.MessageLogger


     * @return a corresponding entry point, or null if there was a problem compiling the definition.
     */
    private EntryPoint compileAdjunct(QualifiedName qualifiedTargetName, String functionBodyText) {
        String unqualifiedTargetName = qualifiedTargetName.getUnqualifiedName();
        String scDef = unqualifiedTargetName + " = \n" + functionBodyText + "\n;";
        CompilerMessageLogger ml = new MessageLogger ();

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

        // Compile it, indicating that this is an adjunct
View Full Code Here


    private static final String WORKSPACE_FILE_NAME = "cal.platform.test.cws";
   
    public static void main(String[] args) {
        CompilerMessageLogger messageLogger = new MessageLogger();
        BasicCALServices calServices = BasicCALServices.makeCompiled(WORKSPACE_FILE_NAME, messageLogger);       

        try {

            {
View Full Code Here

       
    EventLoop() {
       
        calServices = BasicCALServices.make(WORKSPACE_FILE_NAME);
              
        CompilerMessageLogger messageLogger = new MessageLogger();       
        if (!calServices.compileWorkspace(null, messageLogger)) {
            System.err.println(messageLogger.toString());
        }
              
        executionContext = calServices.getWorkspaceManager().makeExecutionContextWithDefaultProperties();       
                              
    }
View Full Code Here

        //the result of getNthPrime 5001 is 48623
        //the result of getNthPrime 5002 is 48647
        //the result of getNthPrime 5003 is 48649
        //the result of getNthPrime 5004 is 48661
              
        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());
        }
        CALExecutor executor = workspaceManager.makeExecutor(executionContext);
       
        try {
            for (int i = 0; i < nTimes; ++i) {
View Full Code Here

        //4
        //the next 4 primes are [7, 11, 13, 17]
        //How many more primes would you like? (enter q to quit)
        //q       

        CompilerMessageLogger messageLogger = new MessageLogger();
       
        WorkspaceManager workspaceManager = calServices.getWorkspaceManager();
        Compiler compiler = calServices.getCompiler();   
      
        CALExecutor executor = workspaceManager.makeExecutor(executionContext)
       
        //the below function represent a model of what is created when using EntryPointSpec classes i.e.
        //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);       
       
        EntryPoint allPrimesEntryPoint =
            compiler.getEntryPoint(allPrimesEntryPointSpec, CALPlatformTestModuleNames.M1, messageLogger);
       
        if (messageLogger.getNMessages() > 0) {
            System.err.println(messageLogger.toString());
        }
 
        try {
            Iterator<?> primesIterator = (Iterator<?>)executor.exec(allPrimesEntryPoint, null);
           
View Full Code Here

        //  4
        //  the next 4 names are [Frank, Fred, Helen, Linda]
        //  How many more primes would you like? (enter q to quit)
        //  q
                       
        CompilerMessageLogger messageLogger = new MessageLogger();
       
        WorkspaceManager workspaceManager = calServices.getWorkspaceManager();
        Compiler compiler = calServices.getCompiler();           
       
        CALExecutor executor = workspaceManager.makeExecutor(executionContext);               
       
        List<EntryPointSpec> entryPointSpecs = new ArrayList<EntryPointSpec>(); //list of EntryPointSpec
       
        //the below function represent a model of what is created when using EntryPointSpec classes i.e.
        //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);
                      
        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 {
View Full Code Here

        //2
        //the next 2 are [31, 37]
        //How many more primes would you like? (enter q to quit)
        //q
              
        CompilerMessageLogger messageLogger = new MessageLogger();
       
        WorkspaceManager workspaceManager = calServices.getWorkspaceManager();
        Compiler compiler = calServices.getCompiler();    
       
        CALExecutor executor = workspaceManager.makeExecutor(executionContext);
       
        EntryPoint allPrimesExternalEntryPoint =
            compiler.getEntryPoint(
                EntryPointSpec.make(QualifiedName.make(CALPlatformTestModuleNames.M2, "allPrimesExternal")),
                CALPlatformTestModuleNames.M2, messageLogger);
        if (messageLogger.getNMessages() > 0) {
            System.err.println(messageLogger.toString());
        }
             
        try {
           
            CalValue remainingPrimesCalValue = (CalValue)executor.exec(allPrimesExternalEntryPoint, null);
View Full Code Here

        //2
        //the next 2 names are [Frank, Fred]
        //How many more primes would you like? (enter q to quit)
        //q      
       
        CompilerMessageLogger messageLogger = new MessageLogger();
       
        WorkspaceManager workspaceManager = calServices.getWorkspaceManager();
        Compiler compiler = calServices.getCompiler();    
       
        CALExecutor executor = workspaceManager.makeExecutor(executionContext);               
       
        List<QualifiedName> entryPointNames = new ArrayList<QualifiedName>(); //list of QualifiedName
        entryPointNames.add(QualifiedName.make(CALPlatformTestModuleNames.M2, "allPrimesExternal"));
        entryPointNames.add(QualifiedName.make(CALPlatformTestModuleNames.M2, "stringListExternal"));
        entryPointNames.add(QualifiedName.make(CALPlatformTestModuleNames.M2, "takeNExternal_ListOfInt"));
        entryPointNames.add(QualifiedName.make(CALPlatformTestModuleNames.M2, "takeNExternal_ListOfString"));                      
       
        List<EntryPoint> entryPoints =
            compiler.getEntryPoints(
                EntryPointSpec.buildListFromQualifiedNames(entryPointNames),
                CALPlatformTestModuleNames.M2,
                messageLogger);
       
        if (messageLogger.getNMessages() > 0) {
            System.err.println(messageLogger.toString());
        }
        EntryPoint allPrimesExternal = entryPoints.get(0);
        EntryPoint stringListExternal = entryPoints.get(1);
        EntryPoint takeNExternal_ListOfInt = entryPoints.get(2);
        EntryPoint takeNExternal_ListOfString = entryPoints.get(3);
View Full Code Here

        //  4
        //  the next 4 names are [Frank, Fred, Helen, Linda]
        //  How many more primes would you like? (enter q to quit)
        //  q
                       
        CompilerMessageLogger messageLogger = new MessageLogger();
       
        WorkspaceManager workspaceManager = calServices.getWorkspaceManager();
        Compiler compiler = calServices.getCompiler();          
       
        CALExecutor executor = workspaceManager.makeExecutor(executionContext);               
       
        List<EntryPointSpec> entryPointSpecs = new ArrayList<EntryPointSpec>(); //list of EntryPointSpec
       
        //the below 2 functions represent a model of what is created when using EntryPointSpec classes i.e.
        //explicit input and output policies.
       
        //allPrimesAdjunct :: Prelude.JObject;
        //allPrimesAdjunct = (\x -> Prelude.output ((Prelude.unsafeCoerce x) ::  Prelude.CalValue)) M1.allPrimes;
        //
        //takeNIntAdjunct :: Prelude.JObject -> Prelude.JObject -> Prelude.JObject;
        //takeNIntAdjunct list nToTake =
        //    (\x -> Prelude.output ((Prelude.unsafeCoerce x) :: ([Int], CalValue)))
        //        (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 + ")))"));       
                     
        entryPointSpecs.add(allPrimesEntryPointSpec);
        entryPointSpecs.add(stringListEntryPointSpec);
        entryPointSpecs.add(takeNListOfInt);
        entryPointSpecs.add(takeNListOfString);       
                      
        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);
        EntryPoint takeNListOfIntEntryPoint = entryPoints.get(2);
        EntryPoint takeNListOfStringEntryPoint = entryPoints.get(3);
View Full Code Here

    /**
     * Performs the setup for the test suite.
     */
    private static void oneTimeSetUp() {
        calServices = BasicCALServices.make(GemCutter.GEMCUTTER_PROP_WORKSPACE_FILE, "cal.platform.test.cws", null);                  
        calServices.compileWorkspace(null, new MessageLogger());       
        gemFactory = new GemFactory(calServices);
    }
View Full Code Here

TOP

Related Classes of org.openquark.cal.compiler.MessageLogger

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.