Search in sources :

Example 1 with TimeTracker

use of com.google.devtools.j2objc.util.TimeTracker in project j2objc by google.

the class TranslationProcessor method processConvertedTree.

@Override
protected void processConvertedTree(ProcessingContext input, CompilationUnit unit) {
    String unitName = input.getOriginalSourcePath();
    if (logger.isLoggable(Level.INFO)) {
        System.out.println("translating " + unitName);
    }
    TimeTracker ticker = TimeTracker.getTicker(unitName, options.timingLevel());
    if (options.dumpAST()) {
        // Dump compilation unit to an .ast output file instead of translating.
        DebugASTDump.dumpUnit(unit);
    } else {
        applyMutations(unit, deadCodeMap, ticker);
        ticker.tick("Tree mutations");
        ticker.printResults(System.out);
        GenerationUnit genUnit = input.getGenerationUnit();
        genUnit.addCompilationUnit(unit);
        // Add out-of-date dependencies to translation list.
        if (closureQueue != null) {
            checkDependencies(unit);
        }
        if (genUnit.isFullyParsed()) {
            generateObjectiveCSource(genUnit);
        }
    }
    processedCount++;
}
Also used : GenerationUnit(com.google.devtools.j2objc.gen.GenerationUnit) TimeTracker(com.google.devtools.j2objc.util.TimeTracker)

Example 2 with TimeTracker

use of com.google.devtools.j2objc.util.TimeTracker in project j2objc by google.

the class TranslationProcessor method generateObjectiveCSource.

@VisibleForTesting
public static void generateObjectiveCSource(GenerationUnit unit) {
    assert unit.getOutputPath() != null;
    assert unit.isFullyParsed();
    TimeTracker ticker = TimeTracker.getTicker(unit.getSourceName(), unit.options().timingLevel());
    logger.fine("Generating " + unit.getOutputPath());
    logger.finest("writing output file(s) to " + unit.options().fileUtil().getOutputDirectory().getAbsolutePath());
    ticker.push();
    // write header
    if (unit.options().generateSegmentedHeaders()) {
        ObjectiveCSegmentedHeaderGenerator.generate(unit);
    } else {
        ObjectiveCHeaderGenerator.generate(unit);
    }
    ticker.tick("Header generation");
    // write implementation file
    ObjectiveCImplementationGenerator.generate(unit);
    ticker.tick("Implementation generation");
    unit.finished();
    ticker.pop();
    ticker.tick("Source generation");
    ticker.printResults(System.out);
}
Also used : TimeTracker(com.google.devtools.j2objc.util.TimeTracker) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

TimeTracker (com.google.devtools.j2objc.util.TimeTracker)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 GenerationUnit (com.google.devtools.j2objc.gen.GenerationUnit)1