Compile module - parse source files and generate code using specified outputs.
431922
public void compile(ModuleConfiguration configuration) {
        LOGGER.debug("Compiling module {}", configuration);
        FileReaderFactory fileReaderFactory = injector.getInstance(FileReaderFactory.class);
        Importer importer = injector.getInstance(Importer.class);
        CompilerRegistry registry = injector.getInstance(CompilerRegistry.class);
        ProtoCompiler compiler = registry.findCompiler(configuration.getGenerator());
        if (compiler == null) {
            throw new GeneratorException("Unknown template: %s | %s", configuration.getGenerator(), registry.availableCompilers());
        }
        FileReader fileReader = fileReaderFactory.create(configuration.getIncludePaths());
        Map<String, Proto> importedFiles = new HashMap<>();
        for (String path : configuration.getProtoFiles()) {
            LOGGER.info("Parse {}", path);
            ProtoContext context = importer.importFile(fileReader, path);
            Proto proto = context.getProto();
            importedFiles.put(path, proto);
        }
        ImmutableModule.Builder builder = ImmutableModule.builder();
        builder.name(configuration.getName());
        builder.output(configuration.getOutput());
        builder.options(configuration.getOptions());
        for (Proto proto : importedFiles.values()) {
            builder.addProtos(proto);
        }
        UsageIndex index = UsageIndex.build(importedFiles.values());
        builder.usageIndex(index);
        ImmutableModule module = builder.build();
        for (Proto proto : importedFiles.values()) {
            proto.setModule(module);
        }
        compiler.compile(module);
    }
1332452
def process_compile_entries(
        processor, spec, entries, modpath_logger=None, targetpath_logger=None):
    

    # Contains a mapping of the module name to the compiled file's
    # relative path starting from the base build_dir.
    all_modpaths = {}
    all_targets = {}
    # List of exported module names, should be equal to all keys of
    # the compiled and bundled sources.
    all_export_module_names = []

    def update(base, fresh, logger):
        if callable(logger):
            for dupes in dict_update_overwrite_check(base, fresh):
                logger(*dupes)
        else:
            base.update(fresh)

    for entry in entries:
        modpaths, targetpaths, export_module_names = processor(spec, entry)
        update(all_modpaths, modpaths, modpath_logger)
        update(all_targets, targetpaths, targetpath_logger)
        all_export_module_names.extend(export_module_names)

    return all_modpaths, all_targets, all_export_module_names
752546
def main():
    """"""
    desc = 'Generate files to benchmark'
    parser = argparse.ArgumentParser(description=desc)
    parser.add_argument(
        '--src',
        dest='src_dir',
        default='src',
        help='The directory containing the templates'
    )
    parser.add_argument(
        '--out',
        dest='out_dir',
        default='generated',
        help='The output directory'
    )
    parser.add_argument(
        '--seed',
        dest='seed',
        default='13',
        help='The random seed (to ensure consistent regeneration)'
    )

    args = parser.parse_args()

    random.seed(int(args.seed))

    mkdir_p(args.out_dir)

    for template in templates_in(args.src_dir):
        modes = template.modes()

        n_range = template.range()
        for n_value in n_range:
            base = template.instantiate(n_value)
            for mode in modes:
                write_file(
                    os.path.join(
                        args.out_dir,
                        out_filename(template, n_value, mode)
                    ),
                    mode.convert_from(base)
                )
        write_file(
            os.path.join(args.out_dir, '{0}.json'.format(template.name)),
            json.dumps({
                'files': {
                    n: {
                        m.identifier: out_filename(template, n, m)
                        for m in modes
                    } for n in n_range
                },
                'name': template.name,
                'x_axis_label': template.property('x_axis_label'),
                'desc': template.property('desc'),
                'modes': {m.identifier: m.description() for m in modes}
            })
        )
830262
function CompileModules(inputTree, options) {
    if (!(this instanceof CompileModules)) {
        return new CompileModules(inputTree, options);
    }

    options || (options = {});

    var formatter = options.formatter;

    if (!formatter) {
        formatter = transpiler.formatters.DEFAULT;
    }

    if (typeof formatter === 'string') {
        formatter = transpiler.formatters[formatter];
    }

    var resolverClasses = options.resolvers;

    if (!resolverClasses) {
        resolverClasses = [ FileResolver ];
    }

    this.inputTree       = inputTree;
    this.resolverClasses = resolverClasses;
    this.formatter       = formatter;
    this.output          = options.output || '.';
    this.basePath        = options.basePath;
    this.sourceRoot      = options.sourceRoot || '/';
    this.description     = options.description;

    this._cache = {};
}
524447
function _compile(str, filename) {
    var parent = this;
    try {
      var requires = detective(str);
    } catch (ex) {
      ex.toString = function() {
        return filename + ':' + this.loc.line + '\n ' + ex.message;
      }
      throw ex;
    }
    requires.forEach(function(req) {
      if (modules.isRelative(req)) {
        Module._load(req, parent);
      } else {
        if (!modules.isCore(req)) {
          dependencies.push(modules.name(req));
        }
      }
    });
  }
248003
def _process_module(self, name, contents, parent, match, filepath=None):
        """"""
        #First, get hold of the name and contents of the module so that we can process the other
        #parts of the module.
        modifiers = []

        #We need to check for the private keyword before any type or contains declarations
        if self.RE_PRIV.search(contents):
            modifiers.append("private")
        #The only other modifier for modules ought to be implicit none
        if re.search("implicit\s+none", contents):
            modifiers.append("implicit none")

        #Next, parse out the dependencies of the module on other modules
        dependencies = self._parse_use(contents)
        publics, pubstart = self._process_publics(match.string)

        #We can now create the CodeElement
        result = Module(name, modifiers, dependencies, publics, contents, parent)
        if filepath is not None:
            result.filepath = filepath.lower()
        result.start = match.start()
        result.end = match.end()
        result.refstring = match.string
        result.set_public_start(pubstart)
        if self.RE_PRECOMP.search(contents):
            result.precompile = True

        self.xparser.parse(result)
        self.tparser.parse(result)

        #It is possible for the module to have members, parse those
        self._parse_members(contents, result)
        self.iparser.parse(result)

        #Now we can update the docstrings for the types. They rely on data
        #extracted during parse_members() which is why they have to run
        #separately over here.
        for t in result.types:
            self.tparser.update_docs(result.types[t], result)

        return result
1224158
def compile(self, source, path=None):
        

        container = self._generate_code(source)

        def make_module_name(name, suffix=None):
            output = 'pybars._templates.%s' % name
            if suffix:
                output += '_%s' % suffix
            return output

        if not path:
            path = '_template'
            generate_name = True
        else:
            path = path.replace('\\', '/')
            path = path.replace('/', '_')
            mod_name = make_module_name(path)
            generate_name = mod_name in sys.modules

        if generate_name:
            mod_name = make_module_name(path, self.template_counter)
            while mod_name in sys.modules:
                self.template_counter += 1
                mod_name = make_module_name(path, self.template_counter)

        mod = ModuleType(mod_name)
        filename = '%s.py' % mod_name.replace('pybars.', '').replace('.', '/')
        exec(compile(container.full_code, filename, 'exec', dont_inherit=True), mod.__dict__)
        sys.modules[mod_name] = mod
        linecache.getlines(filename, mod.__dict__)

        return mod.__dict__[container.name]
139635
function compileTypescript(module) {
    let project = typescript.createProject("./src/tsconfig.json", {
        module: module,
    });
    return typescriptSource()
        .pipe(project());
}
402527
def compile(source, options = {})
      source  = prepare_source(source)
      options = prepare_options(options)
      snippet = compilation_snippet \
        method:    "compile#{ "Client" if options[:client] }",
        arguments: [source, options],
        locals:    options.fetch(:locals, {}),
        options:   options
      result  = @execjs.eval(snippet)
      process_result(source, result, options)
    rescue ExecJS::ProgramError => e
      raise engine::CompilationError, e.message
    end
1287703
function compilejs(sources, outdir, outfile, opt_options) {
  var bundler = browserify({
    entries: sources,
    debug: false
  });
  return rebundle_(bundler, outdir, outfile, opt_options);
}
911633
def compile_cxxcode(module_name, cxxcode, output_binary=None, keep_temp=False,
                    **kwargs):
    '''

    '''

    # Get a temporary C++ file to compile
    fdpath = _write_temp(cxxcode, '.cpp')
    output_binary = compile_cxxfile(module_name, fdpath,
                                    output_binary, **kwargs)
    if not keep_temp:
        # remove tempfile
        os.remove(fdpath)
    else:
        logger.warn("Keeping temporary generated file:" + fdpath)

    return output_binary
579090
function generateOutput(source) {
    return __awaiter(this, void 0, void 0, function () {
        var isCached, artifact, compiled, artifact, _a;
        return __generator(this, function (_b) {
            switch (_b.label) {
                case 0: return [4 /*yield*/, caching.has(source.codeHash)];
                case 1:
                    isCached = _b.sent();
                    if (!isCached) return [3 /*break*/, 3];
                    return [4 /*yield*/, caching.get(source.codeHash)];
                case 2:
                    artifact = _b.sent();
                    return [2 /*return*/, artifact];
                case 3: return [4 /*yield*/, solc_install_1.installVersion(source.solcVersion)];
                case 4:
                    _b.sent();
                    return [4 /*yield*/, compile_1.default(source)];
                case 5:
                    compiled = _b.sent();
                    _a = {
                        compiled: compiled
                    };
                    return [4 /*yield*/, output_files_1.createJavascriptFile(source, compiled)];
                case 6:
                    _a.javascript = _b.sent();
                    return [4 /*yield*/, output_files_1.createTypescriptFile(source, compiled)];
                case 7:
                    artifact = (_a.typescript = _b.sent(),
                        _a);
                    return [4 /*yield*/, caching.set(source.codeHash, artifact)];
                case 8:
                    _b.sent();
                    return [2 /*return*/, artifact];
            }
        });
    });
}
930951
def compile_to_python(exp, env, done=None): 
  ''''''
  original_exp = exp
  compiler = Compiler()
  if done is None:
    done = il.Done(compiler.new_var(il.ConstLocalVar('v')))
  compiler.exit_block_cont_map = {}
  compiler.continue_block_cont_map = {}
  compiler.protect_cont = done
  if env is None: env = Environment()
  exp = element(exp)
  exp = exp.alpha(env, compiler)
  exp = exp.cps(compiler, done)
  exp.analyse(compiler)
  env = Environment()
  exp = exp.optimize(env, compiler)
  #exp = exp.tail_recursive_convert()
  function = compiler.new_var(il.ConstLocalVar('compiled_dao_function'))
  exp = il.Function(function, (), exp)
  exp = il.begin(*exp.pythonize(env, compiler)[0])
  if isinstance(exp, il.Begin):
    exp = exp.statements[0]
  exp.body = exp.body.replace_return_with_yield()
  compiler = Compiler()
  result = exp.to_code(compiler)
  return prelude + result
1061625
def generate(inputfilename, outputfilename='', dump=0, **flags):
    """"""

    if not outputfilename:
        if inputfilename[-2:] == '.g':
            outputfilename = inputfilename[:-2] + '.py'
        else:
            raise Exception("Missing output filename")

    print 'Input Grammar:', inputfilename
    print 'Output File:', outputfilename

    DIVIDER = '\n%%\n'  # This pattern separates the pre/post parsers
    preparser, postparser = None, None  # Code before and after the parser desc

    # Read the entire file
    s = open(inputfilename, 'r').read()

    # See if there's a separation between the pre-parser and parser
    f = find(s, DIVIDER)
    if f >= 0:
        preparser, s = s[:f] + '\n\n', s[f + len(DIVIDER):]

    # See if there's a separation between the parser and post-parser
    f = find(s, DIVIDER)
    if f >= 0:
        s, postparser = s[:f], '\n\n' + s[f + len(DIVIDER):]

    # Create the parser and scanner
    p = ParserDescription(ParserDescriptionScanner(s))
    if not p:
        return

    # Now parse the file
    t = wrap_error_reporter(p, 'Parser')
    if not t:
        return  # Error
    if preparser is not None:
        t.preparser = preparser
    if postparser is not None:
        t.postparser = postparser

    # Check the options
    for f in t.options.keys():
        for opt, _, _ in yapps_options:
            if f == opt:
                break
        else:
            print 'Warning: unrecognized option', f
    # Add command line options to the set
    for f in flags.keys():
        t.options[f] = flags[f]

    # Generate the output
    if dump:
        t.dump_information()
    else:
        t.output = open(outputfilename, 'w')
        t.generate_output()
152029
def make_source(self, groups, code_opts, gen_opts):
        """"""
        modules = self.make_modules(groups, code_opts)
        var_decls = modules.var_decls
        relocs = AttrsGetter(modules.relocs)
        x86, x64 = relocs.get_attrs('x86', 'x64')
        if code_opts.windll:
            structs, x86_reloc, x64_reloc = make_windll(
                modules.structs
            )
            x86 += x86_reloc
            x64 += x64_reloc
        else:
            structs = ''.join(modules.structs)
        c_relocs = reloc_both(relocs.strings + x86, x64)
        data = var_decls.strip()
        c_header = make_c_header(
            gen_opts.filename, 'NOTICE',
            modules.typedefs + structs + data
        )
        c_source = make_init(
            modules.hashes + c_relocs + modules.libprocs,
            callable(code_opts.hash_func)
        )
        return [c_header, c_source]
496005
def compile(cls, code, path=None, libraries=None,
                contract_name='', extra_args=None):
        
        result = cls._code_or_path(
            code,
            path,
            contract_name,
            libraries,
            'bin',
            extra_args)
        return result['bin']
892012
function generateModule (f) {

      // f.dest must be a string or write will fail
      var moduleNames = [];
      var filePaths = f.src.filter(existsFilter);

      if (options.watch) {
        watcher.add(filePaths);
      }

      var modules = filePaths.map(function (filepath) {

        var moduleName = normalizePath(path.relative(options.base, filepath));
        if (grunt.util.kindOf(options.rename) === 'function') {
          moduleName = options.rename(moduleName);
        }
        moduleNames.push(options.quoteChar + moduleName + options.quoteChar);

        var compiled;

        if (options.watch && (compiled = fileCache[filepath])) {
          // return compiled file contents from cache
          return compiled;
        }

        if (options.target === 'js') {
          compiled = compileTemplate(moduleName, filepath, options);
        } else if (options.target === 'coffee') {
          compiled = compileCoffeeTemplate(moduleName, filepath, options);
        } else {
          grunt.fail.fatal('Unknown target "' + options.target + '" specified');
        }

        if (options.watch) {
          // store compiled file contents in cache
          fileCache[filepath] = compiled;
        }

        return compiled;
      });

      // don't generate empty modules
      if (!modules.length) {
        return;
      }

      counter += modules.length;
      modules = modules.join('\n');

      var fileHeader = options.fileHeaderString !== '' ? options.fileHeaderString + '\n' : '';
      var fileFooter = options.fileFooterString !== '' ? options.fileFooterString + '\n' : '';
      var bundle = '';
      var targetModule = f.module || options.module;
      var indentString = options.indentString;
      var quoteChar = options.quoteChar;
      var strict = (options.useStrict) ? indentString + quoteChar + 'use strict' + quoteChar + ';\n' : '';
      var amdPrefix = '';
      var amdSuffix = '';
      // If options.module is a function, use that to get the targetModule
      if (grunt.util.kindOf(targetModule) === 'function') {
        targetModule = targetModule(f, target);
      }

      if (options.amd) {
        amdPrefix = options.amdPrefixString;
        amdSuffix = options.amdSuffixString;
      }

      if (!targetModule && options.singleModule) {
        throw new Error('When using singleModule: true be sure to specify a (target) module');
      }

      if (options.existingModule && !options.singleModule) {
        throw new Error('When using existingModule: true be sure to set singleModule: true');
      }

      if (options.singleModule) {
        var moduleSuffix = options.existingModule ? '' : ', []';
        if (options.target === 'js') {
          bundle = 'angular.module(' + quoteChar + targetModule + quoteChar + moduleSuffix + ').run([' + quoteChar + '$templateCache' + quoteChar + ', function($templateCache) {\n' + strict;
          modules += '\n}]);\n';
        } else if (options.target === 'coffee') {
          bundle = 'angular.module(' + quoteChar + targetModule + quoteChar + moduleSuffix + ').run([' + quoteChar + '$templateCache' + quoteChar + ', ($templateCache) ->\n';
          modules += '\n])\n';
        }
      } else if (targetModule) {
        //Allow a 'no targetModule if module is null' option
        bundle = 'angular.module(' + quoteChar + targetModule + quoteChar + ', [' + moduleNames.join(', ') + '])';
        if (options.target === 'js') {
          bundle += ';';
        }

        bundle += '\n\n';
      }
      grunt.file.write(f.dest, grunt.util.normalizelf(fileHeader + amdPrefix + bundle + modules + amdSuffix + fileFooter));
    }