@@ -5,7 +5,7 @@ module C-EXECUTION-INIT-SYNTAX
55 imports COMMON-SORTS
66 syntax KItem ::= pgmArgs(List) [function]
77 syntax KItem ::= incomingArguments(List)
8- syntax KItem ::= callEntryPoint(String, Int, K )
8+ syntax KItem ::= callEntryPoint(String, Int, KItem )
99 syntax KItem ::= initMainThread(String)
1010 syntax KItem ::= "initMainThread'" "(" String ")"
1111 syntax KItem ::= "callAtExit" | "callAtQuickExit"
@@ -85,23 +85,21 @@ module C-EXECUTION-INIT
8585 => tv(NullPointer, utype(pointerType(type(void))))
8686
8787 syntax Type ::= strType(String) [function]
88- rule strType(S:String)
88+ rule strType(S:: String)
8989 => type(arrayType(type(char), lengthString(S) +Int 1))
9090
91- syntax KItem ::= "incomingArguments-aux" "(" List "," Int ")"
92-
93- rule incomingArguments(L:List) => incomingArguments-aux(L, 0)
91+ rule incomingArguments(L::List) => #incomingArguments(L, 0)
9492 [structural]
95- rule incomingArguments-aux(ListItem(S:String) L:List, N:Int)
93+
94+ syntax KItem ::= #incomingArguments(List, Int)
95+ rule #incomingArguments(ListItem(S:String) L::List, N::Int)
9696 => allocObject(bnew(N +Int 1, strType(S), argv), strType(S))
9797 ~> writeString(lnew(bnew(N +Int 1, strType(S), argv)), S)
98- ~> Initializer(*(mainArguments + tv(N, utype(int)))
99- := lv(lnew(bnew(N +Int 1, strType(S), argv)), strType(S)))
100- ~> incomingArguments-aux(L:List, N:Int +Int 1)
98+ ~> Initializer(*(mainArguments + tv(N, utype(int))) := lv(lnew(bnew(N +Int 1, strType(S), argv)), strType(S)))
99+ ~> #incomingArguments(L, N +Int 1)
101100 [structural]
102- rule incomingArguments-aux(.List, N:Int)
103- => Initializer(*(mainArguments + tv(N, utype(int)))
104- := NullPointerConstant)
101+ rule #incomingArguments(.List, N::Int)
102+ => Initializer(*(mainArguments + tv(N, utype(int))) := NullPointerConstant)
105103 [structural]
106104
107105 rule pgmArgs(L:List)
@@ -193,9 +191,9 @@ module C-EXECUTION-INIT
193191
194192 /*@ this bit of indirection is used to check that the main prototype is
195193 correct, and to call it with the appropriate arguments */
196- rule <k> callEntryPoint(EP::String, N::Int, Args:K )
194+ rule <k> callEntryPoint(EP::String, N::Int, Args::KItem )
197195 => enterRestrictTU
198- ~> reval(#callEntryPoint(EP, N, mainArguments, Args, T))
196+ ~> reval(#callEntryPoint(EP, N, Args, T))
199197 ~> callAtExit
200198 ...</k>
201199 <types>... Identifier(EP) |-> T::Type ...</types>
@@ -206,14 +204,14 @@ module C-EXECUTION-INIT
206204 rule getEntryPoint(_) => "main" [owise]
207205
208206 // int main(void) -- also, int main() gets normalized to main(void)
209- syntax K ::= #callEntryPoint(String, Int, CId, K , Type) [function]
210- rule #callEntryPoint(Entry::String, _, _, _,
207+ syntax K ::= #callEntryPoint(String, Int, KItem , Type) [function]
208+ rule #callEntryPoint(Entry::String, _, _,
211209 t(quals(.Set), _, functionType(ut(.Set, int),
212210 ListItem(typedDeclaration(t(quals(.Set), .Set, void), _)))))
213211 => Call(Identifier(Entry), list(.List))
214212 // int main(int argc, char* argv[]), int main(int argc, char** argv), and old style (no prototype).
215- rule #callEntryPoint(Entry::String, N::Int, X::CId, Args:K , _)
216- => Args ~> Call(Identifier(Entry), list(ListItem(tv(N, utype(int))) ListItem(X )))
213+ rule #callEntryPoint(Entry::String, N::Int, Args::KItem , _)
214+ => Args ~> Call(Identifier(Entry), list(ListItem(tv(N, utype(int))) ListItem(mainArguments )))
217215 [owise]
218216
219217 rule <k> reval(V:RValue) ~> callAtExit => AtExit ~> reval(V) ~> callAtExit ...</k>
@@ -231,8 +229,7 @@ module C-EXECUTION-INIT
231229 <status> _ => mainExited </status>
232230
233231 // fixme I'm not sure threads clean up their memory
234- rule [terminate]:
235- <exec>...
232+ rule <exec>...
236233 (<thread>...
237234 // main's thread, not the global "thread"
238235 <thread-id> 0 </thread-id>
0 commit comments