Skip to content

Instantly share code, notes, and snippets.

View flaviut's full-sized avatar

Flaviu Tamas flaviut

View GitHub Profile
import macros
macro void(name: expr): stmt {.immediate.} =
echo reprTree name
#CurlyExpr
# Call
# Ident !"abc"
# Command
# Ident !"int"
@flaviut
flaviut / test.nim
Last active August 29, 2015 13:59
C in nimrod
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:
<?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
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))
@flaviut
flaviut / SMHasher Output
Last active August 29, 2015 14:01
Running the CrapWow hash through SMHasher
-------------------------------------------------------------------------------
--- Testing CrapWow (CrapWow)
[[[ Sanity Tests ]]]
Verification value 0x49ECB015 : Passed!
Running sanity check 1..........PASS
Running sanity check 2..........PASS
[[[ Speed Tests ]]]
{.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
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
diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim
index 70eced0..7c11d3e 100644
--- a/compiler/ccgtypes.nim
+++ b/compiler/ccgtypes.nim
@@ -13,7 +13,7 @@
proc mangleField(name: string): string =
result = mangle(name)
- if name[0] in Letters:
+ if name[0] in 'a'..'z':
diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim
index 7c11d3e..70eced0 100644
--- a/compiler/ccgtypes.nim
+++ b/compiler/ccgtypes.nim
@@ -13,7 +13,7 @@
proc mangleField(name: string): string =
result = mangle(name)
- if name[0] in 'a'..'z':
+ if name[0] in Letters:
import macros
# StmtList
# Call
# Ident !"asda"
# Call
# Ident !"gfa"
# BlockStmt
# Ident !"a"
# StmtList