Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort compiler files into more manageable structure #177

Merged
merged 1 commit into from
Jan 21, 2022

Conversation

haxscramper
Copy link
Collaborator

@haxscramper haxscramper commented Jan 19, 2022

Organized compiler source code into smaller sections - if we plan to untangle implementation parts from each other, we can start small, with simple file organization and later continue to remove unnecessary cross-directory imports and so on.

current moved files:

 { => ast}/ast.nim 
 { => ast}/ast_types.nim 
 { => ast}/astalgo.nim 
 { => ast}/astmsgs.nim 
 { => ast}/enumtostr.nim 
 { => ast}/errorhandling.nim 
 { => ast}/errorreporting.nim 
 { => ast}/layouter.nim 
 { => ast}/lexer.nim 
 { => ast}/lineinfos.nim 
 { => ast}/linter.nim 
 { => ast}/llstream.nim 
 { => ast}/ndi.nim 
 { => ast}/nimlexbase.nim 
 { => ast}/nimsets.nim 
 { => ast}/parser.nim 
 { => ast}/renderer.nim 
 { => ast}/reports.nim 
 { => ast}/syntaxes.nim 
 { => ast}/trees.nim 
 { => ast}/treetab.nim 
 { => ast}/types.nim 
 { => ast}/typesrenderer.nim 
 { => ast}/wordrecg.nim 
 { => backend}/ccgcalls.nim 
 { => backend}/ccgexprs.nim 
 { => backend}/ccgliterals.nim 
 { => backend}/ccgmerge_unused.nim 
 { => backend}/ccgreset.nim 
 { => backend}/ccgstmts.nim 
 { => backend}/ccgthreadvars.nim 
 { => backend}/ccgtrav.nim 
 { => backend}/ccgtypes.nim 
 { => backend}/ccgutils.nim 
 { => backend}/cgen.nim 
 { => backend}/cgendata.nim 
 { => backend}/cgmeth.nim 
 { => backend}/extccomp.nim (99%)
 { => backend}/jsgen.nim 
 { => backend}/jstypes.nim 
 { => backend}/tccgen.nim 
 { => font}/cli_reporter.nim 
 { => font}/cmdlinehelper.nim 
 { => font}/commands.nim 
 { => font}/condsyms.nim 
 { => font}/main.nim 
 { => font}/msgs.nim 
 { => font}/nimconf.nim 
 { => font}/options.nim 
 { => font}/scriptconfig.nim 
 { => modules}/depends.nim 
 { => modules}/importer.nim 
 { => modules}/magicsys.nim 
 { => modules}/modulegraphs.nim 
 { => modules}/modulepaths.nim 
 { => modules}/modules.nim 
 { => modules}/nimblecmd.nim 
 { => modules}/nimpaths.nim 
 { => modules}/packagehandling.nim 
 { => sem}/aliases.nim 
 { => sem}/closureiters.nim 
 { => sem}/concepts.nim 
 { => sem}/debuginfo.nim 
 { => sem}/dfa.nim 
 { => sem}/evaltempl.nim 
 { => sem}/filter_tmpl.nim 
 { => sem}/filters.nim 
 { => sem}/guards.nim 
 { => sem}/hlo.nim 
 { => sem}/idents.nim 
 { => sem}/index.nim 
 { => sem}/injectdestructors.nim 
 { => sem}/installer.ini 
 { => sem}/isolation_check.nim 
 { => sem}/lambdalifting.nim 
 { => sem}/liftdestructors.nim 
 { => sem}/liftlocals.nim 
 { => sem}/lookups.nim 
 { => sem}/lowerings.nim 
 { => sem}/nilcheck.nim 
 { => sem}/nilcheck_enums.nim 
 { => sem}/optimizer.nim 
 { => sem}/parampatterns.nim 
 { => sem}/passaux.nim 
 { => sem}/passes.nim 
 { => sem}/patterns.nim 
 { => sem}/pragmas.nim 
 { => sem}/procfind.nim 
 { => sem}/renderverbatim.nim 
 { => sem}/reorder.nim 
 { => sem}/rodutils.nim 
 { => sem}/sem.nim 
 { => sem}/semcall.nim 
 { => sem}/semdata.nim 
 { => sem}/semexprs.nim 
 { => sem}/semfields.nim 
 { => sem}/semfold.nim 
 { => sem}/semgnrc.nim 
 { => sem}/seminst.nim 
 { => sem}/semmacrosanity.nim 
 { => sem}/semmagic.nim 
 { => sem}/semobjconstr.nim 
 { => sem}/semparallel.nim 
 { => sem}/sempass2.nim 
 { => sem}/semstmts.nim 
 { => sem}/semtempl.nim 
 { => sem}/semtypes.nim 
 { => sem}/semtypinst.nim 
 { => sem}/sighashes.nim 
 { => sem}/sigmatch.nim 
 { => sem}/sinkparameter_inference.nim 
 { => sem}/sizealignoffsetimpl.nim 
 { => sem}/sourcemap.nim 
 { => sem}/spawn.nim 
 { => sem}/transf.nim 
 { => sem}/typeallowed.nim 
 { => sem}/varpartitions.nim 
 { => tools}/docgen.nim 
 { => tools}/docgen2.nim 
 { => tools}/suggest.nim 
 { => utils}/bitsets.nim 
 { => utils}/btrees.nim 
 { => utils}/debugutils.nim 
 { => utils}/int128.nim 
 { => utils}/nodejs.nim 
 { => utils}/nversion.nim 
 { => utils}/pathutils.nim 
 { => utils}/platform.nim 
 { => utils}/pluginsupport.nim 
 { => utils}/prefixmatches.nim 
 { => utils}/ropes.nim 
 { => utils}/saturate.nim 
 { => utils}/strutils2.nim 
 { => vm}/evalffi.nim 
 { => vm}/gorgeimpl.nim 
 { => vm}/macrocacheimpl.nim 
 { => vm}/nimeval.nim 
 { => vm}/vm.nim 
 { => vm}/vm_enums.nim 
 { => vm}/vmconv.nim 
 { => vm}/vmdef.nim 
 { => vm}/vmdeps.nim 
 { => vm}/vmgen.nim 
 { => vm}/vmhooks.nim 
 { => vm}/vmops.nim 
 { => vm}/vmprofiler.nim 

directory structure


├── ast
│   ├── astalgo.nim
│   ├── astmsgs.nim
│   ├── ast.nim
│   ├── ast_types.nim
│   ├── enumtostr.nim
│   ├── errorhandling.nim
│   ├── errorreporting.nim
│   ├── layouter.nim
│   ├── lexer.nim
│   ├── lineinfos.nim
│   ├── linter.nim
│   ├── llstream.nim
│   ├── ndi.nim
│   ├── nimlexbase.nim
│   ├── nimsets.nim
│   ├── parser.nim
│   ├── renderer.nim
│   ├── reports.nim
│   ├── syntaxes.nim
│   ├── trees.nim
│   ├── treetab.nim
│   ├── types.nim
│   ├── typesrenderer.nim
│   └── wordrecg.nim
├── backend
│   ├── ccgcalls.nim
│   ├── ccgexprs.nim
│   ├── ccgliterals.nim
│   ├── ccgmerge_unused.nim
│   ├── ccgreset.nim
│   ├── ccgstmts.nim
│   ├── ccgthreadvars.nim
│   ├── ccgtrav.nim
│   ├── ccgtypes.nim
│   ├── ccgutils.nim
│   ├── cgendata.nim
│   ├── cgen.nim
│   ├── cgmeth.nim
│   ├── extccomp.nim
│   ├── jsgen.nim
│   ├── jstypes.nim
│   └── tccgen.nim
├── font
│   ├── cli_reporter.nim
│   ├── cmdlinehelper.nim
│   ├── commands.nim
│   ├── condsyms.nim
│   ├── main.nim
│   ├── msgs.nim
│   ├── nimconf.nim
│   ├── options.nim
│   └── scriptconfig.nim
├── htmldocs
│   ├── ast_types.html
│   └── nimdoc.out.css
├── ic
│   ├── bitabs.nim
│   ├── cbackend.nim
│   ├── dce.nim
│   ├── design.rst
│   ├── ic
│   ├── ic.nim
│   ├── integrity.nim
│   ├── navigator.nim
│   ├── packed_ast.nim
│   ├── replayer.nim
│   └── rodfiles.nim
├── modules
│   ├── depends.nim
│   ├── importer.nim
│   ├── magicsys.nim
│   ├── modulegraphs.nim
│   ├── modulepaths.nim
│   ├── modules.nim
│   ├── nimblecmd.nim
│   ├── nimpaths.nim
│   └── packagehandling.nim
├── nim.cfg
├── nimfix
│   ├── nimfix.nim
│   ├── nimfix.nim.cfg
│   └── prettybase.nim
├── nim.nim
├── plugins
│   ├── active.nim
│   ├── itersgen.nim
│   └── locals.nim
├── readme.md
├── sem
│   ├── aliases.nim
│   ├── closureiters.nim
│   ├── concepts.nim
│   ├── debuginfo.nim
│   ├── dfa.nim
│   ├── evaltempl.nim
│   ├── filters.nim
│   ├── filter_tmpl.nim
│   ├── guards.nim
│   ├── hlo.nim
│   ├── idents.nim
│   ├── index.nim
│   ├── injectdestructors.nim
│   ├── installer.ini
│   ├── isolation_check.nim
│   ├── lambdalifting.nim
│   ├── liftdestructors.nim
│   ├── liftlocals.nim
│   ├── lookups.nim
│   ├── lowerings.nim
│   ├── nilcheck_enums.nim
│   ├── nilcheck.nim
│   ├── optimizer.nim
│   ├── parampatterns.nim
│   ├── passaux.nim
│   ├── passes.nim
│   ├── patterns.nim
│   ├── pragmas.nim
│   ├── procfind.nim
│   ├── renderverbatim.nim
│   ├── reorder.nim
│   ├── rodutils.nim
│   ├── semcall.nim
│   ├── semdata.nim
│   ├── semexprs.nim
│   ├── semfields.nim
│   ├── semfold.nim
│   ├── semgnrc.nim
│   ├── seminst.nim
│   ├── semmacrosanity.nim
│   ├── semmagic.nim
│   ├── sem.nim
│   ├── semobjconstr.nim
│   ├── semparallel.nim
│   ├── sempass2.nim
│   ├── semstmts.nim
│   ├── semtempl.nim
│   ├── semtypes.nim
│   ├── semtypinst.nim
│   ├── sighashes.nim
│   ├── sigmatch.nim
│   ├── sinkparameter_inference.nim
│   ├── sizealignoffsetimpl.nim
│   ├── sourcemap.nim
│   ├── spawn.nim
│   ├── transf.nim
│   ├── typeallowed.nim
│   └── varpartitions.nim
├── tools
│   ├── docgen2.nim
│   ├── docgen.nim
│   └── suggest.nim
├── utils
│   ├── bitsets.nim
│   ├── btrees.nim
│   ├── debugutils.nim
│   ├── int128.nim
│   ├── nodejs.nim
│   ├── nversion.nim
│   ├── pathutils.nim
│   ├── platform.nim
│   ├── pluginsupport.nim
│   ├── prefixmatches.nim
│   ├── ropes.nim
│   ├── saturate.nim
│   └── strutils2.nim
└── vm
    ├── evalffi.nim
    ├── gorgeimpl.nim
    ├── macrocacheimpl.nim
    ├── nimeval.nim
    ├── vmconv.nim
    ├── vmdef.nim
    ├── vmdeps.nim
    ├── vm_enums.nim
    ├── vmgen.nim
    ├── vmhooks.nim
    ├── vm.nim
    ├── vmops.nim
    └── vmprofiler.nim

for now this is just a placeholder, so comment on the file movements, and general directory structure, and when we are ok with this, I will do a full compiler import fix.

@canelhasmateus
Copy link
Contributor

god's work.

@haxscramper haxscramper force-pushed the file-shuffle branch 4 times, most recently from 6d9bcb5 to 299cd8b Compare January 19, 2022 21:04
@haxscramper
Copy link
Collaborator Author

Also sorting out all stdlib imports into compiler and making them use std/ prefix while I'm at it

Copy link
Collaborator

@saem saem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did an initial scan mostly ok, but one thing is nagging me:

If we have imports like compiler/foothen that implies we could just as easily end up with testament/bar as an import. At least right now we'd spot the .. and know it's broken more easily than a myriad of directories one might import.

I don't think we should start from the root instead we should be within the compiler and std is just nim itself bringing in the standard library. Hell I'd argue that we should disable relative import by default and people should have to enable it as a special case -- separate PR.

export int128
compiler/ast/[
lineinfos, # Positional information
idents, # Ast identifiers
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I fell really compelled to be nitpicky here -- just because it's going to end up everywhere.

Can we align the comments so all the starting # line up in instance where we gave lists like this?

@haxscramper haxscramper force-pushed the file-shuffle branch 2 times, most recently from 5310cc2 to 8e6087b Compare January 20, 2022 15:10
@haxscramper
Copy link
Collaborator Author

About vertical spacing:

  1. They allow for trailing comments without reformatting
  2. If new import is added it is easy to spot
  3. If merge conflict happens it is very localized wrt. to imports, and not this kind of thing:
<<<<<<< HEAD:compiler/cli_reporter.nim
import reports,
       ast,
       types,
       renderer,
       astmsgs,
       astalgo,
       msgs,
       lineinfos,
       nilcheck_enums,
       vm_enums,
       platform,
       nversion

import options as compiler_options
import std/[
  strutils, terminal, options, algorithm,
  sequtils, strformat, tables, intsets,
  json
]
=======
import
  std/[
    strutils,
    terminal,
    options,
    algorithm,
    sequtils,
    strformat,
    tables,
    intsets,
    json
  ],
  ast/[
    lineinfos,
    astalgo,
    astmsgs,
    renderer,
    types,
    ast,
    reports
  ],
  front/[
    msgs
  ],
  sem/[
    nilcheck_enums
  ],
  vm/[
    vm_enums
  ]
>>>>>>> 8e6087ba9 (.):compiler/front/cli_reporter.nim

@haxscramper haxscramper force-pushed the file-shuffle branch 8 times, most recently from 16942b1 to 9c33e2a Compare January 20, 2022 17:45
@haxscramper
Copy link
Collaborator Author

bors try

bors bot added a commit that referenced this pull request Jan 20, 2022
@bors
Copy link
Contributor

bors bot commented Jan 20, 2022

try

Build failed:

Organized compiler source code into smaller sections - if
we plan to untangle implementation parts from each other,
we can start small, with simple file organization and later
continue to remove unnecessary cross-directory imports and so on.
@haxscramper
Copy link
Collaborator Author

bors try

bors bot added a commit that referenced this pull request Jan 20, 2022
@bors
Copy link
Contributor

bors bot commented Jan 20, 2022

try

Build succeeded:

@haxscramper
Copy link
Collaborator Author

Can be merged, and since this will bitrot really quickly (due to modification of all imports) better done soon.

@saem
Copy link
Collaborator

saem commented Jan 21, 2022

Bors r+

@bors
Copy link
Contributor

bors bot commented Jan 21, 2022

Build succeeded:

@bors bors bot merged commit a03c3e4 into nim-works:devel Jan 21, 2022
haxscramper added a commit to haxscramper/nimskull that referenced this pull request Jan 27, 2022
- Removes main drnim directory along with all the hacks added into `sem*`
  implementation - special keywords for
  `ensures/requires/assume/invariant`, more logic built into sempass and so
  on. Sem reports that were added in the main compilation.
- External tooling for code analysis should better be implemented via
  completely external modifications, instead of clobbering the main
  compiler codebase with logic for barely functioning tooling. With dod
  refactor this task becomes much easier, since extra metada can be
  attached to any symbol.
- We definitely want to move in the direction of automatic code correctness
  and static analysis, but right now this is not a priority, and
  considering dubious implementation of the tool it would be easier to
  remove it for now and come up with a proper implementation later on, or
  wen can turn all hacks back into sem.
- Not testsed as a part of CI so right now it can't even be built, due to
  file reorganization nim-works#177.
- Adds reports for `--staticBounds:on|off` that were mistakenly assumed to
  be drnim-only during earlier refactor
  nim-works#94 for structured reports.

Closes nim-works#130 as this pull removes
`drnim` as well, and the author of that PR is no longer responsive. Due to
multiple merge conflicts it is highly unlikely the old PR will be revived.
@haxscramper haxscramper mentioned this pull request Jan 27, 2022
haxscramper added a commit to haxscramper/nimskull that referenced this pull request Jan 27, 2022
- Removes main drnim directory along with all the hacks added into `sem*`
  implementation - special keywords for
  `ensures/requires/assume/invariant`, more logic built into sempass and so
  on. Sem reports that were added in the main compilation.
- External tooling for code analysis should better be implemented via
  completely external modifications, instead of clobbering the main
  compiler codebase with logic for barely functioning tooling. With DOD
  refactor this task becomes much easier, since extra metadata can be
  attached to any symbol.
- We definitely want to move in the direction of automatic code correctness
  and static analysis, but right now this is not a priority, and
  considering dubious implementation of the tool, it would be easier to
  remove it for now and come up with a proper implementation later on, or
  when can turn all hacks back into sem.
- drnim itself not tested as a part of CI so right now it can't even be
  built, due to file reorganization
  nim-works#177.
- Adds reports for `--staticBounds:on|off` that were mistakenly assumed to
  be drnim-only during earlier refactor
  nim-works#94 for structured reports.

Closes nim-works#130 as this pull removes
`drnim` as well, and the author of that PR is no longer responsive. Due to
multiple merge conflicts it is highly unlikely the old PR will be revived.
haxscramper added a commit to haxscramper/nimskull that referenced this pull request Jan 27, 2022
- Removes main drnim directory along with all the hacks added into `sem*`
  implementation - special keywords for
  `ensures/requires/assume/invariant`, more logic built into sempass and so
  on. Sem reports that were added in the main compilation.
- External tooling for code analysis should better be implemented via
  completely external modifications, instead of clobbering the main
  compiler codebase with logic for barely functioning tooling. With DOD
  refactor this task becomes much easier, since extra metadata can be
  attached to any symbol.
- We definitely want to move in the direction of automatic code correctness
  and static analysis, but right now this is not a priority, and
  considering dubious implementation of the tool, it would be easier to
  remove it for now and come up with a proper implementation later on, or
  when can turn all hacks back into sem.
- drnim itself not tested as a part of CI so right now it can't even be
  built, due to file reorganization
  nim-works#177.
- Adds reports for `--staticBounds:on|off` that were mistakenly assumed to
  be drnim-only during earlier refactor
  nim-works#94 for structured reports.

Closes nim-works#130 as this pull removes
`drnim` as well, and the author of that PR is no longer responsive. Due to
multiple merge conflicts it is highly unlikely the old PR will be revived.
haxscramper added a commit to haxscramper/nimskull that referenced this pull request Jan 27, 2022
- Removes main drnim directory along with all the hacks added into `sem*`
  implementation - special keywords for
  `ensures/requires/assume/invariant`, more logic built into sempass and so
  on. Sem reports that were added in the main compilation.
- External tooling for code analysis should better be implemented via
  completely external modifications, instead of clobbering the main
  compiler codebase with logic for barely functioning tooling. With DOD
  refactor this task becomes much easier, since extra metadata can be
  attached to any symbol.
- We definitely want to move in the direction of automatic code correctness
  and static analysis, but right now this is not a priority, and
  considering dubious implementation of the tool, it would be easier to
  remove it for now and come up with a proper implementation later on, or
  when can turn all hacks back into sem.
- drnim itself not tested as a part of CI so right now it can't even be
  built, due to file reorganization
  nim-works#177.
- Adds reports for `--staticBounds:on|off` that were mistakenly assumed to
  be drnim-only during earlier refactor
  nim-works#94 for structured reports.

Closes nim-works#130 as this pull removes
`drnim` as well, and the author of that PR is no longer responsive. Due to
multiple merge conflicts it is highly unlikely the old PR will be revived.
haxscramper added a commit to haxscramper/nimskull that referenced this pull request Jan 27, 2022
- Removes main drnim directory along with all the hacks added into `sem*`
  implementation - special keywords for
  `ensures/requires/assume/invariant`, more logic built into sempass and so
  on. Sem reports that were added in the main compilation.
- External tooling for code analysis should better be implemented via
  completely external modifications, instead of clobbering the main
  compiler codebase with logic for barely functioning tooling. With DOD
  refactor this task becomes much easier, since extra metadata can be
  attached to any symbol.
- We definitely want to move in the direction of automatic code correctness
  and static analysis, but right now this is not a priority, and
  considering dubious implementation of the tool, it would be easier to
  remove it for now and come up with a proper implementation later on, or
  when can turn all hacks back into sem.
- drnim itself not tested as a part of CI so right now it can't even be
  built, due to file reorganization
  nim-works#177.
- Adds reports for `--staticBounds:on|off` that were mistakenly assumed to
  be drnim-only during earlier refactor
  nim-works#94 for structured reports.

Closes nim-works#130 as this pull removes
`drnim` as well, and the author of that PR is no longer responsive. Due to
multiple merge conflicts it is highly unlikely the old PR will be revived.
haxscramper added a commit to haxscramper/nimskull that referenced this pull request Jan 27, 2022
- Removes main drnim directory along with all the hacks added into `sem*`
  implementation - special keywords for
  `ensures/requires/assume/invariant`, more logic built into sempass and so
  on. Sem reports that were added in the main compilation.
- External tooling for code analysis should better be implemented via
  completely external modifications, instead of clobbering the main
  compiler codebase with logic for barely functioning tooling. With DOD
  refactor this task becomes much easier, since extra metadata can be
  attached to any symbol.
- We definitely want to move in the direction of automatic code correctness
  and static analysis, but right now this is not a priority, and
  considering dubious implementation of the tool, it would be easier to
  remove it for now and come up with a proper implementation later on, or
  when can turn all hacks back into sem.
- drnim itself not tested as a part of CI so right now it can't even be
  built, due to file reorganization
  nim-works#177.
- Adds reports for `--staticBounds:on|off` that were mistakenly assumed to
  be drnim-only during earlier refactor
  nim-works#94 for structured reports.

Closes nim-works#130 as this pull removes
`drnim` as well, and the author of that PR is no longer responsive. Due to
multiple merge conflicts it is highly unlikely the old PR will be revived.
bors bot added a commit that referenced this pull request Jan 28, 2022
207: Unbundle drnim r=saem a=haxscramper

- Removes main drnim directory along with all the hacks added into `sem*`
  implementation - special keywords for
  `ensures/requires/assume/invariant`, more logic built into sempass and so
  on. Sem reports that were added in the main compilation.
- External tooling for code analysis should better be implemented via
  completely external modifications, instead of clobbering the main
  compiler codebase with logic for barely functioning tooling. With DOD
  refactor this task becomes much easier, since extra metadata can be
  attached to any symbol.
- We definitely want to move in the direction of automatic code correctness
  and static analysis, but right now this is not a priority, and
  considering dubious implementation of the tool, it would be easier to
  remove it for now and come up with a proper implementation later on, or
  when can turn all hacks back into sem.
- drnim itself Not tested as a part of CI so right now it can't even be built, due to
  file reorganization #177.
- Adds reports for `--staticBounds:on|off` that were mistakenly assumed to
  be drnim-only during earlier refactor
  #94 for structured reports.

Closes #130 as this pull removes
`drnim` as well, and the author of that PR is no longer responsive. Due to
multiple merge conflicts it is highly unlikely the old PR will be revived.



Co-authored-by: haxscramper <haxscramper@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants