From a401a8e5536ead1bfe949df306985c694b60f03d Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Mon, 10 Feb 2020 14:38:40 -0700 Subject: [PATCH] WIP --- build_all.sh | 2 +- compiler/evalffi.nim | 37 ++++++++++++++++++++++++++++++-- compiler/renderer.nim | 2 +- compiler/sizealignoffsetimpl.nim | 2 ++ compiler/vm.nim | 2 ++ lib/system/io.nim | 23 ++++++++------------ 6 files changed, 50 insertions(+), 18 deletions(-) diff --git a/build_all.sh b/build_all.sh index 2ed2233e9..84230c018 100644 --- a/build_all.sh +++ b/build_all.sh @@ -47,5 +47,5 @@ build_nim_csources(){ # Note: if fails, may need to `cd csources && git pull` echo_run bin/nim c --skipUserCfg --skipParentCfg koch -echo_run ./koch boot -d:release +echo_run ./koch boot -d:release -d:nimHasLibFFI echo_run ./koch tools # Compile Nimble and other tools. diff --git a/compiler/evalffi.nim b/compiler/evalffi.nim index 58c505a5b..3c47251c1 100644 --- a/compiler/evalffi.nim +++ b/compiler/evalffi.nim @@ -95,6 +95,21 @@ proc mapType(conf: ConfigRef, t: ast.PType): ptr libffi.Type = result = addr libffi.type_pointer of tyDistinct, tyAlias, tySink: result = mapType(conf, t[0]) + of tyObject: + var els = newSeq[ptr libffi.Type](t.n.sons.len + 1) + var ty: ptr libffi.Type = cast[ptr libffi.Type](alloc(sizeof(libffi.Type))) + + ty.size = 0 + ty.alignment = 0 + ty.typ = tkSTRUCT + ty.elements = addr els[0] + + els[els.len-1] = nil + for i in 0..".} = cint