mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-21 07:04:22 +01:00
Mass rename classes in the cscript module.
This commit is contained in:
parent
e687fc6a4a
commit
e92d4e0f97
File diff suppressed because it is too large
Load Diff
@ -35,8 +35,8 @@
|
|||||||
#include "core/script_language.h"
|
#include "core/script_language.h"
|
||||||
#include "cscript_function.h"
|
#include "cscript_function.h"
|
||||||
|
|
||||||
class GDScriptNativeClass : public Reference {
|
class CScriptNativeClass : public Reference {
|
||||||
GDCLASS(GDScriptNativeClass, Reference);
|
GDCLASS(CScriptNativeClass, Reference);
|
||||||
|
|
||||||
StringName name;
|
StringName name;
|
||||||
|
|
||||||
@ -48,11 +48,11 @@ public:
|
|||||||
_FORCE_INLINE_ const StringName &get_name() const { return name; }
|
_FORCE_INLINE_ const StringName &get_name() const { return name; }
|
||||||
Variant _new();
|
Variant _new();
|
||||||
Object *instance();
|
Object *instance();
|
||||||
GDScriptNativeClass(const StringName &p_name);
|
CScriptNativeClass(const StringName &p_name);
|
||||||
};
|
};
|
||||||
|
|
||||||
class GDScript : public Script {
|
class CScript : public Script {
|
||||||
GDCLASS(GDScript, Script);
|
GDCLASS(CScript, Script);
|
||||||
bool tool;
|
bool tool;
|
||||||
bool valid;
|
bool valid;
|
||||||
|
|
||||||
@ -61,25 +61,25 @@ class GDScript : public Script {
|
|||||||
StringName setter;
|
StringName setter;
|
||||||
StringName getter;
|
StringName getter;
|
||||||
MultiplayerAPI::RPCMode rpc_mode;
|
MultiplayerAPI::RPCMode rpc_mode;
|
||||||
GDScriptDataType data_type;
|
CScriptDataType data_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
friend class GDScriptInstance;
|
friend class CScriptInstance;
|
||||||
friend class GDScriptFunction;
|
friend class CScriptFunction;
|
||||||
friend class GDScriptCompiler;
|
friend class CScriptCompiler;
|
||||||
friend class GDScriptFunctions;
|
friend class CScriptFunctions;
|
||||||
friend class GDScriptLanguage;
|
friend class CScriptLanguage;
|
||||||
|
|
||||||
Ref<GDScriptNativeClass> native;
|
Ref<CScriptNativeClass> native;
|
||||||
Ref<GDScript> base;
|
Ref<CScript> base;
|
||||||
GDScript *_base; //fast pointer access
|
CScript *_base; //fast pointer access
|
||||||
GDScript *_owner; //for subclasses
|
CScript *_owner; //for subclasses
|
||||||
|
|
||||||
Set<StringName> members; //members are just indices to the instanced script.
|
Set<StringName> members; //members are just indices to the instanced script.
|
||||||
Map<StringName, Variant> constants;
|
Map<StringName, Variant> constants;
|
||||||
Map<StringName, GDScriptFunction *> member_functions;
|
Map<StringName, CScriptFunction *> member_functions;
|
||||||
Map<StringName, MemberInfo> member_indices; //members are just indices to the instanced script.
|
Map<StringName, MemberInfo> member_indices; //members are just indices to the instanced script.
|
||||||
Map<StringName, Ref<GDScript>> subclasses;
|
Map<StringName, Ref<CScript>> subclasses;
|
||||||
Map<StringName, Vector<StringName>> _signals;
|
Map<StringName, Vector<StringName>> _signals;
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
@ -90,7 +90,7 @@ class GDScript : public Script {
|
|||||||
|
|
||||||
List<PropertyInfo> members_cache;
|
List<PropertyInfo> members_cache;
|
||||||
Map<StringName, Variant> member_default_values_cache;
|
Map<StringName, Variant> member_default_values_cache;
|
||||||
Ref<GDScript> base_cache;
|
Ref<CScript> base_cache;
|
||||||
Set<ObjectID> inheriters_cache;
|
Set<ObjectID> inheriters_cache;
|
||||||
bool source_changed_cache;
|
bool source_changed_cache;
|
||||||
bool placeholder_fallback_enabled;
|
bool placeholder_fallback_enabled;
|
||||||
@ -99,7 +99,7 @@ class GDScript : public Script {
|
|||||||
#endif
|
#endif
|
||||||
Map<StringName, PropertyInfo> member_info;
|
Map<StringName, PropertyInfo> member_info;
|
||||||
|
|
||||||
GDScriptFunction *initializer; //direct pointer to _init , faster to locate
|
CScriptFunction *initializer; //direct pointer to _init , faster to locate
|
||||||
|
|
||||||
int subclass_count;
|
int subclass_count;
|
||||||
Set<Object *> instances;
|
Set<Object *> instances;
|
||||||
@ -108,14 +108,14 @@ class GDScript : public Script {
|
|||||||
String path;
|
String path;
|
||||||
String name;
|
String name;
|
||||||
String fully_qualified_name;
|
String fully_qualified_name;
|
||||||
SelfList<GDScript> script_list;
|
SelfList<CScript> script_list;
|
||||||
|
|
||||||
SelfList<GDScriptFunctionState>::List pending_func_states;
|
SelfList<CScriptFunctionState>::List pending_func_states;
|
||||||
void _clear_pending_func_states();
|
void _clear_pending_func_states();
|
||||||
|
|
||||||
GDScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error);
|
CScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error);
|
||||||
|
|
||||||
void _set_subclass_path(Ref<GDScript> &p_sc, const String &p_path);
|
void _set_subclass_path(Ref<CScript> &p_sc, const String &p_path);
|
||||||
String _get_debug_path() const;
|
String _get_debug_path() const;
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
@ -151,7 +151,7 @@ public:
|
|||||||
|
|
||||||
bool inherits_script(const Ref<Script> &p_script) const;
|
bool inherits_script(const Ref<Script> &p_script) const;
|
||||||
|
|
||||||
const Map<StringName, Ref<GDScript>> &get_subclasses() const {
|
const Map<StringName, Ref<CScript>> &get_subclasses() const {
|
||||||
return subclasses;
|
return subclasses;
|
||||||
}
|
}
|
||||||
const Map<StringName, Variant> &get_constants() const {
|
const Map<StringName, Variant> &get_constants() const {
|
||||||
@ -160,14 +160,14 @@ public:
|
|||||||
const Set<StringName> &get_members() const {
|
const Set<StringName> &get_members() const {
|
||||||
return members;
|
return members;
|
||||||
}
|
}
|
||||||
const GDScriptDataType &get_member_type(const StringName &p_member) const {
|
const CScriptDataType &get_member_type(const StringName &p_member) const {
|
||||||
CRASH_COND(!member_indices.has(p_member));
|
CRASH_COND(!member_indices.has(p_member));
|
||||||
return member_indices[p_member].data_type;
|
return member_indices[p_member].data_type;
|
||||||
}
|
}
|
||||||
const Map<StringName, GDScriptFunction *> &get_member_functions() const {
|
const Map<StringName, CScriptFunction *> &get_member_functions() const {
|
||||||
return member_functions;
|
return member_functions;
|
||||||
}
|
}
|
||||||
const Ref<GDScriptNativeClass> &get_native() const {
|
const Ref<CScriptNativeClass> &get_native() const {
|
||||||
return native;
|
return native;
|
||||||
}
|
}
|
||||||
const String &get_script_class_name() const {
|
const String &get_script_class_name() const {
|
||||||
@ -180,12 +180,12 @@ public:
|
|||||||
bool is_tool() const {
|
bool is_tool() const {
|
||||||
return tool;
|
return tool;
|
||||||
}
|
}
|
||||||
Ref<GDScript> get_base() const;
|
Ref<CScript> get_base() const;
|
||||||
|
|
||||||
const Map<StringName, MemberInfo> &debug_get_member_indices() const {
|
const Map<StringName, MemberInfo> &debug_get_member_indices() const {
|
||||||
return member_indices;
|
return member_indices;
|
||||||
}
|
}
|
||||||
const Map<StringName, GDScriptFunction *> &debug_get_member_functions() const; //this is debug only
|
const Map<StringName, CScriptFunction *> &debug_get_member_functions() const; //this is debug only
|
||||||
StringName debug_get_member_by_index(int p_idx) const;
|
StringName debug_get_member_by_index(int p_idx) const;
|
||||||
|
|
||||||
Variant _new(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
|
Variant _new(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
|
||||||
@ -241,27 +241,27 @@ public:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GDScript();
|
CScript();
|
||||||
~GDScript();
|
~CScript();
|
||||||
};
|
};
|
||||||
|
|
||||||
class GDScriptInstance : public ScriptInstance {
|
class CScriptInstance : public ScriptInstance {
|
||||||
friend class GDScript;
|
friend class CScript;
|
||||||
friend class GDScriptFunction;
|
friend class CScriptFunction;
|
||||||
friend class GDScriptFunctions;
|
friend class CScriptFunctions;
|
||||||
friend class GDScriptCompiler;
|
friend class CScriptCompiler;
|
||||||
|
|
||||||
Object *owner;
|
Object *owner;
|
||||||
Ref<GDScript> script;
|
Ref<CScript> script;
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
Map<StringName, int> member_indices_cache; //used only for hot script reloading
|
Map<StringName, int> member_indices_cache; //used only for hot script reloading
|
||||||
#endif
|
#endif
|
||||||
Vector<Variant> members;
|
Vector<Variant> members;
|
||||||
bool base_ref;
|
bool base_ref;
|
||||||
|
|
||||||
SelfList<GDScriptFunctionState>::List pending_func_states;
|
SelfList<CScriptFunctionState>::List pending_func_states;
|
||||||
|
|
||||||
void _ml_call_reversed(GDScript *sptr, const StringName &p_method, const Variant **p_args, int p_argcount);
|
void _ml_call_reversed(CScript *sptr, const StringName &p_method, const Variant **p_args, int p_argcount);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual Object *get_owner() {
|
virtual Object *get_owner() {
|
||||||
@ -295,12 +295,12 @@ public:
|
|||||||
virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
|
virtual MultiplayerAPI::RPCMode get_rpc_mode(const StringName &p_method) const;
|
||||||
virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
|
virtual MultiplayerAPI::RPCMode get_rset_mode(const StringName &p_variable) const;
|
||||||
|
|
||||||
GDScriptInstance();
|
CScriptInstance();
|
||||||
~GDScriptInstance();
|
~CScriptInstance();
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
struct GDScriptWarning {
|
struct CScriptWarning {
|
||||||
enum Code {
|
enum Code {
|
||||||
UNASSIGNED_VARIABLE, // Variable used but never assigned
|
UNASSIGNED_VARIABLE, // Variable used but never assigned
|
||||||
UNASSIGNED_VARIABLE_OP_ASSIGN, // Variable never assigned but used in an assignment operation (+=, *=, etc)
|
UNASSIGNED_VARIABLE_OP_ASSIGN, // Variable never assigned but used in an assignment operation (+=, *=, etc)
|
||||||
@ -340,16 +340,16 @@ struct GDScriptWarning {
|
|||||||
static String get_name_from_code(Code p_code);
|
static String get_name_from_code(Code p_code);
|
||||||
static Code get_code_from_name(const String &p_name);
|
static Code get_code_from_name(const String &p_name);
|
||||||
|
|
||||||
GDScriptWarning() :
|
CScriptWarning() :
|
||||||
code(WARNING_MAX),
|
code(WARNING_MAX),
|
||||||
line(-1) {}
|
line(-1) {}
|
||||||
};
|
};
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
|
|
||||||
class GDScriptLanguage : public ScriptLanguage {
|
class CScriptLanguage : public ScriptLanguage {
|
||||||
friend class GDScriptFunctionState;
|
friend class CScriptFunctionState;
|
||||||
|
|
||||||
static GDScriptLanguage *singleton;
|
static CScriptLanguage *singleton;
|
||||||
|
|
||||||
Variant *_global_array;
|
Variant *_global_array;
|
||||||
Vector<Variant> global_array;
|
Vector<Variant> global_array;
|
||||||
@ -358,8 +358,8 @@ class GDScriptLanguage : public ScriptLanguage {
|
|||||||
|
|
||||||
struct CallLevel {
|
struct CallLevel {
|
||||||
Variant *stack;
|
Variant *stack;
|
||||||
GDScriptFunction *function;
|
CScriptFunction *function;
|
||||||
GDScriptInstance *instance;
|
CScriptInstance *instance;
|
||||||
int *ip;
|
int *ip;
|
||||||
int *line;
|
int *line;
|
||||||
};
|
};
|
||||||
@ -373,16 +373,16 @@ class GDScriptLanguage : public ScriptLanguage {
|
|||||||
|
|
||||||
void _add_global(const StringName &p_name, const Variant &p_value);
|
void _add_global(const StringName &p_name, const Variant &p_value);
|
||||||
|
|
||||||
friend class GDScriptInstance;
|
friend class CScriptInstance;
|
||||||
|
|
||||||
Mutex lock;
|
Mutex lock;
|
||||||
|
|
||||||
friend class GDScript;
|
friend class CScript;
|
||||||
|
|
||||||
SelfList<GDScript>::List script_list;
|
SelfList<CScript>::List script_list;
|
||||||
friend class GDScriptFunction;
|
friend class CScriptFunction;
|
||||||
|
|
||||||
SelfList<GDScriptFunction>::List function_list;
|
SelfList<CScriptFunction>::List function_list;
|
||||||
bool profiling;
|
bool profiling;
|
||||||
uint64_t script_frame_time;
|
uint64_t script_frame_time;
|
||||||
|
|
||||||
@ -394,7 +394,7 @@ public:
|
|||||||
bool debug_break(const String &p_error, bool p_allow_continue = true);
|
bool debug_break(const String &p_error, bool p_allow_continue = true);
|
||||||
bool debug_break_parse(const String &p_file, int p_line, const String &p_error);
|
bool debug_break_parse(const String &p_file, int p_line, const String &p_error);
|
||||||
|
|
||||||
_FORCE_INLINE_ void enter_function(GDScriptInstance *p_instance, GDScriptFunction *p_function, Variant *p_stack, int *p_ip, int *p_line) {
|
_FORCE_INLINE_ void enter_function(CScriptInstance *p_instance, CScriptFunction *p_function, Variant *p_stack, int *p_ip, int *p_line) {
|
||||||
if (Thread::get_main_id() != Thread::get_caller_id()) {
|
if (Thread::get_main_id() != Thread::get_caller_id()) {
|
||||||
return; //no support for other threads than main for now
|
return; //no support for other threads than main for now
|
||||||
}
|
}
|
||||||
@ -468,7 +468,7 @@ public:
|
|||||||
_FORCE_INLINE_ const Map<StringName, int> &get_global_map() const { return globals; }
|
_FORCE_INLINE_ const Map<StringName, int> &get_global_map() const { return globals; }
|
||||||
_FORCE_INLINE_ const Map<StringName, Variant> &get_named_globals_map() const { return named_globals; }
|
_FORCE_INLINE_ const Map<StringName, Variant> &get_named_globals_map() const { return named_globals; }
|
||||||
|
|
||||||
_FORCE_INLINE_ static GDScriptLanguage *get_singleton() { return singleton; }
|
_FORCE_INLINE_ static CScriptLanguage *get_singleton() { return singleton; }
|
||||||
|
|
||||||
virtual String get_name() const;
|
virtual String get_name() const;
|
||||||
|
|
||||||
@ -542,13 +542,13 @@ public:
|
|||||||
virtual String get_global_class_name(const String &p_path, String *r_base_type = nullptr, String *r_icon_path = nullptr) const;
|
virtual String get_global_class_name(const String &p_path, String *r_base_type = nullptr, String *r_icon_path = nullptr) const;
|
||||||
|
|
||||||
void add_orphan_subclass(const String &p_qualified_name, const ObjectID &p_subclass);
|
void add_orphan_subclass(const String &p_qualified_name, const ObjectID &p_subclass);
|
||||||
Ref<GDScript> get_orphan_subclass(const String &p_qualified_name);
|
Ref<CScript> get_orphan_subclass(const String &p_qualified_name);
|
||||||
|
|
||||||
GDScriptLanguage();
|
CScriptLanguage();
|
||||||
~GDScriptLanguage();
|
~CScriptLanguage();
|
||||||
};
|
};
|
||||||
|
|
||||||
class ResourceFormatLoaderGDScript : public ResourceFormatLoader {
|
class ResourceFormatLoaderCScript : public ResourceFormatLoader {
|
||||||
public:
|
public:
|
||||||
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr);
|
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr);
|
||||||
virtual void get_recognized_extensions(List<String> *p_extensions) const;
|
virtual void get_recognized_extensions(List<String> *p_extensions) const;
|
||||||
@ -557,11 +557,11 @@ public:
|
|||||||
virtual void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false);
|
virtual void get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types = false);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ResourceFormatSaverGDScript : public ResourceFormatSaver {
|
class ResourceFormatSaverCScript : public ResourceFormatSaver {
|
||||||
public:
|
public:
|
||||||
virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0);
|
virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0);
|
||||||
virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const;
|
virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const;
|
||||||
virtual bool recognize(const RES &p_resource) const;
|
virtual bool recognize(const RES &p_resource) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GDSCRIPT_H
|
#endif // CSCRIPT_H
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -34,21 +34,21 @@
|
|||||||
#include "cscript.h"
|
#include "cscript.h"
|
||||||
#include "cscript_parser.h"
|
#include "cscript_parser.h"
|
||||||
|
|
||||||
class GDScriptCompiler {
|
class CScriptCompiler {
|
||||||
const GDScriptParser *parser;
|
const CScriptParser *parser;
|
||||||
Set<GDScript *> parsed_classes;
|
Set<CScript *> parsed_classes;
|
||||||
Set<GDScript *> parsing_classes;
|
Set<CScript *> parsing_classes;
|
||||||
GDScript *main_script;
|
CScript *main_script;
|
||||||
struct CodeGen {
|
struct CodeGen {
|
||||||
GDScript *script;
|
CScript *script;
|
||||||
const GDScriptParser::ClassNode *class_node;
|
const CScriptParser::ClassNode *class_node;
|
||||||
const GDScriptParser::FunctionNode *function_node;
|
const CScriptParser::FunctionNode *function_node;
|
||||||
bool debug_stack;
|
bool debug_stack;
|
||||||
|
|
||||||
List<Map<StringName, int>> stack_id_stack;
|
List<Map<StringName, int>> stack_id_stack;
|
||||||
Map<StringName, int> stack_identifiers;
|
Map<StringName, int> stack_identifiers;
|
||||||
|
|
||||||
List<GDScriptFunction::StackDebug> stack_debug;
|
List<CScriptFunction::StackDebug> stack_debug;
|
||||||
List<Map<StringName, int>> block_identifier_stack;
|
List<Map<StringName, int>> block_identifier_stack;
|
||||||
Map<StringName, int> block_identifiers;
|
Map<StringName, int> block_identifiers;
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ class GDScriptCompiler {
|
|||||||
stack_identifiers[p_id] = p_stackpos;
|
stack_identifiers[p_id] = p_stackpos;
|
||||||
if (debug_stack) {
|
if (debug_stack) {
|
||||||
block_identifiers[p_id] = p_stackpos;
|
block_identifiers[p_id] = p_stackpos;
|
||||||
GDScriptFunction::StackDebug sd;
|
CScriptFunction::StackDebug sd;
|
||||||
sd.added = true;
|
sd.added = true;
|
||||||
sd.line = current_line;
|
sd.line = current_line;
|
||||||
sd.identifier = p_id;
|
sd.identifier = p_id;
|
||||||
@ -79,7 +79,7 @@ class GDScriptCompiler {
|
|||||||
|
|
||||||
if (debug_stack) {
|
if (debug_stack) {
|
||||||
for (Map<StringName, int>::Element *E = block_identifiers.front(); E; E = E->next()) {
|
for (Map<StringName, int>::Element *E = block_identifiers.front(); E; E = E->next()) {
|
||||||
GDScriptFunction::StackDebug sd;
|
CScriptFunction::StackDebug sd;
|
||||||
sd.added = false;
|
sd.added = false;
|
||||||
sd.identifier = E->key();
|
sd.identifier = E->key();
|
||||||
sd.line = current_line;
|
sd.line = current_line;
|
||||||
@ -135,35 +135,35 @@ class GDScriptCompiler {
|
|||||||
};
|
};
|
||||||
|
|
||||||
bool _is_class_member_property(CodeGen &codegen, const StringName &p_name);
|
bool _is_class_member_property(CodeGen &codegen, const StringName &p_name);
|
||||||
bool _is_class_member_property(GDScript *owner, const StringName &p_name);
|
bool _is_class_member_property(CScript *owner, const StringName &p_name);
|
||||||
|
|
||||||
void _set_error(const String &p_error, const GDScriptParser::Node *p_node);
|
void _set_error(const String &p_error, const CScriptParser::Node *p_node);
|
||||||
|
|
||||||
bool _create_unary_operator(CodeGen &codegen, const GDScriptParser::OperatorNode *on, Variant::Operator op, int p_stack_level);
|
bool _create_unary_operator(CodeGen &codegen, const CScriptParser::OperatorNode *on, Variant::Operator op, int p_stack_level);
|
||||||
bool _create_binary_operator(CodeGen &codegen, const GDScriptParser::OperatorNode *on, Variant::Operator op, int p_stack_level, bool p_initializer = false, int p_index_addr = 0);
|
bool _create_binary_operator(CodeGen &codegen, const CScriptParser::OperatorNode *on, Variant::Operator op, int p_stack_level, bool p_initializer = false, int p_index_addr = 0);
|
||||||
|
|
||||||
GDScriptDataType _gdtype_from_datatype(const GDScriptParser::DataType &p_datatype, GDScript *p_owner = nullptr) const;
|
CScriptDataType _gdtype_from_datatype(const CScriptParser::DataType &p_datatype, CScript *p_owner = nullptr) const;
|
||||||
|
|
||||||
int _parse_assign_right_expression(CodeGen &codegen, const GDScriptParser::OperatorNode *p_expression, int p_stack_level, int p_index_addr = 0);
|
int _parse_assign_right_expression(CodeGen &codegen, const CScriptParser::OperatorNode *p_expression, int p_stack_level, int p_index_addr = 0);
|
||||||
int _parse_expression(CodeGen &codegen, const GDScriptParser::Node *p_expression, int p_stack_level, bool p_root = false, bool p_initializer = false, int p_index_addr = 0);
|
int _parse_expression(CodeGen &codegen, const CScriptParser::Node *p_expression, int p_stack_level, bool p_root = false, bool p_initializer = false, int p_index_addr = 0);
|
||||||
Error _parse_block(CodeGen &codegen, const GDScriptParser::BlockNode *p_block, int p_stack_level = 0, int p_break_addr = -1, int p_continue_addr = -1);
|
Error _parse_block(CodeGen &codegen, const CScriptParser::BlockNode *p_block, int p_stack_level = 0, int p_break_addr = -1, int p_continue_addr = -1);
|
||||||
Error _parse_function(GDScript *p_script, const GDScriptParser::ClassNode *p_class, const GDScriptParser::FunctionNode *p_func, bool p_for_ready = false);
|
Error _parse_function(CScript *p_script, const CScriptParser::ClassNode *p_class, const CScriptParser::FunctionNode *p_func, bool p_for_ready = false);
|
||||||
Error _parse_class_level(GDScript *p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state);
|
Error _parse_class_level(CScript *p_script, const CScriptParser::ClassNode *p_class, bool p_keep_state);
|
||||||
Error _parse_class_blocks(GDScript *p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state);
|
Error _parse_class_blocks(CScript *p_script, const CScriptParser::ClassNode *p_class, bool p_keep_state);
|
||||||
void _make_scripts(GDScript *p_script, const GDScriptParser::ClassNode *p_class, bool p_keep_state);
|
void _make_scripts(CScript *p_script, const CScriptParser::ClassNode *p_class, bool p_keep_state);
|
||||||
int err_line;
|
int err_line;
|
||||||
int err_column;
|
int err_column;
|
||||||
StringName source;
|
StringName source;
|
||||||
String error;
|
String error;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Error compile(const GDScriptParser *p_parser, GDScript *p_script, bool p_keep_state = false);
|
Error compile(const CScriptParser *p_parser, CScript *p_script, bool p_keep_state = false);
|
||||||
|
|
||||||
String get_error() const;
|
String get_error() const;
|
||||||
int get_error_line() const;
|
int get_error_line() const;
|
||||||
int get_error_column() const;
|
int get_error_column() const;
|
||||||
|
|
||||||
GDScriptCompiler();
|
CScriptCompiler();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GDSCRIPT_COMPILER_H
|
#endif // CSCRIPT_COMPILER_H
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -34,7 +34,7 @@
|
|||||||
#include "cscript.h"
|
#include "cscript.h"
|
||||||
#include "cscript_functions.h"
|
#include "cscript_functions.h"
|
||||||
|
|
||||||
Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_instance, GDScript *p_script, Variant &self, Variant &static_ref, Variant *p_stack, String &r_error) const {
|
Variant *CScriptFunction::_get_variant(int p_address, CScriptInstance *p_instance, CScript *p_script, Variant &self, Variant &static_ref, Variant *p_stack, String &r_error) const {
|
||||||
int address = p_address & ADDR_MASK;
|
int address = p_address & ADDR_MASK;
|
||||||
|
|
||||||
//sequential table (jump table generated by compiler)
|
//sequential table (jump table generated by compiler)
|
||||||
@ -63,14 +63,14 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta
|
|||||||
} break;
|
} break;
|
||||||
case ADDR_TYPE_CLASS_CONSTANT: {
|
case ADDR_TYPE_CLASS_CONSTANT: {
|
||||||
//todo change to index!
|
//todo change to index!
|
||||||
GDScript *s = p_script;
|
CScript *s = p_script;
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
ERR_FAIL_INDEX_V(address, _global_names_count, nullptr);
|
ERR_FAIL_INDEX_V(address, _global_names_count, nullptr);
|
||||||
#endif
|
#endif
|
||||||
const StringName *sn = &_global_names_ptr[address];
|
const StringName *sn = &_global_names_ptr[address];
|
||||||
|
|
||||||
while (s) {
|
while (s) {
|
||||||
GDScript *o = s;
|
CScript *o = s;
|
||||||
while (o) {
|
while (o) {
|
||||||
Map<StringName, Variant>::Element *E = o->constants.find(*sn);
|
Map<StringName, Variant>::Element *E = o->constants.find(*sn);
|
||||||
if (E) {
|
if (E) {
|
||||||
@ -81,7 +81,7 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta
|
|||||||
s = s->_base;
|
s = s->_base;
|
||||||
}
|
}
|
||||||
|
|
||||||
ERR_FAIL_V_MSG(nullptr, "GDScriptCompiler bug.");
|
ERR_FAIL_V_MSG(nullptr, "CScriptCompiler bug.");
|
||||||
} break;
|
} break;
|
||||||
case ADDR_TYPE_LOCAL_CONSTANT: {
|
case ADDR_TYPE_LOCAL_CONSTANT: {
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
@ -98,9 +98,9 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta
|
|||||||
} break;
|
} break;
|
||||||
case ADDR_TYPE_GLOBAL: {
|
case ADDR_TYPE_GLOBAL: {
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
ERR_FAIL_INDEX_V(address, GDScriptLanguage::get_singleton()->get_global_array_size(), nullptr);
|
ERR_FAIL_INDEX_V(address, CScriptLanguage::get_singleton()->get_global_array_size(), nullptr);
|
||||||
#endif
|
#endif
|
||||||
return &GDScriptLanguage::get_singleton()->get_global_array()[address];
|
return &CScriptLanguage::get_singleton()->get_global_array()[address];
|
||||||
} break;
|
} break;
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
case ADDR_TYPE_NAMED_GLOBAL: {
|
case ADDR_TYPE_NAMED_GLOBAL: {
|
||||||
@ -109,8 +109,8 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta
|
|||||||
#endif
|
#endif
|
||||||
StringName id = _named_globals_ptr[address];
|
StringName id = _named_globals_ptr[address];
|
||||||
|
|
||||||
if (GDScriptLanguage::get_singleton()->get_named_globals_map().has(id)) {
|
if (CScriptLanguage::get_singleton()->get_named_globals_map().has(id)) {
|
||||||
return (Variant *)&GDScriptLanguage::get_singleton()->get_named_globals_map()[id];
|
return (Variant *)&CScriptLanguage::get_singleton()->get_named_globals_map()[id];
|
||||||
} else {
|
} else {
|
||||||
r_error = "Autoload singleton '" + String(id) + "' has been removed.";
|
r_error = "Autoload singleton '" + String(id) + "' has been removed.";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -154,7 +154,7 @@ static String _get_var_type(const Variant *p_var) {
|
|||||||
}
|
}
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
|
|
||||||
String GDScriptFunction::_get_call_error(const Variant::CallError &p_err, const String &p_where, const Variant **argptrs) const {
|
String CScriptFunction::_get_call_error(const Variant::CallError &p_err, const String &p_where, const Variant **argptrs) const {
|
||||||
String err_text;
|
String err_text;
|
||||||
|
|
||||||
if (p_err.error == Variant::CallError::CALL_ERROR_INVALID_ARGUMENT) {
|
if (p_err.error == Variant::CallError::CALL_ERROR_INVALID_ARGUMENT) {
|
||||||
@ -251,7 +251,7 @@ String GDScriptFunction::_get_call_error(const Variant::CallError &p_err, const
|
|||||||
#define OPCODE_OUT break
|
#define OPCODE_OUT break
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state) {
|
Variant CScriptFunction::call(CScriptInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state) {
|
||||||
OPCODES_TABLE;
|
OPCODES_TABLE;
|
||||||
|
|
||||||
if (!_code_ptr) {
|
if (!_code_ptr) {
|
||||||
@ -269,12 +269,12 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
|
|
||||||
//GDScriptLanguage::get_singleton()->calls++;
|
//CScriptLanguage::get_singleton()->calls++;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint32_t alloca_size = 0;
|
uint32_t alloca_size = 0;
|
||||||
GDScript *script;
|
CScript *script;
|
||||||
int ip = 0;
|
int ip = 0;
|
||||||
int line = _initial_line;
|
int line = _initial_line;
|
||||||
|
|
||||||
@ -327,11 +327,11 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
} else {
|
} else {
|
||||||
r_err.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
r_err.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||||
r_err.argument = i;
|
r_err.argument = i;
|
||||||
r_err.expected = argument_types[i].kind == GDScriptDataType::BUILTIN ? argument_types[i].builtin_type : Variant::OBJECT;
|
r_err.expected = argument_types[i].kind == CScriptDataType::BUILTIN ? argument_types[i].builtin_type : Variant::OBJECT;
|
||||||
return Variant();
|
return Variant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (argument_types[i].kind == GDScriptDataType::BUILTIN) {
|
if (argument_types[i].kind == CScriptDataType::BUILTIN) {
|
||||||
Variant arg = Variant::construct(argument_types[i].builtin_type, &p_args[i], 1, r_err);
|
Variant arg = Variant::construct(argument_types[i].builtin_type, &p_args[i], 1, r_err);
|
||||||
memnew_placement(&stack[i], Variant(arg));
|
memnew_placement(&stack[i], Variant(arg));
|
||||||
} else {
|
} else {
|
||||||
@ -374,7 +374,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
|
|
||||||
if (ScriptDebugger::get_singleton()) {
|
if (ScriptDebugger::get_singleton()) {
|
||||||
GDScriptLanguage::get_singleton()->enter_function(p_instance, this, stack, &ip, &line);
|
CScriptLanguage::get_singleton()->enter_function(p_instance, this, stack, &ip, &line);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GD_ERR_BREAK(m_cond) \
|
#define GD_ERR_BREAK(m_cond) \
|
||||||
@ -408,7 +408,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
uint64_t function_start_time = 0;
|
uint64_t function_start_time = 0;
|
||||||
uint64_t function_call_time = 0;
|
uint64_t function_call_time = 0;
|
||||||
|
|
||||||
if (GDScriptLanguage::get_singleton()->profiling) {
|
if (CScriptLanguage::get_singleton()->profiling) {
|
||||||
function_start_time = OS::get_singleton()->get_ticks_usec();
|
function_start_time = OS::get_singleton()->get_ticks_usec();
|
||||||
function_call_time = 0;
|
function_call_time = 0;
|
||||||
profile.call_count++;
|
profile.call_count++;
|
||||||
@ -484,14 +484,14 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
Object *obj_A = *a;
|
Object *obj_A = *a;
|
||||||
Object *obj_B = *b;
|
Object *obj_B = *b;
|
||||||
|
|
||||||
GDScript *scr_B = Object::cast_to<GDScript>(obj_B);
|
CScript *scr_B = Object::cast_to<CScript>(obj_B);
|
||||||
|
|
||||||
if (scr_B) {
|
if (scr_B) {
|
||||||
//if B is a script, the only valid condition is that A has an instance which inherits from the script
|
//if B is a script, the only valid condition is that A has an instance which inherits from the script
|
||||||
//in other situation, this shoul return false.
|
//in other situation, this shoul return false.
|
||||||
|
|
||||||
if (obj_A->get_script_instance() && obj_A->get_script_instance()->get_language() == GDScriptLanguage::get_singleton()) {
|
if (obj_A->get_script_instance() && obj_A->get_script_instance()->get_language() == CScriptLanguage::get_singleton()) {
|
||||||
GDScript *cmp = static_cast<GDScript *>(obj_A->get_script_instance()->get_script().ptr());
|
CScript *cmp = static_cast<CScript *>(obj_A->get_script_instance()->get_script().ptr());
|
||||||
//bool found=false;
|
//bool found=false;
|
||||||
while (cmp) {
|
while (cmp) {
|
||||||
if (cmp == scr_B) {
|
if (cmp == scr_B) {
|
||||||
@ -505,7 +505,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
GDScriptNativeClass *nc = Object::cast_to<GDScriptNativeClass>(obj_B);
|
CScriptNativeClass *nc = Object::cast_to<CScriptNativeClass>(obj_B);
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if (!nc) {
|
if (!nc) {
|
||||||
@ -769,7 +769,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
GET_VARIANT_PTR(type, 1);
|
GET_VARIANT_PTR(type, 1);
|
||||||
GDScriptNativeClass *nc = Object::cast_to<GDScriptNativeClass>(type->operator Object *());
|
CScriptNativeClass *nc = Object::cast_to<CScriptNativeClass>(type->operator Object *());
|
||||||
GD_ERR_BREAK(!nc);
|
GD_ERR_BREAK(!nc);
|
||||||
if (src->get_type() != Variant::OBJECT && src->get_type() != Variant::NIL) {
|
if (src->get_type() != Variant::OBJECT && src->get_type() != Variant::NIL) {
|
||||||
err_text = "Trying to assign value of type '" + Variant::get_type_name(src->get_type()) +
|
err_text = "Trying to assign value of type '" + Variant::get_type_name(src->get_type()) +
|
||||||
@ -871,7 +871,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
GET_VARIANT_PTR(src, 2);
|
GET_VARIANT_PTR(src, 2);
|
||||||
GET_VARIANT_PTR(dst, 3);
|
GET_VARIANT_PTR(dst, 3);
|
||||||
|
|
||||||
GDScriptNativeClass *nc = Object::cast_to<GDScriptNativeClass>(to_type->operator Object *());
|
CScriptNativeClass *nc = Object::cast_to<CScriptNativeClass>(to_type->operator Object *());
|
||||||
GD_ERR_BREAK(!nc);
|
GD_ERR_BREAK(!nc);
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
@ -1038,7 +1038,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
uint64_t call_time = 0;
|
uint64_t call_time = 0;
|
||||||
|
|
||||||
if (GDScriptLanguage::get_singleton()->profiling) {
|
if (CScriptLanguage::get_singleton()->profiling) {
|
||||||
call_time = OS::get_singleton()->get_ticks_usec();
|
call_time = OS::get_singleton()->get_ticks_usec();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1051,7 +1051,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
base->call_ptr(*methodname, (const Variant **)argptrs, argc, nullptr, err);
|
base->call_ptr(*methodname, (const Variant **)argptrs, argc, nullptr, err);
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if (GDScriptLanguage::get_singleton()->profiling) {
|
if (CScriptLanguage::get_singleton()->profiling) {
|
||||||
function_call_time += OS::get_singleton()->get_ticks_usec() - call_time;
|
function_call_time += OS::get_singleton()->get_ticks_usec() - call_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1097,7 +1097,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
OPCODE(OPCODE_CALL_BUILT_IN) {
|
OPCODE(OPCODE_CALL_BUILT_IN) {
|
||||||
CHECK_SPACE(4);
|
CHECK_SPACE(4);
|
||||||
|
|
||||||
GDScriptFunctions::Function func = GDScriptFunctions::Function(_code_ptr[ip + 1]);
|
CScriptFunctions::Function func = CScriptFunctions::Function(_code_ptr[ip + 1]);
|
||||||
int argc = _code_ptr[ip + 2];
|
int argc = _code_ptr[ip + 2];
|
||||||
GD_ERR_BREAK(argc < 0);
|
GD_ERR_BREAK(argc < 0);
|
||||||
|
|
||||||
@ -1114,11 +1114,11 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
|
|
||||||
Variant::CallError err;
|
Variant::CallError err;
|
||||||
|
|
||||||
GDScriptFunctions::call(func, (const Variant **)argptrs, argc, *dst, err);
|
CScriptFunctions::call(func, (const Variant **)argptrs, argc, *dst, err);
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if (err.error != Variant::CallError::CALL_OK) {
|
if (err.error != Variant::CallError::CALL_OK) {
|
||||||
String methodstr = GDScriptFunctions::get_func_name(func);
|
String methodstr = CScriptFunctions::get_func_name(func);
|
||||||
if (dst->get_type() == Variant::STRING) {
|
if (dst->get_type() == Variant::STRING) {
|
||||||
//call provided error string
|
//call provided error string
|
||||||
err_text = "Error calling built-in function '" + methodstr + "': " + String(*dst);
|
err_text = "Error calling built-in function '" + methodstr + "': " + String(*dst);
|
||||||
@ -1161,9 +1161,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
|
|
||||||
GET_VARIANT_PTR(dst, argc + 3);
|
GET_VARIANT_PTR(dst, argc + 3);
|
||||||
|
|
||||||
const GDScript *gds = _script;
|
const CScript *gds = _script;
|
||||||
|
|
||||||
const Map<StringName, GDScriptFunction *>::Element *E = nullptr;
|
const Map<StringName, CScriptFunction *>::Element *E = nullptr;
|
||||||
while (gds->base.ptr()) {
|
while (gds->base.ptr()) {
|
||||||
gds = gds->base.ptr();
|
gds = gds->base.ptr();
|
||||||
E = gds->member_functions.find(*methodname);
|
E = gds->member_functions.find(*methodname);
|
||||||
@ -1177,7 +1177,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
if (E) {
|
if (E) {
|
||||||
*dst = E->get()->call(p_instance, (const Variant **)argptrs, argc, err);
|
*dst = E->get()->call(p_instance, (const Variant **)argptrs, argc, err);
|
||||||
} else if (gds->native.ptr()) {
|
} else if (gds->native.ptr()) {
|
||||||
if (*methodname != GDScriptLanguage::get_singleton()->strings._init) {
|
if (*methodname != CScriptLanguage::get_singleton()->strings._init) {
|
||||||
MethodBind *mb = ClassDB::get_method(gds->native->get_name(), *methodname);
|
MethodBind *mb = ClassDB::get_method(gds->native->get_name(), *methodname);
|
||||||
if (!mb) {
|
if (!mb) {
|
||||||
err.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
err.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||||
@ -1188,7 +1188,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
err.error = Variant::CallError::CALL_OK;
|
err.error = Variant::CallError::CALL_OK;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (*methodname != GDScriptLanguage::get_singleton()->strings._init) {
|
if (*methodname != CScriptLanguage::get_singleton()->strings._init) {
|
||||||
err.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
err.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||||
} else {
|
} else {
|
||||||
err.error = Variant::CallError::CALL_OK;
|
err.error = Variant::CallError::CALL_OK;
|
||||||
@ -1216,7 +1216,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
CHECK_SPACE(2);
|
CHECK_SPACE(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<GDScriptFunctionState> gdfs = memnew(GDScriptFunctionState);
|
Ref<CScriptFunctionState> gdfs = memnew(CScriptFunctionState);
|
||||||
gdfs->function = this;
|
gdfs->function = this;
|
||||||
|
|
||||||
gdfs->state.stack.resize(alloca_size);
|
gdfs->state.stack.resize(alloca_size);
|
||||||
@ -1230,7 +1230,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
gdfs->state.ip = ip + ipofs;
|
gdfs->state.ip = ip + ipofs;
|
||||||
gdfs->state.line = line;
|
gdfs->state.line = line;
|
||||||
gdfs->state.script = _script;
|
gdfs->state.script = _script;
|
||||||
GDScriptLanguage::singleton->lock.lock();
|
CScriptLanguage::singleton->lock.lock();
|
||||||
|
|
||||||
_script->pending_func_states.add(&gdfs->scripts_list);
|
_script->pending_func_states.add(&gdfs->scripts_list);
|
||||||
if (p_instance) {
|
if (p_instance) {
|
||||||
@ -1239,7 +1239,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
} else {
|
} else {
|
||||||
gdfs->state.instance = nullptr;
|
gdfs->state.instance = nullptr;
|
||||||
}
|
}
|
||||||
GDScriptLanguage::singleton->lock.unlock();
|
CScriptLanguage::singleton->lock.unlock();
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
gdfs->state.function_name = name;
|
gdfs->state.function_name = name;
|
||||||
gdfs->state.script_path = _script->get_path();
|
gdfs->state.script_path = _script->get_path();
|
||||||
@ -1466,7 +1466,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
OPCODE(OPCODE_BREAKPOINT) {
|
OPCODE(OPCODE_BREAKPOINT) {
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if (ScriptDebugger::get_singleton()) {
|
if (ScriptDebugger::get_singleton()) {
|
||||||
GDScriptLanguage::get_singleton()->debug_break("Breakpoint Statement", true);
|
CScriptLanguage::get_singleton()->debug_break("Breakpoint Statement", true);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
ip += 1;
|
ip += 1;
|
||||||
@ -1497,7 +1497,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (do_break) {
|
if (do_break) {
|
||||||
GDScriptLanguage::get_singleton()->debug_break("Breakpoint", true);
|
CScriptLanguage::get_singleton()->debug_break("Breakpoint", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptDebugger::get_singleton()->line_poll();
|
ScriptDebugger::get_singleton()->line_poll();
|
||||||
@ -1545,7 +1545,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
err_text = "Internal script error! Opcode: " + itos(last_opcode) + " (please report).";
|
err_text = "Internal script error! Opcode: " + itos(last_opcode) + " (please report).";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GDScriptLanguage::get_singleton()->debug_break(err_text, false)) {
|
if (!CScriptLanguage::get_singleton()->debug_break(err_text, false)) {
|
||||||
// debugger break did not happen
|
// debugger break did not happen
|
||||||
|
|
||||||
_err_print_error(err_func.utf8().get_data(), err_file.utf8().get_data(), err_line, err_text.utf8().get_data(), ERR_HANDLER_SCRIPT);
|
_err_print_error(err_func.utf8().get_data(), err_file.utf8().get_data(), err_line, err_text.utf8().get_data(), ERR_HANDLER_SCRIPT);
|
||||||
@ -1557,13 +1557,13 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
|
|
||||||
OPCODES_OUT
|
OPCODES_OUT
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if (GDScriptLanguage::get_singleton()->profiling) {
|
if (CScriptLanguage::get_singleton()->profiling) {
|
||||||
uint64_t time_taken = OS::get_singleton()->get_ticks_usec() - function_start_time;
|
uint64_t time_taken = OS::get_singleton()->get_ticks_usec() - function_start_time;
|
||||||
profile.total_time += time_taken;
|
profile.total_time += time_taken;
|
||||||
profile.self_time += time_taken - function_call_time;
|
profile.self_time += time_taken - function_call_time;
|
||||||
profile.frame_total_time += time_taken;
|
profile.frame_total_time += time_taken;
|
||||||
profile.frame_self_time += time_taken - function_call_time;
|
profile.frame_self_time += time_taken - function_call_time;
|
||||||
GDScriptLanguage::get_singleton()->script_frame_time += time_taken - function_call_time;
|
CScriptLanguage::get_singleton()->script_frame_time += time_taken - function_call_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if this is the last time the function is resuming from yield
|
// Check if this is the last time the function is resuming from yield
|
||||||
@ -1572,7 +1572,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
// so the debugger knows which function triggered the resume of the next function (if any)
|
// so the debugger knows which function triggered the resume of the next function (if any)
|
||||||
if (!p_state || yielded) {
|
if (!p_state || yielded) {
|
||||||
if (ScriptDebugger::get_singleton()) {
|
if (ScriptDebugger::get_singleton()) {
|
||||||
GDScriptLanguage::get_singleton()->exit_function();
|
CScriptLanguage::get_singleton()->exit_function();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1590,45 +1590,45 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||||||
return retvalue;
|
return retvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int *GDScriptFunction::get_code() const {
|
const int *CScriptFunction::get_code() const {
|
||||||
return _code_ptr;
|
return _code_ptr;
|
||||||
}
|
}
|
||||||
int GDScriptFunction::get_code_size() const {
|
int CScriptFunction::get_code_size() const {
|
||||||
return _code_size;
|
return _code_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant GDScriptFunction::get_constant(int p_idx) const {
|
Variant CScriptFunction::get_constant(int p_idx) const {
|
||||||
ERR_FAIL_INDEX_V(p_idx, constants.size(), "<errconst>");
|
ERR_FAIL_INDEX_V(p_idx, constants.size(), "<errconst>");
|
||||||
return constants[p_idx];
|
return constants[p_idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
StringName GDScriptFunction::get_global_name(int p_idx) const {
|
StringName CScriptFunction::get_global_name(int p_idx) const {
|
||||||
ERR_FAIL_INDEX_V(p_idx, global_names.size(), "<errgname>");
|
ERR_FAIL_INDEX_V(p_idx, global_names.size(), "<errgname>");
|
||||||
return global_names[p_idx];
|
return global_names[p_idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
int GDScriptFunction::get_default_argument_count() const {
|
int CScriptFunction::get_default_argument_count() const {
|
||||||
return _default_arg_count;
|
return _default_arg_count;
|
||||||
}
|
}
|
||||||
int GDScriptFunction::get_default_argument_addr(int p_idx) const {
|
int CScriptFunction::get_default_argument_addr(int p_idx) const {
|
||||||
ERR_FAIL_INDEX_V(p_idx, default_arguments.size(), -1);
|
ERR_FAIL_INDEX_V(p_idx, default_arguments.size(), -1);
|
||||||
return default_arguments[p_idx];
|
return default_arguments[p_idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
GDScriptDataType GDScriptFunction::get_return_type() const {
|
CScriptDataType CScriptFunction::get_return_type() const {
|
||||||
return return_type;
|
return return_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
GDScriptDataType GDScriptFunction::get_argument_type(int p_idx) const {
|
CScriptDataType CScriptFunction::get_argument_type(int p_idx) const {
|
||||||
ERR_FAIL_INDEX_V(p_idx, argument_types.size(), GDScriptDataType());
|
ERR_FAIL_INDEX_V(p_idx, argument_types.size(), CScriptDataType());
|
||||||
return argument_types[p_idx];
|
return argument_types[p_idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
StringName GDScriptFunction::get_name() const {
|
StringName CScriptFunction::get_name() const {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GDScriptFunction::get_max_stack_size() const {
|
int CScriptFunction::get_max_stack_size() const {
|
||||||
return _stack_size;
|
return _stack_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1647,7 +1647,7 @@ struct _GDFKCS {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void GDScriptFunction::debug_get_stack_member_state(int p_line, List<Pair<StringName, int>> *r_stackvars) const {
|
void CScriptFunction::debug_get_stack_member_state(int p_line, List<Pair<StringName, int>> *r_stackvars) const {
|
||||||
int oc = 0;
|
int oc = 0;
|
||||||
Map<StringName, _GDFKC> sdmap;
|
Map<StringName, _GDFKC> sdmap;
|
||||||
for (const List<StackDebug>::Element *E = stack_debug.front(); E; E = E->next()) {
|
for (const List<StackDebug>::Element *E = stack_debug.front(); E; E = E->next()) {
|
||||||
@ -1695,7 +1695,7 @@ void GDScriptFunction::debug_get_stack_member_state(int p_line, List<Pair<String
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GDScriptFunction::GDScriptFunction() :
|
CScriptFunction::CScriptFunction() :
|
||||||
function_list(this) {
|
function_list(this) {
|
||||||
_stack_size = 0;
|
_stack_size = 0;
|
||||||
_call_size = 0;
|
_call_size = 0;
|
||||||
@ -1704,9 +1704,9 @@ GDScriptFunction::GDScriptFunction() :
|
|||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
_func_cname = nullptr;
|
_func_cname = nullptr;
|
||||||
|
|
||||||
GDScriptLanguage::get_singleton()->lock.lock();
|
CScriptLanguage::get_singleton()->lock.lock();
|
||||||
GDScriptLanguage::get_singleton()->function_list.add(&function_list);
|
CScriptLanguage::get_singleton()->function_list.add(&function_list);
|
||||||
GDScriptLanguage::get_singleton()->lock.unlock();
|
CScriptLanguage::get_singleton()->lock.unlock();
|
||||||
|
|
||||||
profile.call_count = 0;
|
profile.call_count = 0;
|
||||||
profile.self_time = 0;
|
profile.self_time = 0;
|
||||||
@ -1721,17 +1721,17 @@ GDScriptFunction::GDScriptFunction() :
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
GDScriptFunction::~GDScriptFunction() {
|
CScriptFunction::~CScriptFunction() {
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
GDScriptLanguage::get_singleton()->lock.lock();
|
CScriptLanguage::get_singleton()->lock.lock();
|
||||||
GDScriptLanguage::get_singleton()->function_list.remove(&function_list);
|
CScriptLanguage::get_singleton()->function_list.remove(&function_list);
|
||||||
GDScriptLanguage::get_singleton()->lock.unlock();
|
CScriptLanguage::get_singleton()->lock.unlock();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////
|
/////////////////////
|
||||||
|
|
||||||
Variant GDScriptFunctionState::_signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
|
Variant CScriptFunctionState::_signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
|
||||||
Variant arg;
|
Variant arg;
|
||||||
r_error.error = Variant::CallError::CALL_OK;
|
r_error.error = Variant::CallError::CALL_OK;
|
||||||
|
|
||||||
@ -1751,7 +1751,7 @@ Variant GDScriptFunctionState::_signal_callback(const Variant **p_args, int p_ar
|
|||||||
arg = extra_args;
|
arg = extra_args;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<GDScriptFunctionState> self = *p_args[p_argcount - 1];
|
Ref<CScriptFunctionState> self = *p_args[p_argcount - 1];
|
||||||
|
|
||||||
if (self.is_null()) {
|
if (self.is_null()) {
|
||||||
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||||
@ -1763,14 +1763,14 @@ Variant GDScriptFunctionState::_signal_callback(const Variant **p_args, int p_ar
|
|||||||
return resume(arg);
|
return resume(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GDScriptFunctionState::is_valid(bool p_extended_check) const {
|
bool CScriptFunctionState::is_valid(bool p_extended_check) const {
|
||||||
if (function == nullptr) {
|
if (function == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_extended_check) {
|
if (p_extended_check) {
|
||||||
#ifndef NO_THREADS
|
#ifndef NO_THREADS
|
||||||
MutexLock lock(GDScriptLanguage::get_singleton()->lock);
|
MutexLock lock(CScriptLanguage::get_singleton()->lock);
|
||||||
#endif
|
#endif
|
||||||
// Script gone?
|
// Script gone?
|
||||||
if (!scripts_list.in_list()) {
|
if (!scripts_list.in_list()) {
|
||||||
@ -1785,11 +1785,11 @@ bool GDScriptFunctionState::is_valid(bool p_extended_check) const {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant GDScriptFunctionState::resume(const Variant &p_arg) {
|
Variant CScriptFunctionState::resume(const Variant &p_arg) {
|
||||||
ERR_FAIL_COND_V(!function, Variant());
|
ERR_FAIL_COND_V(!function, Variant());
|
||||||
{
|
{
|
||||||
#ifndef NO_THREADS
|
#ifndef NO_THREADS
|
||||||
MutexLock lock(GDScriptLanguage::singleton->lock);
|
MutexLock lock(CScriptLanguage::singleton->lock);
|
||||||
#endif
|
#endif
|
||||||
if (!scripts_list.in_list()) {
|
if (!scripts_list.in_list()) {
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
@ -1816,13 +1816,13 @@ Variant GDScriptFunctionState::resume(const Variant &p_arg) {
|
|||||||
|
|
||||||
bool completed = true;
|
bool completed = true;
|
||||||
|
|
||||||
// If the return value is a GDScriptFunctionState reference,
|
// If the return value is a CScriptFunctionState reference,
|
||||||
// then the function did yield again after resuming.
|
// then the function did yield again after resuming.
|
||||||
if (ret.is_ref()) {
|
if (ret.is_ref()) {
|
||||||
GDScriptFunctionState *gdfs = Object::cast_to<GDScriptFunctionState>(ret);
|
CScriptFunctionState *gdfs = Object::cast_to<CScriptFunctionState>(ret);
|
||||||
if (gdfs && gdfs->function == function) {
|
if (gdfs && gdfs->function == function) {
|
||||||
completed = false;
|
completed = false;
|
||||||
gdfs->first_state = first_state.is_valid() ? first_state : Ref<GDScriptFunctionState>(this);
|
gdfs->first_state = first_state.is_valid() ? first_state : Ref<CScriptFunctionState>(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1838,7 +1838,7 @@ Variant GDScriptFunctionState::resume(const Variant &p_arg) {
|
|||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if (ScriptDebugger::get_singleton()) {
|
if (ScriptDebugger::get_singleton()) {
|
||||||
GDScriptLanguage::get_singleton()->exit_function();
|
CScriptLanguage::get_singleton()->exit_function();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -1846,7 +1846,7 @@ Variant GDScriptFunctionState::resume(const Variant &p_arg) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDScriptFunctionState::_clear_stack() {
|
void CScriptFunctionState::_clear_stack() {
|
||||||
if (state.stack_size) {
|
if (state.stack_size) {
|
||||||
Variant *stack = (Variant *)state.stack.ptr();
|
Variant *stack = (Variant *)state.stack.ptr();
|
||||||
for (int i = 0; i < state.stack_size; i++) {
|
for (int i = 0; i < state.stack_size; i++) {
|
||||||
@ -1856,24 +1856,24 @@ void GDScriptFunctionState::_clear_stack() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDScriptFunctionState::_bind_methods() {
|
void CScriptFunctionState::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("resume", "arg"), &GDScriptFunctionState::resume, DEFVAL(Variant()));
|
ClassDB::bind_method(D_METHOD("resume", "arg"), &CScriptFunctionState::resume, DEFVAL(Variant()));
|
||||||
ClassDB::bind_method(D_METHOD("is_valid", "extended_check"), &GDScriptFunctionState::is_valid, DEFVAL(false));
|
ClassDB::bind_method(D_METHOD("is_valid", "extended_check"), &CScriptFunctionState::is_valid, DEFVAL(false));
|
||||||
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "_signal_callback", &GDScriptFunctionState::_signal_callback, MethodInfo("_signal_callback"));
|
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "_signal_callback", &CScriptFunctionState::_signal_callback, MethodInfo("_signal_callback"));
|
||||||
|
|
||||||
ADD_SIGNAL(MethodInfo("completed", PropertyInfo(Variant::NIL, "result", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT)));
|
ADD_SIGNAL(MethodInfo("completed", PropertyInfo(Variant::NIL, "result", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT)));
|
||||||
}
|
}
|
||||||
|
|
||||||
GDScriptFunctionState::GDScriptFunctionState() :
|
CScriptFunctionState::CScriptFunctionState() :
|
||||||
scripts_list(this),
|
scripts_list(this),
|
||||||
instances_list(this) {
|
instances_list(this) {
|
||||||
function = nullptr;
|
function = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
GDScriptFunctionState::~GDScriptFunctionState() {
|
CScriptFunctionState::~CScriptFunctionState() {
|
||||||
_clear_stack();
|
_clear_stack();
|
||||||
GDScriptLanguage::singleton->lock.lock();
|
CScriptLanguage::singleton->lock.lock();
|
||||||
scripts_list.remove_from_list();
|
scripts_list.remove_from_list();
|
||||||
instances_list.remove_from_list();
|
instances_list.remove_from_list();
|
||||||
GDScriptLanguage::singleton->lock.unlock();
|
CScriptLanguage::singleton->lock.unlock();
|
||||||
}
|
}
|
||||||
|
@ -38,17 +38,17 @@
|
|||||||
#include "core/string_name.h"
|
#include "core/string_name.h"
|
||||||
#include "core/variant.h"
|
#include "core/variant.h"
|
||||||
|
|
||||||
class GDScriptInstance;
|
class CScriptInstance;
|
||||||
class GDScript;
|
class CScript;
|
||||||
|
|
||||||
struct GDScriptDataType {
|
struct CScriptDataType {
|
||||||
bool has_type;
|
bool has_type;
|
||||||
enum {
|
enum {
|
||||||
UNINITIALIZED,
|
UNINITIALIZED,
|
||||||
BUILTIN,
|
BUILTIN,
|
||||||
NATIVE,
|
NATIVE,
|
||||||
SCRIPT,
|
SCRIPT,
|
||||||
GDSCRIPT,
|
CSCRIPT,
|
||||||
} kind;
|
} kind;
|
||||||
Variant::Type builtin_type;
|
Variant::Type builtin_type;
|
||||||
StringName native_type;
|
StringName native_type;
|
||||||
@ -94,7 +94,7 @@ struct GDScriptDataType {
|
|||||||
return true;
|
return true;
|
||||||
} break;
|
} break;
|
||||||
case SCRIPT:
|
case SCRIPT:
|
||||||
case GDSCRIPT: {
|
case CSCRIPT: {
|
||||||
if (p_variant.get_type() == Variant::NIL) {
|
if (p_variant.get_type() == Variant::NIL) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ struct GDScriptDataType {
|
|||||||
info.class_name = native_type;
|
info.class_name = native_type;
|
||||||
} break;
|
} break;
|
||||||
case SCRIPT:
|
case SCRIPT:
|
||||||
case GDSCRIPT: {
|
case CSCRIPT: {
|
||||||
info.type = Variant::OBJECT;
|
info.type = Variant::OBJECT;
|
||||||
info.class_name = script_type->get_instance_base_type();
|
info.class_name = script_type->get_instance_base_type();
|
||||||
} break;
|
} break;
|
||||||
@ -148,14 +148,14 @@ struct GDScriptDataType {
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
GDScriptDataType() :
|
CScriptDataType() :
|
||||||
has_type(false),
|
has_type(false),
|
||||||
kind(UNINITIALIZED),
|
kind(UNINITIALIZED),
|
||||||
builtin_type(Variant::NIL),
|
builtin_type(Variant::NIL),
|
||||||
script_type(nullptr) {}
|
script_type(nullptr) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class GDScriptFunction {
|
class CScriptFunction {
|
||||||
public:
|
public:
|
||||||
enum Opcode {
|
enum Opcode {
|
||||||
OPCODE_OPERATOR,
|
OPCODE_OPERATOR,
|
||||||
@ -224,7 +224,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class GDScriptCompiler;
|
friend class CScriptCompiler;
|
||||||
|
|
||||||
StringName source;
|
StringName source;
|
||||||
|
|
||||||
@ -248,7 +248,7 @@ private:
|
|||||||
bool _static;
|
bool _static;
|
||||||
MultiplayerAPI::RPCMode rpc_mode;
|
MultiplayerAPI::RPCMode rpc_mode;
|
||||||
|
|
||||||
GDScript *_script;
|
CScript *_script;
|
||||||
|
|
||||||
StringName name;
|
StringName name;
|
||||||
Vector<Variant> constants;
|
Vector<Variant> constants;
|
||||||
@ -258,8 +258,8 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
Vector<int> default_arguments;
|
Vector<int> default_arguments;
|
||||||
Vector<int> code;
|
Vector<int> code;
|
||||||
Vector<GDScriptDataType> argument_types;
|
Vector<CScriptDataType> argument_types;
|
||||||
GDScriptDataType return_type;
|
CScriptDataType return_type;
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
Vector<StringName> arg_names;
|
Vector<StringName> arg_names;
|
||||||
@ -267,12 +267,12 @@ private:
|
|||||||
|
|
||||||
List<StackDebug> stack_debug;
|
List<StackDebug> stack_debug;
|
||||||
|
|
||||||
_FORCE_INLINE_ Variant *_get_variant(int p_address, GDScriptInstance *p_instance, GDScript *p_script, Variant &self, Variant &static_ref, Variant *p_stack, String &r_error) const;
|
_FORCE_INLINE_ Variant *_get_variant(int p_address, CScriptInstance *p_instance, CScript *p_script, Variant &self, Variant &static_ref, Variant *p_stack, String &r_error) const;
|
||||||
_FORCE_INLINE_ String _get_call_error(const Variant::CallError &p_err, const String &p_where, const Variant **argptrs) const;
|
_FORCE_INLINE_ String _get_call_error(const Variant::CallError &p_err, const String &p_where, const Variant **argptrs) const;
|
||||||
|
|
||||||
friend class GDScriptLanguage;
|
friend class CScriptLanguage;
|
||||||
|
|
||||||
SelfList<GDScriptFunction> function_list;
|
SelfList<CScriptFunction> function_list;
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
CharString func_cname;
|
CharString func_cname;
|
||||||
const char *_func_cname;
|
const char *_func_cname;
|
||||||
@ -294,8 +294,8 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
struct CallState {
|
struct CallState {
|
||||||
GDScript *script;
|
CScript *script;
|
||||||
GDScriptInstance *instance;
|
CScriptInstance *instance;
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
StringName function_name;
|
StringName function_name;
|
||||||
String script_path;
|
String script_path;
|
||||||
@ -322,9 +322,9 @@ public:
|
|||||||
int get_max_stack_size() const;
|
int get_max_stack_size() const;
|
||||||
int get_default_argument_count() const;
|
int get_default_argument_count() const;
|
||||||
int get_default_argument_addr(int p_idx) const;
|
int get_default_argument_addr(int p_idx) const;
|
||||||
GDScriptDataType get_return_type() const;
|
CScriptDataType get_return_type() const;
|
||||||
GDScriptDataType get_argument_type(int p_idx) const;
|
CScriptDataType get_argument_type(int p_idx) const;
|
||||||
GDScript *get_script() const {
|
CScript *get_script() const {
|
||||||
return _script;
|
return _script;
|
||||||
}
|
}
|
||||||
StringName get_source() const {
|
StringName get_source() const {
|
||||||
@ -353,25 +353,25 @@ public:
|
|||||||
return default_arguments[p_idx];
|
return default_arguments[p_idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state = nullptr);
|
Variant call(CScriptInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state = nullptr);
|
||||||
|
|
||||||
_FORCE_INLINE_ MultiplayerAPI::RPCMode get_rpc_mode() const {
|
_FORCE_INLINE_ MultiplayerAPI::RPCMode get_rpc_mode() const {
|
||||||
return rpc_mode;
|
return rpc_mode;
|
||||||
}
|
}
|
||||||
GDScriptFunction();
|
CScriptFunction();
|
||||||
~GDScriptFunction();
|
~CScriptFunction();
|
||||||
};
|
};
|
||||||
|
|
||||||
class GDScriptFunctionState : public Reference {
|
class CScriptFunctionState : public Reference {
|
||||||
GDCLASS(GDScriptFunctionState, Reference);
|
GDCLASS(CScriptFunctionState, Reference);
|
||||||
friend class GDScriptFunction;
|
friend class CScriptFunction;
|
||||||
GDScriptFunction *function;
|
CScriptFunction *function;
|
||||||
GDScriptFunction::CallState state;
|
CScriptFunction::CallState state;
|
||||||
Variant _signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
|
Variant _signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
|
||||||
Ref<GDScriptFunctionState> first_state;
|
Ref<CScriptFunctionState> first_state;
|
||||||
|
|
||||||
SelfList<GDScriptFunctionState> scripts_list;
|
SelfList<CScriptFunctionState> scripts_list;
|
||||||
SelfList<GDScriptFunctionState> instances_list;
|
SelfList<CScriptFunctionState> instances_list;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
@ -382,8 +382,8 @@ public:
|
|||||||
|
|
||||||
void _clear_stack();
|
void _clear_stack();
|
||||||
|
|
||||||
GDScriptFunctionState();
|
CScriptFunctionState();
|
||||||
~GDScriptFunctionState();
|
~CScriptFunctionState();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GDSCRIPT_FUNCTION_H
|
#endif // CSCRIPT_FUNCTION_H
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
#include "core/variant_parser.h"
|
#include "core/variant_parser.h"
|
||||||
#include "cscript.h"
|
#include "cscript.h"
|
||||||
|
|
||||||
const char *GDScriptFunctions::get_func_name(Function p_func) {
|
const char *CScriptFunctions::get_func_name(Function p_func) {
|
||||||
ERR_FAIL_INDEX_V(p_func, FUNC_MAX, "");
|
ERR_FAIL_INDEX_V(p_func, FUNC_MAX, "");
|
||||||
|
|
||||||
static const char *_names[FUNC_MAX] = {
|
static const char *_names[FUNC_MAX] = {
|
||||||
@ -140,7 +140,7 @@ const char *GDScriptFunctions::get_func_name(Function p_func) {
|
|||||||
return _names[p_func];
|
return _names[p_func];
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_count, Variant &r_ret, Variant::CallError &r_error) {
|
void CScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_count, Variant &r_ret, Variant::CallError &r_error) {
|
||||||
r_error.error = Variant::CallError::CALL_OK;
|
r_error.error = Variant::CallError::CALL_OK;
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
|
|||||||
VALIDATE_ARG_COUNT(1);
|
VALIDATE_ARG_COUNT(1);
|
||||||
VALIDATE_ARG_NUM(0);
|
VALIDATE_ARG_NUM(0);
|
||||||
r_ret = Math::step_decimals((double)*p_args[0]);
|
r_ret = Math::step_decimals((double)*p_args[0]);
|
||||||
WARN_DEPRECATED_MSG("GDScript method 'decimals' is deprecated and has been renamed to 'step_decimals', please update your code accordingly.");
|
WARN_DEPRECATED_MSG("CScript method 'decimals' is deprecated and has been renamed to 'step_decimals', please update your code accordingly.");
|
||||||
} break;
|
} break;
|
||||||
case MATH_STEP_DECIMALS: {
|
case MATH_STEP_DECIMALS: {
|
||||||
VALIDATE_ARG_COUNT(1);
|
VALIDATE_ARG_COUNT(1);
|
||||||
@ -753,7 +753,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
|
|||||||
str += p_args[i]->operator String();
|
str += p_args[i]->operator String();
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptLanguage *script = GDScriptLanguage::get_singleton();
|
ScriptLanguage *script = CScriptLanguage::get_singleton();
|
||||||
if (script->debug_get_stack_level_count() > 0) {
|
if (script->debug_get_stack_level_count() > 0) {
|
||||||
str += "\n At: " + script->debug_get_stack_level_source(0) + ":" + itos(script->debug_get_stack_level_line(0)) + ":" + script->debug_get_stack_level_function(0) + "()";
|
str += "\n At: " + script->debug_get_stack_level_source(0) + ":" + itos(script->debug_get_stack_level_line(0)) + ":" + script->debug_get_stack_level_function(0) + "()";
|
||||||
}
|
}
|
||||||
@ -1041,15 +1041,15 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
|
|||||||
if (!obj) {
|
if (!obj) {
|
||||||
r_ret = Variant();
|
r_ret = Variant();
|
||||||
|
|
||||||
} else if (!obj->get_script_instance() || obj->get_script_instance()->get_language() != GDScriptLanguage::get_singleton()) {
|
} else if (!obj->get_script_instance() || obj->get_script_instance()->get_language() != CScriptLanguage::get_singleton()) {
|
||||||
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||||
r_error.argument = 0;
|
r_error.argument = 0;
|
||||||
r_error.expected = Variant::DICTIONARY;
|
r_error.expected = Variant::DICTIONARY;
|
||||||
r_ret = RTR("Not a script with an instance");
|
r_ret = RTR("Not a script with an instance");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
GDScriptInstance *ins = static_cast<GDScriptInstance *>(obj->get_script_instance());
|
CScriptInstance *ins = static_cast<CScriptInstance *>(obj->get_script_instance());
|
||||||
Ref<GDScript> base = ins->get_script();
|
Ref<CScript> base = ins->get_script();
|
||||||
if (base.is_null()) {
|
if (base.is_null()) {
|
||||||
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||||
r_error.argument = 0;
|
r_error.argument = 0;
|
||||||
@ -1058,7 +1058,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GDScript *p = base.ptr();
|
CScript *p = base.ptr();
|
||||||
Vector<StringName> sname;
|
Vector<StringName> sname;
|
||||||
|
|
||||||
while (p->_owner) {
|
while (p->_owner) {
|
||||||
@ -1084,7 +1084,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
|
|||||||
d["@subpath"] = cp;
|
d["@subpath"] = cp;
|
||||||
d["@path"] = p->get_path();
|
d["@path"] = p->get_path();
|
||||||
|
|
||||||
for (Map<StringName, GDScript::MemberInfo>::Element *E = base->member_indices.front(); E; E = E->next()) {
|
for (Map<StringName, CScript::MemberInfo>::Element *E = base->member_indices.front(); E; E = E->next()) {
|
||||||
if (!d.has(E->key())) {
|
if (!d.has(E->key())) {
|
||||||
d[E->key()] = ins->members[E->get().index];
|
d[E->key()] = ins->members[E->get().index];
|
||||||
}
|
}
|
||||||
@ -1126,7 +1126,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<GDScript> gdscr = scr;
|
Ref<CScript> gdscr = scr;
|
||||||
|
|
||||||
if (!gdscr.is_valid()) {
|
if (!gdscr.is_valid()) {
|
||||||
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||||
@ -1161,10 +1161,10 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GDScriptInstance *ins = static_cast<GDScriptInstance *>(static_cast<Object *>(r_ret)->get_script_instance());
|
CScriptInstance *ins = static_cast<CScriptInstance *>(static_cast<Object *>(r_ret)->get_script_instance());
|
||||||
Ref<GDScript> gd_ref = ins->get_script();
|
Ref<CScript> gd_ref = ins->get_script();
|
||||||
|
|
||||||
for (Map<StringName, GDScript::MemberInfo>::Element *E = gd_ref->member_indices.front(); E; E = E->next()) {
|
for (Map<StringName, CScript::MemberInfo>::Element *E = gd_ref->member_indices.front(); E; E = E->next()) {
|
||||||
if (d.has(E->key())) {
|
if (d.has(E->key())) {
|
||||||
ins->members.write[E->get().index] = d[E->key()];
|
ins->members.write[E->get().index] = d[E->key()];
|
||||||
}
|
}
|
||||||
@ -1289,7 +1289,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
|
|||||||
case PRINT_STACK: {
|
case PRINT_STACK: {
|
||||||
VALIDATE_ARG_COUNT(0);
|
VALIDATE_ARG_COUNT(0);
|
||||||
|
|
||||||
ScriptLanguage *script = GDScriptLanguage::get_singleton();
|
ScriptLanguage *script = CScriptLanguage::get_singleton();
|
||||||
for (int i = 0; i < script->debug_get_stack_level_count(); i++) {
|
for (int i = 0; i < script->debug_get_stack_level_count(); i++) {
|
||||||
print_line("Frame " + itos(i) + " - " + script->debug_get_stack_level_source(i) + ":" + itos(script->debug_get_stack_level_line(i)) + " in function '" + script->debug_get_stack_level_function(i) + "'");
|
print_line("Frame " + itos(i) + " - " + script->debug_get_stack_level_source(i) + ":" + itos(script->debug_get_stack_level_line(i)) + " in function '" + script->debug_get_stack_level_function(i) + "'");
|
||||||
};
|
};
|
||||||
@ -1298,7 +1298,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
|
|||||||
case GET_STACK: {
|
case GET_STACK: {
|
||||||
VALIDATE_ARG_COUNT(0);
|
VALIDATE_ARG_COUNT(0);
|
||||||
|
|
||||||
ScriptLanguage *script = GDScriptLanguage::get_singleton();
|
ScriptLanguage *script = CScriptLanguage::get_singleton();
|
||||||
Array ret;
|
Array ret;
|
||||||
for (int i = 0; i < script->debug_get_stack_level_count(); i++) {
|
for (int i = 0; i < script->debug_get_stack_level_count(); i++) {
|
||||||
Dictionary frame;
|
Dictionary frame;
|
||||||
@ -1405,7 +1405,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GDScriptFunctions::is_deterministic(Function p_func) {
|
bool CScriptFunctions::is_deterministic(Function p_func) {
|
||||||
//man i couldn't have chosen a worse function name,
|
//man i couldn't have chosen a worse function name,
|
||||||
//way too controversial..
|
//way too controversial..
|
||||||
|
|
||||||
@ -1473,7 +1473,7 @@ bool GDScriptFunctions::is_deterministic(Function p_func) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MethodInfo GDScriptFunctions::get_info(Function p_func) {
|
MethodInfo CScriptFunctions::get_info(Function p_func) {
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
//using a switch, so the compiler generates a jumptable
|
//using a switch, so the compiler generates a jumptable
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include "core/variant.h"
|
#include "core/variant.h"
|
||||||
|
|
||||||
class GDScriptFunctions {
|
class CScriptFunctions {
|
||||||
public:
|
public:
|
||||||
enum Function {
|
enum Function {
|
||||||
MATH_SIN,
|
MATH_SIN,
|
||||||
@ -135,4 +135,4 @@ public:
|
|||||||
static MethodInfo get_info(Function p_func);
|
static MethodInfo get_info(Function p_func);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GDSCRIPT_FUNCTIONS_H
|
#endif // CSCRIPT_FUNCTIONS_H
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -36,10 +36,10 @@
|
|||||||
#include "cscript_functions.h"
|
#include "cscript_functions.h"
|
||||||
#include "cscript_tokenizer.h"
|
#include "cscript_tokenizer.h"
|
||||||
|
|
||||||
struct GDScriptDataType;
|
struct CScriptDataType;
|
||||||
struct GDScriptWarning;
|
struct CScriptWarning;
|
||||||
|
|
||||||
class GDScriptParser {
|
class CScriptParser {
|
||||||
public:
|
public:
|
||||||
struct ClassNode;
|
struct ClassNode;
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ public:
|
|||||||
BUILTIN,
|
BUILTIN,
|
||||||
NATIVE,
|
NATIVE,
|
||||||
SCRIPT,
|
SCRIPT,
|
||||||
GDSCRIPT,
|
CSCRIPT,
|
||||||
CLASS,
|
CLASS,
|
||||||
UNRESOLVED
|
UNRESOLVED
|
||||||
} kind;
|
} kind;
|
||||||
@ -80,7 +80,7 @@ public:
|
|||||||
case NATIVE: {
|
case NATIVE: {
|
||||||
return native_type == other.native_type;
|
return native_type == other.native_type;
|
||||||
} break;
|
} break;
|
||||||
case GDSCRIPT:
|
case CSCRIPT:
|
||||||
case SCRIPT: {
|
case SCRIPT: {
|
||||||
return script_type == other.script_type;
|
return script_type == other.script_type;
|
||||||
} break;
|
} break;
|
||||||
@ -264,7 +264,7 @@ public:
|
|||||||
TypeNode() { type = TYPE_TYPE; }
|
TypeNode() { type = TYPE_TYPE; }
|
||||||
};
|
};
|
||||||
struct BuiltInFunctionNode : public Node {
|
struct BuiltInFunctionNode : public Node {
|
||||||
GDScriptFunctions::Function function;
|
CScriptFunctions::Function function;
|
||||||
BuiltInFunctionNode() { type = TYPE_BUILT_IN_FUNCTION; }
|
BuiltInFunctionNode() { type = TYPE_BUILT_IN_FUNCTION; }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -520,7 +520,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GDScriptTokenizer *tokenizer;
|
CScriptTokenizer *tokenizer;
|
||||||
|
|
||||||
Node *head;
|
Node *head;
|
||||||
Node *list;
|
Node *list;
|
||||||
@ -542,7 +542,7 @@ private:
|
|||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
List<GDScriptWarning> warnings;
|
List<CScriptWarning> warnings;
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
|
|
||||||
int pending_newline;
|
int pending_newline;
|
||||||
@ -626,7 +626,7 @@ private:
|
|||||||
DataType _resolve_type(const DataType &p_source, int p_line);
|
DataType _resolve_type(const DataType &p_source, int p_line);
|
||||||
DataType _type_from_variant(const Variant &p_value) const;
|
DataType _type_from_variant(const Variant &p_value) const;
|
||||||
DataType _type_from_property(const PropertyInfo &p_property, bool p_nil_is_variant = true) const;
|
DataType _type_from_property(const PropertyInfo &p_property, bool p_nil_is_variant = true) const;
|
||||||
DataType _type_from_gdtype(const GDScriptDataType &p_gdtype) const;
|
DataType _type_from_gdtype(const CScriptDataType &p_gdtype) const;
|
||||||
DataType _get_operation_type(const Variant::Operator p_op, const DataType &p_a, const DataType &p_b, bool &r_valid) const;
|
DataType _get_operation_type(const Variant::Operator p_op, const DataType &p_a, const DataType &p_b, bool &r_valid) const;
|
||||||
Variant::Operator _get_variant_operation(const OperatorNode::Operator &p_op) const;
|
Variant::Operator _get_variant_operation(const OperatorNode::Operator &p_op) const;
|
||||||
bool _get_function_signature(DataType &p_base_type, const StringName &p_function, DataType &r_return_type, List<DataType> &r_arg_types, int &r_default_arg_count, bool &r_static, bool &r_vararg) const;
|
bool _get_function_signature(DataType &p_base_type, const StringName &p_function, DataType &r_return_type, List<DataType> &r_arg_types, int &r_default_arg_count, bool &r_static, bool &r_vararg) const;
|
||||||
@ -664,7 +664,7 @@ public:
|
|||||||
int get_error_line() const;
|
int get_error_line() const;
|
||||||
int get_error_column() const;
|
int get_error_column() const;
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
const List<GDScriptWarning> &get_warnings() const {
|
const List<CScriptWarning> &get_warnings() const {
|
||||||
return warnings;
|
return warnings;
|
||||||
}
|
}
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
@ -692,8 +692,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
GDScriptParser();
|
CScriptParser();
|
||||||
~GDScriptParser();
|
~CScriptParser();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GDSCRIPT_PARSER_H
|
#endif // CSCRIPT_PARSER_H
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#include "core/print_string.h"
|
#include "core/print_string.h"
|
||||||
#include "cscript_functions.h"
|
#include "cscript_functions.h"
|
||||||
|
|
||||||
const char *GDScriptTokenizer::token_names[TK_MAX] = {
|
const char *CScriptTokenizer::token_names[TK_MAX] = {
|
||||||
"Empty",
|
"Empty",
|
||||||
"Identifier",
|
"Identifier",
|
||||||
"Constant",
|
"Constant",
|
||||||
@ -182,71 +182,71 @@ static const _bit _type_list[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct _kws {
|
struct _kws {
|
||||||
GDScriptTokenizer::Token token;
|
CScriptTokenizer::Token token;
|
||||||
const char *text;
|
const char *text;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const _kws _keyword_list[] = {
|
static const _kws _keyword_list[] = {
|
||||||
//ops
|
//ops
|
||||||
{ GDScriptTokenizer::TK_OP_IN, "in" },
|
{ CScriptTokenizer::TK_OP_IN, "in" },
|
||||||
{ GDScriptTokenizer::TK_OP_NOT, "not" },
|
{ CScriptTokenizer::TK_OP_NOT, "not" },
|
||||||
{ GDScriptTokenizer::TK_OP_OR, "or" },
|
{ CScriptTokenizer::TK_OP_OR, "or" },
|
||||||
{ GDScriptTokenizer::TK_OP_AND, "and" },
|
{ CScriptTokenizer::TK_OP_AND, "and" },
|
||||||
//func
|
//func
|
||||||
{ GDScriptTokenizer::TK_PR_FUNCTION, "func" },
|
{ CScriptTokenizer::TK_PR_FUNCTION, "func" },
|
||||||
{ GDScriptTokenizer::TK_PR_CLASS, "class" },
|
{ CScriptTokenizer::TK_PR_CLASS, "class" },
|
||||||
{ GDScriptTokenizer::TK_PR_CLASS_NAME, "class_name" },
|
{ CScriptTokenizer::TK_PR_CLASS_NAME, "class_name" },
|
||||||
{ GDScriptTokenizer::TK_PR_EXTENDS, "extends" },
|
{ CScriptTokenizer::TK_PR_EXTENDS, "extends" },
|
||||||
{ GDScriptTokenizer::TK_PR_IS, "is" },
|
{ CScriptTokenizer::TK_PR_IS, "is" },
|
||||||
{ GDScriptTokenizer::TK_PR_ONREADY, "onready" },
|
{ CScriptTokenizer::TK_PR_ONREADY, "onready" },
|
||||||
{ GDScriptTokenizer::TK_PR_TOOL, "tool" },
|
{ CScriptTokenizer::TK_PR_TOOL, "tool" },
|
||||||
{ GDScriptTokenizer::TK_PR_STATIC, "static" },
|
{ CScriptTokenizer::TK_PR_STATIC, "static" },
|
||||||
{ GDScriptTokenizer::TK_PR_EXPORT, "export" },
|
{ CScriptTokenizer::TK_PR_EXPORT, "export" },
|
||||||
{ GDScriptTokenizer::TK_PR_SETGET, "setget" },
|
{ CScriptTokenizer::TK_PR_SETGET, "setget" },
|
||||||
{ GDScriptTokenizer::TK_PR_VAR, "var" },
|
{ CScriptTokenizer::TK_PR_VAR, "var" },
|
||||||
{ GDScriptTokenizer::TK_PR_AS, "as" },
|
{ CScriptTokenizer::TK_PR_AS, "as" },
|
||||||
{ GDScriptTokenizer::TK_PR_VOID, "void" },
|
{ CScriptTokenizer::TK_PR_VOID, "void" },
|
||||||
{ GDScriptTokenizer::TK_PR_PRELOAD, "preload" },
|
{ CScriptTokenizer::TK_PR_PRELOAD, "preload" },
|
||||||
{ GDScriptTokenizer::TK_PR_ASSERT, "assert" },
|
{ CScriptTokenizer::TK_PR_ASSERT, "assert" },
|
||||||
{ GDScriptTokenizer::TK_PR_YIELD, "yield" },
|
{ CScriptTokenizer::TK_PR_YIELD, "yield" },
|
||||||
{ GDScriptTokenizer::TK_PR_SIGNAL, "signal" },
|
{ CScriptTokenizer::TK_PR_SIGNAL, "signal" },
|
||||||
{ GDScriptTokenizer::TK_PR_BREAKPOINT, "breakpoint" },
|
{ CScriptTokenizer::TK_PR_BREAKPOINT, "breakpoint" },
|
||||||
{ GDScriptTokenizer::TK_PR_REMOTE, "remote" },
|
{ CScriptTokenizer::TK_PR_REMOTE, "remote" },
|
||||||
{ GDScriptTokenizer::TK_PR_MASTER, "master" },
|
{ CScriptTokenizer::TK_PR_MASTER, "master" },
|
||||||
{ GDScriptTokenizer::TK_PR_SLAVE, "slave" },
|
{ CScriptTokenizer::TK_PR_SLAVE, "slave" },
|
||||||
{ GDScriptTokenizer::TK_PR_PUPPET, "puppet" },
|
{ CScriptTokenizer::TK_PR_PUPPET, "puppet" },
|
||||||
{ GDScriptTokenizer::TK_PR_SYNC, "sync" },
|
{ CScriptTokenizer::TK_PR_SYNC, "sync" },
|
||||||
{ GDScriptTokenizer::TK_PR_REMOTESYNC, "remotesync" },
|
{ CScriptTokenizer::TK_PR_REMOTESYNC, "remotesync" },
|
||||||
{ GDScriptTokenizer::TK_PR_MASTERSYNC, "mastersync" },
|
{ CScriptTokenizer::TK_PR_MASTERSYNC, "mastersync" },
|
||||||
{ GDScriptTokenizer::TK_PR_PUPPETSYNC, "puppetsync" },
|
{ CScriptTokenizer::TK_PR_PUPPETSYNC, "puppetsync" },
|
||||||
{ GDScriptTokenizer::TK_PR_CONST, "const" },
|
{ CScriptTokenizer::TK_PR_CONST, "const" },
|
||||||
{ GDScriptTokenizer::TK_PR_ENUM, "enum" },
|
{ CScriptTokenizer::TK_PR_ENUM, "enum" },
|
||||||
//controlflow
|
//controlflow
|
||||||
{ GDScriptTokenizer::TK_CF_IF, "if" },
|
{ CScriptTokenizer::TK_CF_IF, "if" },
|
||||||
{ GDScriptTokenizer::TK_CF_ELIF, "elif" },
|
{ CScriptTokenizer::TK_CF_ELIF, "elif" },
|
||||||
{ GDScriptTokenizer::TK_CF_ELSE, "else" },
|
{ CScriptTokenizer::TK_CF_ELSE, "else" },
|
||||||
{ GDScriptTokenizer::TK_CF_FOR, "for" },
|
{ CScriptTokenizer::TK_CF_FOR, "for" },
|
||||||
{ GDScriptTokenizer::TK_CF_WHILE, "while" },
|
{ CScriptTokenizer::TK_CF_WHILE, "while" },
|
||||||
{ GDScriptTokenizer::TK_CF_BREAK, "break" },
|
{ CScriptTokenizer::TK_CF_BREAK, "break" },
|
||||||
{ GDScriptTokenizer::TK_CF_CONTINUE, "continue" },
|
{ CScriptTokenizer::TK_CF_CONTINUE, "continue" },
|
||||||
{ GDScriptTokenizer::TK_CF_RETURN, "return" },
|
{ CScriptTokenizer::TK_CF_RETURN, "return" },
|
||||||
{ GDScriptTokenizer::TK_CF_MATCH, "match" },
|
{ CScriptTokenizer::TK_CF_MATCH, "match" },
|
||||||
{ GDScriptTokenizer::TK_CF_PASS, "pass" },
|
{ CScriptTokenizer::TK_CF_PASS, "pass" },
|
||||||
{ GDScriptTokenizer::TK_SELF, "self" },
|
{ CScriptTokenizer::TK_SELF, "self" },
|
||||||
{ GDScriptTokenizer::TK_CONST_PI, "PI" },
|
{ CScriptTokenizer::TK_CONST_PI, "PI" },
|
||||||
{ GDScriptTokenizer::TK_CONST_TAU, "TAU" },
|
{ CScriptTokenizer::TK_CONST_TAU, "TAU" },
|
||||||
{ GDScriptTokenizer::TK_WILDCARD, "_" },
|
{ CScriptTokenizer::TK_WILDCARD, "_" },
|
||||||
{ GDScriptTokenizer::TK_CONST_INF, "INF" },
|
{ CScriptTokenizer::TK_CONST_INF, "INF" },
|
||||||
{ GDScriptTokenizer::TK_CONST_NAN, "NAN" },
|
{ CScriptTokenizer::TK_CONST_NAN, "NAN" },
|
||||||
{ GDScriptTokenizer::TK_ERROR, nullptr }
|
{ CScriptTokenizer::TK_ERROR, nullptr }
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *GDScriptTokenizer::get_token_name(Token p_token) {
|
const char *CScriptTokenizer::get_token_name(Token p_token) {
|
||||||
ERR_FAIL_INDEX_V(p_token, TK_MAX, "<error>");
|
ERR_FAIL_INDEX_V(p_token, TK_MAX, "<error>");
|
||||||
return token_names[p_token];
|
return token_names[p_token];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GDScriptTokenizer::is_token_literal(int p_offset, bool variable_safe) const {
|
bool CScriptTokenizer::is_token_literal(int p_offset, bool variable_safe) const {
|
||||||
switch (get_token(p_offset)) {
|
switch (get_token(p_offset)) {
|
||||||
// Can always be literal:
|
// Can always be literal:
|
||||||
case TK_IDENTIFIER:
|
case TK_IDENTIFIER:
|
||||||
@ -318,7 +318,7 @@ bool GDScriptTokenizer::is_token_literal(int p_offset, bool variable_safe) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StringName GDScriptTokenizer::get_token_literal(int p_offset) const {
|
StringName CScriptTokenizer::get_token_literal(int p_offset) const {
|
||||||
Token token = get_token(p_offset);
|
Token token = get_token(p_offset);
|
||||||
switch (token) {
|
switch (token) {
|
||||||
case TK_IDENTIFIER:
|
case TK_IDENTIFIER:
|
||||||
@ -335,7 +335,7 @@ StringName GDScriptTokenizer::get_token_literal(int p_offset) const {
|
|||||||
}
|
}
|
||||||
} break; // Shouldn't get here, stuff happens
|
} break; // Shouldn't get here, stuff happens
|
||||||
case TK_BUILT_IN_FUNC:
|
case TK_BUILT_IN_FUNC:
|
||||||
return GDScriptFunctions::get_func_name(get_token_built_in_func(p_offset));
|
return CScriptFunctions::get_func_name(get_token_built_in_func(p_offset));
|
||||||
case TK_CONSTANT: {
|
case TK_CONSTANT: {
|
||||||
const Variant value = get_token_constant(p_offset);
|
const Variant value = get_token_constant(p_offset);
|
||||||
|
|
||||||
@ -381,7 +381,7 @@ static bool _is_bin(CharType c) {
|
|||||||
return (c == '0' || c == '1');
|
return (c == '0' || c == '1');
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDScriptTokenizerText::_make_token(Token p_type) {
|
void CScriptTokenizerText::_make_token(Token p_type) {
|
||||||
TokenData &tk = tk_rb[tk_rb_pos];
|
TokenData &tk = tk_rb[tk_rb_pos];
|
||||||
|
|
||||||
tk.type = p_type;
|
tk.type = p_type;
|
||||||
@ -390,7 +390,7 @@ void GDScriptTokenizerText::_make_token(Token p_type) {
|
|||||||
|
|
||||||
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
|
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
|
||||||
}
|
}
|
||||||
void GDScriptTokenizerText::_make_identifier(const StringName &p_identifier) {
|
void CScriptTokenizerText::_make_identifier(const StringName &p_identifier) {
|
||||||
TokenData &tk = tk_rb[tk_rb_pos];
|
TokenData &tk = tk_rb[tk_rb_pos];
|
||||||
|
|
||||||
tk.type = TK_IDENTIFIER;
|
tk.type = TK_IDENTIFIER;
|
||||||
@ -401,7 +401,7 @@ void GDScriptTokenizerText::_make_identifier(const StringName &p_identifier) {
|
|||||||
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
|
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDScriptTokenizerText::_make_built_in_func(GDScriptFunctions::Function p_func) {
|
void CScriptTokenizerText::_make_built_in_func(CScriptFunctions::Function p_func) {
|
||||||
TokenData &tk = tk_rb[tk_rb_pos];
|
TokenData &tk = tk_rb[tk_rb_pos];
|
||||||
|
|
||||||
tk.type = TK_BUILT_IN_FUNC;
|
tk.type = TK_BUILT_IN_FUNC;
|
||||||
@ -411,7 +411,7 @@ void GDScriptTokenizerText::_make_built_in_func(GDScriptFunctions::Function p_fu
|
|||||||
|
|
||||||
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
|
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
|
||||||
}
|
}
|
||||||
void GDScriptTokenizerText::_make_constant(const Variant &p_constant) {
|
void CScriptTokenizerText::_make_constant(const Variant &p_constant) {
|
||||||
TokenData &tk = tk_rb[tk_rb_pos];
|
TokenData &tk = tk_rb[tk_rb_pos];
|
||||||
|
|
||||||
tk.type = TK_CONSTANT;
|
tk.type = TK_CONSTANT;
|
||||||
@ -422,7 +422,7 @@ void GDScriptTokenizerText::_make_constant(const Variant &p_constant) {
|
|||||||
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
|
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDScriptTokenizerText::_make_type(const Variant::Type &p_type) {
|
void CScriptTokenizerText::_make_type(const Variant::Type &p_type) {
|
||||||
TokenData &tk = tk_rb[tk_rb_pos];
|
TokenData &tk = tk_rb[tk_rb_pos];
|
||||||
|
|
||||||
tk.type = TK_BUILT_IN_TYPE;
|
tk.type = TK_BUILT_IN_TYPE;
|
||||||
@ -433,7 +433,7 @@ void GDScriptTokenizerText::_make_type(const Variant::Type &p_type) {
|
|||||||
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
|
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDScriptTokenizerText::_make_error(const String &p_error) {
|
void CScriptTokenizerText::_make_error(const String &p_error) {
|
||||||
error_flag = true;
|
error_flag = true;
|
||||||
last_error = p_error;
|
last_error = p_error;
|
||||||
|
|
||||||
@ -445,7 +445,7 @@ void GDScriptTokenizerText::_make_error(const String &p_error) {
|
|||||||
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
|
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDScriptTokenizerText::_make_newline(int p_indentation, int p_tabs) {
|
void CScriptTokenizerText::_make_newline(int p_indentation, int p_tabs) {
|
||||||
TokenData &tk = tk_rb[tk_rb_pos];
|
TokenData &tk = tk_rb[tk_rb_pos];
|
||||||
tk.type = TK_NEWLINE;
|
tk.type = TK_NEWLINE;
|
||||||
tk.constant = Vector2(p_indentation, p_tabs);
|
tk.constant = Vector2(p_indentation, p_tabs);
|
||||||
@ -454,7 +454,7 @@ void GDScriptTokenizerText::_make_newline(int p_indentation, int p_tabs) {
|
|||||||
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
|
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDScriptTokenizerText::_advance() {
|
void CScriptTokenizerText::_advance() {
|
||||||
if (error_flag) {
|
if (error_flag) {
|
||||||
//parser broke
|
//parser broke
|
||||||
_make_error(last_error);
|
_make_error(last_error);
|
||||||
@ -1012,9 +1012,9 @@ void GDScriptTokenizerText::_advance() {
|
|||||||
if (!found) {
|
if (!found) {
|
||||||
//built in func?
|
//built in func?
|
||||||
|
|
||||||
for (int j = 0; j < GDScriptFunctions::FUNC_MAX; j++) {
|
for (int j = 0; j < CScriptFunctions::FUNC_MAX; j++) {
|
||||||
if (str == GDScriptFunctions::get_func_name(GDScriptFunctions::Function(j))) {
|
if (str == CScriptFunctions::get_func_name(CScriptFunctions::Function(j))) {
|
||||||
_make_built_in_func(GDScriptFunctions::Function(j));
|
_make_built_in_func(CScriptFunctions::Function(j));
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1060,7 +1060,7 @@ void GDScriptTokenizerText::_advance() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDScriptTokenizerText::set_code(const String &p_code) {
|
void CScriptTokenizerText::set_code(const String &p_code) {
|
||||||
code = p_code;
|
code = p_code;
|
||||||
len = p_code.length();
|
len = p_code.length();
|
||||||
if (len) {
|
if (len) {
|
||||||
@ -1082,7 +1082,7 @@ void GDScriptTokenizerText::set_code(const String &p_code) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GDScriptTokenizerText::Token GDScriptTokenizerText::get_token(int p_offset) const {
|
CScriptTokenizerText::Token CScriptTokenizerText::get_token(int p_offset) const {
|
||||||
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, TK_ERROR);
|
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, TK_ERROR);
|
||||||
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, TK_ERROR);
|
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, TK_ERROR);
|
||||||
|
|
||||||
@ -1090,7 +1090,7 @@ GDScriptTokenizerText::Token GDScriptTokenizerText::get_token(int p_offset) cons
|
|||||||
return tk_rb[ofs].type;
|
return tk_rb[ofs].type;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GDScriptTokenizerText::get_token_line(int p_offset) const {
|
int CScriptTokenizerText::get_token_line(int p_offset) const {
|
||||||
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, -1);
|
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, -1);
|
||||||
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, -1);
|
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, -1);
|
||||||
|
|
||||||
@ -1098,7 +1098,7 @@ int GDScriptTokenizerText::get_token_line(int p_offset) const {
|
|||||||
return tk_rb[ofs].line;
|
return tk_rb[ofs].line;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GDScriptTokenizerText::get_token_column(int p_offset) const {
|
int CScriptTokenizerText::get_token_column(int p_offset) const {
|
||||||
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, -1);
|
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, -1);
|
||||||
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, -1);
|
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, -1);
|
||||||
|
|
||||||
@ -1106,7 +1106,7 @@ int GDScriptTokenizerText::get_token_column(int p_offset) const {
|
|||||||
return tk_rb[ofs].col;
|
return tk_rb[ofs].col;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Variant &GDScriptTokenizerText::get_token_constant(int p_offset) const {
|
const Variant &CScriptTokenizerText::get_token_constant(int p_offset) const {
|
||||||
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, tk_rb[0].constant);
|
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, tk_rb[0].constant);
|
||||||
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, tk_rb[0].constant);
|
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, tk_rb[0].constant);
|
||||||
|
|
||||||
@ -1115,7 +1115,7 @@ const Variant &GDScriptTokenizerText::get_token_constant(int p_offset) const {
|
|||||||
return tk_rb[ofs].constant;
|
return tk_rb[ofs].constant;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringName GDScriptTokenizerText::get_token_identifier(int p_offset) const {
|
StringName CScriptTokenizerText::get_token_identifier(int p_offset) const {
|
||||||
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, StringName());
|
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, StringName());
|
||||||
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, StringName());
|
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, StringName());
|
||||||
|
|
||||||
@ -1124,16 +1124,16 @@ StringName GDScriptTokenizerText::get_token_identifier(int p_offset) const {
|
|||||||
return tk_rb[ofs].identifier;
|
return tk_rb[ofs].identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
GDScriptFunctions::Function GDScriptTokenizerText::get_token_built_in_func(int p_offset) const {
|
CScriptFunctions::Function CScriptTokenizerText::get_token_built_in_func(int p_offset) const {
|
||||||
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, GDScriptFunctions::FUNC_MAX);
|
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, CScriptFunctions::FUNC_MAX);
|
||||||
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, GDScriptFunctions::FUNC_MAX);
|
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, CScriptFunctions::FUNC_MAX);
|
||||||
|
|
||||||
int ofs = (TK_RB_SIZE + tk_rb_pos + p_offset - MAX_LOOKAHEAD - 1) % TK_RB_SIZE;
|
int ofs = (TK_RB_SIZE + tk_rb_pos + p_offset - MAX_LOOKAHEAD - 1) % TK_RB_SIZE;
|
||||||
ERR_FAIL_COND_V(tk_rb[ofs].type != TK_BUILT_IN_FUNC, GDScriptFunctions::FUNC_MAX);
|
ERR_FAIL_COND_V(tk_rb[ofs].type != TK_BUILT_IN_FUNC, CScriptFunctions::FUNC_MAX);
|
||||||
return tk_rb[ofs].func;
|
return tk_rb[ofs].func;
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Type GDScriptTokenizerText::get_token_type(int p_offset) const {
|
Variant::Type CScriptTokenizerText::get_token_type(int p_offset) const {
|
||||||
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, Variant::NIL);
|
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, Variant::NIL);
|
||||||
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, Variant::NIL);
|
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, Variant::NIL);
|
||||||
|
|
||||||
@ -1142,7 +1142,7 @@ Variant::Type GDScriptTokenizerText::get_token_type(int p_offset) const {
|
|||||||
return tk_rb[ofs].vtype;
|
return tk_rb[ofs].vtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GDScriptTokenizerText::get_token_line_indent(int p_offset) const {
|
int CScriptTokenizerText::get_token_line_indent(int p_offset) const {
|
||||||
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, 0);
|
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, 0);
|
||||||
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, 0);
|
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, 0);
|
||||||
|
|
||||||
@ -1151,7 +1151,7 @@ int GDScriptTokenizerText::get_token_line_indent(int p_offset) const {
|
|||||||
return tk_rb[ofs].constant.operator Vector2().x;
|
return tk_rb[ofs].constant.operator Vector2().x;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GDScriptTokenizerText::get_token_line_tab_indent(int p_offset) const {
|
int CScriptTokenizerText::get_token_line_tab_indent(int p_offset) const {
|
||||||
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, 0);
|
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, 0);
|
||||||
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, 0);
|
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, 0);
|
||||||
|
|
||||||
@ -1160,7 +1160,7 @@ int GDScriptTokenizerText::get_token_line_tab_indent(int p_offset) const {
|
|||||||
return tk_rb[ofs].constant.operator Vector2().y;
|
return tk_rb[ofs].constant.operator Vector2().y;
|
||||||
}
|
}
|
||||||
|
|
||||||
String GDScriptTokenizerText::get_token_error(int p_offset) const {
|
String CScriptTokenizerText::get_token_error(int p_offset) const {
|
||||||
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, String());
|
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, String());
|
||||||
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, String());
|
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, String());
|
||||||
|
|
||||||
@ -1169,7 +1169,7 @@ String GDScriptTokenizerText::get_token_error(int p_offset) const {
|
|||||||
return tk_rb[ofs].constant;
|
return tk_rb[ofs].constant;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDScriptTokenizerText::advance(int p_amount) {
|
void CScriptTokenizerText::advance(int p_amount) {
|
||||||
ERR_FAIL_COND(p_amount <= 0);
|
ERR_FAIL_COND(p_amount <= 0);
|
||||||
for (int i = 0; i < p_amount; i++) {
|
for (int i = 0; i < p_amount; i++) {
|
||||||
_advance();
|
_advance();
|
||||||
@ -1180,7 +1180,7 @@ void GDScriptTokenizerText::advance(int p_amount) {
|
|||||||
|
|
||||||
#define BYTECODE_VERSION 13
|
#define BYTECODE_VERSION 13
|
||||||
|
|
||||||
Error GDScriptTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer) {
|
Error CScriptTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer) {
|
||||||
const uint8_t *buf = p_buffer.ptr();
|
const uint8_t *buf = p_buffer.ptr();
|
||||||
int total_len = p_buffer.size();
|
int total_len = p_buffer.size();
|
||||||
ERR_FAIL_COND_V(p_buffer.size() < 24 || p_buffer[0] != 'G' || p_buffer[1] != 'D' || p_buffer[2] != 'S' || p_buffer[3] != 'C', ERR_INVALID_DATA);
|
ERR_FAIL_COND_V(p_buffer.size() < 24 || p_buffer[0] != 'G' || p_buffer[1] != 'D' || p_buffer[2] != 'S' || p_buffer[3] != 'C', ERR_INVALID_DATA);
|
||||||
@ -1263,7 +1263,7 @@ Error GDScriptTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code) {
|
Vector<uint8_t> CScriptTokenizerBuffer::parse_code_string(const String &p_code) {
|
||||||
Vector<uint8_t> buf;
|
Vector<uint8_t> buf;
|
||||||
|
|
||||||
Map<StringName, int> identifier_map;
|
Map<StringName, int> identifier_map;
|
||||||
@ -1271,7 +1271,7 @@ Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code)
|
|||||||
Map<uint32_t, int> line_map;
|
Map<uint32_t, int> line_map;
|
||||||
Vector<uint32_t> token_array;
|
Vector<uint32_t> token_array;
|
||||||
|
|
||||||
GDScriptTokenizerText tt;
|
CScriptTokenizerText tt;
|
||||||
tt.set_code(p_code);
|
tt.set_code(p_code);
|
||||||
int line = -1;
|
int line = -1;
|
||||||
|
|
||||||
@ -1413,17 +1413,17 @@ Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code)
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
GDScriptTokenizerBuffer::Token GDScriptTokenizerBuffer::get_token(int p_offset) const {
|
CScriptTokenizerBuffer::Token CScriptTokenizerBuffer::get_token(int p_offset) const {
|
||||||
int offset = token + p_offset;
|
int offset = token + p_offset;
|
||||||
|
|
||||||
if (offset < 0 || offset >= tokens.size()) {
|
if (offset < 0 || offset >= tokens.size()) {
|
||||||
return TK_EOF;
|
return TK_EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
return GDScriptTokenizerBuffer::Token(tokens[offset] & TOKEN_MASK);
|
return CScriptTokenizerBuffer::Token(tokens[offset] & TOKEN_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringName GDScriptTokenizerBuffer::get_token_identifier(int p_offset) const {
|
StringName CScriptTokenizerBuffer::get_token_identifier(int p_offset) const {
|
||||||
int offset = token + p_offset;
|
int offset = token + p_offset;
|
||||||
|
|
||||||
ERR_FAIL_INDEX_V(offset, tokens.size(), StringName());
|
ERR_FAIL_INDEX_V(offset, tokens.size(), StringName());
|
||||||
@ -1433,20 +1433,20 @@ StringName GDScriptTokenizerBuffer::get_token_identifier(int p_offset) const {
|
|||||||
return identifiers[identifier];
|
return identifiers[identifier];
|
||||||
}
|
}
|
||||||
|
|
||||||
GDScriptFunctions::Function GDScriptTokenizerBuffer::get_token_built_in_func(int p_offset) const {
|
CScriptFunctions::Function CScriptTokenizerBuffer::get_token_built_in_func(int p_offset) const {
|
||||||
int offset = token + p_offset;
|
int offset = token + p_offset;
|
||||||
ERR_FAIL_INDEX_V(offset, tokens.size(), GDScriptFunctions::FUNC_MAX);
|
ERR_FAIL_INDEX_V(offset, tokens.size(), CScriptFunctions::FUNC_MAX);
|
||||||
return GDScriptFunctions::Function(tokens[offset] >> TOKEN_BITS);
|
return CScriptFunctions::Function(tokens[offset] >> TOKEN_BITS);
|
||||||
}
|
}
|
||||||
|
|
||||||
Variant::Type GDScriptTokenizerBuffer::get_token_type(int p_offset) const {
|
Variant::Type CScriptTokenizerBuffer::get_token_type(int p_offset) const {
|
||||||
int offset = token + p_offset;
|
int offset = token + p_offset;
|
||||||
ERR_FAIL_INDEX_V(offset, tokens.size(), Variant::NIL);
|
ERR_FAIL_INDEX_V(offset, tokens.size(), Variant::NIL);
|
||||||
|
|
||||||
return Variant::Type(tokens[offset] >> TOKEN_BITS);
|
return Variant::Type(tokens[offset] >> TOKEN_BITS);
|
||||||
}
|
}
|
||||||
|
|
||||||
int GDScriptTokenizerBuffer::get_token_line(int p_offset) const {
|
int CScriptTokenizerBuffer::get_token_line(int p_offset) const {
|
||||||
int offset = token + p_offset;
|
int offset = token + p_offset;
|
||||||
int pos = lines.find_nearest(offset);
|
int pos = lines.find_nearest(offset);
|
||||||
|
|
||||||
@ -1460,7 +1460,7 @@ int GDScriptTokenizerBuffer::get_token_line(int p_offset) const {
|
|||||||
uint32_t l = lines.getv(pos);
|
uint32_t l = lines.getv(pos);
|
||||||
return l & TOKEN_LINE_MASK;
|
return l & TOKEN_LINE_MASK;
|
||||||
}
|
}
|
||||||
int GDScriptTokenizerBuffer::get_token_column(int p_offset) const {
|
int CScriptTokenizerBuffer::get_token_column(int p_offset) const {
|
||||||
int offset = token + p_offset;
|
int offset = token + p_offset;
|
||||||
int pos = lines.find_nearest(offset);
|
int pos = lines.find_nearest(offset);
|
||||||
if (pos < 0) {
|
if (pos < 0) {
|
||||||
@ -1473,26 +1473,26 @@ int GDScriptTokenizerBuffer::get_token_column(int p_offset) const {
|
|||||||
uint32_t l = lines.getv(pos);
|
uint32_t l = lines.getv(pos);
|
||||||
return l >> TOKEN_LINE_BITS;
|
return l >> TOKEN_LINE_BITS;
|
||||||
}
|
}
|
||||||
int GDScriptTokenizerBuffer::get_token_line_indent(int p_offset) const {
|
int CScriptTokenizerBuffer::get_token_line_indent(int p_offset) const {
|
||||||
int offset = token + p_offset;
|
int offset = token + p_offset;
|
||||||
ERR_FAIL_INDEX_V(offset, tokens.size(), 0);
|
ERR_FAIL_INDEX_V(offset, tokens.size(), 0);
|
||||||
return tokens[offset] >> TOKEN_BITS;
|
return tokens[offset] >> TOKEN_BITS;
|
||||||
}
|
}
|
||||||
const Variant &GDScriptTokenizerBuffer::get_token_constant(int p_offset) const {
|
const Variant &CScriptTokenizerBuffer::get_token_constant(int p_offset) const {
|
||||||
int offset = token + p_offset;
|
int offset = token + p_offset;
|
||||||
ERR_FAIL_INDEX_V(offset, tokens.size(), nil);
|
ERR_FAIL_INDEX_V(offset, tokens.size(), nil);
|
||||||
uint32_t constant = tokens[offset] >> TOKEN_BITS;
|
uint32_t constant = tokens[offset] >> TOKEN_BITS;
|
||||||
ERR_FAIL_UNSIGNED_INDEX_V(constant, (uint32_t)constants.size(), nil);
|
ERR_FAIL_UNSIGNED_INDEX_V(constant, (uint32_t)constants.size(), nil);
|
||||||
return constants[constant];
|
return constants[constant];
|
||||||
}
|
}
|
||||||
String GDScriptTokenizerBuffer::get_token_error(int p_offset) const {
|
String CScriptTokenizerBuffer::get_token_error(int p_offset) const {
|
||||||
ERR_FAIL_V(String());
|
ERR_FAIL_V(String());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDScriptTokenizerBuffer::advance(int p_amount) {
|
void CScriptTokenizerBuffer::advance(int p_amount) {
|
||||||
ERR_FAIL_INDEX(p_amount + token, tokens.size());
|
ERR_FAIL_INDEX(p_amount + token, tokens.size());
|
||||||
token += p_amount;
|
token += p_amount;
|
||||||
}
|
}
|
||||||
GDScriptTokenizerBuffer::GDScriptTokenizerBuffer() {
|
CScriptTokenizerBuffer::CScriptTokenizerBuffer() {
|
||||||
token = 0;
|
token = 0;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include "core/vmap.h"
|
#include "core/vmap.h"
|
||||||
#include "cscript_functions.h"
|
#include "cscript_functions.h"
|
||||||
|
|
||||||
class GDScriptTokenizer {
|
class CScriptTokenizer {
|
||||||
public:
|
public:
|
||||||
enum Token {
|
enum Token {
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ public:
|
|||||||
virtual const Variant &get_token_constant(int p_offset = 0) const = 0;
|
virtual const Variant &get_token_constant(int p_offset = 0) const = 0;
|
||||||
virtual Token get_token(int p_offset = 0) const = 0;
|
virtual Token get_token(int p_offset = 0) const = 0;
|
||||||
virtual StringName get_token_identifier(int p_offset = 0) const = 0;
|
virtual StringName get_token_identifier(int p_offset = 0) const = 0;
|
||||||
virtual GDScriptFunctions::Function get_token_built_in_func(int p_offset = 0) const = 0;
|
virtual CScriptFunctions::Function get_token_built_in_func(int p_offset = 0) const = 0;
|
||||||
virtual Variant::Type get_token_type(int p_offset = 0) const = 0;
|
virtual Variant::Type get_token_type(int p_offset = 0) const = 0;
|
||||||
virtual int get_token_line(int p_offset = 0) const = 0;
|
virtual int get_token_line(int p_offset = 0) const = 0;
|
||||||
virtual int get_token_column(int p_offset = 0) const = 0;
|
virtual int get_token_column(int p_offset = 0) const = 0;
|
||||||
@ -176,10 +176,10 @@ public:
|
|||||||
virtual bool is_ignoring_warnings() const = 0;
|
virtual bool is_ignoring_warnings() const = 0;
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
|
|
||||||
virtual ~GDScriptTokenizer(){};
|
virtual ~CScriptTokenizer(){};
|
||||||
};
|
};
|
||||||
|
|
||||||
class GDScriptTokenizerText : public GDScriptTokenizer {
|
class CScriptTokenizerText : public CScriptTokenizer {
|
||||||
enum {
|
enum {
|
||||||
MAX_LOOKAHEAD = 4,
|
MAX_LOOKAHEAD = 4,
|
||||||
TK_RB_SIZE = MAX_LOOKAHEAD * 2 + 1
|
TK_RB_SIZE = MAX_LOOKAHEAD * 2 + 1
|
||||||
@ -192,7 +192,7 @@ class GDScriptTokenizerText : public GDScriptTokenizer {
|
|||||||
Variant constant; //for constant types
|
Variant constant; //for constant types
|
||||||
union {
|
union {
|
||||||
Variant::Type vtype; //for type types
|
Variant::Type vtype; //for type types
|
||||||
GDScriptFunctions::Function func; //function for built in functions
|
CScriptFunctions::Function func; //function for built in functions
|
||||||
int warning_code; //for warning skip
|
int warning_code; //for warning skip
|
||||||
};
|
};
|
||||||
int line, col;
|
int line, col;
|
||||||
@ -206,7 +206,7 @@ class GDScriptTokenizerText : public GDScriptTokenizer {
|
|||||||
void _make_token(Token p_type);
|
void _make_token(Token p_type);
|
||||||
void _make_newline(int p_indentation = 0, int p_tabs = 0);
|
void _make_newline(int p_indentation = 0, int p_tabs = 0);
|
||||||
void _make_identifier(const StringName &p_identifier);
|
void _make_identifier(const StringName &p_identifier);
|
||||||
void _make_built_in_func(GDScriptFunctions::Function p_func);
|
void _make_built_in_func(CScriptFunctions::Function p_func);
|
||||||
void _make_constant(const Variant &p_constant);
|
void _make_constant(const Variant &p_constant);
|
||||||
void _make_type(const Variant::Type &p_type);
|
void _make_type(const Variant::Type &p_type);
|
||||||
void _make_error(const String &p_error);
|
void _make_error(const String &p_error);
|
||||||
@ -234,7 +234,7 @@ public:
|
|||||||
void set_code(const String &p_code);
|
void set_code(const String &p_code);
|
||||||
virtual Token get_token(int p_offset = 0) const;
|
virtual Token get_token(int p_offset = 0) const;
|
||||||
virtual StringName get_token_identifier(int p_offset = 0) const;
|
virtual StringName get_token_identifier(int p_offset = 0) const;
|
||||||
virtual GDScriptFunctions::Function get_token_built_in_func(int p_offset = 0) const;
|
virtual CScriptFunctions::Function get_token_built_in_func(int p_offset = 0) const;
|
||||||
virtual Variant::Type get_token_type(int p_offset = 0) const;
|
virtual Variant::Type get_token_type(int p_offset = 0) const;
|
||||||
virtual int get_token_line(int p_offset = 0) const;
|
virtual int get_token_line(int p_offset = 0) const;
|
||||||
virtual int get_token_column(int p_offset = 0) const;
|
virtual int get_token_column(int p_offset = 0) const;
|
||||||
@ -256,7 +256,7 @@ public:
|
|||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
};
|
};
|
||||||
|
|
||||||
class GDScriptTokenizerBuffer : public GDScriptTokenizer {
|
class CScriptTokenizerBuffer : public CScriptTokenizer {
|
||||||
enum {
|
enum {
|
||||||
|
|
||||||
TOKEN_BYTE_MASK = 0x80,
|
TOKEN_BYTE_MASK = 0x80,
|
||||||
@ -278,7 +278,7 @@ public:
|
|||||||
static Vector<uint8_t> parse_code_string(const String &p_code);
|
static Vector<uint8_t> parse_code_string(const String &p_code);
|
||||||
virtual Token get_token(int p_offset = 0) const;
|
virtual Token get_token(int p_offset = 0) const;
|
||||||
virtual StringName get_token_identifier(int p_offset = 0) const;
|
virtual StringName get_token_identifier(int p_offset = 0) const;
|
||||||
virtual GDScriptFunctions::Function get_token_built_in_func(int p_offset = 0) const;
|
virtual CScriptFunctions::Function get_token_built_in_func(int p_offset = 0) const;
|
||||||
virtual Variant::Type get_token_type(int p_offset = 0) const;
|
virtual Variant::Type get_token_type(int p_offset = 0) const;
|
||||||
virtual int get_token_line(int p_offset = 0) const;
|
virtual int get_token_line(int p_offset = 0) const;
|
||||||
virtual int get_token_column(int p_offset = 0) const;
|
virtual int get_token_column(int p_offset = 0) const;
|
||||||
@ -300,7 +300,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
GDScriptTokenizerBuffer();
|
CScriptTokenizerBuffer();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GDSCRIPT_TOKENIZER_H
|
#endif // CSCRIPT_TOKENIZER_H
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,25 +1,25 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<class name="GDScript" inherits="Script" version="3.5">
|
<class name="CScript" inherits="Script" version="3.5">
|
||||||
<brief_description>
|
<brief_description>
|
||||||
A script implemented in the GDScript programming language.
|
A script implemented in the CScript programming language.
|
||||||
</brief_description>
|
</brief_description>
|
||||||
<description>
|
<description>
|
||||||
A script implemented in the GDScript programming language. The script extends the functionality of all objects that instance it.
|
A script implemented in the CScript programming language. The script extends the functionality of all objects that instance it.
|
||||||
[method new] creates a new instance of the script. [method Object.set_script] extends an existing object, if that object's class matches one of the script's base classes.
|
[method new] creates a new instance of the script. [method Object.set_script] extends an existing object, if that object's class matches one of the script's base classes.
|
||||||
</description>
|
</description>
|
||||||
<tutorials>
|
<tutorials>
|
||||||
<link>$DOCS_URL/tutorials/scripting/gdscript/index.html</link>
|
<link>$DOCS_URL/tutorials/scripting/gdscript/index.html</link>
|
||||||
</tutorials>
|
</tutorials>
|
||||||
<methods>
|
<methods>
|
||||||
<method name="get_as_byte_code" qualifiers="const">
|
<method name="get_as_byte_code" qualifiers="const">
|
||||||
<return type="PoolByteArray" />
|
<return type="PoolByteArray" />
|
||||||
<description>
|
<description>
|
||||||
Returns byte code for the script source code.
|
Returns byte code for the script source code.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="new" qualifiers="vararg">
|
<method name="new" qualifiers="vararg">
|
||||||
<return type="Variant" />
|
<return type="Variant" />
|
||||||
<description>
|
<description>
|
||||||
Returns a new instance of the script.
|
Returns a new instance of the script.
|
||||||
For example:
|
For example:
|
||||||
[codeblock]
|
[codeblock]
|
||||||
@ -28,8 +28,7 @@
|
|||||||
assert(instance.get_script() == MyClass)
|
assert(instance.get_script() == MyClass)
|
||||||
[/codeblock]
|
[/codeblock]
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
</methods>
|
</methods>
|
||||||
<constants>
|
<constants></constants>
|
||||||
</constants>
|
|
||||||
</class>
|
</class>
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "gdscript_highlighter.h"
|
#include "cscript_highlighter.h"
|
||||||
#include "../gdscript_tokenizer.h"
|
#include "../cscript_tokenizer.h"
|
||||||
#include "editor/editor_settings.h"
|
#include "editor/editor_settings.h"
|
||||||
#include "scene/gui/text_edit.h"
|
#include "scene/gui/text_edit.h"
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ static bool _is_bin_symbol(CharType c) {
|
|||||||
return (c == '0' || c == '1');
|
return (c == '0' || c == '1');
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<int, TextEdit::HighlighterInfo> GDScriptSyntaxHighlighter::_get_line_syntax_highlighting(int p_line) {
|
Map<int, TextEdit::HighlighterInfo> CScriptSyntaxHighlighter::_get_line_syntax_highlighting(int p_line) {
|
||||||
Map<int, TextEdit::HighlighterInfo> color_map;
|
Map<int, TextEdit::HighlighterInfo> color_map;
|
||||||
|
|
||||||
Type next_type = NONE;
|
Type next_type = NONE;
|
||||||
@ -219,7 +219,7 @@ Map<int, TextEdit::HighlighterInfo> GDScriptSyntaxHighlighter::_get_line_syntax_
|
|||||||
|
|
||||||
if (str[k] == '(') {
|
if (str[k] == '(') {
|
||||||
in_function_name = true;
|
in_function_name = true;
|
||||||
} else if (previous_text == GDScriptTokenizer::get_token_name(GDScriptTokenizer::TK_PR_VAR)) {
|
} else if (previous_text == CScriptTokenizer::get_token_name(CScriptTokenizer::TK_PR_VAR)) {
|
||||||
in_variable_declaration = true;
|
in_variable_declaration = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -291,7 +291,7 @@ Map<int, TextEdit::HighlighterInfo> GDScriptSyntaxHighlighter::_get_line_syntax_
|
|||||||
} else if (in_function_name) {
|
} else if (in_function_name) {
|
||||||
next_type = FUNCTION;
|
next_type = FUNCTION;
|
||||||
|
|
||||||
if (previous_text == GDScriptTokenizer::get_token_name(GDScriptTokenizer::TK_PR_FUNCTION)) {
|
if (previous_text == CScriptTokenizer::get_token_name(CScriptTokenizer::TK_PR_FUNCTION)) {
|
||||||
color = function_definition_color;
|
color = function_definition_color;
|
||||||
} else {
|
} else {
|
||||||
color = function_color;
|
color = function_color;
|
||||||
@ -344,17 +344,17 @@ Map<int, TextEdit::HighlighterInfo> GDScriptSyntaxHighlighter::_get_line_syntax_
|
|||||||
return color_map;
|
return color_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
String GDScriptSyntaxHighlighter::get_name() const {
|
String CScriptSyntaxHighlighter::get_name() const {
|
||||||
return "GDScript";
|
return "CScript";
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> GDScriptSyntaxHighlighter::get_supported_languages() {
|
List<String> CScriptSyntaxHighlighter::get_supported_languages() {
|
||||||
List<String> languages;
|
List<String> languages;
|
||||||
languages.push_back("GDScript");
|
languages.push_back("CScript");
|
||||||
return languages;
|
return languages;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDScriptSyntaxHighlighter::_update_cache() {
|
void CScriptSyntaxHighlighter::_update_cache() {
|
||||||
font_color = text_editor->get_color("font_color");
|
font_color = text_editor->get_color("font_color");
|
||||||
symbol_color = text_editor->get_color("symbol_color");
|
symbol_color = text_editor->get_color("symbol_color");
|
||||||
function_color = text_editor->get_color("function_color");
|
function_color = text_editor->get_color("function_color");
|
||||||
@ -390,6 +390,6 @@ void GDScriptSyntaxHighlighter::_update_cache() {
|
|||||||
type_color = EDITOR_GET("text_editor/highlighting/base_type_color");
|
type_color = EDITOR_GET("text_editor/highlighting/base_type_color");
|
||||||
}
|
}
|
||||||
|
|
||||||
SyntaxHighlighter *GDScriptSyntaxHighlighter::create() {
|
SyntaxHighlighter *CScriptSyntaxHighlighter::create() {
|
||||||
return memnew(GDScriptSyntaxHighlighter);
|
return memnew(CScriptSyntaxHighlighter);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include "scene/gui/text_edit.h"
|
#include "scene/gui/text_edit.h"
|
||||||
|
|
||||||
class GDScriptSyntaxHighlighter : public SyntaxHighlighter {
|
class CScriptSyntaxHighlighter : public SyntaxHighlighter {
|
||||||
private:
|
private:
|
||||||
enum Type {
|
enum Type {
|
||||||
NONE,
|
NONE,
|
||||||
@ -68,4 +68,4 @@ public:
|
|||||||
virtual List<String> get_supported_languages();
|
virtual List<String> get_supported_languages();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GDSCRIPT_HIGHLIGHTER_H
|
#endif // CSCRIPT_HIGHLIGHTER_H
|
||||||
|
@ -37,19 +37,19 @@
|
|||||||
#include "cscript.h"
|
#include "cscript.h"
|
||||||
#include "cscript_tokenizer.h"
|
#include "cscript_tokenizer.h"
|
||||||
|
|
||||||
GDScriptLanguage *script_language_gd = nullptr;
|
CScriptLanguage *script_language_cscript = nullptr;
|
||||||
Ref<ResourceFormatLoaderGDScript> resource_loader_gd;
|
Ref<ResourceFormatLoaderCScript> resource_loader_cscript;
|
||||||
Ref<ResourceFormatSaverGDScript> resource_saver_gd;
|
Ref<ResourceFormatSaverCScript> resource_saver_cscript;
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
|
|
||||||
|
#include "editor/cscript_highlighter.h"
|
||||||
#include "editor/editor_export.h"
|
#include "editor/editor_export.h"
|
||||||
#include "editor/editor_node.h"
|
#include "editor/editor_node.h"
|
||||||
#include "editor/editor_settings.h"
|
#include "editor/editor_settings.h"
|
||||||
#include "editor/gdscript_highlighter.h"
|
|
||||||
|
|
||||||
class EditorExportGDScript : public EditorExportPlugin {
|
class EditorExportCScript : public EditorExportPlugin {
|
||||||
GDCLASS(EditorExportGDScript, EditorExportPlugin);
|
GDCLASS(EditorExportCScript, EditorExportPlugin);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void _export_file(const String &p_path, const String &p_type, const Set<String> &p_features) {
|
virtual void _export_file(const String &p_path, const String &p_type, const Set<String> &p_features) {
|
||||||
@ -74,7 +74,7 @@ public:
|
|||||||
|
|
||||||
String txt;
|
String txt;
|
||||||
txt.parse_utf8((const char *)file.ptr(), file.size());
|
txt.parse_utf8((const char *)file.ptr(), file.size());
|
||||||
file = GDScriptTokenizerBuffer::parse_code_string(txt);
|
file = CScriptTokenizerBuffer::parse_code_string(txt);
|
||||||
|
|
||||||
if (!file.empty()) {
|
if (!file.empty()) {
|
||||||
if (script_mode == EditorExportPreset::MODE_SCRIPT_ENCRYPTED) {
|
if (script_mode == EditorExportPreset::MODE_SCRIPT_ENCRYPTED) {
|
||||||
@ -129,42 +129,42 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
static void _editor_init() {
|
static void _editor_init() {
|
||||||
Ref<EditorExportGDScript> gd_export;
|
Ref<EditorExportCScript> gd_export;
|
||||||
gd_export.instance();
|
gd_export.instance();
|
||||||
EditorExport::get_singleton()->add_export_plugin(gd_export);
|
EditorExport::get_singleton()->add_export_plugin(gd_export);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TOOLS_ENABLED
|
#endif // TOOLS_ENABLED
|
||||||
|
|
||||||
void register_gdscript_types() {
|
void register_cscript_types() {
|
||||||
ClassDB::register_class<GDScript>();
|
ClassDB::register_class<CScript>();
|
||||||
ClassDB::register_virtual_class<GDScriptFunctionState>();
|
ClassDB::register_virtual_class<CScriptFunctionState>();
|
||||||
|
|
||||||
script_language_gd = memnew(GDScriptLanguage);
|
script_language_cscript = memnew(CScriptLanguage);
|
||||||
ScriptServer::register_language(script_language_gd);
|
ScriptServer::register_language(script_language_cscript);
|
||||||
|
|
||||||
resource_loader_gd.instance();
|
resource_loader_cscript.instance();
|
||||||
ResourceLoader::add_resource_format_loader(resource_loader_gd);
|
ResourceLoader::add_resource_format_loader(resource_loader_cscript);
|
||||||
|
|
||||||
resource_saver_gd.instance();
|
resource_saver_cscript.instance();
|
||||||
ResourceSaver::add_resource_format_saver(resource_saver_gd);
|
ResourceSaver::add_resource_format_saver(resource_saver_cscript);
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
ScriptEditor::register_create_syntax_highlighter_function(GDScriptSyntaxHighlighter::create);
|
ScriptEditor::register_create_syntax_highlighter_function(CScriptSyntaxHighlighter::create);
|
||||||
EditorNode::add_init_callback(_editor_init);
|
EditorNode::add_init_callback(_editor_init);
|
||||||
#endif // TOOLS_ENABLED
|
#endif // TOOLS_ENABLED
|
||||||
}
|
}
|
||||||
|
|
||||||
void unregister_gdscript_types() {
|
void unregister_cscript_types() {
|
||||||
ScriptServer::unregister_language(script_language_gd);
|
ScriptServer::unregister_language(script_language_cscript);
|
||||||
|
|
||||||
if (script_language_gd) {
|
if (script_language_cscript) {
|
||||||
memdelete(script_language_gd);
|
memdelete(script_language_cscript);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceLoader::remove_resource_format_loader(resource_loader_gd);
|
ResourceLoader::remove_resource_format_loader(resource_loader_cscript);
|
||||||
resource_loader_gd.unref();
|
resource_loader_cscript.unref();
|
||||||
|
|
||||||
ResourceSaver::remove_resource_format_saver(resource_saver_gd);
|
ResourceSaver::remove_resource_format_saver(resource_saver_cscript);
|
||||||
resource_saver_gd.unref();
|
resource_saver_cscript.unref();
|
||||||
}
|
}
|
||||||
|
@ -33,4 +33,4 @@
|
|||||||
void register_cscript_types();
|
void register_cscript_types();
|
||||||
void unregister_cscript_types();
|
void unregister_cscript_types();
|
||||||
|
|
||||||
#endif // GDSCRIPT_REGISTER_TYPES_H
|
#endif // CSCRIPT_REGISTER_TYPES_H
|
||||||
|
Loading…
Reference in New Issue
Block a user