【发布时间】:2019-08-31 09:04:28
【问题描述】:
在对sicstus-prolog 进行黑客攻击的背景下,我想看看 SICStus Prolog 生成的warren-abstract-machine 代码。 例如,让我们剖析以下谓词!
is_list([]).
is_list([_|Es]) :- is_list(Es).
这是我现在正在做的事情:
-
将
is_list__clause1(dummy1). % 虚拟子句 is_list__clause1([])。 is_list__clause2(dummy2). % 虚拟子句 is_list__clause2([_|Es]) :- is_list(Es)。is_list/1的2个子句拆分为2个独立的谓词,并在前面加上2个虚拟子句: -
(Ab-)像这样使用 SICStus prolog-toplevel:
| ?- is_list__clause1(X). X = 虚拟 1 ? t … 0x7eff37281300:GET_NIL_X0 0x7eff37281304:继续 0x7eff37281308:END_OF_CLAUSEQ 用户:is_list__clause1/1 … | ?- is_list__clause2(X). X = 虚拟 2 ? t … 0x7eff37281150:GET_LIST_X0 0x7eff37281154: U2_VOID_XVAR 1,x(0) 0x7eff37281160:执行用户:is_list/1 0x7eff37281170:END_OF_CLAUSEQ 用户:is_list__clause2/1 …
这个输出——尽管有点神秘——让我对 WAM 级别的情况有所了解。我喜欢!
但是已经有一个更简单的方法......请帮忙!
【问题讨论】:
-
你确定是 WAM 吗?见:SICStus Prolog—the first 25 years本来以为SWI-Prolog没有抽象机,后来发现是基于ZIPSWI-Prolog Implementation historySICStusWhat Is New In Release 4
-
但是在 2019 年 4 月的 Sicstus 手册中,4.5.1 版本指出:
The system consists of a WAM emulator written in C, a library and runtime system written in C and Prolog and an interpreter and a compiler written in Prolog. The Prolog engine is a Warren Abstract Machine (WAM) emulator [Warren 83]. -
此版本早于第 4 版,并且由于版本似乎是完全重写的,因此很可能已将其忽略:The SICStus Emulator 由 Mats Carlsson 1991 年 9 月 -- 发现于:Prolog and Logic Programming Historical Sources Archive
-
@GuyCoder。我发现历史资料档案非常有趣。这对我来说是新的,所以你的 cmets 非常有帮助。不要让互联网拖累你。 ☮
-
谢谢。我不会让互联网拖累我。我已经将我的重心从 StackOverflow 转移到了SWI-Prolog Discourse forum 上,通过 Prolog 在线帮助其他人。我把历史资料档案作为链接放在Useful Prolog references上。
标签: clpz sicstus-prolog warren-abstract-machine prolog-toplevel prolog sicstus-prolog warren-abstract-machine