@@ -98,11 +98,7 @@ class ScriptTreeGenerator {
9898 }
9999 }
100100
101- this . oldCompilerStub = (
102- oldCompilerCompatiblity . enabled ?
103- new oldCompilerCompatiblity . ScriptTreeGeneratorStub ( this ) :
104- null
105- ) ;
101+ this . oldCompilerStub = new oldCompilerCompatiblity . ScriptTreeGeneratorStub ( this ) ;
106102 }
107103
108104 setProcedureVariant ( procedureVariant ) {
@@ -206,13 +202,6 @@ class ScriptTreeGenerator {
206202 * @returns {IntermediateInput } Compiled input node for this input.
207203 */
208204 descendInput ( block , preserveStrings = false ) {
209- if ( this . oldCompilerStub ) {
210- const oldCompilerResult = this . oldCompilerStub . descendInputFromNewCompiler ( block ) ;
211- if ( oldCompilerResult ) {
212- return oldCompilerResult ;
213- }
214- }
215-
216205 switch ( block . opcode ) {
217206 case 'colour_picker' :
218207 return this . createConstantInput ( block . fields . COLOUR . value , true ) ;
@@ -577,7 +566,14 @@ class ScriptTreeGenerator {
577566 if ( compatBlocks . inputs . includes ( block . opcode ) ) {
578567 return this . descendCompatLayerInput ( block ) ;
579568 }
580- // It might be an extension block.
569+
570+ // It might be an extension block using patches for the old compiler.
571+ const oldCompilerResult = this . oldCompilerStub . descendInputFromNewCompiler ( block ) ;
572+ if ( oldCompilerResult ) {
573+ return oldCompilerResult ;
574+ }
575+
576+ // It might be an extension block using the default compatibility layer.
581577 const blockInfo = this . getBlockInfo ( block . opcode ) ;
582578 if ( blockInfo ) {
583579 const type = blockInfo . info . blockType ;
@@ -607,13 +603,6 @@ class ScriptTreeGenerator {
607603 * @returns {IntermediateStackBlock } Compiled node for this block.
608604 */
609605 descendStackedBlock ( block ) {
610- if ( this . oldCompilerStub ) {
611- const oldCompilerResult = this . oldCompilerStub . descendStackedBlockFromNewCompiler ( block ) ;
612- if ( oldCompilerResult ) {
613- return oldCompilerResult ;
614- }
615- }
616-
617606 switch ( block . opcode ) {
618607 case 'control_all_at_once' :
619608 // In Scratch 3, this block behaves like "if 1 = 1"
@@ -955,7 +944,14 @@ class ScriptTreeGenerator {
955944 if ( compatBlocks . stacked . includes ( block . opcode ) ) {
956945 return this . descendCompatLayerStack ( block ) ;
957946 }
958- // It might be an extension block.
947+
948+ // It might be an extension block using patches for the old compiler.
949+ const oldCompilerResult = this . oldCompilerStub . descendStackedBlockFromNewCompiler ( block ) ;
950+ if ( oldCompilerResult ) {
951+ return oldCompilerResult ;
952+ }
953+
954+ // It might be an extension block using the default compatibility layer.
959955 const blockInfo = this . getBlockInfo ( block . opcode ) ;
960956 if ( blockInfo ) {
961957 const type = blockInfo . info . blockType ;
0 commit comments