@@ -180,134 +180,6 @@ const MyBlocksConverter = {
180180
181181 return block ;
182182 } ) ;
183- } ,
184-
185- // eslint-disable-next-line no-unused-vars
186- onVar : function ( scope , variable ) {
187- let block ;
188- if ( scope === 'local' ) {
189- let opcode ;
190- let blockType ;
191- if ( variable . isBoolean ) {
192- opcode = 'argument_reporter_boolean' ;
193- blockType = 'value_boolean' ;
194- } else {
195- opcode = 'argument_reporter_string_number' ;
196- blockType = 'value' ;
197- }
198- // Use normalized variable name (should already be in snake_case lowercase)
199- const normalizedName = this . _toSnakeCaseLowercase ( variable . name ) ;
200- block = this . _createBlock ( opcode , blockType , {
201- fields : {
202- VALUE : {
203- name : 'VALUE' ,
204- value : normalizedName
205- }
206- }
207- } ) ;
208- if ( Object . prototype . hasOwnProperty . call ( this . _context . argumentBlocks , variable . id ) ) {
209- this . _context . argumentBlocks [ variable . id ] . push ( block . id ) ;
210- } else {
211- this . _context . argumentBlocks [ variable . id ] = [ block . id ] ;
212- }
213- }
214- return block ;
215- } ,
216-
217- // eslint-disable-next-line no-unused-vars
218- onDefs : function ( node , saved ) {
219- const receiver = this . _process ( node . children [ 0 ] ) ;
220- if ( ! this . _isSelf ( receiver ) ) {
221- return null ;
222- }
223-
224- const procedureName = node . children [ 1 ] . toString ( ) ;
225- const block = this . _createBlock ( 'procedures_definition' , 'hat' , {
226- topLevel : true
227- } ) ;
228- const procedure = this . _createProcedure ( procedureName ) ;
229-
230- const customBlock = this . _createBlock ( 'procedures_prototype' , 'statement' , {
231- shadow : true
232- } ) ;
233- this . _addInput ( block , 'custom_block' , customBlock ) ;
234-
235- this . _context . localVariables = { } ;
236- this . _process ( node . children [ 2 ] ) . forEach ( n => {
237- const originalName = n . toString ( ) ;
238- // Convert argument name to snake_case lowercase
239- const normalizedName = this . _toSnakeCaseLowercase ( originalName ) ;
240-
241- procedure . argumentNames . push ( normalizedName ) ;
242- procedure . argumentVariables . push ( this . _lookupOrCreateVariable ( normalizedName ) ) ;
243- procedure . procCode . push ( '%s' ) ;
244- procedure . argumentDefaults . push ( '' ) ;
245- const inputId = Blockly . utils . genUid ( ) ;
246- procedure . argumentIds . push ( inputId ) ;
247- const inputBlock = this . _createBlock ( 'argument_reporter_string_number' , 'value' , {
248- fields : {
249- VALUE : {
250- name : 'VALUE' ,
251- value : normalizedName
252- }
253- } ,
254- shadow : true
255- } ) ;
256- this . _addInput ( customBlock , inputId , inputBlock ) ;
257- procedure . argumentBlocks . push ( inputBlock ) ;
258- } ) ;
259-
260- let body = this . _process ( node . children [ 3 ] ) ;
261- if ( ! _ . isArray ( body ) ) {
262- body = [ body ] ;
263- }
264- if ( this . _isBlock ( body [ 0 ] ) ) {
265- block . next = body [ 0 ] . id ;
266- body [ 0 ] . parent = block . id ;
267- }
268-
269- const booleanIndexes = [ ] ;
270- procedure . argumentVariables . forEach ( ( v , i ) => {
271- if ( v . isBoolean ) {
272- booleanIndexes . push ( i ) ;
273- procedure . procCode [ i + 1 ] = '%b' ;
274- procedure . argumentDefaults [ i ] = 'false' ;
275- procedure . argumentBlocks [ i ] . opcode = 'argument_reporter_boolean' ;
276- this . _setBlockType ( procedure . argumentBlocks [ i ] , 'value_boolean' ) ;
277- }
278- } ) ;
279-
280- if ( booleanIndexes . length > 0 &&
281- Object . prototype . hasOwnProperty . call ( this . _context . procedureCallBlocks , procedure . id ) ) {
282- this . _context . procedureCallBlocks [ procedure . id ] . forEach ( id => {
283- const b = this . _context . blocks [ id ] ;
284- b . mutation . proccode = procedure . procCode . join ( ' ' ) ;
285- booleanIndexes . forEach ( booleanIndex => {
286- const input = b . inputs [ procedure . argumentIds [ booleanIndex ] ] ;
287- const inputBlock = this . _context . blocks [ input . block ] ;
288- if ( inputBlock ) {
289- if ( ! inputBlock . shadow && input . shadow ) {
290- delete this . _context . blocks [ input . shadow ] ;
291- input . shadow = null ;
292- }
293- }
294- } ) ;
295- } ) ;
296- }
297-
298- customBlock . mutation = {
299- argumentdefaults : JSON . stringify ( procedure . argumentDefaults ) ,
300- argumentids : JSON . stringify ( procedure . argumentIds ) ,
301- argumentnames : JSON . stringify ( procedure . argumentNames ) ,
302- children : [ ] ,
303- proccode : procedure . procCode . join ( ' ' ) ,
304- tagName : 'mutation' ,
305- warp : 'false'
306- } ;
307-
308- this . _restoreContext ( { localVariables : saved . localVariables } ) ;
309-
310- return block ;
311183 }
312184} ;
313185
0 commit comments