Skip to content

Instantly share code, notes, and snippets.

type
VTable = object
methodA: proc (this: MyObject; a, b: int)
methodB: proc (this: MyObject; a, b: string)
OtherObject = object
fieldA: int
fieldB: int
MyObject = object
vtab {.delegate(this).}: ptr VTable
const CacheLineSize = 32 # true for most archs
type
Barrier = object
entered: int
cv: Semaphore # Semaphore takes 3 words at least
when sizeof(int) < 8:
cacheAlign: array[CacheLineSize-4*sizeof(int), byte]
left: int
cacheAlign2: array[CacheLineSize-sizeof(int), byte]
template ov1(a: int; b: untyped; s1: untyped) =
let b = 10
if a != 0:
s1
template ov1(a: int; b: untyped; s1, s2: untyped) =
let b = 11
if a != 0:
s1
else:
REM - Run the full testsuite; tests\testament\tester all
REM - Uncomment the list of changes in news.txt
REM - write a news ticker entry
REM - Update the version
REM - Generate the full docs; koch web0
REM - Generate the installers;
REM - Update the version in system.nim
REM - Test the installers
import re
{.experimental.}
{.this: it.}
using
it: string
proc say(it) = system.echo it
proc test(it) =
Traceback (most recent call last)
storebug.nim(33) storebug
storebug.nim(31) main
asyncdispatch.nim(1627) waitFor
asyncdispatch.nim(1208) poll
system.nim(2542) cb
asyncfutures.nim(125) fail
asyncfutures.nim(150) :anonymous
zerruntime.nim(368) :anonymous
asyncfutures.nim(125) fail
import strutils, os, pegs
proc modFile(f: string) =
transformFile f, f & paramStr(1), [(peg"\_[A-Za-z0-9]+", "")]
proc main(dir: string) =
for f in walkPattern(dir):
modFile f
type
CanMove = concept x
x.move(0.0)
ICanMove = ref object
move: proc(tick: float)
Mover = ref object
movees: seq[ICanMove]
364 LdDeref r3, r1, r0 #deques:169
365 LdObj r5, r3, r3 #deques:69
366 NodeToReg r4, r5, r0 #deques:69
367 LdImmInt r5, 1 #deques:69
368 LtInt r2, r4, r5 #deques:69
369 FJmp r2, L379 #deques:69
370 LdNull r6, 8 #system:2683
371 New r6, 9 #system:2684
372 LdConst r7, "Empty deque." (31) #deques:70
373 AsgnStr r8, r7, r0 #system:2685
import macros
proc generateAccessors(name, hidden, typ, fieldTyp: NimNode): NimNode =
template helper(name, hidden, typ, fieldTyp) {.dirty.} =
proc name*(self: typ): auto = self.hidden
proc `name=`*(self: var typ; val: fieldTyp) =
self.hidden = val
result = getAst(helper(name, hidden, typ, fieldTyp))
proc transform(n: NimNode; stmts, obj: NimNode): NimNode =