Skip to content

Commit ee4c39a

Browse files
authored
jwScope depth
1 parent c7a61a9 commit ee4c39a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/extensions/jwScope/index.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ const jwScope = {
6262
}
6363
},
6464

65+
depth(array) {
66+
return array.length
67+
}
68+
6569
current(array) {
6670
let set = new Set()
6771
for (let i = 0; i < array.length; i++) {
@@ -186,13 +190,18 @@ class Extension {
186190
}
187191
},
188192
},
189-
"---",
190193
{
191194
opcode: "reset",
192195
blockType: BlockType.COMMAND,
193196
text: "reset scope"
194197
},
195198
"---",
199+
{
200+
opcode: "depth",
201+
blockType: BlockType.REPORTER,
202+
text: "depth of scope"
203+
},
204+
"---",
196205
{
197206
opcode: "current",
198207
text: "current scope",
@@ -245,6 +254,9 @@ class Extension {
245254
reset: (generator, block) => ({
246255
kind: 'stack'
247256
}),
257+
depth: (generator, block) => ({
258+
kind: 'input'
259+
}),
248260
current: (generator, block) => ({
249261
kind: 'input'
250262
}),
@@ -274,6 +286,9 @@ class Extension {
274286
reset: (node, compiler, imports) => {
275287
compiler.source += `vm.jwScope.reset(jwScope);\n`
276288
},
289+
depth: (node, compiler, imports) => {
290+
return new imports.TypedInput(`vm.jwScope.depth(jwScope)`, imports.TYPE_NUMBER)
291+
},
277292
current: (node, compiler, imports) => {
278293
return new imports.TypedInput(!!vm.jwArray ? 'vm.jwScope.current(jwScope)' : '0', imports.TYPE_UNKNOWN)
279294
},

0 commit comments

Comments
 (0)