@naanlang/naan 1.0.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.
- package/LICENSE.md +21 -0
- package/README.md +46 -0
- package/dist/env_web.js +431 -0
- package/dist/naan.min.js +73 -0
- package/frameworks/browser/browser.nlg +30 -0
- package/frameworks/browser/pouchdb/pouchdb.min.js +7 -0
- package/frameworks/browser/spark-md5/spark-md5.min.js +1 -0
- package/frameworks/browser/sworker.js +192 -0
- package/frameworks/browser/terminals.nlg +787 -0
- package/frameworks/browser/workers.nlg +386 -0
- package/frameworks/client/apiclient.nlg +183 -0
- package/frameworks/client/client.nlg +29 -0
- package/frameworks/client/psm_client.nlg +572 -0
- package/frameworks/common/common.nlg +464 -0
- package/frameworks/common/preferences.nlg +131 -0
- package/frameworks/common/repltools.nlg +100 -0
- package/frameworks/common/watching.nlg +97 -0
- package/frameworks/node/apiserver.nlg +399 -0
- package/frameworks/node/filesystem.nlg +1012 -0
- package/frameworks/node/gitter.nlg +234 -0
- package/frameworks/node/node.nlg +81 -0
- package/frameworks/node/psm_server.nlg +465 -0
- package/frameworks/node/worker.nlg +560 -0
- package/frameworks/project/build.nlg +1229 -0
- package/frameworks/project/jszip.js +30 -0
- package/frameworks/project/jszip.nlg +87 -0
- package/frameworks/project/proj_cliser.nlg +139 -0
- package/frameworks/project/proj_console.nlg +137 -0
- package/frameworks/project/proj_folder.nlg +143 -0
- package/frameworks/project/proj_lambda.nlg +137 -0
- package/frameworks/project/proj_static.nlg +138 -0
- package/frameworks/project/project.nlg +29 -0
- package/frameworks/project/projects.nlg +587 -0
- package/frameworks/project/uglifyjs.js +1 -0
- package/frameworks/project/uglifyjs.nlg +79 -0
- package/frameworks/running/debugcom.nlg +163 -0
- package/frameworks/running/debugnub.nlg +565 -0
- package/frameworks/running/debugutil.nlg +510 -0
- package/frameworks/running/executors.nlg +767 -0
- package/frameworks/running/running.nlg +151 -0
- package/frameworks/running/sourcecode.nlg +346 -0
- package/frameworks/running/taskexec.nlg +196 -0
- package/frameworks/storage/dbt_pouch.nlg +773 -0
- package/frameworks/storage/file_manager.nlg +772 -0
- package/frameworks/storage/psm.nlg +326 -0
- package/frameworks/storage/psm_dbtables.nlg +814 -0
- package/frameworks/storage/resources.nlg +445 -0
- package/frameworks/storage/storage.nlg +52 -0
- package/lib/browser/env_web.js +431 -0
- package/lib/browser/env_webworker.js +146 -0
- package/lib/browser/require.js +1653 -0
- package/lib/core/naanlib.js +73 -0
- package/lib/env_node.js +282 -0
- package/lib/env_nodeworker.js +165 -0
- package/lib/node_repl.js +25 -0
- package/lib/node_repl_init.nlg +52 -0
- package/package.json +13 -0
- package/plugins/gitClient/clientops.nlg +317 -0
- package/plugins/gitClient/gitClient.nlg +63 -0
- package/plugins/gitClient/gitutils.nlg +1331 -0
- package/plugins/gitClient/minimatch.js +945 -0
- package/plugins/gitClient/minimatch_license.txt +15 -0
- package/plugins/gitClient/minimatch_readme.md +208 -0
- package/plugins/nodeLib/nodeLib.nlg +26 -0
- package/plugins/nodeLib/node_cp.nlg +65 -0
- package/plugins/nodeLib/node_fs.nlg +137 -0
- package/plugins/nodeLib/node_https.nlg +172 -0
- package/plugins/nodeLib/node_util.nlg +180 -0
- package/plugins/serviceAws/aws/aws-sdk.min.js +88 -0
- package/plugins/serviceAws/aws/lambda_rest_index.js +122 -0
- package/plugins/serviceAws/aws/lambda_rest_init.nlg +58 -0
- package/plugins/serviceAws/aws/lambda_ws_index.js +498 -0
- package/plugins/serviceAws/aws/lambda_ws_init.nlg +49 -0
- package/plugins/serviceAws/aws_cloudwatchlogs.nlg +122 -0
- package/plugins/serviceAws/aws_cognito.nlg +76 -0
- package/plugins/serviceAws/aws_dynamo.nlg +509 -0
- package/plugins/serviceAws/aws_lambda.nlg +95 -0
- package/plugins/serviceAws/aws_s3.nlg +134 -0
- package/plugins/serviceAws/aws_utils.nlg +86 -0
- package/plugins/serviceAws/dbt_aws.nlg +769 -0
- package/plugins/serviceAws/lambda_naan_control.nlg +175 -0
- package/plugins/serviceAws/psm_aws.nlg +258 -0
- package/plugins/serviceAws/serviceAws.nlg +38 -0
- package/plugins/serviceGitHub/gitops.nlg +522 -0
- package/plugins/serviceGitHub/psm_github.nlg +205 -0
- package/plugins/serviceGitHub/serviceGitHub.nlg +65 -0
- package/plugins/serviceGitLab/gitops.nlg +528 -0
- package/plugins/serviceGitLab/psm_gitlab.nlg +205 -0
- package/plugins/serviceGitLab/serviceGitLab.nlg +65 -0
- package/test/harness.nlg +312 -0
- package/test/node_test.js +33 -0
- package/test/test_01_core.nlg +768 -0
- package/test/test_02_context.nlg +269 -0
- package/test/test_03_jsinterop.nlg +137 -0
- package/test/test_04_numerics.nlg +450 -0
- package/test/test_05_strings.nlg +63 -0
- package/test/test_06_lingoparse.nlg +500 -0
- package/test/test_07_lingo.nlg +623 -0
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* debugnub.nlg
|
|
3
|
+
*
|
|
4
|
+
* Debug nub allowing remote debugging.
|
|
5
|
+
*
|
|
6
|
+
* column positioning: // // !
|
|
7
|
+
*
|
|
8
|
+
* Copyright (c) 2021 by Richard C. Zulch
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* DebugNub
|
|
15
|
+
*
|
|
16
|
+
* Install a debug nub for a remote debugger. This communicates between the CLI/debugger.nlg
|
|
17
|
+
* debug controller in the local worker and the DebugCommander in the remote with its debugger.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
closure DebugNub(local nub, debug, paused) {
|
|
22
|
+
debug = module.owner.list.Util.exports.DebugController()
|
|
23
|
+
if !debug { // no debugger support in worker
|
|
24
|
+
debuglog("DebugNub: no debugger support in this execution instance")
|
|
25
|
+
return (false)
|
|
26
|
+
}
|
|
27
|
+
if debugNub !== `debugNub { // multiple load attempt
|
|
28
|
+
debuglog("DebugNub: a debugNub already exsts; there can be only one")
|
|
29
|
+
return (false)
|
|
30
|
+
}
|
|
31
|
+
nub = new(object, this)
|
|
32
|
+
debugNub = nub // access from taskDispatcher
|
|
33
|
+
nub.codemgr = CodeManager()
|
|
34
|
+
nub.exenable = true
|
|
35
|
+
nub.watches = []
|
|
36
|
+
|
|
37
|
+
// debugDepth
|
|
38
|
+
// Return the recursive debugging depth as an integer.
|
|
39
|
+
//
|
|
40
|
+
function debugDepth(local curdepth) {
|
|
41
|
+
curdepth = debug.depth()
|
|
42
|
+
if !integer(curdepth)
|
|
43
|
+
curdepth = 0
|
|
44
|
+
curdepth
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// onDebugger proc
|
|
48
|
+
// Process an incoming debugger command.
|
|
49
|
+
//
|
|
50
|
+
function onDebugger(msg) {
|
|
51
|
+
if msg.op == "attach" {
|
|
52
|
+
debug.setCommander(nub)
|
|
53
|
+
js.t.ReplyDebugger({
|
|
54
|
+
op: "status"
|
|
55
|
+
depth: debugDepth()
|
|
56
|
+
bpenable: debug.bpenable
|
|
57
|
+
exenable: nub.exenable
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
else if msg.op == "detach" {
|
|
61
|
+
debug.setCommander(false)
|
|
62
|
+
paused.wait = false // false: go back to ndb
|
|
63
|
+
}
|
|
64
|
+
else if msg.op == "pause"
|
|
65
|
+
future(function(){ debugger() }, 1) // enter at convenient time
|
|
66
|
+
else if msg.op == "resume" || msg.op == "stop"
|
|
67
|
+
|| msg.op == "stepover" || msg.op == "stepinto" || msg.op == "stepout"
|
|
68
|
+
paused.wait = msg.op
|
|
69
|
+
else
|
|
70
|
+
debuglog("DebugNub received unknown message op", msg.op)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// sourcePos
|
|
74
|
+
//
|
|
75
|
+
// Return our current source position. If task is not specified then this uses the top of
|
|
76
|
+
// the stack. The result is a position dictionary, or false if the source location not found.
|
|
77
|
+
|
|
78
|
+
function sourcePos(procdef, task, local frame, comp, position) {
|
|
79
|
+
if !procdef || !task {
|
|
80
|
+
for frame in nub.frames
|
|
81
|
+
if procedure(frame)
|
|
82
|
+
break
|
|
83
|
+
`(procdef, task) = nub.procTask(frame)
|
|
84
|
+
}
|
|
85
|
+
if !procdef
|
|
86
|
+
return (false)
|
|
87
|
+
comp = nub.codemgr.procComponent(procdef)
|
|
88
|
+
position = comp.textpos(procdef, task)
|
|
89
|
+
position
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// lineStepSet
|
|
93
|
+
//
|
|
94
|
+
// Configure to step whole lines with the specified step type.
|
|
95
|
+
|
|
96
|
+
function lineStepSet() {
|
|
97
|
+
if !nub.lineStepProc {
|
|
98
|
+
procdef = debug.insideProc()
|
|
99
|
+
position = sourcePos()
|
|
100
|
+
nub.lineStepProc = procdef
|
|
101
|
+
nub.lineStepLine = position.first.0
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// lineStepClear
|
|
106
|
+
//
|
|
107
|
+
// Clear lineStep info.
|
|
108
|
+
|
|
109
|
+
function lineStepClear() {
|
|
110
|
+
nub.stepType = false
|
|
111
|
+
nub.lineStepProc = false
|
|
112
|
+
nub.lineStepLine = false
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// nubStep
|
|
116
|
+
//
|
|
117
|
+
// Step: 1-into, 2-over, or 3-up.
|
|
118
|
+
|
|
119
|
+
function nubStep(type) {
|
|
120
|
+
nub.stepType = type
|
|
121
|
+
if type == 1 { // into
|
|
122
|
+
lineStepSet()
|
|
123
|
+
debug.step(1)
|
|
124
|
+
} else if type == 2 { // over
|
|
125
|
+
lineStepSet()
|
|
126
|
+
debug.stepover()
|
|
127
|
+
} else if type == 3 { // up
|
|
128
|
+
lineStepClear()
|
|
129
|
+
debug.stepup()
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// stepHit
|
|
134
|
+
//
|
|
135
|
+
// A step was completed. This returns true to resume execution.
|
|
136
|
+
|
|
137
|
+
function stepHit(msg, dict, local procdef, position) {
|
|
138
|
+
msg.stepstate = dict.state
|
|
139
|
+
procdef = debug.insideProc()
|
|
140
|
+
if !procdef
|
|
141
|
+
msg.error = Error("Stepped to unknown location: ", dict.task)
|
|
142
|
+
else {
|
|
143
|
+
if member(procdef.1.namespace, debug.nshidden) {
|
|
144
|
+
debug.stepup()
|
|
145
|
+
return (true)
|
|
146
|
+
}
|
|
147
|
+
position = sourcePos(procdef, dict.task) // about to execute task
|
|
148
|
+
if nub.stepType && nub.lineStepProc == procdef && nub.lineStepLine == position.first.0 {
|
|
149
|
+
nubStep(nub.stepType) // keep stepping until line changes
|
|
150
|
+
return (true)
|
|
151
|
+
}
|
|
152
|
+
nub.lineStepProc = procdef
|
|
153
|
+
nub.lineStepLine = position.first.0
|
|
154
|
+
}
|
|
155
|
+
nub.stepValue = list(dict.value) // encapsulate in tuple for undefined, etc.
|
|
156
|
+
js.t.ReplyDebugger({
|
|
157
|
+
op: "stepped"
|
|
158
|
+
depth: debugDepth()
|
|
159
|
+
value: tostring(dict.value, { quote: true })
|
|
160
|
+
})
|
|
161
|
+
false
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// breakpointHit
|
|
165
|
+
//
|
|
166
|
+
// We hit a breakpoint. This returns true to resume execution.
|
|
167
|
+
|
|
168
|
+
function breakpointHit(msg, where, value) {
|
|
169
|
+
msg.bpid = debug.breakHit(where, value)
|
|
170
|
+
if !msg.bpid
|
|
171
|
+
return (true)
|
|
172
|
+
js.t.ReplyDebugger({
|
|
173
|
+
op: "breakpoint"
|
|
174
|
+
depth: debugDepth()
|
|
175
|
+
bpid: msg.bpid
|
|
176
|
+
value: tostring(value, { quote: true })
|
|
177
|
+
})
|
|
178
|
+
false
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// exceptionHit
|
|
182
|
+
//
|
|
183
|
+
// We hit an exception. This returns true to resume execution.
|
|
184
|
+
|
|
185
|
+
function exceptionHit(msg, except) {
|
|
186
|
+
if !nub.exenable || tuple(nub.exenable) && !eval(nub.exenable)
|
|
187
|
+
return (true) // catch break not enabled or expression false
|
|
188
|
+
exceptstr = debug.startExcept
|
|
189
|
+
if dictionary(exceptstr) && exceptstr.error == "Naan Error"
|
|
190
|
+
exceptstr = ErrorString(exceptstr)
|
|
191
|
+
js.t.ReplyDebugger({
|
|
192
|
+
op: "exception"
|
|
193
|
+
depth: debugDepth()
|
|
194
|
+
exceptstr: exceptstr
|
|
195
|
+
exception: debug.startExcept
|
|
196
|
+
})
|
|
197
|
+
false
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// entering
|
|
201
|
+
// leaving
|
|
202
|
+
//
|
|
203
|
+
// Notice that the debugger is being entered/left. Entering or leaving may not be called if we
|
|
204
|
+
// switch debuggers while in the debugger.
|
|
205
|
+
//
|
|
206
|
+
|
|
207
|
+
nub.entering = function entering(state) {
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
nub.leaving = function leaving(state) {
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// pauser
|
|
214
|
+
//
|
|
215
|
+
// Enter the debugger to allow the user to have a say in the proceedings. When this returns
|
|
216
|
+
// non-false then execution resumes. The entry argument defines the reason for entering using a
|
|
217
|
+
// constant string, with corresponding arguments defined as follows:
|
|
218
|
+
//
|
|
219
|
+
// "startpause" - pause at start of evaluating an expression
|
|
220
|
+
// tuple - expression being evaluated
|
|
221
|
+
// "breakpoint" - hit a breakpoint
|
|
222
|
+
// where - dictionary
|
|
223
|
+
// value - applied value
|
|
224
|
+
// "steptrap" - finished stepping
|
|
225
|
+
// dict - dictionary of current step info
|
|
226
|
+
// "startfail" - failed pause at start of eval
|
|
227
|
+
// "escape" - debugger entered via escape request
|
|
228
|
+
// "exception" - debugger entered due to exception
|
|
229
|
+
// value - exception that occurred
|
|
230
|
+
// "" - normal entry (e.g. debugger call)
|
|
231
|
+
//
|
|
232
|
+
nub.pauser = closure pauser(entry, arg1, arg2, arg3, local msg, frame, proc1) {
|
|
233
|
+
msg = {
|
|
234
|
+
op: "pauser"
|
|
235
|
+
entry: entry
|
|
236
|
+
}
|
|
237
|
+
if entry != "steptrap"
|
|
238
|
+
lineStepClear()
|
|
239
|
+
if entry == "startpause" {
|
|
240
|
+
if atom(arg1)
|
|
241
|
+
msg.error = Error("can't debug atom:", arg1)
|
|
242
|
+
else
|
|
243
|
+
msg.expr = arg1
|
|
244
|
+
} else if entry == "breakpoint" {
|
|
245
|
+
if breakpointHit(msg, arg1, arg2)
|
|
246
|
+
return
|
|
247
|
+
} else if entry == "steptrap" {
|
|
248
|
+
if stepHit(msg, arg1)
|
|
249
|
+
return
|
|
250
|
+
} else if entry == "startfail" {
|
|
251
|
+
msg.error = Error("can't pause before eval")
|
|
252
|
+
} else if entry == "escape" {
|
|
253
|
+
{ }
|
|
254
|
+
} else if entry == "exception" {
|
|
255
|
+
if exceptionHit(msg, arg1)
|
|
256
|
+
return
|
|
257
|
+
} else if entry == "" {
|
|
258
|
+
} else
|
|
259
|
+
msg.error = Error("debugger entry type unknown:", entry)
|
|
260
|
+
nub.frames = []
|
|
261
|
+
for frame in debug.frames {
|
|
262
|
+
if procedure(frame)
|
|
263
|
+
proc1 = true
|
|
264
|
+
if frame.0 != `body && (!proc1 || frame.0 != `loop)
|
|
265
|
+
nub.frames.push(frame) } // we ignore body and loop frames
|
|
266
|
+
msg.depth = debugDepth()
|
|
267
|
+
msg.bpenable = debug.bpenable
|
|
268
|
+
msg.exenable = nub.exenable
|
|
269
|
+
js.t.ReplyDebugger(msg)
|
|
270
|
+
paused = { wait: true }
|
|
271
|
+
msg.entry = undefined
|
|
272
|
+
while paused.wait == true
|
|
273
|
+
wait()
|
|
274
|
+
msg.exit = paused.wait
|
|
275
|
+
msg.depth = debugDepth()
|
|
276
|
+
msg.bpenable = debug.bpenable
|
|
277
|
+
msg.exenable = nub.exenable
|
|
278
|
+
js.t.ReplyDebugger(msg)
|
|
279
|
+
if msg.exit == "resume"
|
|
280
|
+
debug.resume()
|
|
281
|
+
else if msg.exit == "stop"
|
|
282
|
+
debug.quit() // throw to quit
|
|
283
|
+
else if msg.exit == "stepinto"
|
|
284
|
+
msg.exit = nubStep(1)
|
|
285
|
+
else if msg.exit == "stepover"
|
|
286
|
+
msg.exit = nubStep(2)
|
|
287
|
+
else if msg.exit == "stepout"
|
|
288
|
+
nubStep(3)
|
|
289
|
+
msg.exit
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// endPauser
|
|
293
|
+
//
|
|
294
|
+
// End our pause so we can switch to REPL debugger.
|
|
295
|
+
|
|
296
|
+
nub.endPauser = function endPauser() {
|
|
297
|
+
paused.wait = false
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// breakGlobalEnable
|
|
301
|
+
//
|
|
302
|
+
// Enable or disable global breakpoints.
|
|
303
|
+
|
|
304
|
+
nub.breakGlobalEnable = function breakGlobalEnable(enable) {
|
|
305
|
+
debug.breakGlobalAble(enable)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// catchGlobalEnable
|
|
309
|
+
//
|
|
310
|
+
// Enable or disable exception traps, or if a tuple then an expression to evaluate.
|
|
311
|
+
|
|
312
|
+
nub.catchGlobalEnable = function catchGlobalEnable(enablex) {
|
|
313
|
+
nub.exenable = enablex
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// breakAdd
|
|
317
|
+
//
|
|
318
|
+
// Add a breakpoint as specified.
|
|
319
|
+
|
|
320
|
+
nub.breakAdd = function breakAdd(modname, compname, lineno, column, expr, local result, bpid) {
|
|
321
|
+
result = nub.codemgr.component(modname, compname).findbreak(lineno, column)
|
|
322
|
+
if !result
|
|
323
|
+
return (list(Error("breakpoint location invalid at (", lineno, ", ", column, ")")))
|
|
324
|
+
bpid = debug.breakAdd(result.proc, result.task, expr)
|
|
325
|
+
if !bpid
|
|
326
|
+
return (list(Error("can't add breakpoint at (", lineno, ", ", column, ")")))
|
|
327
|
+
list(false, {
|
|
328
|
+
first: result.first
|
|
329
|
+
last: result.last
|
|
330
|
+
bpid: bpid
|
|
331
|
+
})
|
|
332
|
+
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// breakClear
|
|
336
|
+
//
|
|
337
|
+
// Clear a breakpoint given the text location.
|
|
338
|
+
|
|
339
|
+
nub.breakClear = function breakClear(modname, compname, lineno, column, local result) {
|
|
340
|
+
result = nub.codemgr.component(modname, compname).findbreak(lineno, column)
|
|
341
|
+
if !result
|
|
342
|
+
return (list(Error("breakpoint location invalid at (", lineno, ", ", column, ")")))
|
|
343
|
+
if !debug.breakClear(result.proc, result.task)
|
|
344
|
+
return (list(Error("breakpoint not found at (", lineno, ", ", column, ")")))
|
|
345
|
+
list(false, true)
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// breakDelete
|
|
349
|
+
//
|
|
350
|
+
// Delete breakpoint(s) given the number(s) in our breakpoint list.
|
|
351
|
+
|
|
352
|
+
nub.breakDelete = function breakDelete(bpid) {
|
|
353
|
+
if !debug.breakDelete(bpid)
|
|
354
|
+
return (list(Error("breakpoint", bpid, "not found")))
|
|
355
|
+
list(false, true )
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// breakAble
|
|
359
|
+
//
|
|
360
|
+
// Enable/disable a breakpoint given the number.
|
|
361
|
+
|
|
362
|
+
nub.breakAble = function breakAble(bpid, enable) {
|
|
363
|
+
debug.breakAble(bpid, enable)
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// breakInfo
|
|
367
|
+
//
|
|
368
|
+
// Provide info on a breakpoint:
|
|
369
|
+
// {
|
|
370
|
+
// bpid: <integer identifier from 1>
|
|
371
|
+
// enable: true/false
|
|
372
|
+
// count: hit count
|
|
373
|
+
// proc: procdef
|
|
374
|
+
// task: task
|
|
375
|
+
// condition: <expression
|
|
376
|
+
// }
|
|
377
|
+
|
|
378
|
+
nub.breakInfo = function breakInfo(bpid, local bp) {
|
|
379
|
+
bp = debug.breakpoints[bpid]
|
|
380
|
+
if !bp
|
|
381
|
+
return (false)
|
|
382
|
+
{
|
|
383
|
+
bpid: bpid
|
|
384
|
+
enable: bp.where.enable
|
|
385
|
+
count: bp.hitcount
|
|
386
|
+
proc: bp.procdef
|
|
387
|
+
task: bp.where.task
|
|
388
|
+
condition: bp.conditional
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// breakList
|
|
393
|
+
//
|
|
394
|
+
// Report all our breakpoints as an array of dictionary items.
|
|
395
|
+
|
|
396
|
+
nub.breakList = function breakList(local output, id, bp) {
|
|
397
|
+
output = []
|
|
398
|
+
for bpid in debug.breakpoints
|
|
399
|
+
output.push(breakInfo(bpid))
|
|
400
|
+
output
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// callStack
|
|
404
|
+
//
|
|
405
|
+
// List our callers as of the last entry.
|
|
406
|
+
|
|
407
|
+
nub.callStack = function callStack(local output, frame, type, record) {
|
|
408
|
+
output = []
|
|
409
|
+
for frame in nub.frames {
|
|
410
|
+
record = {
|
|
411
|
+
type: frame.0.tostring // e.g. "function"
|
|
412
|
+
}
|
|
413
|
+
if procedure(frame) {
|
|
414
|
+
record.namespace = frame.1.namespace.tostring
|
|
415
|
+
record.procname = frame.3.1
|
|
416
|
+
record.params = frame.3.2
|
|
417
|
+
}
|
|
418
|
+
else if record.type == "interrupt"
|
|
419
|
+
record.variant = frame.2.tostring
|
|
420
|
+
else
|
|
421
|
+
continue
|
|
422
|
+
output.push(record)
|
|
423
|
+
}
|
|
424
|
+
output
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// nthFrame
|
|
428
|
+
//
|
|
429
|
+
// Return the nth stack frame in the list returned by callStack above.
|
|
430
|
+
|
|
431
|
+
nub.nthFrame = function nthFrame(nth, local frame) {
|
|
432
|
+
for frame in nub.frames
|
|
433
|
+
if procedure(frame) || frame.0.tostring == "interrupt" {
|
|
434
|
+
if nth-- == 0
|
|
435
|
+
return (frame)
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// localist
|
|
440
|
+
//
|
|
441
|
+
// Obtain a tuple of all local variables in scope on the specified stack frame.
|
|
442
|
+
|
|
443
|
+
nub.localist = function localist(frame, local symbols) {
|
|
444
|
+
if !procedure(frame)
|
|
445
|
+
return (false)
|
|
446
|
+
|
|
447
|
+
function scope(parent, local lex1, ex1, proc) { // capture scope variables
|
|
448
|
+
while parent {
|
|
449
|
+
proc = getproc(parent)
|
|
450
|
+
lex1 = third(proc)
|
|
451
|
+
if atom(lex1)
|
|
452
|
+
push(lex1, symbols)
|
|
453
|
+
else
|
|
454
|
+
loop {
|
|
455
|
+
if empty(lex1) break
|
|
456
|
+
ex1 = pop(lex1)
|
|
457
|
+
if ex1
|
|
458
|
+
push(ex1, symbols)
|
|
459
|
+
}
|
|
460
|
+
push(parent, symbols)
|
|
461
|
+
lex1 = parent@\.children
|
|
462
|
+
loop {
|
|
463
|
+
if empty(lex1) break
|
|
464
|
+
ex1 = pop(lex1)
|
|
465
|
+
if ex1 && !member(ex1, symbols)
|
|
466
|
+
push(ex1, symbols)
|
|
467
|
+
}
|
|
468
|
+
parent = parent@\.parent } } (frame.3.1)
|
|
469
|
+
|
|
470
|
+
reverse(symbols)
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// evalWatchesInFrame
|
|
474
|
+
//
|
|
475
|
+
// Parse and evaluate our watchpoints, optionally in the context of the nth frame. Each entry
|
|
476
|
+
// in the returned array is for a watchpoint, comprising a tuple: `(error, expression, evaluated)
|
|
477
|
+
|
|
478
|
+
nub.evalWatchesInFrame = function evalWatchesInFrame(nth,
|
|
479
|
+
local frame, locals, ns, mod, gohome, texts, watch, exprs, error, expr)
|
|
480
|
+
{
|
|
481
|
+
if integer(nth) {
|
|
482
|
+
frame = nthFrame(nth)
|
|
483
|
+
locals = localist(frame)
|
|
484
|
+
ns = frame.3.1.namespace
|
|
485
|
+
if ns !== nsactive().0 {
|
|
486
|
+
mod = module.owner.findModule(ns)
|
|
487
|
+
if mod {
|
|
488
|
+
gohome = makeActivator(nsactive())
|
|
489
|
+
chns(mod.id)
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
texts = []
|
|
494
|
+
for watch in nub.watches
|
|
495
|
+
texts.push(watch.source)
|
|
496
|
+
exprs = nub.codemgr.parseExprs(texts, locals)
|
|
497
|
+
results = []
|
|
498
|
+
for watch in nub.watches {
|
|
499
|
+
`(error, expr) = exprs.shift()
|
|
500
|
+
if !watch.source
|
|
501
|
+
expr = watch.expr
|
|
502
|
+
results.push(list(error, expr, eval(expr)))
|
|
503
|
+
}
|
|
504
|
+
gohome()
|
|
505
|
+
results
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// procTask
|
|
509
|
+
//
|
|
510
|
+
// Return procedure and task from a frame, as a `(procdef, task) tuple.
|
|
511
|
+
|
|
512
|
+
nub.procTask = function procTask(frame) {
|
|
513
|
+
debug.frameProcTask(frame)
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
// lastStepValue
|
|
517
|
+
//
|
|
518
|
+
// Return the applied value after the last step. This is encapsulated in a tuple so that we can
|
|
519
|
+
// get undefined, null, etc.
|
|
520
|
+
|
|
521
|
+
nub.lastStepValue = function lastStepValue() {
|
|
522
|
+
nub.stepValue
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// utilities
|
|
526
|
+
//
|
|
527
|
+
// Procedure utilities.
|
|
528
|
+
|
|
529
|
+
nub.rootproc = rootproc.proc // root procdef from nested procdef
|
|
530
|
+
nub.baseproc = baseproc.proc // base procdef from procdef
|
|
531
|
+
nub.pathmatch = pathmatch.proc // child symbol from (parent, path)
|
|
532
|
+
nub.procpath = procpath.proc // tuple of parents from nested procdef
|
|
533
|
+
nub.procname = procname.proc // return full pathname of nested procsym
|
|
534
|
+
nub.procstring = procstring.proc // return proc string with arguments
|
|
535
|
+
|
|
536
|
+
// nubInstall
|
|
537
|
+
// Install the nub for receiving debugger messages, and reload on state load.
|
|
538
|
+
//
|
|
539
|
+
function nubInstall() {
|
|
540
|
+
js.t.OnDebugger(onDebugger.proc) // receive debug messages
|
|
541
|
+
}()
|
|
542
|
+
LoadNotify(nubInstall)
|
|
543
|
+
|
|
544
|
+
// finis
|
|
545
|
+
nub
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
/*
|
|
550
|
+
* dnubInit
|
|
551
|
+
*
|
|
552
|
+
* Initialize the component.
|
|
553
|
+
*
|
|
554
|
+
*/
|
|
555
|
+
|
|
556
|
+
function dnubInit(local manifest) {
|
|
557
|
+
manifest = `(DebugNub, dnubInit)
|
|
558
|
+
|
|
559
|
+
Naan.module.build(module.id, "debugnub", function(modobj, compobj) {
|
|
560
|
+
require("./running.nlg")
|
|
561
|
+
require("./sourcecode.nlg")
|
|
562
|
+
compobj.manifest = manifest
|
|
563
|
+
modobj.exports.DebugNub = DebugNub
|
|
564
|
+
})
|
|
565
|
+
} ();
|