每条规则都会在kompile
时间进行排序检查以保持排序,因此不需要在运行时进行检查。如果有正确种类的东西进来,就会有正确种类的东西出来。
单元格<k>
得到 sort K
,至少例如,在这个定义中:https ://github.com/kframework/evm-semantics/blob/272608d70f363ed3d8d921887b98a26102a03032/evm.md#configuration
它导致compiled.txt
(在 找到.build/defn/java/driver-kompiled/compiled.txt
),它看起来像:
...
syntax KCell ::= "project:KCell" "(" K ")" [function, projection]
syntax KCell ::= "initKCell" "(" Map ")" [function, initializer, noThread]
syntax KCell ::= "<k>" K "</k>" [cell, cellName(k), contentStartColumn(7), contentStartLine(31), format(%1%i%n%2%d%n%3), maincell, org.kframework.definition.Production(syntax #RuleContent ::= #RuleBody [klabel(#ruleNoConditions), symbol])]
...
但其他细胞得到更具体的种类:
...
syntax JumpDestsCell ::= "project:JumpDestsCell" "(" K ")" [function, projection]
syntax JumpDestsCell ::= "initJumpDestsCell" [function, initializer, noThread]
syntax JumpDestsCell ::= "<jumpDests>" Set "</jumpDests>" [cell, cellName(jumpDests), contentStartColumn(7), contentStartLine(31), format(%1%i%n%2%d%n%3), org.kframework.definition.Production(syntax #RuleContent ::= #RuleBody [klabel(#ruleNoConditions), symbol])]
...
我不确定 K 如何决定<k>
单元格需要排序K
,但我认为它不是基于分析规则。我认为它很可能$PGM
在该单元格中看到,因此它添加了maincell
您看到的属性并赋予它 sort K
。Everthing 是K
.
我相当确定它在配置中没有任何 $
变量赋予它 sort K
,因为<chainID>
KEVM 中的单元格获取这些声明:
...
syntax ChainIDCell ::= "project:ChainIDCell" "(" K ")" [function, projection]
syntax ChainIDCell ::= "initChainIDCell" "(" Map ")" [function, initializer, noThread]
syntax ChainIDCell ::= "<chainID>" Int "</chainID>" [cell, cellName(chainID), contentStartColumn(7), contentStartLine(31), format(%1%i%n%2%d%n%3), org.kframework.definition.Production(syntax #RuleContent ::= #RuleBody [klabel(#ruleNoConditions), symbol])]
...
请注意,运算符并没有什么特别之处_~>_
。它在这里声明:https ://github.com/kframework/k/blob/135469ea0ebea96dacf0f9a49261ff1171440c20/k-distribution/include/kframework/builtin/kast.k#L57