first version of an PHP codegen

This commit is contained in:
Andreas Rumpf 2016-02-04 03:40:39 +01:00
commit 35567a1eb9
8 changed files with 665 additions and 411 deletions

View file

@ -2452,14 +2452,17 @@ type
when defined(JS):
proc add*(x: var string, y: cstring) {.asmNoStackFrame.} =
asm """
var len = `x`[0].length-1;
for (var i = 0; i < `y`.length; ++i) {
`x`[0][len] = `y`.charCodeAt(i);
++len;
}
`x`[0][len] = 0
"""
when defined(nimphp):
asm """`x` .= `y`;"""
else:
asm """
var len = `x`[0].length-1;
for (var i = 0; i < `y`.length; ++i) {
`x`[0][len] = `y`.charCodeAt(i);
++len;
}
`x`[0][len] = 0
"""
proc add*(x: var cstring, y: cstring) {.magic: "AppendStrStr".}
elif hasAlloc: