diff options
author | Yuriy Glukhov <yuriy.glukhov@gmail.com> | 2015-08-21 13:29:25 +0300 |
---|---|---|
committer | Yuriy Glukhov <yuriy.glukhov@gmail.com> | 2015-08-21 13:29:25 +0300 |
commit | a5be556a4cd58371f21cab6bffc8b333a9aa5c51 (patch) | |
tree | 814f4bad8759d5209b3bdd8c106dd4a93d09968b /lib/system/jssys.nim | |
parent | 0cc662d8b854335bc31d7739ed41dd222c0cfca8 (diff) | |
download | Nim-a5be556a4cd58371f21cab6bffc8b333a9aa5c51.tar.gz |
Untyped pointers godegen changed. addr expression fixed.
Diffstat (limited to 'lib/system/jssys.nim')
-rw-r--r-- | lib/system/jssys.nim | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim index 242f42c16..a6839c48e 100644 --- a/lib/system/jssys.nim +++ b/lib/system/jssys.nim @@ -532,15 +532,17 @@ proc nimMax(a, b: int): int {.compilerproc.} = return if a >= b: a else: b type NimString = string # hack for hti.nim include "system/hti" +type JSRef = int # Fake type. + proc isFatPointer(ti: PNimType): bool = # This has to be consistent with the code generator! return ti.base.kind notin {tyObject, tyArray, tyArrayConstr, tyTuple, tyOpenArray, tySet, tyVar, tyRef, tyPtr} -proc nimCopy(dest, src: pointer, ti: PNimType): pointer {.compilerproc.} +proc nimCopy(dest, src: JSRef, ti: PNimType): JSRef {.compilerproc.} -proc nimCopyAux(dest, src: pointer, n: ptr TNimNode) {.compilerproc.} = +proc nimCopyAux(dest, src: JSRef, n: ptr TNimNode) {.compilerproc.} = case n.kind of nkNone: sysAssert(false, "nimCopyAux") of nkSlot: @@ -562,7 +564,7 @@ proc nimCopyAux(dest, src: pointer, n: ptr TNimNode) {.compilerproc.} = } """ -proc nimCopy(dest, src: pointer, ti: PNimType): pointer = +proc nimCopy(dest, src: JSRef, ti: PNimType): JSRef = case ti.kind of tyPtr, tyRef, tyVar, tyNil: if not isFatPointer(ti): @@ -603,12 +605,11 @@ proc nimCopy(dest, src: pointer, ti: PNimType): pointer = else: result = src -proc genericReset(x: pointer, ti: PNimType): pointer {.compilerproc.} = +proc genericReset(x: JSRef, ti: PNimType): JSRef {.compilerproc.} = + asm "`result` = null;" case ti.kind of tyPtr, tyRef, tyVar, tyNil: - if not isFatPointer(ti): - result = nil - else: + if isFatPointer(ti): asm """ `result` = [null, 0]; """ @@ -633,9 +634,9 @@ proc genericReset(x: pointer, ti: PNimType): pointer {.compilerproc.} = } """ else: - result = nil + discard -proc arrayConstr(len: int, value: pointer, typ: PNimType): pointer {. +proc arrayConstr(len: int, value: JSRef, typ: PNimType): JSRef {. asmNoStackFrame, compilerproc.} = # types are fake asm """ |