Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- compiler/evalffi.nim | 62 ++++++++++++++++++++++++++--------------------------
- compiler/main.nim | 4 ++--
- lib/pure/dynlib.nim | 2 +-
- lib/system/excpt.nim | 2 +-
- 4 files changed, 35 insertions(+), 35 deletions(-)
- diff --git a/compiler/evalffi.nim b/compiler/evalffi.nim
- index 74f0663..a534046 100644
- --- a/compiler/evalffi.nim
- +++ b/compiler/evalffi.nim
- @@ -22,9 +22,9 @@ var
- gDllCache = initTable[string, TLibHandle]()
- when defined(windows):
- - var gExeHandle = loadLib(os.getAppFilename())
- + var gExeHandle = LoadLib(os.getAppFilename())
- else:
- - var gExeHandle = loadLib()
- + var gExeHandle = LoadLib()
- proc getDll(cache: var TDllCache; dll: string; info: TLineInfo): pointer =
- result = cache[dll]
- @@ -32,7 +32,7 @@ proc getDll(cache: var TDllCache; dll: string; info: TLineInfo): pointer =
- var libs: seq[string] = @[]
- libCandidates(dll, libs)
- for c in libs:
- - result = loadLib(c)
- + result = LoadLib(c)
- if not result.isNil: break
- if result.isNil:
- globalError(info, "cannot load: " & dll)
- @@ -102,7 +102,7 @@ proc mapCallConv(cc: TCallingConvention, info: TLineInfo): TABI =
- of ccStdCall: result = when defined(windows): STDCALL else: DEFAULT_ABI
- of ccCDecl: result = DEFAULT_ABI
- else:
- - GlobalError(info, "cannot map calling convention to FFI")
- + globalError(info, "cannot map calling convention to FFI")
- template rd(T, p: expr): expr {.immediate.} = (cast[ptr T](p))[]
- template wr(T, p, v: expr) {.immediate.} = (cast[ptr T](p))[] = v
- @@ -151,7 +151,7 @@ proc getField(n: PNode; position: int): PSym =
- else: discard
- proc packObject(x: PNode, typ: PType, res: pointer) =
- - InternalAssert x.kind in {nkObjConstr, nkPar}
- + internalAssert x.kind in {nkObjConstr, nkPar}
- # compute the field's offsets:
- discard typ.getSize
- for i in countup(ord(x.kind == nkObjConstr), sonsLen(x) - 1):
- @@ -164,7 +164,7 @@ proc packObject(x: PNode, typ: PType, res: pointer) =
- let field = getField(typ.n, i)
- pack(it, field.typ, res +! field.offset)
- else:
- - GlobalError(x.info, "cannot pack unnamed tuple")
- + globalError(x.info, "cannot pack unnamed tuple")
- const maxPackDepth = 20
- var packRecCheck = 0
- @@ -193,7 +193,7 @@ proc pack(v: PNode, typ: PType, res: pointer) =
- of 4: awr(int32, v.intVal.int32)
- of 8: awr(int64, v.intVal.int64)
- else:
- - GlobalError(v.info, "cannot map value to FFI (tyEnum, tySet)")
- + globalError(v.info, "cannot map value to FFI (tyEnum, tySet)")
- of tyFloat: awr(float, v.floatVal)
- of tyFloat32: awr(float32, v.floatVal)
- of tyFloat64: awr(float64, v.floatVal)
- @@ -207,7 +207,7 @@ proc pack(v: PNode, typ: PType, res: pointer) =
- elif v.kind in {nkStrLit..nkTripleStrLit}:
- awr(cstring, cstring(v.strVal))
- else:
- - GlobalError(v.info, "cannot map pointer/proc value to FFI")
- + globalError(v.info, "cannot map pointer/proc value to FFI")
- of tyPtr, tyRef, tyVar:
- if v.kind == nkNilLit:
- # nothing to do since the memory is 0 initialized anyway
- @@ -217,7 +217,7 @@ proc pack(v: PNode, typ: PType, res: pointer) =
- else:
- if packRecCheck > maxPackDepth:
- packRecCheck = 0
- - GlobalError(v.info, "cannot map value to FFI " & typeToString(v.typ))
- + globalError(v.info, "cannot map value to FFI " & typeToString(v.typ))
- inc packRecCheck
- pack(v.sons[0], typ.sons[0], res +! sizeof(pointer))
- dec packRecCheck
- @@ -233,7 +233,7 @@ proc pack(v: PNode, typ: PType, res: pointer) =
- of tyDistinct, tyGenericInst:
- pack(v, typ.sons[0], res)
- else:
- - GlobalError(v.info, "cannot map value to FFI " & typeToString(v.typ))
- + globalError(v.info, "cannot map value to FFI " & typeToString(v.typ))
- proc unpack(x: pointer, typ: PType, n: PNode): PNode
- @@ -243,7 +243,7 @@ proc unpackObjectAdd(x: pointer, n, result: PNode) =
- for i in countup(0, sonsLen(n) - 1):
- unpackObjectAdd(x, n.sons[i], result)
- of nkRecCase:
- - GlobalError(result.info, "case objects cannot be unpacked")
- + globalError(result.info, "case objects cannot be unpacked")
- of nkSym:
- var pair = newNodeI(nkExprColonExpr, result.info, 2)
- pair.sons[0] = n
- @@ -262,14 +262,14 @@ proc unpackObject(x: pointer, typ: PType, n: PNode): PNode =
- result = newNode(nkPar)
- result.typ = typ
- if typ.n.isNil:
- - InternalError("cannot unpack unnamed tuple")
- + internalError("cannot unpack unnamed tuple")
- unpackObjectAdd(x, typ.n, result)
- else:
- result = n
- if result.kind notin {nkObjConstr, nkPar}:
- - GlobalError(n.info, "cannot map value from FFI")
- + globalError(n.info, "cannot map value from FFI")
- if typ.n.isNil:
- - GlobalError(n.info, "cannot unpack unnamed tuple")
- + globalError(n.info, "cannot unpack unnamed tuple")
- for i in countup(ord(n.kind == nkObjConstr), sonsLen(n) - 1):
- var it = n.sons[i]
- if it.kind == nkExprColonExpr:
- @@ -288,7 +288,7 @@ proc unpackArray(x: pointer, typ: PType, n: PNode): PNode =
- else:
- result = n
- if result.kind != nkBracket:
- - GlobalError(n.info, "cannot map value from FFI")
- + globalError(n.info, "cannot map value from FFI")
- let baseSize = typ.sons[1].getSize
- for i in 0 .. < result.len:
- result.sons[i] = unpack(x +! i * baseSize, typ.sons[1], result.sons[i])
- @@ -312,7 +312,7 @@ proc unpack(x: pointer, typ: PType, n: PNode): PNode =
- #echo "expected ", k, " but got ", result.kind
- #debug result
- return newNodeI(nkExceptBranch, n.info)
- - #GlobalError(n.info, "cannot map value from FFI")
- + #globalError(n.info, "cannot map value from FFI")
- result.field = v
- template setNil() =
- @@ -337,19 +337,19 @@ proc unpack(x: pointer, typ: PType, n: PNode): PNode =
- of tyInt16: awi(nkInt16Lit, rd(int16, x))
- of tyInt32: awi(nkInt32Lit, rd(int32, x))
- of tyInt64: awi(nkInt64Lit, rd(int64, x))
- - of tyUInt: awi(nkUIntLit, rd(uint, x).biggestInt)
- - of tyUInt8: awi(nkUInt8Lit, rd(uint8, x).biggestInt)
- - of tyUInt16: awi(nkUInt16Lit, rd(uint16, x).biggestInt)
- - of tyUInt32: awi(nkUInt32Lit, rd(uint32, x).biggestInt)
- - of tyUInt64: awi(nkUInt64Lit, rd(uint64, x).biggestInt)
- + of tyUInt: awi(nkUIntLit, rd(uint, x).BiggestInt)
- + of tyUInt8: awi(nkUInt8Lit, rd(uint8, x).BiggestInt)
- + of tyUInt16: awi(nkUInt16Lit, rd(uint16, x).BiggestInt)
- + of tyUInt32: awi(nkUInt32Lit, rd(uint32, x).BiggestInt)
- + of tyUInt64: awi(nkUInt64Lit, rd(uint64, x).BiggestInt)
- of tyEnum:
- case typ.getSize
- - of 1: awi(nkIntLit, rd(uint8, x).biggestInt)
- - of 2: awi(nkIntLit, rd(uint16, x).biggestInt)
- - of 4: awi(nkIntLit, rd(int32, x).biggestInt)
- - of 8: awi(nkIntLit, rd(int64, x).biggestInt)
- + of 1: awi(nkIntLit, rd(uint8, x).BiggestInt)
- + of 2: awi(nkIntLit, rd(uint16, x).BiggestInt)
- + of 4: awi(nkIntLit, rd(int32, x).BiggestInt)
- + of 8: awi(nkIntLit, rd(int64, x).BiggestInt)
- else:
- - GlobalError(n.info, "cannot map value from FFI (tyEnum, tySet)")
- + globalError(n.info, "cannot map value from FFI (tyEnum, tySet)")
- of tyFloat: awf(nkFloatLit, rd(float, x))
- of tyFloat32: awf(nkFloat32Lit, rd(float32, x))
- of tyFloat64: awf(nkFloat64Lit, rd(float64, x))
- @@ -374,7 +374,7 @@ proc unpack(x: pointer, typ: PType, n: PNode): PNode =
- n.sons[0] = unpack(p, typ.sons[0], n.sons[0])
- result = n
- else:
- - GlobalError(n.info, "cannot map value from FFI " & typeToString(typ))
- + globalError(n.info, "cannot map value from FFI " & typeToString(typ))
- of tyObject, tyTuple:
- result = unpackObject(x, typ, n)
- of tyArray, tyArrayConstr:
- @@ -391,7 +391,7 @@ proc unpack(x: pointer, typ: PType, n: PNode): PNode =
- result = unpack(x, typ.sons[0], n)
- else:
- # XXX what to do with 'array' here?
- - GlobalError(n.info, "cannot map value from FFI " & typeToString(typ))
- + globalError(n.info, "cannot map value from FFI " & typeToString(typ))
- proc fficast*(x: PNode, destTyp: PType): PNode =
- if x.kind == nkPtrLit and x.typ.kind in {tyPtr, tyRef, tyVar, tyPointer,
- @@ -414,7 +414,7 @@ proc fficast*(x: PNode, destTyp: PType): PNode =
- dealloc a
- proc callForeignFunction*(call: PNode): PNode =
- - InternalAssert call.sons[0].kind == nkPtrLit
- + internalAssert call.sons[0].kind == nkPtrLit
- var cif: TCif
- var sig: TParamList
- @@ -422,12 +422,12 @@ proc callForeignFunction*(call: PNode): PNode =
- for i in 1..call.len-1:
- sig[i-1] = mapType(call.sons[i].typ)
- if sig[i-1].isNil:
- - GlobalError(call.info, "cannot map FFI type")
- + globalError(call.info, "cannot map FFI type")
- let typ = call.sons[0].typ
- if prep_cif(cif, mapCallConv(typ.callConv, call.info), cuint(call.len-1),
- mapType(typ.sons[0]), sig) != OK:
- - GlobalError(call.info, "error in FFI call")
- + globalError(call.info, "error in FFI call")
- var args: TArgList
- let fn = cast[pointer](call.sons[0].intVal)
- diff --git a/compiler/main.nim b/compiler/main.nim
- index cdea7b5..584cfe9 100644
- --- a/compiler/main.nim
- +++ b/compiler/main.nim
- @@ -135,7 +135,7 @@ proc interactivePasses =
- #setTarget(osNimrodVM, cpuNimrodVM)
- initDefines()
- defineSymbol("nimrodvm")
- - when hasFFI: DefineSymbol("nimffi")
- + when hasFFI: defineSymbol("nimffi")
- registerPass(verbosePass)
- registerPass(semPass)
- registerPass(evalPass)
- @@ -324,7 +324,7 @@ proc mainCommand* =
- wantMainModule()
- when hasTinyCBackend:
- extccomp.setCC("tcc")
- - CommandCompileToC()
- + commandCompileToC()
- else:
- rawMessage(errInvalidCommandX, command)
- of "js", "compiletojs":
- diff --git a/lib/pure/dynlib.nim b/lib/pure/dynlib.nim
- index a64b7f1..b09716f 100644
- --- a/lib/pure/dynlib.nim
- +++ b/lib/pure/dynlib.nim
- @@ -55,7 +55,7 @@ when defined(posix):
- RTLD_NOW {.importc: "RTLD_NOW", header: "<dlfcn.h>".}: int
- proc dlclose(lib: TLibHandle) {.importc, header: "<dlfcn.h>".}
- - proc dlopen(path: CString, mode: int): TLibHandle {.
- + proc dlopen(path: cstring, mode: int): TLibHandle {.
- importc, header: "<dlfcn.h>".}
- proc dlsym(lib: TLibHandle, name: cstring): pointer {.
- importc, header: "<dlfcn.h>".}
- diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim
- index a3f6669..e50ba7b 100644
- --- a/lib/system/excpt.nim
- +++ b/lib/system/excpt.nim
- @@ -23,7 +23,7 @@ else:
- proc MessageBoxA(hWnd: cint, lpText, lpCaption: cstring, uType: int): int32 {.
- header: "<windows.h>", nodecl.}
- - proc writeToStdErr(msg: CString) =
- + proc writeToStdErr(msg: cstring) =
- discard MessageBoxA(0, msg, nil, 0)
- proc showErrorMessage(data: cstring) =
- --
- 1.8.5.3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement