mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 01:14:41 +00:00
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:
@@ -731,16 +731,19 @@ proc genericReset(x: JSRef, ti: PNimType): JSRef {.compilerproc.} =
|
||||
else:
|
||||
discard
|
||||
|
||||
proc arrayConstr(len: int, value: JSRef, typ: PNimType): JSRef {.
|
||||
asmNoStackFrame, compilerproc.} =
|
||||
# types are fake
|
||||
when defined(nimphp):
|
||||
when defined(nimphp):
|
||||
proc arrayConstr(len: int, value: string, typ: string): JSRef {.
|
||||
asmNoStackFrame, compilerproc.} =
|
||||
# types are fake
|
||||
asm """
|
||||
$result = array();
|
||||
for ($i = 0; $i < `len`; $i++) $result[] = `value`;
|
||||
return $result;
|
||||
"""
|
||||
else:
|
||||
else:
|
||||
proc arrayConstr(len: int, value: JSRef, typ: PNimType): JSRef {.
|
||||
asmNoStackFrame, compilerproc.} =
|
||||
# types are fake
|
||||
asm """
|
||||
var result = new Array(`len`);
|
||||
for (var i = 0; i < `len`; ++i) result[i] = nimCopy(null, `value`, `typ`);
|
||||
|
||||
Reference in New Issue
Block a user