Skip to content

Commit

Permalink
Merge branch 'devel' into opensym-switch
Browse files Browse the repository at this point in the history
  • Loading branch information
Araq authored Dec 22, 2023
2 parents 467e02e + df3c95d commit 45004e7
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- target: windows
os: windows-2019
- target: osx
os: macos-11
os: macos-12

name: ${{ matrix.target }}
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
if: |
github.event_name == 'push' && github.ref == 'refs/heads/devel' &&
matrix.target == 'linux'
uses: crazy-max/ghaction-github-pages@v3
uses: crazy-max/ghaction-github-pages@v4
with:
build_dir: doc/html
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
run: nim c -r -d:release ci/action.nim

- name: 'Comment'
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v8
- uses: actions/stale@v9
with:
days-before-pr-stale: 365
days-before-pr-close: 30
Expand Down
38 changes: 37 additions & 1 deletion doc/manual_experimental.md
Original file line number Diff line number Diff line change
Expand Up @@ -2450,7 +2450,7 @@ main()

Will produce:

```c++
```cpp

struct Test {
Foo foo;
Expand Down Expand Up @@ -2559,3 +2559,39 @@ proc baz[T](): string =
return value
assert baz[int]() == "captured"
```
VTable for methods
==================
Methods now support implementations based on a VTable by using `--experimental:vtables`. Note that the option needs to enabled
globally. The virtual method table is stored in the type info of
an object, which is an array of function pointers.
```nim
method foo(x: Base, ...) {.base.}
method foo(x: Derived, ...) {.base.}
```
It roughly generates a dispatcher like
```nim
proc foo_dispatch(x: Base, ...) =
x.typeinfo.vtable[method_index](x, ...) # method_index is the index of the sorted order of a method
```
Methods are required to be in the same module where their type has been defined.
```nim
# types.nim
type
Base* = ref object
```
```nim
import types
method foo(x: Base) {.base.} = discard
```
It gives an error: method `foo` can be defined only in the same module with its type (Base).
9 changes: 6 additions & 3 deletions nimsuggest/nimsuggest.nim
Original file line number Diff line number Diff line change
Expand Up @@ -984,10 +984,10 @@ proc executeNoHooksV3(cmd: IdeCmd, file: AbsoluteFile, dirtyfile: AbsoluteFile,
graph.unmarkAllDirty()

# these commands require partially compiled project
elif cmd in {ideSug, ideOutline, ideHighlight, ideDef, ideChkFile, ideType, ideDeclaration, ideExpand} and
(graph.needsCompilation(fileIndex) or cmd == ideSug):
elif cmd in {ideSug, ideCon, ideOutline, ideHighlight, ideDef, ideChkFile, ideType, ideDeclaration, ideExpand} and
(graph.needsCompilation(fileIndex) or cmd in {ideSug, ideCon}):
# for ideSug use v2 implementation
if cmd == ideSug:
if cmd in {ideSug, ideCon}:
conf.m.trackPos = newLineInfo(fileIndex, line, col)
conf.m.trackPosAttached = false
else:
Expand Down Expand Up @@ -1033,6 +1033,9 @@ proc executeNoHooksV3(cmd: IdeCmd, file: AbsoluteFile, dirtyfile: AbsoluteFile,
# ideSug performs partial build of the file, thus mark it dirty for the
# future calls.
graph.markDirtyIfNeeded(file.string, fileIndex)
of ideCon:
graph.markDirty fileIndex
graph.markClientsDirty fileIndex
of ideOutline:
let n = parseFile(fileIndex, graph.cache, graph.config)
graph.iterateOutlineNodes(n, graph.fileSymbols(fileIndex).deduplicateSymInfoPair)
Expand Down
13 changes: 13 additions & 0 deletions nimsuggest/tests/tv3_con.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# tests v3

proc test(a: string, b:string) = discard
proc test(a: int) = discard

test(#[!]#

discard """
$nimsuggest --v3 --tester $file
>con $1
con;;skProc;;tv3_con.test;;proc (a: string, b: string);;$file;;3;;5;;"";;100
con;;skProc;;tv3_con.test;;proc (a: int);;$file;;4;;5;;"";;100
"""

0 comments on commit 45004e7

Please sign in to comment.