我正在为idris(idris代码(缩写))编写后端
main = putStrLn "hello"
生成了此内容:
(SLet
(Loc 1)
(SLet
(Loc 1)
(SConst "hello\n")
(SOp LWriteStr [Loc 0,Loc 1]))
(SCon Nothing 0 MkUnit [])
)
如何了解那里的Loc n
?与德布吕金指数有关吗?
答案 0 :(得分:1)
这是一个#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
int main (void)
{
uint64_t a;
scanf ("%" SCNu32 "%" SCNu32,
&((uint32_t*)(void*)&a)[0], &((uint32_t*)(void*)&a)[1]);
printf ("%" PRIu64, (uint64_t)((uint32_t*)(void*)&a)[0] +
((uint32_t*)(void*)&a)[1]);
}
,而不是SExp
,因此尚未进行Bruijn化:
TT
Module : IRTS.Simplified
Description : Simplified expressions, where functions/constructors can only be applied to variables.
只是生成的标识符,因此在您的示例中,内部SLoc n
确实遮盖了外部(未使用)SLet
;它可以加糖
SLet
或为变量分配唯一名称,
let v1 = let v1 = "hello\n" in writeStr v0 v1
in v1
请注意,此片段中未绑定let v1 = let v2 = "hello\n" in writeStr v0 v2
in v1
的{{1}}参数;我想这将是传递给Loc 0
的{{1}}世界令牌,因此整个LWriteStr
将是
IO