gdscript.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. /*************************************************************************/
  2. /* gdscript.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef GDSCRIPT_H
  31. #define GDSCRIPT_H
  32. #include "core/debugger/engine_debugger.h"
  33. #include "core/debugger/script_debugger.h"
  34. #include "core/io/resource_loader.h"
  35. #include "core/io/resource_saver.h"
  36. #include "core/script_language.h"
  37. #include "gdscript_function.h"
  38. class GDScriptNativeClass : public Reference {
  39. GDCLASS(GDScriptNativeClass, Reference);
  40. StringName name;
  41. protected:
  42. bool _get(const StringName &p_name, Variant &r_ret) const;
  43. static void _bind_methods();
  44. public:
  45. _FORCE_INLINE_ const StringName &get_name() const { return name; }
  46. Variant _new();
  47. Object *instance();
  48. GDScriptNativeClass(const StringName &p_name);
  49. };
  50. class GDScript : public Script {
  51. GDCLASS(GDScript, Script);
  52. bool tool;
  53. bool valid;
  54. struct MemberInfo {
  55. int index;
  56. StringName setter;
  57. StringName getter;
  58. MultiplayerAPI::RPCMode rpc_mode;
  59. GDScriptDataType data_type;
  60. };
  61. friend class GDScriptInstance;
  62. friend class GDScriptFunction;
  63. friend class GDScriptCompiler;
  64. friend class GDScriptFunctions;
  65. friend class GDScriptLanguage;
  66. Ref<GDScriptNativeClass> native;
  67. Ref<GDScript> base;
  68. GDScript *_base; //fast pointer access
  69. GDScript *_owner; //for subclasses
  70. Set<StringName> members; //members are just indices to the instanced script.
  71. Map<StringName, Variant> constants;
  72. Map<StringName, GDScriptFunction *> member_functions;
  73. Map<StringName, MemberInfo> member_indices; //members are just indices to the instanced script.
  74. Map<StringName, Ref<GDScript>> subclasses;
  75. Map<StringName, Vector<StringName>> _signals;
  76. Vector<ScriptNetData> rpc_functions;
  77. Vector<ScriptNetData> rpc_variables;
  78. #ifdef TOOLS_ENABLED
  79. Map<StringName, int> member_lines;
  80. Map<StringName, Variant> member_default_values;
  81. List<PropertyInfo> members_cache;
  82. Map<StringName, Variant> member_default_values_cache;
  83. Ref<GDScript> base_cache;
  84. Set<ObjectID> inheriters_cache;
  85. bool source_changed_cache;
  86. bool placeholder_fallback_enabled;
  87. void _update_exports_values(Map<StringName, Variant> &values, List<PropertyInfo> &propnames);
  88. #endif
  89. Map<StringName, PropertyInfo> member_info;
  90. GDScriptFunction *initializer; //direct pointer to _init , faster to locate
  91. int subclass_count;
  92. Set<Object *> instances;
  93. //exported members
  94. String source;
  95. String path;
  96. String name;
  97. String fully_qualified_name;
  98. SelfList<GDScript> script_list;
  99. SelfList<GDScriptFunctionState>::List pending_func_states;
  100. GDScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Callable::CallError &r_error);
  101. void _set_subclass_path(Ref<GDScript> &p_sc, const String &p_path);
  102. #ifdef TOOLS_ENABLED
  103. Set<PlaceHolderScriptInstance *> placeholders;
  104. //void _update_placeholder(PlaceHolderScriptInstance *p_placeholder);
  105. virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder);
  106. #endif
  107. #ifdef DEBUG_ENABLED
  108. Map<ObjectID, List<Pair<StringName, Variant>>> pending_reload_state;
  109. #endif
  110. bool _update_exports(bool *r_err = nullptr, bool p_recursive_call = false);
  111. void _save_orphaned_subclasses();
  112. void _init_rpc_methods_properties();
  113. protected:
  114. bool _get(const StringName &p_name, Variant &r_ret) const;
  115. bool _set(const StringName &p_name, const Variant &p_value);
  116. void _get_property_list(List<PropertyInfo> *p_properties) const;
  117. Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error);
  118. //void call_multilevel(const StringName& p_method,const Variant** p_args,int p_argcount);
  119. static void _bind_methods();
  120. public:
  121. virtual bool is_valid() const { return valid; }
  122. bool inherits_script(const Ref<Script> &p_script) const;
  123. const Map<StringName, Ref<GDScript>> &get_subclasses() const { return subclasses; }
  124. const Map<StringName, Variant> &get_constants() const { return constants; }
  125. const Set<StringName> &get_members() const { return members; }
  126. const GDScriptDataType &get_member_type(const StringName &p_member) const {
  127. CRASH_COND(!member_indices.has(p_member));
  128. return member_indices[p_member].data_type;
  129. }
  130. const Map<StringName, GDScriptFunction *> &get_member_functions() const { return member_functions; }
  131. const Ref<GDScriptNativeClass> &get_native() const { return native; }
  132. const String &get_script_class_name() const { return name; }
  133. virtual bool has_script_signal(const StringName &p_signal) const;
  134. virtual void get_script_signal_list(List<MethodInfo> *r_signals) const;
  135. bool is_tool() const { return tool; }
  136. Ref<GDScript> get_base() const;
  137. const Map<StringName, MemberInfo> &debug_get_member_indices() const { return member_indices; }
  138. const Map<StringName, GDScriptFunction *> &debug_get_member_functions() const; //this is debug only
  139. StringName debug_get_member_by_index(int p_idx) const;
  140. Variant _new(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
  141. virtual bool can_instance() const;
  142. virtual Ref<Script> get_base_script() const;
  143. virtual StringName get_instance_base_type() const; // this may not work in all scripts, will return empty if so
  144. virtual ScriptInstance *instance_create(Object *p_this);
  145. virtual PlaceHolderScriptInstance *placeholder_instance_create(Object *p_this);
  146. virtual bool instance_has(const Object *p_this) const;
  147. virtual bool has_source_code() const;
  148. virtual String get_source_code() const;
  149. virtual void set_source_code(const String &p_code);
  150. virtual void update_exports();
  151. virtual Error reload(bool p_keep_state = false);
  152. void set_script_path(const String &p_path) { path = p_path; } //because subclasses need a path too...
  153. Error load_source_code(const String &p_path);
  154. Error load_byte_code(const String &p_path);
  155. Vector<uint8_t> get_as_byte_code() const;
  156. bool get_property_default_value(const StringName &p_property, Variant &r_value) const;
  157. virtual void get_script_method_list(List<MethodInfo> *p_list) const;
  158. virtual bool has_method(const StringName &p_method) const;
  159. virtual MethodInfo get_method_info(const StringName &p_method) const;
  160. virtual void get_script_property_list(List<PropertyInfo> *p_list) const;
  161. virtual ScriptLanguage *get_language() const;
  162. virtual int get_member_line(const StringName &p_member) const {
  163. #ifdef TOOLS_ENABLED
  164. if (member_lines.has(p_member))
  165. return member_lines[p_member];
  166. else
  167. #endif
  168. return -1;
  169. }
  170. virtual void get_constants(Map<StringName, Variant> *p_constants);
  171. virtual void get_members(Set<StringName> *p_members);
  172. virtual Vector<ScriptNetData> get_rpc_methods() const;
  173. virtual uint16_t get_rpc_method_id(const StringName &p_method) const;
  174. virtual StringName get_rpc_method(const uint16_t p_rpc_method_id) const;
  175. virtual MultiplayerAPI::RPCMode get_rpc_mode_by_id(const uint16_t p_rpc_method_id) const;
  176. virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
  177. virtual Vector<ScriptNetData> get_rset_properties() const;
  178. virtual uint16_t get_rset_property_id(const StringName &p_variable) const;
  179. virtual StringName get_rset_property(const uint16_t p_variable_id) const;
  180. virtual MultiplayerAPI::RPCMode get_rset_mode_by_id(const uint16_t p_variable_id) const;
  181. virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
  182. #ifdef TOOLS_ENABLED
  183. virtual bool is_placeholder_fallback_enabled() const { return placeholder_fallback_enabled; }
  184. #endif
  185. GDScript();
  186. ~GDScript();
  187. };
  188. class GDScriptInstance : public ScriptInstance {
  189. friend class GDScript;
  190. friend class GDScriptFunction;
  191. friend class GDScriptFunctions;
  192. friend class GDScriptCompiler;
  193. ObjectID owner_id;
  194. Object *owner;
  195. Ref<GDScript> script;
  196. #ifdef DEBUG_ENABLED
  197. Map<StringName, int> member_indices_cache; //used only for hot script reloading
  198. #endif
  199. Vector<Variant> members;
  200. bool base_ref;
  201. SelfList<GDScriptFunctionState>::List pending_func_states;
  202. void _ml_call_reversed(GDScript *sptr, const StringName &p_method, const Variant **p_args, int p_argcount);
  203. public:
  204. virtual Object *get_owner() { return owner; }
  205. virtual bool set(const StringName &p_name, const Variant &p_value);
  206. virtual bool get(const StringName &p_name, Variant &r_ret) const;
  207. virtual void get_property_list(List<PropertyInfo> *p_properties) const;
  208. virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const;
  209. virtual void get_method_list(List<MethodInfo> *p_list) const;
  210. virtual bool has_method(const StringName &p_method) const;
  211. virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error);
  212. virtual void call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount);
  213. virtual void call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount);
  214. Variant debug_get_member_by_index(int p_idx) const { return members[p_idx]; }
  215. virtual void notification(int p_notification);
  216. String to_string(bool *r_valid);
  217. virtual Ref<Script> get_script() const;
  218. virtual ScriptLanguage *get_language();
  219. void set_path(const String &p_path);
  220. void reload_members();
  221. virtual Vector<ScriptNetData> get_rpc_methods() const;
  222. virtual uint16_t get_rpc_method_id(const StringName &p_method) const;
  223. virtual StringName get_rpc_method(const uint16_t p_rpc_method_id) const;
  224. virtual MultiplayerAPI::RPCMode get_rpc_mode_by_id(const uint16_t p_rpc_method_id) const;
  225. virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
  226. virtual Vector<ScriptNetData> get_rset_properties() const;
  227. virtual uint16_t get_rset_property_id(const StringName &p_variable) const;
  228. virtual StringName get_rset_property(const uint16_t p_variable_id) const;
  229. virtual MultiplayerAPI::RPCMode get_rset_mode_by_id(const uint16_t p_variable_id) const;
  230. virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
  231. GDScriptInstance();
  232. ~GDScriptInstance();
  233. };
  234. #ifdef DEBUG_ENABLED
  235. struct GDScriptWarning {
  236. enum Code {
  237. UNASSIGNED_VARIABLE, // Variable used but never assigned
  238. UNASSIGNED_VARIABLE_OP_ASSIGN, // Variable never assigned but used in an assignment operation (+=, *=, etc)
  239. UNUSED_VARIABLE, // Local variable is declared but never used
  240. SHADOWED_VARIABLE, // Variable name shadowed by other variable
  241. UNUSED_CLASS_VARIABLE, // Class variable is declared but never used in the file
  242. UNUSED_ARGUMENT, // Function argument is never used
  243. UNREACHABLE_CODE, // Code after a return statement
  244. STANDALONE_EXPRESSION, // Expression not assigned to a variable
  245. VOID_ASSIGNMENT, // Function returns void but it's assigned to a variable
  246. NARROWING_CONVERSION, // Float value into an integer slot, precision is lost
  247. FUNCTION_MAY_YIELD, // Typed assign of function call that yields (it may return a function state)
  248. VARIABLE_CONFLICTS_FUNCTION, // Variable has the same name of a function
  249. FUNCTION_CONFLICTS_VARIABLE, // Function has the same name of a variable
  250. FUNCTION_CONFLICTS_CONSTANT, // Function has the same name of a constant
  251. INCOMPATIBLE_TERNARY, // Possible values of a ternary if are not mutually compatible
  252. UNUSED_SIGNAL, // Signal is defined but never emitted
  253. RETURN_VALUE_DISCARDED, // Function call returns something but the value isn't used
  254. PROPERTY_USED_AS_FUNCTION, // Function not found, but there's a property with the same name
  255. CONSTANT_USED_AS_FUNCTION, // Function not found, but there's a constant with the same name
  256. FUNCTION_USED_AS_PROPERTY, // Property not found, but there's a function with the same name
  257. INTEGER_DIVISION, // Integer divide by integer, decimal part is discarded
  258. UNSAFE_PROPERTY_ACCESS, // Property not found in the detected type (but can be in subtypes)
  259. UNSAFE_METHOD_ACCESS, // Function not found in the detected type (but can be in subtypes)
  260. UNSAFE_CAST, // Cast used in an unknown type
  261. UNSAFE_CALL_ARGUMENT, // Function call argument is of a supertype of the require argument
  262. DEPRECATED_KEYWORD, // The keyword is deprecated and should be replaced
  263. STANDALONE_TERNARY, // Return value of ternary expression is discarded
  264. WARNING_MAX,
  265. } code;
  266. Vector<String> symbols;
  267. int line;
  268. String get_name() const;
  269. String get_message() const;
  270. static String get_name_from_code(Code p_code);
  271. static Code get_code_from_name(const String &p_name);
  272. GDScriptWarning() :
  273. code(WARNING_MAX),
  274. line(-1) {}
  275. };
  276. #endif // DEBUG_ENABLED
  277. class GDScriptLanguage : public ScriptLanguage {
  278. friend class GDScriptFunctionState;
  279. static GDScriptLanguage *singleton;
  280. Variant *_global_array;
  281. Vector<Variant> global_array;
  282. Map<StringName, int> globals;
  283. Map<StringName, Variant> named_globals;
  284. struct CallLevel {
  285. Variant *stack;
  286. GDScriptFunction *function;
  287. GDScriptInstance *instance;
  288. int *ip;
  289. int *line;
  290. };
  291. int _debug_parse_err_line;
  292. String _debug_parse_err_file;
  293. String _debug_error;
  294. int _debug_call_stack_pos;
  295. int _debug_max_call_stack;
  296. CallLevel *_call_stack;
  297. void _add_global(const StringName &p_name, const Variant &p_value);
  298. friend class GDScriptInstance;
  299. Mutex lock;
  300. friend class GDScript;
  301. SelfList<GDScript>::List script_list;
  302. friend class GDScriptFunction;
  303. SelfList<GDScriptFunction>::List function_list;
  304. bool profiling;
  305. uint64_t script_frame_time;
  306. Map<String, ObjectID> orphan_subclasses;
  307. public:
  308. int calls;
  309. bool debug_break(const String &p_error, bool p_allow_continue = true);
  310. bool debug_break_parse(const String &p_file, int p_line, const String &p_error);
  311. _FORCE_INLINE_ void enter_function(GDScriptInstance *p_instance, GDScriptFunction *p_function, Variant *p_stack, int *p_ip, int *p_line) {
  312. if (Thread::get_main_id() != Thread::get_caller_id())
  313. return; //no support for other threads than main for now
  314. if (EngineDebugger::get_script_debugger()->get_lines_left() > 0 && EngineDebugger::get_script_debugger()->get_depth() >= 0)
  315. EngineDebugger::get_script_debugger()->set_depth(EngineDebugger::get_script_debugger()->get_depth() + 1);
  316. if (_debug_call_stack_pos >= _debug_max_call_stack) {
  317. //stack overflow
  318. _debug_error = "Stack Overflow (Stack Size: " + itos(_debug_max_call_stack) + ")";
  319. EngineDebugger::get_script_debugger()->debug(this);
  320. return;
  321. }
  322. _call_stack[_debug_call_stack_pos].stack = p_stack;
  323. _call_stack[_debug_call_stack_pos].instance = p_instance;
  324. _call_stack[_debug_call_stack_pos].function = p_function;
  325. _call_stack[_debug_call_stack_pos].ip = p_ip;
  326. _call_stack[_debug_call_stack_pos].line = p_line;
  327. _debug_call_stack_pos++;
  328. }
  329. _FORCE_INLINE_ void exit_function() {
  330. if (Thread::get_main_id() != Thread::get_caller_id())
  331. return; //no support for other threads than main for now
  332. if (EngineDebugger::get_script_debugger()->get_lines_left() > 0 && EngineDebugger::get_script_debugger()->get_depth() >= 0)
  333. EngineDebugger::get_script_debugger()->set_depth(EngineDebugger::get_script_debugger()->get_depth() - 1);
  334. if (_debug_call_stack_pos == 0) {
  335. _debug_error = "Stack Underflow (Engine Bug)";
  336. EngineDebugger::get_script_debugger()->debug(this);
  337. return;
  338. }
  339. _debug_call_stack_pos--;
  340. }
  341. virtual Vector<StackInfo> debug_get_current_stack_info() {
  342. if (Thread::get_main_id() != Thread::get_caller_id())
  343. return Vector<StackInfo>();
  344. Vector<StackInfo> csi;
  345. csi.resize(_debug_call_stack_pos);
  346. for (int i = 0; i < _debug_call_stack_pos; i++) {
  347. csi.write[_debug_call_stack_pos - i - 1].line = _call_stack[i].line ? *_call_stack[i].line : 0;
  348. if (_call_stack[i].function) {
  349. csi.write[_debug_call_stack_pos - i - 1].func = _call_stack[i].function->get_name();
  350. csi.write[_debug_call_stack_pos - i - 1].file = _call_stack[i].function->get_script()->get_path();
  351. }
  352. }
  353. return csi;
  354. }
  355. struct {
  356. StringName _init;
  357. StringName _notification;
  358. StringName _set;
  359. StringName _get;
  360. StringName _get_property_list;
  361. StringName _script_source;
  362. } strings;
  363. _FORCE_INLINE_ int get_global_array_size() const { return global_array.size(); }
  364. _FORCE_INLINE_ Variant *get_global_array() { return _global_array; }
  365. _FORCE_INLINE_ const Map<StringName, int> &get_global_map() const { return globals; }
  366. _FORCE_INLINE_ const Map<StringName, Variant> &get_named_globals_map() const { return named_globals; }
  367. _FORCE_INLINE_ static GDScriptLanguage *get_singleton() { return singleton; }
  368. virtual String get_name() const;
  369. /* LANGUAGE FUNCTIONS */
  370. virtual void init();
  371. virtual String get_type() const;
  372. virtual String get_extension() const;
  373. virtual Error execute_file(const String &p_path);
  374. virtual void finish();
  375. /* EDITOR FUNCTIONS */
  376. virtual void get_reserved_words(List<String> *p_words) const;
  377. virtual void get_comment_delimiters(List<String> *p_delimiters) const;
  378. virtual void get_string_delimiters(List<String> *p_delimiters) const;
  379. virtual String _get_processed_template(const String &p_template, const String &p_base_class_name) const;
  380. virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
  381. virtual bool is_using_templates();
  382. virtual void make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script);
  383. virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const;
  384. virtual Script *create_script() const;
  385. virtual bool has_named_classes() const;
  386. virtual bool supports_builtin_mode() const;
  387. virtual bool can_inherit_from_file() { return true; }
  388. virtual int find_function(const String &p_function, const String &p_code) const;
  389. virtual String make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const;
  390. virtual Error complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint);
  391. #ifdef TOOLS_ENABLED
  392. virtual Error lookup_code(const String &p_code, const String &p_symbol, const String &p_path, Object *p_owner, LookupResult &r_result);
  393. #endif
  394. virtual String _get_indentation() const;
  395. virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const;
  396. virtual void add_global_constant(const StringName &p_variable, const Variant &p_value);
  397. virtual void add_named_global_constant(const StringName &p_name, const Variant &p_value);
  398. virtual void remove_named_global_constant(const StringName &p_name);
  399. /* DEBUGGER FUNCTIONS */
  400. virtual String debug_get_error() const;
  401. virtual int debug_get_stack_level_count() const;
  402. virtual int debug_get_stack_level_line(int p_level) const;
  403. virtual String debug_get_stack_level_function(int p_level) const;
  404. virtual String debug_get_stack_level_source(int p_level) const;
  405. virtual void debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1);
  406. virtual void debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1);
  407. virtual ScriptInstance *debug_get_stack_level_instance(int p_level);
  408. virtual void debug_get_globals(List<String> *p_globals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1);
  409. virtual String debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems = -1, int p_max_depth = -1);
  410. virtual void reload_all_scripts();
  411. virtual void reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload);
  412. virtual void frame();
  413. virtual void get_public_functions(List<MethodInfo> *p_functions) const;
  414. virtual void get_public_constants(List<Pair<String, Variant>> *p_constants) const;
  415. virtual void profiling_start();
  416. virtual void profiling_stop();
  417. virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max);
  418. virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max);
  419. /* LOADER FUNCTIONS */
  420. virtual void get_recognized_extensions(List<String> *p_extensions) const;
  421. /* GLOBAL CLASSES */
  422. virtual bool handles_global_class_type(const String &p_type) const;
  423. virtual String get_global_class_name(const String &p_path, String *r_base_type = nullptr, String *r_icon_path = nullptr) const;
  424. void add_orphan_subclass(const String &p_qualified_name, const ObjectID &p_subclass);
  425. Ref<GDScript> get_orphan_subclass(const String &p_qualified_name);
  426. GDScriptLanguage();
  427. ~GDScriptLanguage();
  428. };
  429. class ResourceFormatLoaderGDScript : public ResourceFormatLoader {
  430. public:
  431. virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false);
  432. virtual void get_recognized_extensions(List<String> *p_extensions) const;
  433. virtual bool handles_type(const String &p_type) const;
  434. virtual String get_resource_type(const String &p_path) const;
  435. virtual void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false);
  436. };
  437. class ResourceFormatSaverGDScript : public ResourceFormatSaver {
  438. public:
  439. virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0);
  440. virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const;
  441. virtual bool recognize(const RES &p_resource) const;
  442. };
  443. #endif // GDSCRIPT_H