Merge pull request #4149 from oderwat/HARA-PHP_ArrayConstr_Hack
PHP codegen array constructor hack (!!!) for demo purpose only I guess
This commit is contained in:
commit
81ebb96922
1 changed files with 8 additions and 5 deletions
|
|
@ -731,16 +731,19 @@ proc genericReset(x: JSRef, ti: PNimType): JSRef {.compilerproc.} =
|
||||||
else:
|
else:
|
||||||
discard
|
discard
|
||||||
|
|
||||||
proc arrayConstr(len: int, value: JSRef, typ: PNimType): JSRef {.
|
when defined(nimphp):
|
||||||
asmNoStackFrame, compilerproc.} =
|
proc arrayConstr(len: int, value: string, typ: string): JSRef {.
|
||||||
# types are fake
|
asmNoStackFrame, compilerproc.} =
|
||||||
when defined(nimphp):
|
# types are fake
|
||||||
asm """
|
asm """
|
||||||
$result = array();
|
$result = array();
|
||||||
for ($i = 0; $i < `len`; $i++) $result[] = `value`;
|
for ($i = 0; $i < `len`; $i++) $result[] = `value`;
|
||||||
return $result;
|
return $result;
|
||||||
"""
|
"""
|
||||||
else:
|
else:
|
||||||
|
proc arrayConstr(len: int, value: JSRef, typ: PNimType): JSRef {.
|
||||||
|
asmNoStackFrame, compilerproc.} =
|
||||||
|
# types are fake
|
||||||
asm """
|
asm """
|
||||||
var result = new Array(`len`);
|
var result = new Array(`len`);
|
||||||
for (var i = 0; i < `len`; ++i) result[i] = nimCopy(null, `value`, `typ`);
|
for (var i = 0; i < `len`; ++i) result[i] = nimCopy(null, `value`, `typ`);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue