2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								/**************************************************************************/  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*  gdscript_cache.cpp                                                    */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/**************************************************************************/  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                         This file is part of:                          */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                             GODOT ENGINE                               */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                        https://godotengine.org                         */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/**************************************************************************/  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                                                                        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* Permission is hereby granted, free of charge, to any person obtaining  */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* a copy of this software and associated documentation files (the        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* "Software"), to deal in the Software without restriction, including    */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* without limitation the rights to use, copy, modify, merge, publish,    */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* distribute, sublicense, and/or sell copies of the Software, and to     */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* permit persons to whom the Software is furnished to do so, subject to  */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* the following conditions:                                              */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                                                                        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* The above copyright notice and this permission notice shall be         */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* included in all copies or substantial portions of the Software.        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*                                                                        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/**************************************************************************/  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "gdscript_cache.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "gdscript.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "gdscript_analyzer.h" 
  
						 
					
						
							
								
									
										
										
										
											2022-11-08 03:51:20 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "gdscript_compiler.h" 
  
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# include  "gdscript_parser.h" 
  
						 
					
						
							
								
									
										
										
										
											2023-06-13 16:56:21 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "core/io/file_access.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "core/templates/vector.h" 
  
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								GDScriptParserRef : : Status  GDScriptParserRef : : get_status ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  status ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-15 18:36:04 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								String  GDScriptParserRef : : get_path ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  path ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 16:13:25 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								uint32_t  GDScriptParserRef : : get_source_hash ( )  const  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  source_hash ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								GDScriptParser  * GDScriptParserRef : : get_parser ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( parser  = =  nullptr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										parser  =  memnew ( GDScriptParser ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									return  parser ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-10 21:57:35 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								GDScriptAnalyzer  * GDScriptParserRef : : get_analyzer ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( analyzer  = =  nullptr )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 16:13:25 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										analyzer  =  memnew ( GDScriptAnalyzer ( get_parser ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-10 21:57:35 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  analyzer ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								Error  GDScriptParserRef : : raise_status ( Status  p_new_status )  {  
						 
					
						
							
								
									
										
										
										
											2024-04-12 16:13:25 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ERR_FAIL_COND_V ( clearing ,  ERR_BUG ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_COND_V ( parser  = =  nullptr  & &  status  ! =  EMPTY ,  ERR_BUG ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 16:13:25 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									while  ( result  = =  OK  & &  p_new_status  >  status )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										switch  ( status )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-22 11:31:55 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											case  EMPTY :  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 16:13:25 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												// Calling parse will clear the parser, which can destruct another GDScriptParserRef which can clear the last reference to the script with this path, calling remove_script, which clears this GDScriptParserRef.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												// It's ok if its the first thing done here.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												get_parser ( ) - > clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
												status  =  PARSED ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-22 11:31:55 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												String  remapped_path  =  ResourceLoader : : path_remap ( path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												if  ( remapped_path . get_extension ( ) . to_lower ( )  = =  " gdc " )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 16:13:25 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													Vector < uint8_t >  tokens  =  GDScriptCache : : get_binary_tokens ( remapped_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													source_hash  =  hash_djb2_buffer ( tokens . ptr ( ) ,  tokens . size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													result  =  get_parser ( ) - > parse_binary ( tokens ,  path ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-22 11:31:55 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 16:13:25 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													String  source  =  GDScriptCache : : get_source_code ( remapped_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													source_hash  =  source . hash ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													result  =  get_parser ( ) - > parse ( source ,  path ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-22 11:31:55 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											}  break ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											case  PARSED :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												status  =  INHERITANCE_SOLVED ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 16:13:25 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												result  =  get_analyzer ( ) - > resolve_inheritance ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											case  INHERITANCE_SOLVED :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												status  =  INTERFACE_SOLVED ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 16:13:25 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												result  =  get_analyzer ( ) - > resolve_interface ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											case  INTERFACE_SOLVED :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												status  =  FULLY_SOLVED ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-02 02:07:47 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												result  =  get_analyzer ( ) - > resolve_body ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
											}  break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											case  FULLY_SOLVED :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												return  result ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  result ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  GDScriptParserRef : : clear ( )  {  
						 
					
						
							
								
									
										
										
										
											2024-04-12 16:13:25 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( clearing )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 16:13:25 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									clearing  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									GDScriptParser  * lparser  =  parser ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									GDScriptAnalyzer  * lanalyzer  =  analyzer ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 16:13:25 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									parser  =  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									analyzer  =  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									status  =  EMPTY ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									result  =  OK ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									source_hash  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									clearing  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( lanalyzer  ! =  nullptr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										memdelete ( lanalyzer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 16:13:25 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( lparser  ! =  nullptr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										memdelete ( lparser ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								GDScriptParserRef : : ~ GDScriptParserRef ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-02 20:55:13 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-23 12:38:30 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! abandoned )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-08-02 20:55:13 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										MutexLock  lock ( GDScriptCache : : singleton - > mutex ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										GDScriptCache : : singleton - > parser_map . erase ( path ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-23 12:38:30 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								GDScriptCache  * GDScriptCache : : singleton  =  nullptr ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-18 14:54:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								SafeBinaryMutex < GDScriptCache : : BINARY_MUTEX_TAG >  & _get_gdscript_cache_mutex ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  GDScriptCache : : mutex ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								template  < >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								thread_local  SafeBinaryMutex < GDScriptCache : : BINARY_MUTEX_TAG > : : TLSData  SafeBinaryMutex < GDScriptCache : : BINARY_MUTEX_TAG > : : tls_data ( _get_gdscript_cache_mutex ( ) ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								SafeBinaryMutex < GDScriptCache : : BINARY_MUTEX_TAG >  GDScriptCache : : mutex ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  GDScriptCache : : move_script ( const  String  & p_from ,  const  String  & p_to )  {  
						 
					
						
							
								
									
										
										
										
											2022-11-20 15:21:57 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( singleton  = =  nullptr  | |  p_from  = =  p_to )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MutexLock  lock ( singleton - > mutex ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-10 12:48:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( singleton - > cleared )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-09 08:23:22 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									remove_parser ( p_from ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-15 18:36:04 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( singleton - > shallow_gdscript_cache . has ( p_from )  & &  ! p_from . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										singleton - > shallow_gdscript_cache [ p_to ]  =  singleton - > shallow_gdscript_cache [ p_from ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									singleton - > shallow_gdscript_cache . erase ( p_from ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( singleton - > full_gdscript_cache . has ( p_from )  & &  ! p_from . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										singleton - > full_gdscript_cache [ p_to ]  =  singleton - > full_gdscript_cache [ p_from ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									singleton - > full_gdscript_cache . erase ( p_from ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								void  GDScriptCache : : remove_script ( const  String  & p_path )  {  
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( singleton  = =  nullptr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MutexLock  lock ( singleton - > mutex ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-10 12:48:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( singleton - > cleared )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-23 12:38:30 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( HashMap < String ,  Vector < ObjectID > > : : Iterator  E  =  singleton - > abandoned_parser_map . find ( p_path ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for  ( ObjectID  parser_ref_id  :  E - > value )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											Ref < GDScriptParserRef >  parser_ref {  ObjectDB : : get_instance ( parser_ref_id )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( parser_ref . is_valid ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												parser_ref - > clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									singleton - > abandoned_parser_map . erase ( p_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( singleton - > parser_map . has ( p_path ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-15 18:36:04 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										singleton - > parser_map [ p_path ] - > clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-15 18:36:04 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									remove_parser ( p_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									singleton - > dependencies . erase ( p_path ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									singleton - > shallow_gdscript_cache . erase ( p_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									singleton - > full_gdscript_cache . erase ( p_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-15 22:02:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Ref < GDScriptParserRef >  GDScriptCache : : get_parser ( const  String  & p_path ,  GDScriptParserRef : : Status  p_status ,  Error  & r_error ,  const  String  & p_owner )  {  
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									MutexLock  lock ( singleton - > mutex ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									Ref < GDScriptParserRef >  ref ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-09 03:42:46 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! p_owner . is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-15 22:02:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										singleton - > dependencies [ p_owner ] . insert ( p_path ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-15 18:36:04 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										singleton - > parser_inverse_dependencies [ p_path ] . insert ( p_owner ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-15 22:02:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  ( singleton - > parser_map . has ( p_path ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-23 11:19:35 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										ref  =  Ref < GDScriptParserRef > ( singleton - > parser_map [ p_path ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-01 00:35:05 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( ref . is_null ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											r_error  =  ERR_INVALID_DATA ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  ref ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-22 11:31:55 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										String  remapped_path  =  ResourceLoader : : path_remap ( p_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( ! FileAccess : : exists ( remapped_path ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-17 21:30:39 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											r_error  =  ERR_FILE_NOT_FOUND ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  ref ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-17 16:03:09 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										ref . instantiate ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										ref - > path  =  p_path ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-23 11:19:35 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										singleton - > parser_map [ p_path ]  =  ref . ptr ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									r_error  =  ref - > raise_status ( p_status ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  ref ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 16:13:25 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								bool  GDScriptCache : : has_parser ( const  String  & p_path )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MutexLock  lock ( singleton - > mutex ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  singleton - > parser_map . has ( p_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  GDScriptCache : : remove_parser ( const  String  & p_path )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MutexLock  lock ( singleton - > mutex ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-23 12:38:30 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( singleton - > parser_map . has ( p_path ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										GDScriptParserRef  * parser_ref  =  singleton - > parser_map [ p_path ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										parser_ref - > abandoned  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										singleton - > abandoned_parser_map [ p_path ] . push_back ( parser_ref - > get_instance_id ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 16:13:25 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Can't clear the parser because some other parser might be currently using it in the chain of calls.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									singleton - > parser_map . erase ( p_path ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-05-15 18:36:04 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Have to copy while iterating, because parser_inverse_dependencies is modified.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									HashSet < String >  ideps  =  singleton - > parser_inverse_dependencies [ p_path ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									singleton - > parser_inverse_dependencies . erase ( p_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( String  idep_path  :  ideps )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										remove_parser ( idep_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 16:13:25 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								String  GDScriptCache : : get_source_code ( const  String  & p_path )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Vector < uint8_t >  source_file ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Error  err ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-23 11:08:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Ref < FileAccess >  f  =  FileAccess : : open ( p_path ,  FileAccess : : READ ,  & err ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-11 16:56:49 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ERR_FAIL_COND_V ( err ,  " " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-05-25 07:58:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									uint64_t  len  =  f - > get_length ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									source_file . resize ( len  +  1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2019-03-26 18:51:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									uint64_t  r  =  f - > get_buffer ( source_file . ptrw ( ) ,  len ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_COND_V ( r  ! =  len ,  " " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									source_file . write [ len ]  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									String  source ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 15:18:29 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( source . parse_utf8 ( ( const  char  * ) source_file . ptr ( ) )  ! =  OK )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										ERR_FAIL_V_MSG ( " " ,  " Script ' "  +  p_path  +  " ' contains invalid unicode (UTF-8), so it was not loaded. Please ensure that scripts are saved in valid UTF-8 unicode. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  source ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-22 11:31:55 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Vector < uint8_t >  GDScriptCache : : get_binary_tokens ( const  String  & p_path )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Vector < uint8_t >  buffer ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Error  err  =  OK ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Ref < FileAccess >  f  =  FileAccess : : open ( p_path ,  FileAccess : : READ ,  & err ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_COND_V_MSG ( err  ! =  OK ,  buffer ,  " Failed to open binary GDScript file ' "  +  p_path  +  " '. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									uint64_t  len  =  f - > get_length ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									buffer . resize ( len ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									uint64_t  read  =  f - > get_buffer ( buffer . ptrw ( ) ,  buffer . size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_COND_V_MSG ( read  ! =  len ,  Vector < uint8_t > ( ) ,  " Failed to read binary GDScript file ' "  +  p_path  +  " '. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  buffer ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-08 03:51:20 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Ref < GDScript >  GDScriptCache : : get_shallow_script ( const  String  & p_path ,  Error  & r_error ,  const  String  & p_owner )  {  
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									MutexLock  lock ( singleton - > mutex ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-09 03:42:46 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! p_owner . is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										singleton - > dependencies [ p_owner ] . insert ( p_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( singleton - > full_gdscript_cache . has ( p_path ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  singleton - > full_gdscript_cache [ p_path ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( singleton - > shallow_gdscript_cache . has ( p_path ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  singleton - > shallow_gdscript_cache [ p_path ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-01-22 11:31:55 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									String  remapped_path  =  ResourceLoader : : path_remap ( p_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									Ref < GDScript >  script ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-17 16:03:09 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									script . instantiate ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-15 22:02:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									script - > set_path ( p_path ,  true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-22 11:31:55 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( remapped_path . get_extension ( ) . to_lower ( )  = =  " gdc " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Vector < uint8_t >  buffer  =  get_binary_tokens ( remapped_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( buffer . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											r_error  =  ERR_FILE_CANT_READ ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										script - > set_binary_tokens_source ( buffer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										r_error  =  script - > load_source_code ( remapped_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-11 22:32:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( r_error )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  Ref < GDScript > ( ) ;  // Returns null and does not cache when the script fails to load.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-20 03:17:16 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Ref < GDScriptParserRef >  parser_ref  =  get_parser ( p_path ,  GDScriptParserRef : : PARSED ,  r_error ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-20 13:06:14 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( r_error  = =  OK )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										GDScriptCompiler : : make_scripts ( script . ptr ( ) ,  parser_ref - > get_parser ( ) - > get_tree ( ) ,  true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-20 03:17:16 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									singleton - > shallow_gdscript_cache [ p_path ]  =  script ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									return  script ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 12:40:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Ref < GDScript >  GDScriptCache : : get_full_script ( const  String  & p_path ,  Error  & r_error ,  const  String  & p_owner ,  bool  p_update_from_disk )  {  
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									MutexLock  lock ( singleton - > mutex ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-09 03:42:46 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! p_owner . is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										singleton - > dependencies [ p_owner ] . insert ( p_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 12:40:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Ref < GDScript >  script ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									r_error  =  OK ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( singleton - > full_gdscript_cache . has ( p_path ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-27 10:31:53 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										script  =  singleton - > full_gdscript_cache [ p_path ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 12:40:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( ! p_update_from_disk )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  script ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-16 16:27:25 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 12:40:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( script . is_null ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-08 03:51:20 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										script  =  get_shallow_script ( p_path ,  r_error ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-18 04:18:29 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Only exit early if script failed to load, otherwise let reload report errors.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( script . is_null ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-08 03:51:20 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  script ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 12:40:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-08 03:51:20 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( p_update_from_disk )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-01-22 11:31:55 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( p_path . get_extension ( ) . to_lower ( )  = =  " gdc " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											Vector < uint8_t >  buffer  =  get_binary_tokens ( p_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( buffer . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												r_error  =  ERR_FILE_CANT_READ ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												return  script ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											script - > set_binary_tokens_source ( buffer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											r_error  =  script - > load_source_code ( p_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( r_error )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												return  script ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-07 11:13:48 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-08 03:51:20 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-15 22:02:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-19 11:13:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Allowing lifting the lock might cause a script to be reloaded multiple times,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// which, as a last resort deadlock prevention strategy, is a good tradeoff.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-18 14:54:58 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									uint32_t  allowance_id  =  WorkerThreadPool : : thread_enter_unlock_allowance_zone ( singleton - > mutex ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-07 11:13:48 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									r_error  =  script - > reload ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-19 11:13:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									WorkerThreadPool : : thread_exit_unlock_allowance_zone ( allowance_id ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-15 22:02:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( r_error )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  script ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									singleton - > full_gdscript_cache [ p_path ]  =  script ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									singleton - > shallow_gdscript_cache . erase ( p_path ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									return  script ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-08 03:51:20 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Ref < GDScript >  GDScriptCache : : get_cached_script ( const  String  & p_path )  {  
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									MutexLock  lock ( singleton - > mutex ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-08 03:51:20 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( singleton - > full_gdscript_cache . has ( p_path ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  singleton - > full_gdscript_cache [ p_path ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( singleton - > shallow_gdscript_cache . has ( p_path ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  singleton - > shallow_gdscript_cache [ p_path ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  Ref < GDScript > ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								Error  GDScriptCache : : finish_compiling ( const  String  & p_owner )  {  
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									MutexLock  lock ( singleton - > mutex ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-08 03:51:20 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-15 22:02:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Mark this as compiled.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-08 03:51:20 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Ref < GDScript >  script  =  get_cached_script ( p_owner ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									singleton - > full_gdscript_cache [ p_owner ]  =  script ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-15 22:02:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									singleton - > shallow_gdscript_cache . erase ( p_owner ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-19 17:00:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									HashSet < String >  depends  =  singleton - > dependencies [ p_owner ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Error  err  =  OK ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-19 17:00:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  ( const  String  & E  :  depends )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										Error  this_err  =  OK ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// No need to save the script. We assume it's already referenced in the owner.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-05-19 17:00:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										get_full_script ( E ,  this_err ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( this_err  ! =  OK )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											err  =  this_err ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-15 22:02:44 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									singleton - > dependencies . erase ( p_owner ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									return  err ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-19 11:10:35 -03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  GDScriptCache : : add_static_script ( Ref < GDScript >  p_script )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_COND_MSG ( p_script . is_null ( ) ,  " Trying to cache empty script as static. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ERR_FAIL_COND_MSG ( ! p_script - > is_valid ( ) ,  " Trying to cache non-compiled script as static. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									singleton - > static_gdscript_cache [ p_script - > get_fully_qualified_name ( ) ]  =  p_script ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  GDScriptCache : : remove_static_script ( const  String  & p_fqcn )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									singleton - > static_gdscript_cache . erase ( p_fqcn ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-02 13:27:26 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  GDScriptCache : : clear ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( singleton  = =  nullptr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-02 13:27:26 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									MutexLock  lock ( singleton - > mutex ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-10 12:48:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( singleton - > cleared )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									singleton - > cleared  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-05-15 18:36:04 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									singleton - > parser_inverse_dependencies . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-23 12:38:30 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  ( const  KeyValue < String ,  Vector < ObjectID > >  & KV  :  singleton - > abandoned_parser_map )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for  ( ObjectID  parser_ref_id  :  KV . value )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											Ref < GDScriptParserRef >  parser_ref {  ObjectDB : : get_instance ( parser_ref_id )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( parser_ref . is_valid ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												parser_ref - > clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									singleton - > abandoned_parser_map . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									RBSet < Ref < GDScriptParserRef > >  parser_map_refs ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-02 13:27:26 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  ( KeyValue < String ,  GDScriptParserRef  * >  & E  :  singleton - > parser_map )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										parser_map_refs . insert ( E . value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 16:13:25 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									singleton - > parser_map . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  ( Ref < GDScriptParserRef >  & E  :  parser_map_refs )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 16:13:25 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( E . is_valid ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											E - > clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-04-12 16:13:25 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									parser_map_refs . clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-02 13:27:26 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									singleton - > shallow_gdscript_cache . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									singleton - > full_gdscript_cache . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								GDScriptCache : : GDScriptCache ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									singleton  =  this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2022-10-09 12:41:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-02 13:27:26 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								GDScriptCache : : ~ GDScriptCache ( )  {  
						 
					
						
							
								
									
										
										
										
											2022-12-10 12:48:07 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! cleared )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 18:15:09 -03:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									singleton  =  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}