# ic/cbackend

Theme:

- Index

Search:
Group by:
Source Edit

New entry point into our C/C++ code generator. Ideally somebody would rewrite the old backend (which is 8000 lines of crufty Nim code) to work on packed trees directly and produce the C code as an AST which can then be rendered to text in a very simple manner. Unfortunately nobody wrote this code. So instead we wrap the existing cgen.nim and its friends so that we call directly into the existing code generation logic but avoiding the naive, outdated `passes` design. Thus you will see some `useAliveDataFromDce in flags` checks in the old code -- the old code is also doing cross-module dependency tracking and DCE that we don't need anymore. DCE is now done as prepass over the entire packed module graph.

# Imports

../ast, ../options, ../lineinfos, ../modulegraphs, ../cgendata, ../cgen, ../pathutils, ../extccomp, ../msgs, ../modulepaths, packed_ast, ic, dce, rodfiles

# Procs

    proc generateCode(g: ModuleGraph) {....raises: [KeyError, ValueError, OSError,
        IOError, Exception, ERecoverableError], tags: [ReadDirEffect, RootEffect,
        ReadEnvEffect, ReadIOEffect, WriteDirEffect, WriteIOEffect, TimeEffect],
                                        forbids: [].}

  The single entry point, generate C(++) code for the entire Nim program aka `ModuleGraph`. Source Edit