@ton/sandbox 0.42.0 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/blockchain/Blockchain.d.ts +1 -6
  2. package/dist/blockchain/Blockchain.js +0 -15
  3. package/dist/blockchain/SmartContract.d.ts +0 -3
  4. package/dist/blockchain/SmartContract.js +1 -39
  5. package/dist/config/config.tlb-gen.d.ts +69 -18
  6. package/dist/config/config.tlb-gen.js +273 -53
  7. package/dist/config/defaultConfig.d.ts +2 -2
  8. package/dist/config/defaultConfig.js +2 -2
  9. package/dist/config/slimConfig.d.ts +2 -2
  10. package/dist/config/slimConfig.js +2 -2
  11. package/dist/executor/Executor.d.ts +1 -37
  12. package/dist/executor/Executor.js +3 -160
  13. package/dist/executor/emulator-emscripten.js +1 -1
  14. package/dist/executor/emulator-emscripten.wasm.js +1 -1
  15. package/dist/index.d.ts +0 -1
  16. package/dist/index.js +1 -3
  17. package/package.json +3 -5
  18. package/dist/debugger/DebugContext.d.ts +0 -14
  19. package/dist/debugger/DebugContext.js +0 -29
  20. package/dist/debugger/DebugInfoCache.d.ts +0 -9
  21. package/dist/debugger/DebugInfoCache.js +0 -87
  22. package/dist/debugger/Debuggee.d.ts +0 -147
  23. package/dist/debugger/Debuggee.js +0 -451
  24. package/dist/debugger/TVMDebugSession.d.ts +0 -26
  25. package/dist/debugger/TVMDebugSession.js +0 -272
  26. package/dist/debugger/debug.d.ts +0 -4
  27. package/dist/debugger/debug.js +0 -76
  28. package/dist/debugger/index.d.ts +0 -1
  29. package/dist/debugger/index.js +0 -5
  30. package/dist/debugger/marks.d.ts +0 -2
  31. package/dist/debugger/marks.js +0 -127
  32. package/dist/executor/emulator-emscripten.debugger.bpatch.gzip.js +0 -1
  33. package/dist/executor/emulator-emscripten.debugger.js +0 -20
  34. package/dist/utils/bpatch.d.ts +0 -9
  35. package/dist/utils/bpatch.js +0 -52
@@ -1,451 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Debuggee = void 0;
7
- const node_events_1 = __importDefault(require("node:events"));
8
- class Debuggee extends node_events_1.default {
9
- executor;
10
- ptr = 0;
11
- debugType = 'get';
12
- sourceMap = {};
13
- availableLines = {};
14
- breakpoints = new Map();
15
- breakpointID = 0;
16
- frames = [];
17
- globals = [];
18
- debugMarks = new Map();
19
- tryContexts = [];
20
- finishedCallback;
21
- constructor(executor, finishedCallback) {
22
- super();
23
- this.executor = executor;
24
- this.executor.debugLogFunc = (s) => {
25
- this.sendEvent('output', s);
26
- };
27
- this.finishedCallback = finishedCallback;
28
- }
29
- setDebugInfo(debugInfo) {
30
- this.setSourceMap(debugInfo.sourceMap);
31
- this.setGlobals(debugInfo.globals);
32
- this.setDebugMarks(debugInfo.marks);
33
- }
34
- setDebugMarks(marks) {
35
- this.debugMarks = marks;
36
- }
37
- setSourceMap(sourceMap) {
38
- this.sourceMap = sourceMap;
39
- for (const di in sourceMap) {
40
- const sem = sourceMap[di];
41
- if (!(sem.path in this.availableLines)) {
42
- this.availableLines[sem.path] = [];
43
- }
44
- this.availableLines[sem.path].push(sem.line);
45
- }
46
- }
47
- setGlobals(globals) {
48
- this.globals = globals;
49
- }
50
- getAvailableSourcePaths() {
51
- return Object.keys(this.availableLines);
52
- }
53
- getAvailableLines(path) {
54
- return this.availableLines[path] ?? [];
55
- }
56
- isLineAvailable(path, line) {
57
- if (!(path in this.availableLines)) {
58
- return false;
59
- }
60
- const lines = this.availableLines[path];
61
- return lines.indexOf(line) >= 0;
62
- }
63
- continue() {
64
- this.stepUntil({ type: 'breakpoint' });
65
- }
66
- stepIn() {
67
- this.stepUntil({ type: 'any-line', stopEvent: 'stopOnStep' });
68
- }
69
- stepOver() {
70
- this.stepUntil({ type: 'next-line' });
71
- }
72
- stepOut() {
73
- this.stepUntil({ type: 'out' });
74
- }
75
- startGetMethod(args) {
76
- this.ptr = this.executor.sbsGetMethodSetup(args);
77
- this.debugType = 'get';
78
- }
79
- startTransaction(args) {
80
- const { emptr, res } = this.executor.sbsTransactionSetup(args);
81
- if (res !== 1) {
82
- throw new Error('Could not setup SBS transaction, result: ' + res);
83
- }
84
- this.ptr = emptr;
85
- this.debugType = 'tx';
86
- }
87
- getC7() {
88
- switch (this.debugType) {
89
- case 'get':
90
- return this.executor.sbsGetMethodC7(this.ptr);
91
- case 'tx':
92
- return this.executor.sbsTransactionC7(this.ptr);
93
- }
94
- }
95
- vmStep() {
96
- switch (this.debugType) {
97
- case 'get':
98
- return this.executor.sbsGetMethodStep(this.ptr);
99
- case 'tx':
100
- return this.executor.sbsTransactionStep(this.ptr);
101
- }
102
- }
103
- codePos() {
104
- switch (this.debugType) {
105
- case 'get':
106
- return this.executor.sbsGetMethodCodePos(this.ptr);
107
- case 'tx':
108
- return this.executor.sbsTransactionCodePos(this.ptr);
109
- }
110
- }
111
- getStack() {
112
- switch (this.debugType) {
113
- case 'get':
114
- return this.executor.sbsGetMethodStack(this.ptr);
115
- case 'tx':
116
- return this.executor.sbsTransactionStack(this.ptr);
117
- }
118
- }
119
- getContDistinguisher() {
120
- switch (this.debugType) {
121
- case 'get':
122
- return this.executor.sbsGetMethodGetContDistinguisher(this.ptr);
123
- case 'tx':
124
- return this.executor.sbsTransactionGetContDistinguisher(this.ptr);
125
- }
126
- }
127
- setContDistinguishers(distinguisher, trueDistinguisher, falseDistinguisher) {
128
- switch (this.debugType) {
129
- case 'get':
130
- this.executor.sbsGetMethodSetContDistinguishers(this.ptr, distinguisher, trueDistinguisher, falseDistinguisher);
131
- break;
132
- case 'tx':
133
- this.executor.sbsTransactionSetContDistinguishers(this.ptr, distinguisher, trueDistinguisher, falseDistinguisher);
134
- break;
135
- }
136
- }
137
- getContDistinguisherTriggered() {
138
- switch (this.debugType) {
139
- case 'get':
140
- return this.executor.sbsGetMethodGetContDistinguisherTriggered(this.ptr);
141
- case 'tx':
142
- return this.executor.sbsTransactionGetContDistinguisherTriggered(this.ptr);
143
- }
144
- }
145
- setTryParams(primed, triggered) {
146
- switch (this.debugType) {
147
- case 'get':
148
- this.executor.sbsGetMethodSetTryParams(this.ptr, primed, triggered);
149
- break;
150
- case 'tx':
151
- this.executor.sbsTransactionSetTryParams(this.ptr, primed, triggered);
152
- break;
153
- }
154
- }
155
- getTriggeredTryParam() {
156
- switch (this.debugType) {
157
- case 'get':
158
- return this.executor.sbsGetMethodGetTriggeredTryParam(this.ptr);
159
- case 'tx':
160
- return this.executor.sbsTransactionGetTriggeredTryParam(this.ptr);
161
- }
162
- }
163
- getLocalVariables() {
164
- const sme = this.currentSourceMapEntry(false);
165
- if (sme === undefined || sme.type !== 'statement') {
166
- return undefined;
167
- }
168
- const vars = [];
169
- const stack = this.getStack();
170
- for (let i = 0; i < sme.variables.length; i++) {
171
- vars.push({
172
- name: sme.variables[i],
173
- value: stack[i],
174
- });
175
- }
176
- return vars;
177
- }
178
- getGlobalVariables() {
179
- const vars = [];
180
- const c7item = this.getC7();
181
- if (c7item.type !== 'tuple') {
182
- return undefined;
183
- }
184
- const c7 = c7item.items;
185
- for (let i = 0; i < this.globals.length; i++) {
186
- if (i + 1 < c7.length) {
187
- vars.push({
188
- name: this.globals[i].name,
189
- value: c7[i + 1],
190
- });
191
- continue;
192
- }
193
- vars.push({
194
- name: this.globals[i].name,
195
- value: { type: 'null' },
196
- });
197
- }
198
- return vars;
199
- }
200
- currentDebugMarks() {
201
- const codepos = this.codePos();
202
- return this.debugMarks.get(codepos.hash)?.get(codepos.offset);
203
- }
204
- currentSourceMapEntry(honorStepped) {
205
- const dms = this.currentDebugMarks();
206
- if (dms === undefined) {
207
- return undefined;
208
- }
209
- let currentContextId;
210
- let stepped;
211
- if (this.frames.length > 0) {
212
- const topFrame = this.frames[this.frames.length - 1];
213
- currentContextId = topFrame.contextId;
214
- stepped = topFrame.stepped;
215
- }
216
- for (const dm of dms) {
217
- const entry = this.sourceMap[dm];
218
- if ((entry.type === 'statement' &&
219
- entry.firstStatement &&
220
- entry.requireContextId === undefined &&
221
- (stepped || !honorStepped)) ||
222
- entry.requireContextId === currentContextId) {
223
- return entry;
224
- }
225
- }
226
- return undefined;
227
- }
228
- breakpointKey(path, line) {
229
- return path + ':' + line;
230
- }
231
- splitBreakpointKey(k) {
232
- const i = k.lastIndexOf(':');
233
- return {
234
- path: k.slice(0, i),
235
- line: parseInt(k.slice(i + 1)),
236
- };
237
- }
238
- clearBreakpoints(path) {
239
- this.breakpoints.set(path, []);
240
- }
241
- hasBreakpoint(path, line) {
242
- return (this.breakpoints.get(path) ?? []).findIndex((v) => v.line === line) >= 0;
243
- }
244
- setBreakpoint(path, line) {
245
- let arr = this.breakpoints.get(path);
246
- if (arr === undefined) {
247
- arr = [];
248
- this.breakpoints.set(path, arr);
249
- }
250
- const bp = {
251
- id: this.breakpointID++,
252
- line,
253
- verified: this.isLineAvailable(path, line),
254
- };
255
- arr.push(bp);
256
- return bp;
257
- }
258
- sendEvent(event, ...args) {
259
- setTimeout(() => {
260
- this.emit(event, ...args);
261
- }, 0);
262
- }
263
- onFinished() {
264
- this.sendEvent('end');
265
- let r;
266
- switch (this.debugType) {
267
- case 'get': {
268
- r = this.executor.sbsGetMethodResult(this.ptr);
269
- this.executor.destroyTvmEmulator(this.ptr);
270
- break;
271
- }
272
- case 'tx': {
273
- r = this.executor.sbsTransactionResult(this.ptr);
274
- this.executor.destroyEmulator(this.ptr);
275
- break;
276
- }
277
- }
278
- this.finishedCallback(r);
279
- }
280
- stackFrames() {
281
- return this.frames;
282
- }
283
- applySourceMapEntry(sme, until) {
284
- let stopStepping = false;
285
- switch (sme.type) {
286
- case 'statement': {
287
- if (sme.firstStatement) {
288
- this.frames.push({
289
- function: sme.function,
290
- path: sme.path,
291
- line: sme.line,
292
- contextId: sme.contextId,
293
- shouldTryNoStep: true,
294
- nextContextId: sme.contextId,
295
- stepped: false,
296
- });
297
- }
298
- if (this.frames.length > 0) {
299
- const topFrame = this.frames[this.frames.length - 1];
300
- topFrame.line = sme.line;
301
- }
302
- switch (until.type) {
303
- case 'breakpoint': {
304
- if (this.hasBreakpoint(sme.path, sme.line)) {
305
- this.sendEvent('stopOnBreakpoint');
306
- stopStepping = true;
307
- }
308
- break;
309
- }
310
- case 'any-line': {
311
- this.sendEvent(until.stopEvent);
312
- stopStepping = true;
313
- break;
314
- }
315
- case 'next-line': {
316
- if (this.frames.length <= until.depth) {
317
- this.sendEvent('stopOnStep');
318
- stopStepping = true;
319
- }
320
- break;
321
- }
322
- case 'out': {
323
- if (this.frames.length < until.depth) {
324
- this.sendEvent('stopOnStep');
325
- stopStepping = true;
326
- }
327
- break;
328
- }
329
- }
330
- break;
331
- }
332
- case 'return': {
333
- this.frames.pop();
334
- return { stopStepping };
335
- }
336
- case 'try_begin': {
337
- this.tryContexts.push({
338
- contextId: sme.catchContextId,
339
- frameDepth: this.frames.length,
340
- });
341
- this.setTryParams(this.tryContexts.length - 1, -1);
342
- break;
343
- }
344
- case 'try_end': {
345
- this.tryContexts.pop();
346
- this.setTryParams(-1, -1);
347
- break;
348
- }
349
- case 'branch': {
350
- let falseId = -1;
351
- if (sme.falseContextId !== undefined) {
352
- falseId = sme.falseContextId;
353
- }
354
- this.setContDistinguishers(-1, sme.trueContextId, falseId);
355
- break;
356
- }
357
- }
358
- if (this.frames.length > 0) {
359
- const topFrame = this.frames[this.frames.length - 1];
360
- topFrame.shouldTryNoStep = true;
361
- topFrame.nextContextId = sme.contextId;
362
- }
363
- return { stopStepping };
364
- }
365
- stepUntil(what) {
366
- let until;
367
- switch (what.type) {
368
- case 'next-line':
369
- case 'out': {
370
- until = { type: what.type, depth: this.frames.length };
371
- break;
372
- }
373
- default:
374
- until = what;
375
- }
376
- while (true) {
377
- if (this.frames.length > 0) {
378
- const topFrame = this.frames[this.frames.length - 1];
379
- while (topFrame.shouldTryNoStep) {
380
- topFrame.contextId = topFrame.nextContextId;
381
- const sme = this.currentSourceMapEntry(true);
382
- if (sme === undefined) {
383
- topFrame.shouldTryNoStep = false;
384
- break;
385
- }
386
- const { stopStepping } = this.applySourceMapEntry(sme, until);
387
- if (stopStepping) {
388
- return;
389
- }
390
- }
391
- }
392
- if (this.frames.length > 0) {
393
- const topFrame = this.frames[this.frames.length - 1];
394
- topFrame.stepped = true;
395
- }
396
- const finished = this.vmStep();
397
- if (finished) {
398
- this.onFinished();
399
- return;
400
- }
401
- const triggeredTryParam = this.getTriggeredTryParam();
402
- if (triggeredTryParam >= 0) {
403
- if (triggeredTryParam !== this.tryContexts.length - 1) {
404
- throw new Error(`Got triggered try param ${triggeredTryParam} but expected ${this.tryContexts.length - 1}`);
405
- }
406
- const tryContext = this.tryContexts[triggeredTryParam];
407
- this.tryContexts.pop();
408
- this.setTryParams(-1, -1);
409
- this.frames = this.frames.slice(0, tryContext.frameDepth);
410
- this.frames[this.frames.length - 1].contextId = tryContext.contextId;
411
- }
412
- if (this.getContDistinguisherTriggered()) {
413
- const distinguisher = this.getContDistinguisher();
414
- this.setContDistinguishers(-1, -1, -1);
415
- if (distinguisher >= 0 && this.frames.length > 0) {
416
- const topFrame = this.frames[this.frames.length - 1];
417
- topFrame.contextId = distinguisher;
418
- }
419
- }
420
- const sme = this.currentSourceMapEntry(true);
421
- if (sme !== undefined) {
422
- const { stopStepping } = this.applySourceMapEntry(sme, until);
423
- if (stopStepping) {
424
- return;
425
- }
426
- }
427
- }
428
- }
429
- prepareGetMethod(args, debugInfo) {
430
- this.startGetMethod(args);
431
- this.setDebugInfo(debugInfo);
432
- }
433
- prepareTransaction(args, debugInfo) {
434
- this.startTransaction(args);
435
- this.setDebugInfo(debugInfo);
436
- }
437
- start(debug, stopOnEntry) {
438
- if (debug) {
439
- if (stopOnEntry) {
440
- this.stepUntil({ type: 'any-line', stopEvent: 'stopOnBreakpoint' });
441
- }
442
- else {
443
- this.continue();
444
- }
445
- }
446
- else {
447
- this.continue();
448
- }
449
- }
450
- }
451
- exports.Debuggee = Debuggee;
@@ -1,26 +0,0 @@
1
- import { LoggingDebugSession } from '@vscode/debugadapter';
2
- import { DebugProtocol } from '@vscode/debugprotocol';
3
- import { Debuggee } from './Debuggee';
4
- export declare class TVMDebugSession extends LoggingDebugSession {
5
- static readonly threadID = 1;
6
- static readonly stackFrameID = 1;
7
- static readonly localVariablesReference = 1;
8
- static readonly globalVariablesReference = 2;
9
- debuggee: Debuggee;
10
- constructor(debuggee: Debuggee);
11
- protected initializeRequest(response: DebugProtocol.InitializeResponse, _args: DebugProtocol.InitializeRequestArguments): void;
12
- protected loadedSourcesRequest(response: DebugProtocol.LoadedSourcesResponse, _args: DebugProtocol.LoadedSourcesArguments, _request?: DebugProtocol.Request | undefined): void;
13
- protected breakpointLocationsRequest(response: DebugProtocol.BreakpointLocationsResponse, args: DebugProtocol.BreakpointLocationsArguments, _request?: DebugProtocol.Request | undefined): void;
14
- protected launchRequest(response: DebugProtocol.LaunchResponse, args: DebugProtocol.LaunchRequestArguments, _request?: DebugProtocol.Request | undefined): void;
15
- protected attachRequest(response: DebugProtocol.AttachResponse, args: DebugProtocol.AttachRequestArguments, request?: DebugProtocol.Request | undefined): void;
16
- protected setBreakPointsRequest(response: DebugProtocol.SetBreakpointsResponse, args: DebugProtocol.SetBreakpointsArguments, _request?: DebugProtocol.Request | undefined): void;
17
- protected threadsRequest(response: DebugProtocol.ThreadsResponse, _request?: DebugProtocol.Request | undefined): void;
18
- protected continueRequest(response: DebugProtocol.ContinueResponse, _args: DebugProtocol.ContinueArguments, _request?: DebugProtocol.Request | undefined): void;
19
- protected nextRequest(response: DebugProtocol.NextResponse, _args: DebugProtocol.NextArguments, _request?: DebugProtocol.Request | undefined): void;
20
- protected stepInRequest(response: DebugProtocol.StepInResponse, _args: DebugProtocol.StepInArguments, _request?: DebugProtocol.Request | undefined): void;
21
- protected stepOutRequest(response: DebugProtocol.StepOutResponse, _args: DebugProtocol.StepOutArguments, _request?: DebugProtocol.Request | undefined): void;
22
- protected stackTraceRequest(response: DebugProtocol.StackTraceResponse, args: DebugProtocol.StackTraceArguments, _request?: DebugProtocol.Request | undefined): void;
23
- protected scopesRequest(response: DebugProtocol.ScopesResponse, args: DebugProtocol.ScopesArguments, _request?: DebugProtocol.Request | undefined): void;
24
- protected variablesRequest(response: DebugProtocol.VariablesResponse, args: DebugProtocol.VariablesArguments, _request?: DebugProtocol.Request | undefined): void;
25
- protected disconnectRequest(response: DebugProtocol.DisconnectResponse, args: DebugProtocol.DisconnectArguments, _request?: DebugProtocol.Request | undefined): void;
26
- }