diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 0e6e483998..5057ae558e 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -911,29 +911,29 @@ proc addIntTypes(result: var PRope) {.inline.} = appf(result, "#define NIM_INTBITS $1", [ platform.CPU[targetCPU].intSize.toRope]) -proc getCopyright(cfilenoext: string): PRope = - if optCompileOnly in gGlobalOptions: - result = ropeff("/* Generated by Nimrod Compiler v$1 */$n" & - "/* (c) 2014 Andreas Rumpf */$n" & - "/* The generated code is subject to the original license. */$n", - "; Generated by Nimrod Compiler v$1$n" & - "; (c) 2012 Andreas Rumpf$n", [toRope(VersionAsString)]) - else: - result = ropeff("/* Generated by Nimrod Compiler v$1 */$n" & - "/* (c) 2014 Andreas Rumpf */$n" & - "/* The generated code is subject to the original license. */$n" & - "/* Compiled for: $2, $3, $4 */$n" & - "/* Command for C compiler:$n $5 */$n", - "; Generated by Nimrod Compiler v$1$n" & - "; (c) 2014 Andreas Rumpf$n" & - "; Compiled for: $2, $3, $4$n" & - "; Command for LLVM compiler:$n $5$n", [toRope(VersionAsString), - toRope(platform.OS[targetOS].name), - toRope(platform.CPU[targetCPU].name), - toRope(extccomp.CC[extccomp.cCompiler].name), +proc getCopyright(cfilenoext: string): PRope = + if optCompileOnly in gGlobalOptions: + result = ropeff("/* Generated by Nimrod Compiler v$1 */$N" & + "/* (c) 2014 Andreas Rumpf */$N" & + "/* The generated code is subject to the original license. */$N", + "; Generated by Nimrod Compiler v$1$N" & + "; (c) 2012 Andreas Rumpf$N", [toRope(VersionAsString)]) + else: + result = ropeff("/* Generated by Nimrod Compiler v$1 */$N" & + "/* (c) 2014 Andreas Rumpf */$N" & + "/* The generated code is subject to the original license. */$N" & + "/* Compiled for: $2, $3, $4 */$N" & + "/* Command for C compiler:$n $5 */$N", + "; Generated by Nimrod Compiler v$1$N" & + "; (c) 2014 Andreas Rumpf$N" & + "; Compiled for: $2, $3, $4$N" & + "; Command for LLVM compiler:$N $5$N", [toRope(VersionAsString), + toRope(platform.OS[targetOS].name), + toRope(platform.CPU[targetCPU].name), + toRope(extccomp.CC[extccomp.cCompiler].name), toRope(getCompileCFileCmd(cfilenoext))]) -proc getFileHeader(cfilenoext: string): PRope = +proc getFileHeader(cfilenoext: string): PRope = result = getCopyright(cfilenoext) addIntTypes(result) @@ -941,61 +941,71 @@ proc genFilenames(m: BModule): PRope = discard cgsym(m, "dbgRegisterFilename") result = nil for i in 0.. 0: appcg(m, m.s[cfsTypeInit1], "static #TNimNode $1[$2];$n", @@ -1101,7 +1111,7 @@ proc genInitCode(m: BModule) = app(prc, deinitGCFrame(m.initProc)) appf(prc, "}$N$N") - prc.appff("N_NOINLINE(void, $1)(void) {$n", + prc.appff("N_NOINLINE(void, $1)(void) {$N", "define void $1() noinline {$n", [getDatInitName(m.module)]) for i in cfsTypeInit1..cfsDynLibInit: diff --git a/lib/system.nim b/lib/system.nim index 75bebf7025..de23a71fa1 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -447,38 +447,38 @@ proc chr*(u: range[0..255]): char {.magic: "Chr", noSideEffect.} # -------------------------------------------------------------------------- # built-in operators -proc ze*(x: int8): int {.magic: "Ze8ToI", noSideEffect.} - ## zero extends a smaller integer type to ``int``. This treats `x` as - ## unsigned. -proc ze*(x: int16): int {.magic: "Ze16ToI", noSideEffect.} - ## zero extends a smaller integer type to ``int``. This treats `x` as - ## unsigned. +when not defined(JS): + proc ze*(x: int8): int {.magic: "Ze8ToI", noSideEffect.} + ## zero extends a smaller integer type to ``int``. This treats `x` as + ## unsigned. + proc ze*(x: int16): int {.magic: "Ze16ToI", noSideEffect.} + ## zero extends a smaller integer type to ``int``. This treats `x` as + ## unsigned. -proc ze64*(x: int8): int64 {.magic: "Ze8ToI64", noSideEffect.} - ## zero extends a smaller integer type to ``int64``. This treats `x` as - ## unsigned. -proc ze64*(x: int16): int64 {.magic: "Ze16ToI64", noSideEffect.} - ## zero extends a smaller integer type to ``int64``. This treats `x` as - ## unsigned. + proc ze64*(x: int8): int64 {.magic: "Ze8ToI64", noSideEffect.} + ## zero extends a smaller integer type to ``int64``. This treats `x` as + ## unsigned. + proc ze64*(x: int16): int64 {.magic: "Ze16ToI64", noSideEffect.} + ## zero extends a smaller integer type to ``int64``. This treats `x` as + ## unsigned. -proc ze64*(x: int32): int64 {.magic: "Ze32ToI64", noSideEffect.} - ## zero extends a smaller integer type to ``int64``. This treats `x` as - ## unsigned. -proc ze64*(x: int): int64 {.magic: "ZeIToI64", noSideEffect.} - ## zero extends a smaller integer type to ``int64``. This treats `x` as - ## unsigned. Does nothing if the size of an ``int`` is the same as ``int64``. - ## (This is the case on 64 bit processors.) - -proc toU8*(x: int): int8 {.magic: "ToU8", noSideEffect.} - ## treats `x` as unsigned and converts it to a byte by taking the last 8 bits - ## from `x`. -proc toU16*(x: int): int16 {.magic: "ToU16", noSideEffect.} - ## treats `x` as unsigned and converts it to an ``int16`` by taking the last - ## 16 bits from `x`. -proc toU32*(x: int64): int32 {.magic: "ToU32", noSideEffect.} - ## treats `x` as unsigned and converts it to an ``int32`` by taking the - ## last 32 bits from `x`. + proc ze64*(x: int32): int64 {.magic: "Ze32ToI64", noSideEffect.} + ## zero extends a smaller integer type to ``int64``. This treats `x` as + ## unsigned. + proc ze64*(x: int): int64 {.magic: "ZeIToI64", noSideEffect.} + ## zero extends a smaller integer type to ``int64``. This treats `x` as + ## unsigned. Does nothing if the size of an ``int`` is the same as ``int64``. + ## (This is the case on 64 bit processors.) + proc toU8*(x: int): int8 {.magic: "ToU8", noSideEffect.} + ## treats `x` as unsigned and converts it to a byte by taking the last 8 bits + ## from `x`. + proc toU16*(x: int): int16 {.magic: "ToU16", noSideEffect.} + ## treats `x` as unsigned and converts it to an ``int16`` by taking the last + ## 16 bits from `x`. + proc toU32*(x: int64): int32 {.magic: "ToU32", noSideEffect.} + ## treats `x` as unsigned and converts it to an ``int32`` by taking the + ## last 32 bits from `x`. # integer calculations: proc `+` *(x: int): int {.magic: "UnaryPlusI", noSideEffect.} diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim index 850dd1e114..4fc5f479b7 100644 --- a/lib/system/jssys.nim +++ b/lib/system/jssys.nim @@ -472,17 +472,17 @@ proc Ze(a: int): int {.compilerproc.} = proc Ze64(a: int64): int64 {.compilerproc.} = result = a -proc toU8(a: int): int8 {.noStackFrame, compilerproc.} = +proc ToU8(a: int): int8 {.noStackFrame, compilerproc.} = asm """ return `a`; """ -proc toU16(a: int): int16 {.noStackFrame, compilerproc.} = +proc ToU16(a: int): int16 {.noStackFrame, compilerproc.} = asm """ return `a`; """ -proc toU32(a: int): int32 {.noStackFrame, compilerproc.} = +proc ToU32(a: int): int32 {.noStackFrame, compilerproc.} = asm """ return `a`; """ diff --git a/tests/assert/tfailedassert.nim b/tests/assert/tfailedassert.nim index d99e6dc608..2638937671 100644 --- a/tests/assert/tfailedassert.nim +++ b/tests/assert/tfailedassert.nim @@ -3,7 +3,7 @@ discard """ WARNING: false first asseertion from bar ERROR: false second assertion from bar -1 -tests/run/tfailedassert.nim:27 false assertion from foo +tests/assert/tfailedassert.nim:27 false assertion from foo ''' """