@@ -77,12 +77,33 @@ The various kinds of rvalues that can appear in MIR.
7777
7878  syntax Unsafety ::= "Unsafe" | "Normal" 
7979
80-   syntax NullaryOp ::= Identifier  "(" Type ")" 
81- 
82-   syntax UnaryOp ::= Identifier "(" Operand ")"  
80+   syntax NullaryOp ::= NullaryOpName  "(" Type ")" 
81+   syntax NullaryOpName ::= "SizeOf"  [token] 
82+                          | "AlignOf" [token]    
8383
84-   syntax BinaryOp ::= Identifier "(" Operand "," Operand ")" 
84+   syntax UnaryOp ::= UnaryOpName "(" Operand ")" 
85+   syntax UnaryOpName ::= "Not" [token] 
86+                        | "Neg" [token] 
8587
88+   syntax BinaryOp ::= BinaryOpName "(" Operand "," Operand ")" 
89+   syntax BinaryOpName ::= "Add"    [token] 
90+                         | "Sub"    [token] 
91+                         | "Mul"    [token] 
92+                         | "Div"    [token] 
93+                         | "Rem"    [token] 
94+                         | "BitXor" [token] 
95+                         | "BitAnd" [token] 
96+                         | "BitOr"  [token] 
97+                         | "Shl"    [token] 
98+                         | "Shr"    [token] 
99+                         | "Eq"     [token] 
100+                         | "Lt"     [token] 
101+                         | "Le"     [token] 
102+                         | "Ne"     [token] 
103+                         | "Ge"     [token] 
104+                         | "Gt"     [token] 
105+                         | "Offset" [token] 
106+                          
86107  syntax Discriminant ::= "discriminant" "(" Place ")" 
87108
88109  syntax CopyForDeref ::= "deref_copy" NonTerminalPlace 
@@ -176,93 +197,12 @@ TODO: these sorts may need refactoring to closer match the `rustc` implementatio
176197endmodule 
177198``` 
178199
179- ### Build-in operations  
180- 
181- ``` k 
182- module MIR-BUILTINS-SYNTAX 
183-   imports BOOL 
184-   imports STRING 
185- 
186-   syntax MirBuiltInToken ::= NullaryOpName 
187-                            | UnaryOpName 
188-                            | BinaryOpName 
189-                            | CheckedBinaryOpName 
190- 
191-   syntax MirBuiltInToken ::= String2MirBuiltInToken(MirBuiltInToken) [function, hook(STRING.token2string)] 
192- 
193-   syntax NullaryOpName ::= "SizeOf"  [token] 
194-                          | "AlignOf" [token] 
195- 
196-   syntax UnaryOpName ::= String2UnaryOpName(String) [function, hook(STRING.string2token)] 
197- 
198-   syntax UnaryOpName ::= "Not" [token] 
199-                        | "Neg" [token] 
200- 
201-   syntax BinaryOpName ::= String2BinaryOpName(String) [function, hook(STRING.string2token)] 
202- 
203-   syntax BinaryOpName ::= "Add"    [token] 
204-                         | "Sub"    [token] 
205-                         | "Mul"    [token] 
206-                         | "Div"    [token] 
207-                         | "Rem"    [token] 
208-                         | "BitXor" [token] 
209-                         | "BitAnd" [token] 
210-                         | "BitOr"  [token] 
211-                         | "Shl"    [token] 
212-                         | "Shr"    [token] 
213-                         | "Eq"     [token] 
214-                         | "Lt"     [token] 
215-                         | "Le"     [token] 
216-                         | "Ne"     [token] 
217-                         | "Ge"     [token] 
218-                         | "Gt"     [token] 
219-                         | "Offset" [token] 
220- 
221-   syntax Bool ::= isUnOp(String) [function, total] 
222-   //---------------------------------------------- 
223-   rule isUnOp(OP_NAME)  => true 
224-     requires OP_NAME ==String "Not" 
225-       orBool OP_NAME ==String "Neg" 
226-   rule isUnOp(_)       => false [owise] 
227- 
228-   syntax Bool ::= isBinOp(String) [function, total] 
229-   //----------------------------------------------- 
230-   rule isBinOp(OP_NAME)  => true 
231-     requires OP_NAME ==String "Add" 
232-       orBool OP_NAME ==String "Sub" 
233-       orBool OP_NAME ==String "Mul" 
234-       orBool OP_NAME ==String "Div" 
235-       orBool OP_NAME ==String "Rem" 
236-       orBool OP_NAME ==String "BitXor" 
237-       orBool OP_NAME ==String "BitAnd" 
238-       orBool OP_NAME ==String "BitOr" 
239-       orBool OP_NAME ==String "Shl" 
240-       orBool OP_NAME ==String "Shr" 
241-       orBool OP_NAME ==String "Eq" 
242-       orBool OP_NAME ==String "Lt" 
243-       orBool OP_NAME ==String "Le" 
244-       orBool OP_NAME ==String "Ne" 
245-       orBool OP_NAME ==String "Ge" 
246-       orBool OP_NAME ==String "Gt" 
247-       orBool OP_NAME ==String "Offset" 
248-   rule isBinOp(_)       => false [owise] 
249- 
250-   syntax CheckedBinaryOpName ::= "CheckedAdd" 
251-                                | "CheckedSub" 
252-                                | "CheckedMul" 
253-                                | "CheckedShl" 
254-                                | "CheckedShr" 
255- 
256- endmodule 
257- ``` 
258- 
259200Evaluation of rvalues
260201--------------------- 
261202
262203``` k 
263204module MIR-RVALUE 
264205  imports MIR-RVALUE-SYNTAX 
265-   imports MIR-BUILTINS-SYNTAX 
266206  imports MIR-TYPES 
267207  imports MIR-CONFIGURATION 
268208``` 
@@ -293,8 +233,8 @@ Evaluate a syntactic `RValue` into a semantics `RValueResult`. Inspired by [eval
293233``` k 
294234  syntax MIRValue ::= evalUnaryOp(FunctionLikeKey, UnaryOp) [function] 
295235  //------------------------------------------------------------------ 
296-   rule evalUnaryOp(FN_KEY, NAME:IdentifierToken  (X:Operand)) => 
297-        evalUnaryOpImpl(FN_KEY, String2UnaryOpName(IdentifierToken2String( NAME)) , X) 
236+   rule evalUnaryOp(FN_KEY, NAME:UnaryOpName  (X:Operand)) => 
237+        evalUnaryOpImpl(FN_KEY, NAME, X) 
298238
299239  syntax MIRValue ::= evalUnaryOpImpl(FunctionLikeKey, UnaryOpName, Operand) [function] 
300240  //----------------------------------------------------------------------------------- 
@@ -307,8 +247,8 @@ Evaluate a syntactic `RValue` into a semantics `RValueResult`. Inspired by [eval
307247``` k 
308248  syntax MIRValue ::= evalBinaryOp(FunctionLikeKey, BinaryOp) [function] 
309249  //-------------------------------------------------------------------- 
310-   rule evalBinaryOp(FN_KEY, NAME:IdentifierToken  (X:Operand, Y:Operand)) => 
311-        evalBinaryOpImpl(FN_KEY, String2BinaryOpName(IdentifierToken2String( NAME)) , X, Y) 
250+   rule evalBinaryOp(FN_KEY, NAME:BinaryOpName  (X:Operand, Y:Operand)) => 
251+        evalBinaryOpImpl(FN_KEY, NAME, X, Y) 
312252
313253  syntax MIRValue ::= evalBinaryOpImpl(FunctionLikeKey, BinaryOpName, Operand, Operand) [function] 
314254  //----------------------------------------------------------------------- 
@@ -328,7 +268,7 @@ Evaluate a syntactic `RValue` into a semantics `RValueResult`. Inspired by [eval
328268  rule evalBinaryOpImpl(FN_KEY, Ne, X, Y)     => {evalOperand(FN_KEY, X)}:>Int =/=Int {evalOperand(FN_KEY, Y)}:>Int 
329269  rule evalBinaryOpImpl(FN_KEY, Ge, X, Y)     => {evalOperand(FN_KEY, X)}:>Int >=Int {evalOperand(FN_KEY, Y)}:>Int 
330270  rule evalBinaryOpImpl(FN_KEY, Gt, X, Y)     => {evalOperand(FN_KEY, X)}:>Int >Int {evalOperand(FN_KEY, Y)}:>Int 
331-   // rule evalBinaryOpImpl("Offset",  X, Y) => "not implemented"  
271+   // rule evalBinaryOpImpl(FN_KEY, _,  X, Y) => "not supported" [owise]  
332272``` 
333273
334274### Constant evaluation.  
0 commit comments