From 8ec7c0af2046e66fc4f3d3d8b04c06ddfc2b566d Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sat, 6 Feb 2016 19:58:28 +0100 Subject: php-codegen fixes --- compiler/jsgen.nim | 11 +++++++---- lib/system/jssys.nim | 5 +++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 972fcf393..7a927f41e 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -180,12 +180,15 @@ proc mangleName(s: PSym; target: TTarget): Rope = var i = 0 while i < s.name.s.len: let c = s.name.s[i] - if c in {'A'..'Z'}: + case c + of 'A'..'Z': if i > 0 and s.name.s[i-1] in {'a'..'z'}: x.add '_' x.add(chr(c.ord - 'A'.ord + 'a'.ord)) - else: + of 'a'..'z', '_', '0'..'9': x.add c + else: + x.add("HEX" & toHex(ord(c), 2)) inc i result = rope(x) add(result, "_") @@ -1571,7 +1574,7 @@ proc genMagic(p: PProc, n: PNode, r: var TCompRes) = "(strlen($1)-1)") else: unaryExpr(p, n, r, "", "($1 != null ? ($1.length-1) : -1)" | - "(count($1.length)-1)") + "(count($1)-1)") of mInc: if n[1].typ.skipTypes(abstractRange).kind in tyUInt .. tyUInt64: binaryUintExpr(p, n, r, "+", true) @@ -1614,7 +1617,7 @@ proc genMagic(p: PProc, n: PNode, r: var TCompRes) = if p.target == targetJS: unaryExpr(p, n, r, "mnewString", "mnewString(0)") else: - unaryExpr(p, n, r, "", "$# = ''") + unaryExpr(p, n, r, "", "''") of mDotDot: genProcForSymIfNeeded(p, n.sons[0].sym) genCall(p, n, r) diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim index 8394396b5..ceeb5563f 100644 --- a/lib/system/jssys.nim +++ b/lib/system/jssys.nim @@ -275,6 +275,11 @@ proc mnewString(len: int): string {.asmNoStackFrame, compilerproc.} = return result; """ +when defined(nimphp): + proc nimSubstr(s: string; a, b: int): string {. + asmNoStackFrame, compilerproc.} = + asm """return substr(`s`,`a`,`b`-`a`+1);""" + proc SetCard(a: int): int {.compilerproc, asmNoStackFrame.} = # argument type is a fake when defined(nimphp): -- cgit 1.4.1-2-gfad0 >
path: root/doc/keywords.txt
blob: 4eea3403adb6c94dae6dd2cb3c29c2ff3bd3f7b7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20