@@ -13,8 +13,10 @@ import {
1313 CallbackMapping ,
1414 Checkpoint ,
1515 Command ,
16+ ContinueFor ,
1617 Event as ProtocolEvent ,
1718 EventsQueue ,
19+ FunctionRef ,
1820 FunctionMessage ,
1921 HitBreakpoint ,
2022 Inspect as ProtocolInspect ,
@@ -26,6 +28,8 @@ import {
2628 RemoteFunctionCall ,
2729 ValueUpdate ,
2830 Snapshot ,
31+ SnapshotPolicyConfig ,
32+ Override ,
2933 Value as ProtocolValue
3034} from '../protocol/vendor/debug' ;
3135
@@ -172,6 +176,20 @@ export namespace Message {
172176 } ;
173177 }
174178
179+ export function updateGlobal ( index : number , value : ProtocolValue ) : Request < OperationResult > {
180+ if ( ! Number . isInteger ( index ) || index < 0 || value === undefined ) throw Error ( "A global update requires a non-negative integer index and a value." ) ;
181+ return { ...operation ( Command . COMMAND_UPDATE_GLOBAL ) , payload : ( ) => ValueUpdate . encode ( { index, value} ) . finish ( ) } ;
182+ }
183+
184+ export function updateStack ( index : number , value : ProtocolValue ) : Request < OperationResult > {
185+ if ( ! Number . isInteger ( index ) || index < 0 || value === undefined ) throw Error ( "A stack update requires a non-negative integer index and a value." ) ;
186+ return { ...operation ( Command . COMMAND_UPDATE_STACK ) , payload : ( ) => ValueUpdate . encode ( { index, value} ) . finish ( ) } ;
187+ }
188+
189+ export function updateCallbacks ( callbacks : CallbackMapping ) : Request < OperationResult > {
190+ return { ...operation ( Command . COMMAND_UPDATE_CALLBACKS ) , payload : ( ) => CallbackMapping . encode ( callbacks ) . finish ( ) } ;
191+ }
192+
175193 export async function uploadFile ( program : string ) : Promise < Request < OperationResult > > {
176194 const compiled : CompileOutput = await new CompilerFactory ( WABT ) . pickCompiler ( program ) . compile ( program ) ;
177195 return updateModule ( compiled . file ) ;
@@ -238,6 +256,43 @@ export namespace Message {
238256 parser : notificationParsers [ NotificationType . NOTIFICATION_SNAPSHOT ]
239257 }
240258
259+ export function loadSnapshot ( snapshot : Snapshot ) : Request < OperationResult > {
260+ return { ...operation ( Command . COMMAND_LOAD_SNAPSHOT ) , payload : ( ) => Snapshot . encode ( snapshot ) . finish ( ) } ;
261+ }
262+
263+ export function addProxy ( functionRef : FunctionRef ) : Request < OperationResult > {
264+ return { ...operation ( Command . COMMAND_ADD_PROXY ) , payload : ( ) => FunctionRef . encode ( functionRef ) . finish ( ) } ;
265+ }
266+
267+ export function removeProxy ( functionRef : FunctionRef ) : Request < OperationResult > {
268+ return { ...operation ( Command . COMMAND_REMOVE_PROXY ) , payload : ( ) => FunctionRef . encode ( functionRef ) . finish ( ) } ;
269+ }
270+
271+ export function proxyCall ( call : RemoteFunctionCall ) : Request < WasmValue < Type > | Exception > {
272+ return { type : Command . COMMAND_PROXY_CALL , notification : NotificationType . NOTIFICATION_REMOTE_FUNCTION_RESULT , payload : ( ) => RemoteFunctionCall . encode ( call ) . finish ( ) , parser : notificationParsers [ NotificationType . NOTIFICATION_REMOTE_FUNCTION_RESULT ] } ;
273+ }
274+
275+ export function continueFor ( continuation : ContinueFor ) : Request < Checkpoint > {
276+ return { type : Command . COMMAND_CONTINUE_FOR , notification : NotificationType . NOTIFICATION_CHECKPOINT , payload : ( ) => ContinueFor . encode ( continuation ) . finish ( ) , parser : notificationParsers [ NotificationType . NOTIFICATION_CHECKPOINT ] } ;
277+ }
278+
279+ export const popEvent : Request < OperationResult > = operation ( Command . COMMAND_POP_EVENT ) ;
280+
281+ export function setOverride ( override : Override ) : Request < OperationResult > {
282+ return { ...operation ( Command . COMMAND_SET_OVERRIDE ) , payload : ( ) => Override . encode ( override ) . finish ( ) } ;
283+ }
284+
285+ export function removeOverride ( override : Override ) : Request < OperationResult > {
286+ return { ...operation ( Command . COMMAND_REMOVE_OVERRIDE ) , payload : ( ) => Override . encode ( override ) . finish ( ) } ;
287+ }
288+
289+ export function setSnapshotPolicy ( config : SnapshotPolicyConfig ) : Request < OperationResult > {
290+ return {
291+ ...operation ( Command . COMMAND_SET_SNAPSHOT_POLICY ) ,
292+ payload : ( ) => SnapshotPolicyConfig . encode ( config ) . finish ( )
293+ } ;
294+ }
295+
241296 /** The protocol default range (0, 0) requests the complete event queue. */
242297 export const dumpAllEvents : Request < EventsQueue > = {
243298 type : Command . COMMAND_DUMP_EVENTS ,
0 commit comments