This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type | |
TTest* = object | |
pos*: range[0..15] | |
proc next(state: var TTest): int64 = | |
assert(state.pos >= 0 and state.pos < 16, "pos is " & $state.pos) | |
# Error: unhandled exception: state.pos >= 0 and state.pos < 16 pos is 140736480769200 [EAssertionFailed] | |
# 140736480769200 is incremented by a few million each execution | |
state.pos = (state.pos + 1) and 15 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import macros | |
macro void(name: expr, body: stmt): stmt {.immediate.} = | |
echo treeRepr name | |
void abc(int a, string b){ | |
echo "test" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import macros | |
macro void(name: expr): stmt {.immediate.} = | |
echo reprTree name | |
#CurlyExpr | |
# Call | |
# Ident !"abc" | |
# Command | |
# Ident !"int" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import macros | |
template ctypedef(name: expr): stmt {.immediate.} = | |
macro `name`(body: expr): stmt {.immediate.} = | |
let head = body[0] | |
let procname = head[0] | |
var params = newSeq[PNimrodNode]() | |
for node in head.children: | |
case node.kind | |
of nnkCommand: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<Document xmlns="http://www.evolus.vn/Namespace/Pencil"><Properties/><Pages><Page><Properties><Property name="name">Untitled Page</Property><Property name="id">1397597259991_8851</Property><Property name="width">1000</Property><Property name="height">1500</Property><Property name="dimBackground"/><Property name="transparentBackground">false</Property><Property name="backgroundColor">#C0C0C0FF</Property><Property name="fid">untitled_page</Property></Properties><Content><g xmlns="http://www.w3.org/2000/svg" p:type="Shape" xmlns:p="http://www.evolus.vn/Namespace/Pencil" p:def="Evolus.BasicWebElements:heading" p:sc="Heading 1" id="f632af5c128b455f867b3e967423d64e" transform="matrix(1,0,0,1,273,34)"><p:metadata><p:property name="textContent"><![CDATA[Prelude]]></p:property><p:property name="textFont"><![CDATA["Liberation Sans",Arial,sans-serif|bold|normal|24px|none]]></p:property><p:property name="textColor"><![CDATA[#000000FF]]></p:property><p:property name="customStyle"><![CDATA[]]></p:prop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import macros, strutils | |
macro `:=`(a, b: expr): stmt {.immediate.} = | |
let tempVar = newIdentNode(!"tmp") | |
result = newLetStmt(tempVar, b) | |
var i = 0 | |
for child in a.children: | |
var arrAccess = newNimNode(nnkBracketExpr) | |
.add(tempVar) | |
.add(newIntLitNode(i)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Provides utility methods to make working with bit manipulations | |
## easier and less error prone | |
const | |
validBitfieldType = ["int", "int8", "int16", "int32", "int64", "uint", | |
"uint8", "uint16", "uint32", "uint64", "bool"] | |
macro bitfield(values: varargs[stmt]): stmt = | |
## Creates a bitfield with the given fields | |
# Validate and initial parameter processing | |
if values.len %% 3 != 0: | |
error("Each field requires three values") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------------------------------------------------------------------- | |
--- Testing CrapWow (CrapWow) | |
[[[ Sanity Tests ]]] | |
Verification value 0x49ECB015 : Passed! | |
Running sanity check 1..........PASS | |
Running sanity check 2..........PASS | |
[[[ Speed Tests ]]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{.emit: "#include <stdint.h>\n".} | |
type | |
FInt8* {.importc: "int8_t".} = object | |
proc `*`(a, b: FInt8): FInt8 = | |
{.emit: "return ((`a`)*(`b`));".} | |
proc toInt(a: FInt8): int = | |
{.emit: "return `a`;".} | |
var a: FInt8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import exceptions | |
template checkBounds(idx, min, max: int) = | |
when not defined(release): | |
if idx < min or idx > max: | |
raiseException(errOutOfBounds, idx, min, max) | |
# TBuffer {{{ | |
type |