Skip to content

Instantly share code, notes, and snippets.

@zah
zah / Tupfile
Created July 31, 2012 16:46
tup coffee-script project
: test.coffee |> coffee.bat -c %f |> %B.js
#include <cstring>
#include <iostream>
class Base
{
struct SetParamHelper
{
Base* obj;
SetParamHelper(Base* obj): obj(obj) {}
@zah
zah / gist:2006104
Created March 9, 2012 11:11
CMake unity builds
function(enable_unity_build UB_SUFFIX SOURCE_VARIABLE_NAME)
set(files ${${SOURCE_VARIABLE_NAME}})
# Generate a unique filename for the unity build translation unit
set(unit_build_file ${CMAKE_CURRENT_BINARY_DIR}/ub_${UB_SUFFIX}.cpp)
# Exclude all translation units from compilation
set_source_files_properties(${files} PROPERTIES HEADER_FILE_ONLY true)
# Open the ub file
FILE(WRITE ${unit_build_file} "// Unity Build generated by CMake\n")
# Add include statement for each translation unit
foreach(source_file ${files} )
009A5BE7 pop edi
009A5BE8 pop esi
009A5BE9 pop ebp
009A5BEA pop ebx
009A5BEB mov esp,ebp
009A5BED pop ebp
009A5BEE ret
LOC10 = Nextpoweroftwo_53262(Strings_223635);
009A5BEF call @ILT+6745(@Nextpoweroftwo_53262@4) (982A5Eh)
Bitmask_223694 = (NI32)(LOC10 - 1);
@zah
zah / integers.c
Created December 13, 2011 01:31
volatile stack roots
int main()
{
009F1000 push ecx
volatile int y;
volatile int z;
void* x;
x = malloc(10);
009F1001 push 0Ah
009F1003 call dword ptr [__imp__malloc (9F20A0h)]
y = (int)x;
@zah
zah / check.nim
Created December 10, 2011 22:33
Unified check
proc computeSomething: TSomething =
check_failed:
return safeTSomethingValue
check foo
check bar
check_failed:
raise newException(ECustomError)
> nimrod.exe!Rawalloc_11409(TY10274 * A_11412=0x00000014, long Requestedsize_11413=0) Line 2145 C
nimrod.exe!Newobj_16401(TNimType * Typ_16403=0x00000014, long Size_16404=0, TY12474 * Gch_16406=0x0124d580) Line 1896 C
nimrod.exe!newObj(TNimType * Typ_17003=0x00000014, long Size_17004=0) Line 1916 C
nimrod.exe!Con_56015(TY56008 * A_56017=0x00000014, TY56008 * B_56018=0x00000000) Line 422 + 0x11 bytes C
nimrod.exe!Ropef_56066(NimStringDesc * Frmt_56068=0x00000014, TY56008 * * Args_56070=0x00000000, long Args_56070Len0=2) Line 550 + 0x5a bytes C
nimrod.exe!Appf_56071(TY56008 * * C_56074=0x00000014, NimStringDesc * Frmt_56075=0x00000000, TY56008 * * Args_56077=0x032df618, long Args_56077Len0=2) Line 568 C
nimrod.exe!Genstringcase_197302(TY181021 * P_197304=0x00000014, TY62553 * T_197305=0x00000000) Line 10820 C
nimrod.exe!Genstmts_187557(TY181021 * P_187559=0x00000014, TY62553 * T_187560=0x00000000) Line 11668 + 0x7 bytes C
nimrod.exe!Genstmts_187557(TY181021 * P_187559=0x00000014, TY62553
proc unsureAsgnRef(dest: ppointer, src: pointer) {.compilerproc, inline.} =
assertAllocatedPtr(src)
dest[] = src
proc asgnRef(dest: ppointer, src: pointer) {.compilerproc, inline.} =
dest[] = src
assertAllocatedPtr(src)
proc asgnRefNoCycle(dest: ppointer, src: pointer) {.compilerproc, inline.} =
dest[] = src
assertAllocatedPtr(src)
proc rawAlloc(a: var TMemRegion, requestedSize: int): pointer =
00D84CA0 push ebx
00D84CA1 push esi
sysAssert(roundup(65, 8) == 72, "rawAlloc 1")
sysAssert requestedSize >= sizeof(TFreeCell), "rawAlloc 2"
var size = roundup(requestedSize, MemAlign)
00D84CA2 lea esi,[edx+7]
00D84CA5 and esi,0FFFFFFF8h
00D84CA8 mov ebx,ecx
#c_fprintf(c_stdout, "alloc; size: %ld; %ld\n", requestedSize, size)
@zah
zah / let.nimrod
Created December 1, 2011 14:55
Let - first tests
type
TBar = object
f: int
TFoo = object
str: string
sq: seq[string]
bar: TBar
proc makeFoo: TFoo =