Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.MessageLogger


                machineType, workspaceFileProperty, defaultWorkspaceFile,
                defaultWorkspaceClientID);

            conditionallyCleanupRuntime(calServices, null);
           
            MessageLogger logger = new MessageLogger();
           
            calServices.compileWorkspace(null, logger);

            commonCALServices.put(key, calServices);
           
            if (SHOW_INSTANCE_CREATION) {
                System.out.println("New common CAL services - " + key);
                try {
                    throw new Exception();
                } catch (Exception e) {
                    StackTraceElement[] stackTrace = e.getStackTrace();
                    for (final StackTraceElement element : stackTrace) {
                        System.out.println("   at " + element);
                    }
                }
            }

            if (logger.getNErrors() > 0) {
                Assert.fail("Compilation of workspace failed: " + logger.getCompilerMessages());
            }
            return calServices;
        }
    }
View Full Code Here


            defaultWorkspaceClientID, sourceGenerationRootSuffix);
       
        conditionallyCleanupRuntime(calServices, sourceGenerationRootSuffix);
       
        if (shouldCompile) {
            MessageLogger logger = new MessageLogger();

            calServices.compileWorkspace(null, logger);

            if (logger.getNErrors() > 0) {
                Assert.fail("Compilation of workspace failed: " + logger.getCompilerMessages());
            }
        }
        return calServices;
    }
View Full Code Here

    public static void testWorkspaceValidity(String workspaceName) {
       
        BasicCALServices privateCopyLeccServices =
            CALServicesTestUtilities.makeUnsharedUnitTestCALServices(workspaceName, false);
       
        MessageLogger logger = new MessageLogger();
        privateCopyLeccServices.compileWorkspace(null, logger);
       
        if (logger.getNErrors() > 0) {
            String message = "Compilation of the workspace failed with these errors:\n" + logger.toString();
           
            if (SHOW_DEBUGGING_OUTPUT) {
                System.err.println(message);
            }
           
View Full Code Here

        AdjunctSource source = new AdjunctSource.FromSourceModel(
                SourceModel.FunctionDefn.Algebraic.make(adjunctUnqualifiedName, Scope.PUBLIC, null, funcExpr));
       

        WorkspaceManager workspaceManager = leccCALServices.getWorkspaceManager();
        CompilerMessageLogger logger = new MessageLogger();
       
       
        // Compile the adjunct definition.       
        EntryPointSpec entryPointSpec = EntryPointSpec.make(qualifiedAdjunctName, new InputPolicy[0], OutputPolicy.DEFAULT_OUTPUT_POLICY);
        workspaceManager.getCompiler().getEntryPoint (source, entryPointSpec, adjunctModuleName,  logger);

        if (logger.getMaxSeverity().compareTo(CompilerMessage.Severity.ERROR) >= 0) {
            fail("Compilation failed: " + logger.getFirstError().getMessage());
        }
       

        // Get the classloader for module with the adjunct we compiled.
        LECCModule module = (LECCModule)workspaceManager.getModuleTypeInfo(adjunctModuleName).getModule();
View Full Code Here

       
        // Init the workspace.
        workspaceManager.initWorkspace(workspaceDeclarationProvider, true, compileStatus);
        assertEquals(compileStatus.getSeverity(), Status.Severity.OK);
       
        MessageLogger logger = new MessageLogger();
        workspaceManager.compile(logger, false, null);
       
        if (logger.getMaxSeverity().compareTo(CompilerMessage.Severity.WARNING) > 0) {
            fail("Compilation failed:\n" + logger.toString());
        }
       
        return new Pair<WorkspaceManager, File>(workspaceManager, rootDir);
    }
View Full Code Here

     * @param functionName
     * @throws CALExecutorException
     */
    static void help_testWithFunction(WorkspaceManager workspaceManager, ModuleName moduleName, String functionName) throws CALExecutorException {

        CompilerMessageLogger logger = new MessageLogger();
        EntryPoint entryPoint = workspaceManager.getCompiler().getEntryPoint(
            EntryPointSpec.make(QualifiedName.make(moduleName, functionName)),
            moduleName,
            logger);
       
View Full Code Here

        /// Create and compile a workspace through a BasicCALServices
        //
       
        WorkspaceManager workspaceManager = calServices.getWorkspaceManager();
       
        MessageLogger msgLogger = new MessageLogger();
       
        StatusListener.StatusListenerAdapter statusListener = new StatusListener.StatusListenerAdapter() {
            /**
             * {@inheritDoc}
             */
            @Override
            public void setModuleStatus(StatusListener.Status.Module moduleStatus, ModuleName moduleName) {
                if (moduleStatus == StatusListener.SM_GENCODE) {
                    logger.fine("Compiling " + moduleName);
                }
            }
        };
       
        logger.info("Compiling CAL workspace...");
        calServices.compileWorkspace(statusListener, msgLogger);
       
        if (msgLogger.getNErrors() == 0) {
            logger.info("Compilation successful");
           
            ////
            /// We only run the CarBuilder if everything compiled properly without errors
            //
           
            CarBuilder.Monitor monitor = new CarBuilder.Monitor() {
                public boolean isCanceled() {
                    return false;
                }
                public void operationStarted(int nCars, int nTotalModules) {}
                public void showMessages(String[] messages) {
                    for (final String element : messages) {
                        logger.info(element);
                    }
                }
                public void carBuildingStarted(String carName, int nModules) {
                    logger.info("Creating the Car file " + carName);
                }
                public void processingModule(String carName, ModuleName moduleName) {
                    logger.info("Adding module " + moduleName + " to the Car...");
                }
                public void carBuildingDone(String carName) {
                    logger.info("Done creating the Car file " + carName);
                }
                public void operationDone() {
                    logger.info("All done");
                }
            };
           
            ///
            // Command line syntax:
            //
            // [-notVerbose] [-keepsource] [-nocws | -nosuffix] [-s] [-excludeCarsInDirs ... --] [-excludeCarJarsInDirs ... --] [-jar] outputDirectory [carSpecName1 carSpecName2...]
            // OR
            // [-notVerbose] [-keepsource] [-nocws | -nosuffix] [-s] [-excludeCarsInDirs ... --] [-excludeCarJarsInDirs ... --] [-jar] -d outputDirectory
           
            boolean verboseMode = true; // default: verbose
            if (arguments.getArgument().equals("-notVerbose")) {
                verboseMode = false;
                arguments.consumeArgument();
            }
           
            boolean shouldBuildSourcelessModules = true; // default: generate sourceless modules
            if (arguments.getArgument().equals("-keepsource")) {
                shouldBuildSourcelessModules = false;
                arguments.consumeArgument();
            }
           
            boolean shouldGenerateCorrespWorspaceDecl = true; // default: generated the cws files
            boolean noCarSuffixInWorkspaceDeclName = false;   // default: generated cws files end with .car.cws
           
            if (arguments.getArgument().equals("-nocws")) {
                shouldGenerateCorrespWorspaceDecl = false;
                arguments.consumeArgument();
            } else if (arguments.getArgument().equals("-nosuffix")) {
                noCarSuffixInWorkspaceDeclName = true;
                arguments.consumeArgument();
            }
           
            boolean shouldSkipModulesAlreadyInCars = false; // default: do not skip modules already in Cars
            if (arguments.getArgument().equals("-s")) {
                shouldSkipModulesAlreadyInCars = true;
                arguments.consumeArgument();
            }
           
            Set<String> carsToExclude = new HashSet<String>(additionalCarsToExclude);
            if (arguments.getArgument().equals("-excludeCarsInDirs")) {
                arguments.consumeArgument();
               
                while (!arguments.getArgument().equals("--")) {
                    File directory = new File(arguments.getAndConsumeArgument(), "Car");
                   
                    File[] files = directory.listFiles();
                    if (files == null) {
                        logger.warning("Folder does not exist: " + directory);
                    } else {
                        for (final File element : files) {
                            carsToExclude.add(element.getName());
                        }
                    }
                }
                arguments.consumeArgument(); // consume the -- delimiter
            }
           
            if (arguments.getArgument().equals("-excludeCarJarsInDirs")) {
                arguments.consumeArgument();
               
                while (!arguments.getArgument().equals("--")) {
                    File directory = new File(arguments.getAndConsumeArgument());
                   
                    File[] files = directory.listFiles();
                    if (files == null) {
                        logger.warning("Folder does not exist: " + directory);
                    } else {
                        for (final File element : files) {
                            String fileName = element.getName();
                            if (fileName.endsWith(CarBuilder.DOT_CAR_DOT_JAR)) {
                                String carName = fileName.substring(0, fileName.length() - 4); // chop ".jar" off the end
                                carsToExclude.add(carName);
                            }
                        }
                    }
                }
                arguments.consumeArgument(); // consume the -- delimiter
            }
           
            boolean shouldGenerateCarJarSuffix = false; // default: generate Cars and not Car-jars.
            if (arguments.getArgument().equals("-jar")) {
                shouldGenerateCarJarSuffix = true;
                arguments.consumeArgument();
            }
           
            if (verboseMode) {
                System.out.println();
                System.out.println(workspaceManager.getDebugInfo());
                System.out.println();
            }
           
            CarBuilder.BuilderOptions options = new CarBuilder.BuilderOptions(
                shouldSkipModulesAlreadyInCars,
                shouldGenerateCorrespWorspaceDecl,
                noCarSuffixInWorkspaceDeclName,
                shouldBuildSourcelessModules,
                carsToExclude,
                shouldGenerateCarJarSuffix);
               
            if (arguments.getArgument().equals("-d")) {
                // the user wants one Car per workspace declaration file
               
                arguments.consumeArgument();
               
                final String outputDir = arguments.getAndConsumeArgument();
               
                arguments.noMoreArgumentsAllowed();
               
                final File outputDirectory = new File(outputDir);
               
                try {
                    String[] carsBuilt = CarBuilder.buildOneCarPerWorkspaceDeclaration(workspaceManager, monitor, outputDirectory, options);
                    return carsBuilt;
                   
                } catch (IOException e) {
                    logger.info("Error occurred generating the Car files: " + e.getMessage());
                    throw new OperationFailedException();
                }
               
               
            } else {
                // the user wants just one Car for all modules in the workspace
                if (!carsToExclude.equals(additionalCarsToExclude)) {
                    logger.info("The option -excludeCarsInDirs does not apply for building just one Car. Ignoring...");
                }
               
                final String carName = CarBuilder.makeCarNameFromSourceWorkspaceDeclName(workspaceDeclarationName);
                   
                final String outputDir = arguments.getAndConsumeArgument();
               
                final File outputDirectory = new File(outputDir);
               
                CarBuilder.Configuration config =
                    CarBuilder.Configuration.makeConfigOptionallySkippingModulesAlreadyInCars(workspaceManager, options);
               
                for (Iterator<String> it = arguments.getRemainingArgumentsIterator(); it.hasNext(); ) {
                    String carSpecName = it.next();
                    File specFile = new File(carSpecName);
                    config.addFileBasedCarSpec(specFile.getName(), specFile);
                }
               
                config.setMonitor(monitor);
               
                try {
                    boolean notCanceled = CarBuilder.buildCar(config, outputDirectory, carName, options);
                    if (notCanceled) {
                        return new String[] {carName};
                    }
                   
                } catch (IOException e) {
                    logger.info("Error occurred generating the Car file: " + e.getMessage());
                    throw new OperationFailedException();
                }
            }
           
        } else {
            logger.severe("Compilation failed:");
            List<CompilerMessage> messages = msgLogger.getCompilerMessages();
            for (int i = 0, n = messages.size(); i < n; i++) {
                logger.info("  " + messages.get(i).toString());
            }
           
            throw new OperationFailedException();
View Full Code Here

                }
            }
        });

       
        CompilerMessageLogger ml = new MessageLogger();
       
        // Init and compile the workspace.
        Status initStatus = new Status("Init status.");
        workspaceManager.initWorkspace(streamProvider, initStatus);
       
        if (initStatus.getSeverity() != Status.Severity.OK) {
            ml.logMessage(initStatus.asCompilerMessage());
        }
       
        long startCompile = System.currentTimeMillis();
       
        // If there are no errors go ahead and compile the workspace.
        if (ml.getMaxSeverity().compareTo(CompilerMessage.Severity.ERROR) < 0) {
            WorkspaceManager.CompilationOptions options = new WorkspaceManager.CompilationOptions();
            options.setForceCodeRegeneration(forceCodeRegen);
            workspaceManager.compile(ml, dirtyOnly, null, options);
        }
       
        long compileTime = System.currentTimeMillis() - startCompile;
       
        boolean compilationSucceeded;
        if (ml.getMaxSeverity().compareTo(CompilerMessage.Severity.ERROR) >= 0) {
            // Errors
            jfitLogger.severe("Compilation unsuccessful because of errors:");
            compilationSucceeded = false;
        } else {
            // Compilation successful
            jfitLogger.fine("Compilation successful");
            compilationSucceeded = true;
        }
       
        // Write out compiler messages
        java.util.List<CompilerMessage> errs = ml.getCompilerMessages();
        int errsSize = errs.size();
        for (int i = 0; i < errsSize; i++) {
            CompilerMessage err = errs.get(i);
            jfitLogger.info("  " + err.toString());
        }
View Full Code Here

                HashSet<EntryPointSpec> required = new HashSet<EntryPointSpec>();

                required.addAll(cache.keySet());
                required.addAll(entryPointSpecs);

                CompilerMessageLogger compilerLogger = new MessageLogger();
                      
                List<EntryPointSpec> requiredList = new ArrayList<EntryPointSpec>(required);
                //compile the entry points
                List<EntryPoint> entryPoints
                = programModelManager.getCompiler().getEntryPoints(requiredList, moduleName, compilerLogger);

                if (compilerLogger.getMaxSeverity().compareTo(CompilerMessage.Severity.ERROR) >= 0) {
                    StringBuffer sb = new StringBuffer();
                    sb.append("Failed to generate entry points for module '");
                    sb.append(moduleName);
                    sb.append(General.SYSTEM_EOL);
                    for(CompilerMessage msg : compilerLogger.getCompilerMessages()) {
                        sb.append(msg);
                        sb.append(General.SYSTEM_EOL);
                    }

                    //all of the cached entry points are invalid now.
View Full Code Here

     * @param typeChecker TypeChecker the type checker to use to generate the type
     * @return TypeExpr a new TypeExpr for the target sc.
     */
    protected static final TypeExpr getNewTargetTypeExpr(Target target, ModuleName moduleName, TypeChecker typeChecker) {
        AdjunctSource scDefinition = target.getTargetDef(null, typeChecker.getTypeCheckInfo(moduleName).getModuleTypeInfo());
        CompilerMessageLogger logger = new MessageLogger ();
        return typeChecker.checkFunction(scDefinition, moduleName, logger);
    }
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.