@@ -544,6 +544,9 @@ class ScriptTreeGenerator {
544
544
// This menu is special compared to other menus -- it actually has an opcode function.
545
545
return this . createConstantInput ( block . fields . SOUND_MENU . value ) ;
546
546
547
+ case 'control_get_counter' :
548
+ return new IntermediateInput ( InputOpcode . CONTROL_COUNTER , InputType . NUMBER_POS_INT | InputType . NUMBER_ZERO ) ;
549
+
547
550
case 'tw_getLastKeyPressed' :
548
551
return new IntermediateInput ( InputOpcode . TW_KEY_LAST_PRESSED , InputType . STRING ) ;
549
552
@@ -666,6 +669,10 @@ class ScriptTreeGenerator {
666
669
// We should consider analyzing this like we do for control_repeat_until
667
670
warpTimer : false
668
671
} , this . analyzeLoop ( ) ) ;
672
+ case 'control_clear_counter' :
673
+ return new IntermediateStackBlock ( StackOpcode . CONTROL_CLEAR_COUNTER ) ;
674
+ case 'control_incr_counter' :
675
+ return new IntermediateStackBlock ( StackOpcode . CONTORL_INCR_COUNTER ) ;
669
676
670
677
case 'data_addtolist' :
671
678
return new IntermediateStackBlock ( StackOpcode . LIST_ADD , {
@@ -1102,7 +1109,7 @@ class ScriptTreeGenerator {
1102
1109
const variable = block . fields [ fieldName ] ;
1103
1110
const id = variable . id ;
1104
1111
1105
- if ( Object . prototype . hasOwnProperty . call ( this . variableCache , id ) ) {
1112
+ if ( this . variableCache . hasOwnProperty ( id ) ) {
1106
1113
return this . variableCache [ id ] ;
1107
1114
}
1108
1115
@@ -1123,20 +1130,20 @@ class ScriptTreeGenerator {
1123
1130
const stage = this . stage ;
1124
1131
1125
1132
// Look for by ID in target...
1126
- if ( Object . prototype . hasOwnProperty . call ( target . variables , id ) ) {
1133
+ if ( target . variables . hasOwnProperty ( id ) ) {
1127
1134
return createVariableData ( 'target' , target . variables [ id ] ) ;
1128
1135
}
1129
1136
1130
1137
// Look for by ID in stage...
1131
1138
if ( ! target . isStage ) {
1132
- if ( stage && Object . prototype . hasOwnProperty . call ( stage . variables , id ) ) {
1139
+ if ( stage && stage . variables . hasOwnProperty ( id ) ) {
1133
1140
return createVariableData ( 'stage' , stage . variables [ id ] ) ;
1134
1141
}
1135
1142
}
1136
1143
1137
1144
// Look for by name and type in target...
1138
1145
for ( const varId in target . variables ) {
1139
- if ( Object . prototype . hasOwnProperty . call ( target . variables , varId ) ) {
1146
+ if ( target . variables . hasOwnProperty ( varId ) ) {
1140
1147
const currVar = target . variables [ varId ] ;
1141
1148
if ( currVar . name === name && currVar . type === type ) {
1142
1149
return createVariableData ( 'target' , currVar ) ;
@@ -1147,7 +1154,7 @@ class ScriptTreeGenerator {
1147
1154
// Look for by name and type in stage...
1148
1155
if ( ! target . isStage && stage ) {
1149
1156
for ( const varId in stage . variables ) {
1150
- if ( Object . prototype . hasOwnProperty . call ( stage . variables , varId ) ) {
1157
+ if ( stage . variables . hasOwnProperty ( varId ) ) {
1151
1158
const currVar = stage . variables [ varId ] ;
1152
1159
if ( currVar . name === name && currVar . type === type ) {
1153
1160
return createVariableData ( 'stage' , currVar ) ;
@@ -1165,7 +1172,7 @@ class ScriptTreeGenerator {
1165
1172
// This is necessary because the script cache is shared between clones.
1166
1173
// sprite.clones has all instances of this sprite including the original and all clones
1167
1174
for ( const clone of target . sprite . clones ) {
1168
- if ( ! Object . prototype . hasOwnProperty . call ( clone . variables , id ) ) {
1175
+ if ( ! clone . variables . hasOwnProperty ( id ) ) {
1169
1176
clone . variables [ id ] = new Variable ( id , name , type , false ) ;
1170
1177
}
1171
1178
}
@@ -1174,97 +1181,6 @@ class ScriptTreeGenerator {
1174
1181
return createVariableData ( 'target' , newVariable ) ;
1175
1182
}
1176
1183
1177
- descendProcedure ( block ) {
1178
- const procedureCode = block . mutation . proccode ;
1179
- const paramNamesIdsAndDefaults = this . blocks . getProcedureParamNamesIdsAndDefaults ( procedureCode ) ;
1180
- if ( paramNamesIdsAndDefaults === null ) {
1181
- return {
1182
- kind : 'noop'
1183
- } ;
1184
- }
1185
-
1186
- const [ paramNames , paramIds , paramDefaults ] = paramNamesIdsAndDefaults ;
1187
-
1188
- const addonBlock = this . runtime . getAddonBlock ( procedureCode ) ;
1189
- if ( addonBlock ) {
1190
- this . script . yields = true ;
1191
- const args = { } ;
1192
- for ( let i = 0 ; i < paramIds . length ; i ++ ) {
1193
- let value ;
1194
- if ( block . inputs [ paramIds [ i ] ] && block . inputs [ paramIds [ i ] ] . block ) {
1195
- value = this . descendInputOfBlock ( block , paramIds [ i ] ) ;
1196
- } else {
1197
- value = {
1198
- kind : 'constant' ,
1199
- value : paramDefaults [ i ]
1200
- } ;
1201
- }
1202
- args [ paramNames [ i ] ] = value ;
1203
- }
1204
- return {
1205
- kind : 'addons.call' ,
1206
- code : procedureCode ,
1207
- arguments : args ,
1208
- blockId : block . id
1209
- } ;
1210
- }
1211
-
1212
- const definitionId = this . blocks . getProcedureDefinition ( procedureCode ) ;
1213
- const definitionBlock = this . blocks . getBlock ( definitionId ) ;
1214
- if ( ! definitionBlock ) {
1215
- return {
1216
- kind : 'noop'
1217
- } ;
1218
- }
1219
- const innerDefinition = this . blocks . getBlock ( definitionBlock . inputs . custom_block . block ) ;
1220
-
1221
- let isWarp = this . script . isWarp ;
1222
- if ( ! isWarp ) {
1223
- if ( innerDefinition && innerDefinition . mutation ) {
1224
- const warp = innerDefinition . mutation . warp ;
1225
- if ( typeof warp === 'boolean' ) {
1226
- isWarp = warp ;
1227
- } else if ( typeof warp === 'string' ) {
1228
- isWarp = JSON . parse ( warp ) ;
1229
- }
1230
- }
1231
- }
1232
-
1233
- const variant = generateProcedureVariant ( procedureCode , isWarp ) ;
1234
-
1235
- if ( ! this . script . dependedProcedures . includes ( variant ) ) {
1236
- this . script . dependedProcedures . push ( variant ) ;
1237
- }
1238
-
1239
- // Non-warp direct recursion yields.
1240
- if ( ! this . script . isWarp ) {
1241
- if ( procedureCode === this . script . procedureCode ) {
1242
- this . script . yields = true ;
1243
- }
1244
- }
1245
-
1246
- const args = [ ] ;
1247
- for ( let i = 0 ; i < paramIds . length ; i ++ ) {
1248
- let value ;
1249
- if ( block . inputs [ paramIds [ i ] ] && block . inputs [ paramIds [ i ] ] . block ) {
1250
- value = this . descendInputOfBlock ( block , paramIds [ i ] ) ;
1251
- } else {
1252
- value = {
1253
- kind : 'constant' ,
1254
- value : paramDefaults [ i ]
1255
- } ;
1256
- }
1257
- args . push ( value ) ;
1258
- }
1259
-
1260
- return {
1261
- kind : 'procedures.call' ,
1262
- code : procedureCode ,
1263
- variant,
1264
- arguments : args
1265
- } ;
1266
- }
1267
-
1268
1184
/**
1269
1185
* Descend into an input block that uses the compatibility layer.
1270
1186
* @param {* } block The block to use the compatibility layer for.
@@ -1273,10 +1189,10 @@ class ScriptTreeGenerator {
1273
1189
*/
1274
1190
descendCompatLayerInput ( block ) {
1275
1191
const inputs = { } ;
1192
+ const fields = { } ;
1276
1193
for ( const name of Object . keys ( block . inputs ) ) {
1277
1194
inputs [ name ] = this . descendInputOfBlock ( block , name , true ) ;
1278
1195
}
1279
- const fields = { } ;
1280
1196
for ( const name of Object . keys ( block . fields ) ) {
1281
1197
fields [ name ] = block . fields [ name ] . value ;
1282
1198
}
@@ -1363,72 +1279,6 @@ class ScriptTreeGenerator {
1363
1279
}
1364
1280
}
1365
1281
1366
- descendVisualReport ( block ) {
1367
- if ( ! this . thread . stackClick || block . next ) {
1368
- return null ;
1369
- }
1370
- try {
1371
- return {
1372
- kind : 'visualReport' ,
1373
- input : this . descendInput ( block )
1374
- } ;
1375
- } catch ( e ) {
1376
- return null ;
1377
- }
1378
- }
1379
-
1380
- /**
1381
- * @param {Block } hatBlock
1382
- */
1383
- walkHat ( hatBlock ) {
1384
- const nextBlock = hatBlock . next ;
1385
- const opcode = hatBlock . opcode ;
1386
- const hatInfo = this . runtime . _hats [ opcode ] ;
1387
-
1388
- if ( this . thread . stackClick ) {
1389
- // We still need to treat the hat as a normal block (so executableHat should be false) for
1390
- // interpreter parity, but the reuslt is ignored.
1391
- const opcodeFunction = this . runtime . getOpcodeFunction ( opcode ) ;
1392
- if ( opcodeFunction ) {
1393
- return [
1394
- this . descendCompatLayer ( hatBlock ) ,
1395
- ...this . walkStack ( nextBlock )
1396
- ] ;
1397
- }
1398
- return this . walkStack ( nextBlock ) ;
1399
- }
1400
-
1401
- if ( hatInfo . edgeActivated ) {
1402
- // Edge-activated HAT
1403
- this . script . yields = true ;
1404
- this . script . executableHat = true ;
1405
- return [
1406
- {
1407
- kind : 'hat.edge' ,
1408
- id : hatBlock . id ,
1409
- condition : this . descendCompatLayer ( hatBlock )
1410
- } ,
1411
- ...this . walkStack ( nextBlock )
1412
- ] ;
1413
- }
1414
-
1415
- const opcodeFunction = this . runtime . getOpcodeFunction ( opcode ) ;
1416
- if ( opcodeFunction ) {
1417
- // Predicate-based HAT
1418
- this . script . yields = true ;
1419
- this . script . executableHat = true ;
1420
- return [
1421
- {
1422
- kind : 'hat.predicate' ,
1423
- condition : this . descendCompatLayer ( hatBlock )
1424
- } ,
1425
- ...this . walkStack ( nextBlock )
1426
- ] ;
1427
- }
1428
-
1429
- return this . walkStack ( nextBlock ) ;
1430
- }
1431
-
1432
1282
/**
1433
1283
* @param {* } hatBlock
1434
1284
* @returns {IntermediateStack }
@@ -1541,7 +1391,7 @@ class IRGenerator {
1541
1391
1542
1392
addProcedureDependencies ( dependencies ) {
1543
1393
for ( const procedureVariant of dependencies ) {
1544
- if ( Object . prototype . hasOwnProperty . call ( this . procedures , procedureVariant ) ) {
1394
+ if ( this . procedures . hasOwnProperty ( procedureVariant ) ) {
1545
1395
continue ;
1546
1396
}
1547
1397
if ( this . compilingProcedures . has ( procedureVariant ) ) {
0 commit comments