@@ -7,7 +7,17 @@ import os.signpost
77#endif
88
99struct Run : ParsableCommand {
10- @Flag
10+ static let configuration = CommandConfiguration (
11+ abstract: " Run a WebAssembly module " ,
12+ discussion: """
13+ This command will parse a WebAssembly module and run it.
14+ """
15+ )
16+
17+ @Flag (
18+ name: . shortAndLong,
19+ help: " Enable verbose logging "
20+ )
1121 var verbose = false
1222
1323 @Option (
@@ -47,14 +57,41 @@ struct Run: ParsableCommand {
4757 @Option ( name: . customLong( " dir " ) , help: " Grant access to the given host directory " )
4858 var directories : [ String ] = [ ]
4959
50- enum ThreadingModel : String , ExpressibleByArgument {
60+ enum ThreadingModel : String , ExpressibleByArgument , CaseIterable {
5161 case direct
5262 case token
63+
64+ func resolve( ) -> EngineConfiguration . ThreadingModel {
65+ switch self {
66+ case . direct: return . direct
67+ case . token: return . token
68+ }
69+ }
5370 }
5471
5572 @Option ( help: ArgumentHelp ( " The execution threading model to use " , visibility: . hidden) )
5673 var threadingModel : ThreadingModel ?
5774
75+ enum CompilationMode : String , ExpressibleByArgument , CaseIterable {
76+ case eager
77+ case lazy
78+
79+ func resolve( ) -> EngineConfiguration . CompilationMode {
80+ switch self {
81+ case . eager: return . eager
82+ case . lazy: return . lazy
83+ }
84+ }
85+ }
86+
87+ @Option (
88+ help: ArgumentHelp (
89+ " The compilation mode to use for WebAssembly modules " ,
90+ valueName: " mode " , visibility: . hidden
91+ )
92+ )
93+ var compilationMode : CompilationMode ?
94+
5895 @Option (
5996 help: ArgumentHelp (
6097 " The size of the interpreter stack in bytes " ,
@@ -151,13 +188,11 @@ struct Run: ParsableCommand {
151188 }
152189
153190 private func deriveRuntimeConfiguration( ) -> EngineConfiguration {
154- let threadingModel : EngineConfiguration . ThreadingModel ?
155- switch self . threadingModel {
156- case . direct: threadingModel = . direct
157- case . token: threadingModel = . token
158- case nil : threadingModel = nil
159- }
160- return EngineConfiguration ( threadingModel: threadingModel, stackSize: self . stackSize)
191+ return EngineConfiguration (
192+ threadingModel: threadingModel? . resolve ( ) ,
193+ compilationMode: compilationMode? . resolve ( ) ,
194+ stackSize: self . stackSize
195+ )
161196 }
162197
163198 func instantiateWASI( module: Module , interceptor: EngineInterceptor ? ) throws -> ( ) throws -> Void {
0 commit comments