Package org.openquark.cal.machine

Examples of org.openquark.cal.machine.CALExecutor


            SourceModel.Expr.makeGemCall(CAL_Array.Functions.outputPrimitive,
                SourceModel.Expr.makeGemCall(CAL_Array.Functions.subscript,
                    SourceModel.Expr.makeGemCall(QualifiedName.make(CALPlatformTestModuleNames.Array_Tests, "multiDimArray")),
                    SourceModel.Expr.makeIntValue(0))))),
        EntryPointSpec.make(QualifiedName.make(CALPlatformTestModuleNames.Array_Tests, functionName)), CALPlatformTestModuleNames.Array_Tests, logger);
        CALExecutor executor = calServices.getWorkspaceManager().makeExecutorWithNewContextAndDefaultProperties();
         

        int[] result = (int[]) executor.exec(entryPoint, new Object[0]);
        int[] expected = new int[]{1,2,3};
       
        assertEquals(expected.length, result.length);
        for (int i = 0; i < expected.length; i++) {
            assertEquals(expected[i], result[i]);
View Full Code Here


                        SourceModel.Expr.makeGemCall(QualifiedName.make(CALPlatformTestModuleNames.Array_Tests, "multiDimArray")),
                        SourceModel.Expr.makeIntValue(0)))),
        EntryPointSpec.make(QualifiedName.make(CALPlatformTestModuleNames.Array_Tests, functionName)), CALPlatformTestModuleNames.Array_Tests, logger);


        CALExecutor executor = calServices.getWorkspaceManager().makeExecutorWithNewContextAndDefaultProperties();

        List<?> result = (List<?>) executor.exec(entryPoint, new Object[0]);
        List<?> expected = Arrays.asList(new Object[]{new Integer(1), new Integer(2), new Integer(3)});
       
        assertEquals(expected.size(), result.size());       
        assertEquals(expected, result);      
    }
View Full Code Here

     * Tests the executor's handling of an entry point based on an enumeration data cons.
     * @throws CALExecutorException
     */
    public void testEnumDataConsEntryPoint() {
        final EntryPoint gt = new EntryPointImpl(CAL_Prelude.DataConstructors.GT);
        final CALExecutor executor = leccCALServices.getWorkspaceManager().makeExecutorWithNewContextAndDefaultProperties();
       
        try {
            executor.exec(gt, new Object[0]);
        } catch (CALExecutorException e) {
            assertTrue(e.getMessage().contains("Attempt to call getOpaqueValue() on class: org.openquark.cal.internal.runtime.lecc.RTData$CAL_Int"));
            return;
        }
        fail("exception expected");
View Full Code Here

        EntryPoint entryPoint = workspaceManager.getCompiler().getEntryPoint(
            EntryPointSpec.make(QualifiedName.make(moduleName, functionName)),
            moduleName,
            logger);
       
        CALExecutor executor = workspaceManager.makeExecutor(workspaceManager.makeExecutionContextWithDefaultProperties());
       
        assertEquals(Boolean.TRUE, executor.exec(entryPoint, new Object[0]));
    }
View Full Code Here

                    SourceModel.FunctionDefn.Algebraic.make(
                        functionName, Scope.PRIVATE, null,
                        SourceModel.Expr.makeStringValue(expectedValue))),
                EntryPointSpec.make(QualifiedName.make(targetModule, functionName))
                targetModule, logger);
            CALExecutor executor = workspaceManager.makeExecutorWithNewContextAndDefaultProperties();
            
            try {
                for (int i = 0; i < numEvalTries; i++) {
                    multithreadedAssertEquals(expectedValue, executor.exec(entryPoint, new Object[0]), asserts);
                }
            } finally {
                workspaceManager.resetCachedResults(executor.getContext());
            }
        } catch (Throwable t) {
            StringWriter sw = new StringWriter();
            t.printStackTrace(new PrintWriter(sw));
            multithreadedAssertEquals("No exceptions for " + expectedValue, sw.toString(), asserts);
View Full Code Here

                        functionName, Scope.PRIVATE, null,
                        SourceModelUtilities.TextParsing.parseExprIntoSourceModel(definingExpr))),
                EntryPointSpec.make(QualifiedName.make(targetModule, functionName)),
                targetModule, logger);
           
            CALExecutor executor = workspaceManager.makeExecutorWithNewContextAndDefaultProperties();

            try {
                for (int i = 0; i < numEvalTries; i++) {
                    multithreadedAssertEquals(expectedValue, executor.exec(entryPoint, new Object[0]), asserts);
                }
            } finally {
                workspaceManager.resetCachedResults(executor.getContext());
            }
        } catch (Throwable t) {
            StringWriter sw = new StringWriter();
            t.printStackTrace(new PrintWriter(sw));
            multithreadedAssertEquals("No exceptions for " + expectedValue, sw.toString(), asserts);
View Full Code Here

                EntryPoint ep = cache.get(entryPointSpec);
                if (ep == null) {
                    addEntryPoints(Collections.singletonList(entryPointSpec), true);
                    ep = cache.get(entryPointSpec);
                }      
                CALExecutor executor = programModelManager.makeExecutor(executionContext);

                return executor.exec(ep, arguments);

            } finally {
                cacheLock.readLock().unlock();
            }
        }
View Full Code Here

        functionalAgentNames.add(QualifiedName.make(moduleName, "makeEmptyRoom"));
        functionalAgentNames.add(QualifiedName.make(moduleName, "Red"));
        functionalAgentNames.add(QualifiedName.make(moduleName, "Yellow"));
        functionalAgentNames.add(QualifiedName.make(moduleName, "Blue"));

        CALExecutor executor = calServices.getWorkspaceManager().makeExecutorWithNewContextAndDefaultProperties();

        entryPoints = compiler.getEntryPoints(EntryPointSpec.buildListFromQualifiedNames(functionalAgentNames),
            moduleName, messageLogger);
       
        if (messageLogger.getNMessages() > 0) {
            System.err.println(messageLogger.toString());
            System.exit(1);
        }

        stopWatch.stop();
        System.err.println("Startup took: " + stopWatch);
       
        try {
            stopWatch.start();

            CalMonitor meetingRoom =  (CalMonitor) executor.exec(entryPoints.get(1), new Object[] { new Integer(numberOfMeetings) });
            CalMonitor occupant = new CalMonitor();

            Object red = executor.exec(entryPoints.get(2), null);
            Object yellow = executor.exec(entryPoints.get(3), null);
            Object blue = executor.exec(entryPoints.get(4), null);

            //start the three chameneos, each with a different colors
            ChameneosThread t1 = ChameneosThread.makeChameneosThread(entryPoints.get(0), red, meetingRoom, occupant);
            ChameneosThread t2 = ChameneosThread.makeChameneosThread(entryPoints.get(0), yellow, meetingRoom, occupant);
            ChameneosThread t3 = ChameneosThread.makeChameneosThread(entryPoints.get(0), blue, meetingRoom, occupant);
View Full Code Here

        /**start the CAL implementation of the threadbody running*/
        public void run() {
            try {
                synchronized (this) {
                    CALExecutor executor = calServices.getWorkspaceManager().makeExecutorWithNewContextAndDefaultProperties();

                    numMeetings = (Integer) executor.exec(entryPoint, new Object[] { color, meetingRoom,  occupant, new Integer(0)});
                    notify();
                }
                //System.out.println(numMeetings);
            } catch (CALExecutorException ex) {
                System.err.println("Unexpected CAL compilation error: " + ex);
View Full Code Here

            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) {
                Object result = executor.exec(entryPoint, new Object[] {new Integer(5000 + i)});
                System.out.println("the result of getNthPrime " + (5000 + i) + " is " + result);
            }
        } catch (CALExecutorException executorException) {
            System.out.println("Execution terminated with an executor exception:" + executorException);
        }                                 
View Full Code Here

TOP

Related Classes of org.openquark.cal.machine.CALExecutor

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.