Commit Graph

70 Commits

Author SHA1 Message Date
ringabout
39f2df1972 fixes #23295; don't expand constants for complex structures (#23297)
fixes #23295
2024-02-20 07:31:58 +01:00
Andreas Rumpf
db603237c6 Types: Refactorings; step 1 (#23055) 2023-12-12 16:54:50 +01:00
Andreas Rumpf
8990626ca9 NIR: progress (#22817)
Done:

- [x] Implement conversions to openArray/varargs.
- [x] Implement index/range checking.
2023-10-12 23:33:38 +02:00
Andreas Rumpf
816589b667 NIR: Nim intermediate representation (#22777)
Theoretical Benefits / Plans: 

- Typed assembler-like language.
- Allows for a CPS transformation.
- Can replace the existing C backend by a new C backend.
- Can replace the VM.
- Can do more effective "not nil" checking and static array bounds
checking.
- Can be used instead of the DFA.
- Easily translatable to LLVM.
- Reasonably easy to produce native code from.
- Tiny memory consumption. No pointers, no cry.

**In very early stages of development.**

Todo:
- [x] Map Nim types to IR types.
- [ ] Map Nim AST to IR instructions:
  - [x] Map bitsets to bitops.
  - [ ] Implement string cases.
  - [ ] Implement range and index checks.
  - [x] Implement `default(T)` builtin.
  - [x] Implement multi string concat.
- [ ] Write some analysis passes.
- [ ] Write a backend.
- [x] Integrate into the compilation pipeline.
2023-10-11 17:44:14 +02:00
metagn
602f537eb2 allow non-pragma special words as user pragmas (#22526)
allow non-pragma special words as macro pragmas

fixes #22525
2023-08-21 20:08:57 +02:00
ringabout
93ced31353 use strictdefs for compiler (#22365)
* wip; use strictdefs for compiler

* checkpoint

* complete the chores

* more fixes

* first phase cleanup

* Update compiler/bitsets.nim

* cleanup
2023-08-06 14:26:21 +02:00
metagn
1dedad5620 make runnableExamples a special word (#22024)
* make runnableExamples a special word

* fix imports
2023-06-06 23:31:55 +02:00
Andreas Rumpf
2e4b6b94e6 Revert "fix #16185 (#16195)" (#16197)
This reverts commit bb4b27a2ca.
2020-11-30 23:36:38 +01:00
cooldome
bb4b27a2ca fix #16185 (#16195)
* fix #16185

* fix test

* fix comment

* fix comment

* better approach
2020-11-30 18:45:37 +01:00
Andreas Rumpf
d306a04466 fixes #16069; [backport:1.2] [backport:1.4] (#16115)
* fixes #16069; refs https://github.com/nim-lang/RFCs/issues/257 [backport:1.2] [backport:1.4]

* make tests green again
2020-11-24 16:09:00 +01:00
Andreas Rumpf
92163fa330 implements https://github.com/nim-lang/RFCs/issues/258 (#15503)
* implements https://github.com/nim-lang/RFCs/issues/258

* don't be too strict with custom pragma blocks

* cast pragmas: documentation

* added most missing inference query procs to effecttraits.nim
2020-10-06 16:47:15 +02:00
Andreas Rumpf
2288188fe9 fixes https://github.com/nim-lang/RFCs/issues/257 [backport:1.2] (#15479) 2020-10-03 17:34:42 +02:00
Andreas Rumpf
9828392df3 implements https://github.com/nim-lang/RFCs/issues/257 (#15466) 2020-10-02 18:53:22 +02:00
Andreas Rumpf
ab405c936e views: yet another bugfix (#15447)
* views: yet another bugfix

* views: extended the spec

* views: take into account potential hidden mutations via proc calls
2020-10-01 15:04:36 +02:00
Andreas Rumpf
10988d4840 borrow checking (#15282)
* refactoring: move procs to typeallowed.nim
* frontend preparations for first class openArray support
* prepare the code generator for first class openArray
* code generation for first class openArray; WIP
* code generation for open arrays, progress
* added isViewType proc
* preparations for borrow checking
* added borrow checking to the front end
2020-09-09 07:32:03 +02:00
Andreas Rumpf
3a2697dd73 drnim: tiny progress (#13882)
* drnim: tiny progress
* refactoring complete
* drnim: prove .ensures annotations
* Moved code around to avoid code duplication
* drnim: first implementation of the 'old' property
* drnim: be precise about the assignment statement
* first implementation of --assumeUnique
* progress on forall/exists handling
2020-04-15 20:03:25 +02:00
Andreas Rumpf
9ffec79300 DrNim (Nim compiler with Z3 integration) (#13743)
* code cleanups and feature additions
* added basic test and koch/CI integration
* make it build on Unix
* DrNim: now buildable on Unix, only takes 10 minutes, enjoy
* added basic documentation for DrNim which can also be seen as the RFC we're following
* drnim: change the build setup so that drnim.exe ends up in bin/
* makes simple floating point ranges work
* added basic float range check
* drnim: teach Z3 about Nim's range types plus code refactoring
* drnim: make unsigned numbers work
* added and fixed index checking under setLen
* first implementation of .ensures, .invariant and .assume (.requires still missing and so is proc type compatibility checking
* drnim: .requires checking implemented
* drnim: implemented .ensures properly
* more impressive test involving min()
* drnim: check for proc type compatibility and base method compatibility wrt .requires and .ensures
* testament: support for 'pattern <directory>
* koch: uses new <directory> feature of testament
* drnim: added tiny musings about 'old'
* Make testament work with old SSL versions
* koch: add support for 'koch drnim -d:release'
* drnim: preparations for the param.old notation
2020-03-31 22:54:48 +02:00
Timothee Cour
cfa1a827dc fix #13730 (#13787) 2020-03-28 08:51:16 +01:00
Araq
bcccb74429 trees.nim: compare floating points by their bitpatterns because NaN comparisions are always false (WORST design in the history of computing!) 2020-03-23 12:06:33 +01:00
Araq
28a755dc80 trees.nim: compare floating points by their bitpatterns because NaN comparisions are always false (WORST design in the history of computing!) 2020-03-23 12:05:59 +01:00
Andreas Rumpf
3f29911a94 new feature: --staticBoundChecks:on to enforce static array index checking (#10965) 2020-03-18 14:25:10 +01:00
Andreas Rumpf
0e7338d65c better support for PROGMEM like annotations for lets/vars; fixes #12216 (#12799) 2019-12-05 13:45:16 +01:00
Clyybber
7e747d11c6 Cosmetic compiler cleanup (#12718)
* Cleanup compiler code base

* Unify add calls

* Unify len invocations

* Unify range operators

* Fix oversight

* Remove {.procvar.} pragma

* initCandidate -> newCandidate where reasonable

* Unify safeLen calls
2019-11-28 17:13:04 +01:00
Clyybber
ed1d41c51e Small ast.nim cleanup (#12156)
* Remove sonsLen
* Use Indexable
2019-09-09 11:54:15 +02:00
Araq
07d465ca42 [refactoring] remove unused imports in the compiler and in some stdlib modules 2019-07-18 00:36:03 +02:00
LemonBoy
7d217a71d3 Render deprecated pragmas (#8886)
* Render deprecated pragmas
* fix the expected html
* clean up the documentation regarding deprecations
* fix typo
* fix system.nim
* fix random
2019-06-03 10:15:20 +02:00
Clyybber
f18b3af9d4 Replace countup(x, y-1) with x ..< y 2019-05-07 12:32:05 +02:00
Andreas Rumpf
e1515b53d1 introduce temporary <//> for 'owned' to get this compile with 0.19 (#11145)
* introduce temporary <//> for 'owned' to get this compile with 0.19
* make newTable[string, owned Node]() compile (but it crashes)
* make sink/owned parameters consistent
* make actiontable test compile again
* VM: support sytem.move; makes tests green
2019-05-02 08:07:09 +02:00
Andreas Rumpf
bf592c4e94 more destructor based changes (#10885)
* mark user defined destructors with sfOverriden to simplify the logic
* refactoring in preparation to merge liftings and generic instantiations for destructors
* ast: introduce nkHiddenTryStmt for destructor generation in order to be able to optimize better the code later on
* renamed 'patterns' switch to 'trmacros' as it was totally misleading before
* destructors: introduce tfCheckedForDestructor flag in preparation of strict =destroy checking
* test for invalid/too late destructor introductions
* liftdestructors: make code robust for nimsuggest
* --newruntime works for hello world again
* newruntime: code generation for closures
2019-03-23 00:12:05 +01:00
Jacek Sieka
db51eb3e32 allow uints to appear in deep constant expressions 2018-12-05 20:33:49 -06:00
Andreas Rumpf
47335aab41 introduce nkTupleConstr AST node for unary tuple construction; breaking change 2018-04-13 17:45:58 +02:00
Andreas Rumpf
212457f5e0 the .deprecated pragma for procs now supports a user-definable deprecation message 2018-02-02 12:53:38 +01:00
Andreas Rumpf
e4081a7201 preparations for language extensions: 'sink' and 'lent' types 2018-01-07 23:09:26 +01:00
Andreas Rumpf
70ea45cdba deprecated unary '<' 2017-10-29 08:37:13 +01:00
Zahary Karadjov
cd02561368 introduce a pre-processing pass for the concept bodies
fixes #4982
fixes #3805

close #3414
2017-06-20 11:29:42 +02:00
Arne Döring
eb8e267ff6 improved comment satement support in macros (#5904) 2017-06-02 01:22:21 +02:00
Andreas Rumpf
962d03d671 isDeepConstExpr helper can handle nkRange 2017-05-01 09:31:29 +02:00
Araq
bdd9f971e7 update code from a time when unsigned didn't exist 2017-02-16 23:20:01 +01:00
Araq
9534a5d632 fixes #5391 2017-02-16 22:59:07 +01:00
Araq
e6c5622aa7 removed tyArrayConstr completely from the compiler; introduced tyAlias instead in preparation for further bugfixes 2016-11-14 23:18:30 +01:00
Araq
773d17cd14 big refactoring: step 1 2016-10-31 15:34:44 +01:00
Matthew Baulch
defc7bbded Cleanup and fix isConstExpr to return true for all atomic node types. 2016-08-27 21:09:05 +10:00
Matthew Baulch
c23a3e1f84 Remove unnecessary result initialisations. 2016-08-27 20:07:10 +10:00
Matthew Baulch
ef0d1561d4 Remove useless/misleading comment. flattenStmts not only for patterns. 2016-08-27 19:59:40 +10:00
Matthew Baulch
e1a5732838 Remove unused procs getProcSym, getOpSym. 2016-08-27 19:40:48 +10:00
Matthew Baulch
5e0a062a90 Remove (unused) flattenTree proc. 2016-08-27 19:38:23 +10:00
Matthew Baulch
701109e8c1 Remove (unused) swapOperands proc. 2016-08-27 19:05:26 +10:00
Matthew Baulch
8f86e0f86b Rewrite cyclicTree. Performance improved by approx 50%. 2016-08-27 19:01:59 +10:00
Andreas Rumpf
baeec11808 fixes #4354 2016-08-04 23:34:58 +02:00
Araq
47dce26886 fixes #2985 2015-06-25 11:42:27 +02:00