@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,510 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* debug_util.nlg
|
|
3
|
+
* Naan IDE - guiDebugger plugin
|
|
4
|
+
*
|
|
5
|
+
* Naan IDE GUI debugger utilities.
|
|
6
|
+
*
|
|
7
|
+
* column positioning: // // !
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2021 by Richard C. Zulch
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* libVarExpand
|
|
15
|
+
*
|
|
16
|
+
* Remote-resident support procedure to expand a symbol and its value into expanded values of its
|
|
17
|
+
* children. This is passed a value because we might be doing a lookup for a stack context, not the
|
|
18
|
+
* symbol's currently-bound context. The result is a dictionary shown below that has a "more" key
|
|
19
|
+
* defined with an array of children, if any exist.
|
|
20
|
+
* The purpose of this function is to report two levels of data for a listbox, so that the first
|
|
21
|
+
* level can be exposed by the user immediately, and then the second level updated before the user
|
|
22
|
+
* can expose further depth.
|
|
23
|
+
* The preceding argument determines how far this recurses below the specified symbol and value.
|
|
24
|
+
* Normally the caller provides an empty dictionary and this responds by filling in "more" with an
|
|
25
|
+
* array of children having the same structure. If preceding is false then this responds by setting
|
|
26
|
+
* more to true if it can have children. A previous result can be provided as the preceding argument
|
|
27
|
+
* to control which children are expanded. Setting "visible: true" in a dictionary causes the element
|
|
28
|
+
* and its children to be expanded.
|
|
29
|
+
* If a child has more than 100 elements then an intermediate array of chunks are defined to page
|
|
30
|
+
* the results, where the first N-1 chunks have 100 children and the last has the remainder.
|
|
31
|
+
*
|
|
32
|
+
* Here is the output structure:
|
|
33
|
+
* {
|
|
34
|
+
* symbol: <string> // symbol, or index/key in collection
|
|
35
|
+
* value: <string> // specified value, e.g. Array[3]
|
|
36
|
+
* more: <array> // optional: array of children, or true
|
|
37
|
+
* chunk: true // defined for generated chunks
|
|
38
|
+
* chunked: true // defined in parent if immediate children are chunked
|
|
39
|
+
* visible: true // defined if the item is visible
|
|
40
|
+
* }
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
function libVarExpand(sym, value, preceding, local debugNub, output, keylist, chunksize, nchunks) {
|
|
45
|
+
//
|
|
46
|
+
// extype
|
|
47
|
+
// Annotate a dictionary with type information for the symbol and value.
|
|
48
|
+
//
|
|
49
|
+
function extype(dict, sym, value) {
|
|
50
|
+
if symbol(sym) && !interned(sym) && sym !== false
|
|
51
|
+
dict.symtype = "uninterned"
|
|
52
|
+
else
|
|
53
|
+
dict.symtype = typeof(sym)
|
|
54
|
+
if symbol(value) && !interned(value) && value !== false
|
|
55
|
+
dict.valtype = "uninterned"
|
|
56
|
+
else if symbol(value) && builtin(value.proc) || builtin(value)
|
|
57
|
+
dict.valtype = "builtin"
|
|
58
|
+
else if procedure(value)
|
|
59
|
+
dict.valtype = "procedure"
|
|
60
|
+
else
|
|
61
|
+
dict.valtype = typeof(value)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
debugNub = car(compress("debugNub")) // get remote debugNub's value, which is the nub
|
|
65
|
+
output = { }
|
|
66
|
+
extype(output, sym, value)
|
|
67
|
+
output.symbol = sym.tostring
|
|
68
|
+
if procedure(value) { // procedure tuple
|
|
69
|
+
output.value = debugNub.procstring(value, { namespace: false, fullname: false })
|
|
70
|
+
output.procedure = true
|
|
71
|
+
return (output)
|
|
72
|
+
}
|
|
73
|
+
output.value = tostring(value, {quote:true})
|
|
74
|
+
if array(value)
|
|
75
|
+
keylist = value.map(function(item,index){index}) // 0..n
|
|
76
|
+
else if tuple(value)
|
|
77
|
+
keylist = value.toarray.map(function(item,index){index}) // 0..n
|
|
78
|
+
else if dictionary(value) || object(value)
|
|
79
|
+
keylist = keys(value)
|
|
80
|
+
else
|
|
81
|
+
return (output) // cannot go deeper
|
|
82
|
+
if !preceding {
|
|
83
|
+
output.more = true // there is more below, but
|
|
84
|
+
return (output) // we've reached the recursion limit
|
|
85
|
+
}
|
|
86
|
+
output.visible = preceding.visible
|
|
87
|
+
chunksize = 100
|
|
88
|
+
nchunks = (length(keylist)+chunksize-1) / chunksize
|
|
89
|
+
if !array(preceding.more)
|
|
90
|
+
preceding = false // just fill in our children
|
|
91
|
+
else if preceding.chunked
|
|
92
|
+
preceding = new(preceding.more) // a copy of chunk array we can modify
|
|
93
|
+
else
|
|
94
|
+
preceding = [{ // fake chunk
|
|
95
|
+
symbol: 0
|
|
96
|
+
chunk: true
|
|
97
|
+
more: new(preceding.more)
|
|
98
|
+
visible: preceding.visible
|
|
99
|
+
}]
|
|
100
|
+
output.more = new(Array(nchunks)).map(function(item, index, local kdex, preceding1, count, key) {
|
|
101
|
+
kdex = index * chunksize
|
|
102
|
+
count = length(keylist) - kdex
|
|
103
|
+
if count > chunksize
|
|
104
|
+
count = chunksize
|
|
105
|
+
item = {
|
|
106
|
+
symbol: kdex
|
|
107
|
+
value: "[".concat(kdex, " ... ", kdex+count-1, "]")
|
|
108
|
+
chunk: true // note that this is a "chunk"
|
|
109
|
+
}
|
|
110
|
+
preceding1 = preceding.shift() // get corresponding chunk
|
|
111
|
+
if !output.visible
|
|
112
|
+
preceding1 = false // just fill in our children
|
|
113
|
+
else if preceding1.visible
|
|
114
|
+
item.visible = true // chunk is visible
|
|
115
|
+
item.more = []
|
|
116
|
+
while --count >= 0 {
|
|
117
|
+
key = keylist[kdex++]
|
|
118
|
+
item.more.push(libVarExpand(key, value[key], preceding1.more.shift()))
|
|
119
|
+
}
|
|
120
|
+
item
|
|
121
|
+
})
|
|
122
|
+
if nchunks <= 1
|
|
123
|
+
output.more = output.more[0].more // collapse the chunks
|
|
124
|
+
else
|
|
125
|
+
output.chunked = true
|
|
126
|
+
output
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
/*
|
|
131
|
+
* libBreakInfo
|
|
132
|
+
*
|
|
133
|
+
* Return information about a breakpoint.
|
|
134
|
+
*
|
|
135
|
+
*/
|
|
136
|
+
|
|
137
|
+
function libBreakInfo(bpid, local debugNub, bp, comp, position) {
|
|
138
|
+
debugNub = car(compress("debugNub"))
|
|
139
|
+
bp = debugNub.breakInfo(bpid)
|
|
140
|
+
if !bp
|
|
141
|
+
return (false)
|
|
142
|
+
comp = debugNub.codemgr.procComponent(bp.proc)
|
|
143
|
+
position = comp.textpos(bp.proc, bp.task)
|
|
144
|
+
if !position
|
|
145
|
+
return (false)
|
|
146
|
+
{
|
|
147
|
+
bpid: bpid
|
|
148
|
+
enable: bp.enable
|
|
149
|
+
count: bp.hitcount
|
|
150
|
+
procname: bp.proc.1
|
|
151
|
+
modname: comp.modname
|
|
152
|
+
compname: comp.compname
|
|
153
|
+
first: position.first
|
|
154
|
+
last: position.last
|
|
155
|
+
line: position.line
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
/*
|
|
161
|
+
* DebugRemote
|
|
162
|
+
*
|
|
163
|
+
* Remote evaluation helper object.
|
|
164
|
+
*
|
|
165
|
+
*/
|
|
166
|
+
|
|
167
|
+
closure DebugRemote(commander, local remoter, here, there, library) {
|
|
168
|
+
remoter = new(object, this)
|
|
169
|
+
here = new(object)
|
|
170
|
+
there = {}
|
|
171
|
+
library = list(libVarExpand, libBreakInfo)
|
|
172
|
+
|
|
173
|
+
// modcomp
|
|
174
|
+
//
|
|
175
|
+
// Report modules and components. It is essential that this be self-contained because it is sent
|
|
176
|
+
// to the remote and executed there.
|
|
177
|
+
//
|
|
178
|
+
here.modcomp = function modcomp(local result, id, mod) {
|
|
179
|
+
result = []
|
|
180
|
+
for `(id, mod) in modlist()
|
|
181
|
+
result.push({
|
|
182
|
+
id: id
|
|
183
|
+
created: mod.created
|
|
184
|
+
locpath: mod.locpath
|
|
185
|
+
components: mod.components.*.toarray
|
|
186
|
+
})
|
|
187
|
+
result
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// catchGlobalEnable
|
|
191
|
+
//
|
|
192
|
+
// Enable or disable exception traps globally.
|
|
193
|
+
|
|
194
|
+
here.catchGlobalEnable = function catchGlobalEnable(enablex) {
|
|
195
|
+
debugNub = car(compress("debugNub"))
|
|
196
|
+
debugNub.catchGlobalEnable(enablex)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// breakGlobalEnable
|
|
200
|
+
//
|
|
201
|
+
// Global breakpoint enable/disable.
|
|
202
|
+
//
|
|
203
|
+
here.breakGlobalEnable = function breakGlobalEnable(enable, local debugNub) {
|
|
204
|
+
debugNub = car(compress("debugNub")) // get remote debugNub's value, which is the nub
|
|
205
|
+
debugNub.breakGlobalEnable(enable)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// breakAdd
|
|
209
|
+
//
|
|
210
|
+
// Add or update a breakpoint.
|
|
211
|
+
//
|
|
212
|
+
here.breakAdd = function breakAdd(modname, compname, lineno, column, expr, local debugNub) {
|
|
213
|
+
debugNub = car(compress("debugNub"))
|
|
214
|
+
debugNub.breakAdd(modname, compname, lineno, column, expr)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// breakClear
|
|
218
|
+
//
|
|
219
|
+
// Remove a breakpoint at a location.
|
|
220
|
+
//
|
|
221
|
+
here.breakClear = function breakClear(modname, compname, lineno, column, local debugNub) {
|
|
222
|
+
debugNub = car(compress("debugNub"))
|
|
223
|
+
debugNub.breakClear(modname, compname, lineno, column)
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// breakDelete
|
|
227
|
+
//
|
|
228
|
+
// Remove a breakpoint by ID.
|
|
229
|
+
//
|
|
230
|
+
here.breakDelete = function breakDelete(bpid, local debugNub) {
|
|
231
|
+
debugNub = car(compress("debugNub"))
|
|
232
|
+
debugNub.breakDelete(bpid)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// breakAble
|
|
236
|
+
//
|
|
237
|
+
// Enable/disable a breakpoint by ID.
|
|
238
|
+
//
|
|
239
|
+
here.breakAble = function breakAble(bpid, enable, local debugNub) {
|
|
240
|
+
debugNub = car(compress("debugNub"))
|
|
241
|
+
debugNub.breakAble(bpid, enable)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// breakList
|
|
245
|
+
//
|
|
246
|
+
// List current breakpoints.
|
|
247
|
+
//
|
|
248
|
+
here.breakList = function breakList(local debugNub, bp, output) {
|
|
249
|
+
debugNub = car(compress("debugNub"))
|
|
250
|
+
output = []
|
|
251
|
+
for bp in debugNub.breakList()
|
|
252
|
+
output.push(libBreakInfo(bp.bpid))
|
|
253
|
+
output
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// breakInfo
|
|
257
|
+
//
|
|
258
|
+
// Get info about the specified breakpoint ID.
|
|
259
|
+
//
|
|
260
|
+
here.breakInfo = function breakInfo(bpid) {
|
|
261
|
+
libBreakInfo(bpid)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// callstack
|
|
265
|
+
//
|
|
266
|
+
// Report current callstack.
|
|
267
|
+
//
|
|
268
|
+
here.callStack = function callStack(local debugNub) {
|
|
269
|
+
debugNub = car(compress("debugNub"))
|
|
270
|
+
debugNub.callStack()
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// frameinfo
|
|
274
|
+
//
|
|
275
|
+
// Report information about the nth frame in the callStack.
|
|
276
|
+
//
|
|
277
|
+
here.frameinfo = function frameinfo(nth, local debugNub, frame, proctask, comp, position) {
|
|
278
|
+
debugNub = car(compress("debugNub"))
|
|
279
|
+
frame = debugNub.nthFrame(nth)
|
|
280
|
+
proctask = debugNub.procTask(frame)
|
|
281
|
+
comp = debugNub.codemgr.procComponent(proctask.0)
|
|
282
|
+
position = comp.textpos(proctask.0, proctask.1)
|
|
283
|
+
{
|
|
284
|
+
procname: proctask.0.1
|
|
285
|
+
modname: comp.modname
|
|
286
|
+
compname: comp.compname
|
|
287
|
+
first: position.first
|
|
288
|
+
last: position.last
|
|
289
|
+
line: position.line
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// scopeinfo
|
|
294
|
+
//
|
|
295
|
+
// Return a representation of variables in the nth frame of the callstack. The result is an array
|
|
296
|
+
// of scopes starting with the local and ascending through the parents. Each scope is reported as
|
|
297
|
+
// a dictionary with the full procedure name and an array of variables defined on that procedure.
|
|
298
|
+
// Each variable in the array has the symbol, its current value as a short string, and if not a
|
|
299
|
+
// closure then the previous value of the symbol higher on the callstack. The more key is defined
|
|
300
|
+
// if the value can be further explored, and contains one more level of value dictionaries with
|
|
301
|
+
// additional more keys where applicable.
|
|
302
|
+
// The optional visible array is a preceding result of this function, where "visible=true"
|
|
303
|
+
// can be applied to nested values to add recursive depth.
|
|
304
|
+
//
|
|
305
|
+
here.scopeinfo = function scopeinfo(nth, visible,
|
|
306
|
+
local debugNub, frame, procsym, parent, proc, lex1, ex1, params, content, scope, level, level1)
|
|
307
|
+
{
|
|
308
|
+
debugNub = car(compress("debugNub"))
|
|
309
|
+
frame = debugNub.nthFrame(nth)
|
|
310
|
+
procsym = frame.3.1
|
|
311
|
+
parent = procsym@\.parent
|
|
312
|
+
while parent {
|
|
313
|
+
proc = parent.proc
|
|
314
|
+
lex1 = proc.2 // argument list
|
|
315
|
+
if atom(lex1) && lex1
|
|
316
|
+
params = list(lex1, car(lex1)) // nospread
|
|
317
|
+
else {
|
|
318
|
+
params = false
|
|
319
|
+
while tuple(lex1) { // spread
|
|
320
|
+
ex1 = pop(lex1)
|
|
321
|
+
if ex1
|
|
322
|
+
push(list(ex1, car(ex1)), params)
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
push(reverse(params), parents)
|
|
326
|
+
parent = parent@\.parent
|
|
327
|
+
}
|
|
328
|
+
parents = reverse(parents)
|
|
329
|
+
push(frame.2, parents) // list procedure locals first
|
|
330
|
+
parent = procsym // prime the parent chain with the child
|
|
331
|
+
visible = new(visible) // don't modify original
|
|
332
|
+
content = []
|
|
333
|
+
while parent {
|
|
334
|
+
proc = parent.proc
|
|
335
|
+
level = {
|
|
336
|
+
procscope: debugNub.procstring(proc)
|
|
337
|
+
variables: []
|
|
338
|
+
}
|
|
339
|
+
level1 = visible.shift()
|
|
340
|
+
scope = pop(parents) // tuple of (symbol, value [, previous ])
|
|
341
|
+
if tuple(scope) {
|
|
342
|
+
if atom(car(scope))
|
|
343
|
+
scope = list(scope) // was nospread
|
|
344
|
+
level.variables = scope.toarray.filter(function(item) {
|
|
345
|
+
item && item.0 // eliminate "local", which is false
|
|
346
|
+
}).map(function(item, local child, child1) {
|
|
347
|
+
child1 = level1.variables.shift()
|
|
348
|
+
if !child1
|
|
349
|
+
child1 = { } // always do one level below this
|
|
350
|
+
child = libVarExpand(item.0, item.1, child1)
|
|
351
|
+
if proc.0 != `closure
|
|
352
|
+
child.previous = tostring(item.2, {quote:true})
|
|
353
|
+
child
|
|
354
|
+
})
|
|
355
|
+
}
|
|
356
|
+
content.push(level)
|
|
357
|
+
parent = parent@\.parent
|
|
358
|
+
}
|
|
359
|
+
content
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// watchInfo
|
|
363
|
+
//
|
|
364
|
+
// Return a representation of the evaluated watch expressions. The result is an array watches
|
|
365
|
+
// Each watch is reported as a dictionary with the "symbol", which is the watch expression, and
|
|
366
|
+
// the current value as a short string. The more key is defined if the value can be further
|
|
367
|
+
// explored, and contains one more level of value dictionaries with additional more keys where
|
|
368
|
+
// applicable.
|
|
369
|
+
// The optional visible array is a preceding result of this function, where "visible=true"
|
|
370
|
+
// can be applied to nested values to add recursive depth. A stack frame index can be specified
|
|
371
|
+
// to evaluate an expression in that context.
|
|
372
|
+
|
|
373
|
+
here.watchInfo = function watchInfo(visible, nth,
|
|
374
|
+
local debugNub, values, content, watch, child1, error, value, level, expr)
|
|
375
|
+
{
|
|
376
|
+
debugNub = car(compress("debugNub"))
|
|
377
|
+
values = debugNub.evalWatchesInFrame(nth)
|
|
378
|
+
visible = new(visible) // don't modify original
|
|
379
|
+
content = []
|
|
380
|
+
for watch in debugNub.watches {
|
|
381
|
+
child1 = visible.shift() // any "more" data for the watch
|
|
382
|
+
if !child1
|
|
383
|
+
child1 = { } // always do one level below this
|
|
384
|
+
`(error, expr, value) = values.shift()
|
|
385
|
+
level = libVarExpand(expr, value, child1)
|
|
386
|
+
if error
|
|
387
|
+
level.error = error
|
|
388
|
+
if watch.source
|
|
389
|
+
level.source = watch.source // original source text of expression
|
|
390
|
+
content.push(level)
|
|
391
|
+
}
|
|
392
|
+
content
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// watchWrite
|
|
396
|
+
//
|
|
397
|
+
// Delete the nth watch expression.
|
|
398
|
+
|
|
399
|
+
here.watchWrite = function watchWrite(nth, text) {
|
|
400
|
+
debugNub = car(compress("debugNub"))
|
|
401
|
+
if nth <= debugNub.watches.length
|
|
402
|
+
debugNub.watches[nth] = {
|
|
403
|
+
source: text
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// watchDelete
|
|
408
|
+
//
|
|
409
|
+
// Delete the nth watch expression.
|
|
410
|
+
|
|
411
|
+
here.watchDelete = function watchDelete(nth) {
|
|
412
|
+
debugNub = car(compress("debugNub"))
|
|
413
|
+
debugNub.watches.splice(nth, 1)
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// futureslist
|
|
417
|
+
//
|
|
418
|
+
// List the current futures.
|
|
419
|
+
|
|
420
|
+
here.futureslist = function futureslist(local debugNub, output, future, record, procsym) {
|
|
421
|
+
debugNub = car(compress("debugNub"))
|
|
422
|
+
output = []
|
|
423
|
+
for future in futures() {
|
|
424
|
+
if member(debugNub.pauser, future.waiting)
|
|
425
|
+
continue // omit the debugger
|
|
426
|
+
record = {
|
|
427
|
+
start: future.start
|
|
428
|
+
count: future.count
|
|
429
|
+
delay: future.delay
|
|
430
|
+
}
|
|
431
|
+
if procedure(future.execute) {
|
|
432
|
+
procsym = future.execute.1
|
|
433
|
+
record.execute = strcat(future.execute.0, space, procsym.namespace.tostring, "::", debugNub.procname(procsym))
|
|
434
|
+
}
|
|
435
|
+
else if future.execute
|
|
436
|
+
record.execute = tostring(future.execute)
|
|
437
|
+
if future.waiting {
|
|
438
|
+
record.waiting = future.waiting.toarray.map(function(item) {
|
|
439
|
+
procsym = item.1
|
|
440
|
+
strcat(item.0, space, procsym.namespace.tostring, "::", debugNub.procname(procsym))
|
|
441
|
+
})
|
|
442
|
+
}
|
|
443
|
+
output.push(record)
|
|
444
|
+
}
|
|
445
|
+
output
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// compsources
|
|
449
|
+
//
|
|
450
|
+
// List the sourcecode for a component.
|
|
451
|
+
|
|
452
|
+
here.compsources = function compsources(modname, compname, local debugNub, comp) {
|
|
453
|
+
debugNub = car(compress("debugNub"))
|
|
454
|
+
comp = debugNub.codemgr.component(modname, compname)
|
|
455
|
+
comp.string()
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// .undefined
|
|
459
|
+
// Execute methods remotely, returning a standard `(error, data) tuple.
|
|
460
|
+
|
|
461
|
+
remoter[".undefined"] = closure remoter args {
|
|
462
|
+
closure (selector, arglist, local error, context, result) {
|
|
463
|
+
if !there[selector] { // not over there yet
|
|
464
|
+
proc = here[selector]
|
|
465
|
+
if !proc
|
|
466
|
+
return(list(Error("DebugRemote.remoter: invalid selector", selector)))
|
|
467
|
+
if !remoter.context {
|
|
468
|
+
`(error, context) = commander.context()
|
|
469
|
+
if !error
|
|
470
|
+
`(error, result) = context.evalq(Naan.module.chns("running"))
|
|
471
|
+
if error
|
|
472
|
+
return(list(Error("DebugRemote.remoter: failed to make context", error)))
|
|
473
|
+
`(error, result) = context.eval(false, library)
|
|
474
|
+
if error
|
|
475
|
+
return(list(Error("DebugRemote.remoter: failed to transfer library", error)))
|
|
476
|
+
remoter.context = context
|
|
477
|
+
}
|
|
478
|
+
`(error, result) = remoter.context.eval(false, list(here[selector].1))
|
|
479
|
+
if error
|
|
480
|
+
return(list(Error("DebugRemote.remoter: method transfer failed", error)))
|
|
481
|
+
there[selector] = true // it's over there
|
|
482
|
+
}
|
|
483
|
+
`(error, result) = remoter.context.eval(cons(selector, arglist))
|
|
484
|
+
if error
|
|
485
|
+
return(list(Error("DebugRemote.remoter: method eval failed", error)))
|
|
486
|
+
return(list(false, result))
|
|
487
|
+
} (args.0, args.-1)
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// finis
|
|
491
|
+
remoter
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
/*
|
|
497
|
+
* dutInit
|
|
498
|
+
*
|
|
499
|
+
* Initialize the debugger panel.
|
|
500
|
+
*
|
|
501
|
+
*/
|
|
502
|
+
|
|
503
|
+
function dutInit(local manifest) {
|
|
504
|
+
|
|
505
|
+
manifest = `(libVarExpand, libBreakInfo, DebugRemote, dutInit)
|
|
506
|
+
|
|
507
|
+
Naan.module.build(module.id, "debugutil", function(modobj, compobj) {
|
|
508
|
+
compobj.manifest = manifest
|
|
509
|
+
})
|
|
510
|
+
}();
|