summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/gdscript_function.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2018-08-27 17:48:11 +0200
committerGitHub <noreply@github.com>2018-08-27 17:48:11 +0200
commitf06b7d40c87e6a2435cdfcad6bb620184f16ea42 (patch)
tree89908d9986b9e54525fc2fedb3347aedc1036f8b /modules/gdscript/gdscript_function.cpp
parent5b87864385fb702cf759df588120421bf0bacd68 (diff)
parent4b974a36b77da55d331243bf42fa7ddc8fd9a33d (diff)
downloadredot-engine-f06b7d40c87e6a2435cdfcad6bb620184f16ea42.tar.gz
Merge pull request #21449 from vnen/gdscript-builtin-is
Allow `is` operator to test built-in types
Diffstat (limited to 'modules/gdscript/gdscript_function.cpp')
-rw-r--r--modules/gdscript/gdscript_function.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp
index bae3f48923..d615b58b24 100644
--- a/modules/gdscript/gdscript_function.cpp
+++ b/modules/gdscript/gdscript_function.cpp
@@ -191,6 +191,7 @@ static String _get_var_type(const Variant *p_type) {
static const void *switch_table_ops[] = { \
&&OPCODE_OPERATOR, \
&&OPCODE_EXTENDS_TEST, \
+ &&OPCODE_IS_BUILTIN, \
&&OPCODE_SET, \
&&OPCODE_GET, \
&&OPCODE_SET_NAMED, \
@@ -536,6 +537,21 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
}
DISPATCH_OPCODE;
+ OPCODE(OPCODE_IS_BUILTIN) {
+
+ CHECK_SPACE(4);
+
+ GET_VARIANT_PTR(value, 1);
+ Variant::Type var_type = (Variant::Type)_code_ptr[ip + 2];
+ GET_VARIANT_PTR(dst, 3);
+
+ GD_ERR_BREAK(var_type < 0 || var_type >= Variant::VARIANT_MAX);
+
+ *dst = value->get_type() == var_type;
+ ip += 4;
+ }
+ DISPATCH_OPCODE;
+
OPCODE(OPCODE_SET) {
CHECK_SPACE(3);