/*************************************************************************/ /* gdscript_function.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ /* "Software"), to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of the Software, and to */ /* permit persons to whom the Software is furnished to do so, subject to */ /* the following conditions: */ /* */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the Software. */ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "gdscript_function.h" #include "core/os/os.h" #include "gdscript.h" #include "gdscript_functions.h" Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_instance, GDScript *p_script, Variant &self, Variant *p_stack, String &r_error) const { int address = p_address & ADDR_MASK; //sequential table (jump table generated by compiler) switch ((p_address & ADDR_TYPE_MASK) >> ADDR_BITS) { case ADDR_TYPE_SELF: { #ifdef DEBUG_ENABLED if (unlikely(!p_instance)) { r_error = "Cannot access self without instance."; return NULL; } #endif return &self; } break; case ADDR_TYPE_CLASS: { return &p_script->_static_ref; } break; case ADDR_TYPE_MEMBER: { #ifdef DEBUG_ENABLED if (unlikely(!p_instance)) { r_error = "Cannot access member without instance."; return NULL; } #endif //member indexing is O(1) return &p_instance->members.write[address]; } break; case ADDR_TYPE_CLASS_CONSTANT: { //todo change to index! GDScript *o = p_script; #ifdef DEBUG_ENABLED ERR_FAIL_INDEX_V(address, _global_names_count, NULL); #endif const StringName *sn = &_global_names_ptr[address]; while (o) { GDScript *s = o; while (s) { Map::Element *E = s->constants.find(*sn); if (E) { return &E->get(); } s = s->_base; } o = o->_owner; } ERR_FAIL_V_MSG(NULL, "GDScriptCompiler bug."); } break; case ADDR_TYPE_LOCAL_CONSTANT: { #ifdef DEBUG_ENABLED ERR_FAIL_INDEX_V(address, _constant_count, NULL); #endif return &_constants_ptr[address]; } break; case ADDR_TYPE_STACK: case ADDR_TYPE_STACK_VARIABLE: { #ifdef DEBUG_ENABLED ERR_FAIL_INDEX_V(address, _stack_size, NULL); #endif return &p_stack[address]; } break; case ADDR_TYPE_GLOBAL: { #ifdef DEBUG_ENABLED ERR_FAIL_INDEX_V(address, GDScriptLanguage::get_singleton()->get_global_array_size(), NULL); #endif return &GDScriptLanguage::get_singleton()->get_global_array()[address]; } break; #ifdef TOOLS_ENABLED case ADDR_TYPE_NAMED_GLOBAL: { #ifdef DEBUG_ENABLED ERR_FAIL_INDEX_V(address, _named_globals_count, NULL); #endif StringName id = _named_globals_ptr[address]; if (GDScriptLanguage::get_singleton()->get_named_globals_map().has(id)) { return (Variant *)&GDScriptLanguage::get_singleton()->get_named_globals_map()[id]; } else { r_error = "Autoload singleton '" + String(id) + "' has been removed."; return NULL; } } break; #endif case ADDR_TYPE_NIL: { return &nil; } break; } ERR_FAIL_V_MSG(NULL, "Bad code! (unknown addressing mode)."); return NULL; } #ifdef DEBUG_ENABLED static String _get_var_type(const Variant *p_var) { String basestr; if (p_var->get_type() == Variant::OBJECT) { Object *bobj = *p_var; if (!bobj) { basestr = "null instance"; } else { if (ObjectDB::instance_validate(bobj)) { if (bobj->get_script_instance()) basestr = bobj->get_class() + " (" + bobj->get_script_instance()->get_script()->get_path().get_file() + ")"; else basestr = bobj->get_class(); } else { basestr = "previously freed instance"; } } } else { basestr = Variant::get_type_name(p_var->get_type()); } return basestr; } #endif // DEBUG_ENABLED String GDScriptFunction::_get_call_error(const Variant::CallError &p_err, const String &p_where, const Variant **argptrs) const { String err_text; if (p_err.error == Variant::CallError::CALL_ERROR_INVALID_ARGUMENT) { int errorarg = p_err.argument; // Handle the Object to Object case separately as we don't have further class details. #ifdef DEBUG_ENABLED if (p_err.expected == Variant::OBJECT && argptrs[errorarg]->get_type() == p_err.expected) { err_text = "Invalid type in " + p_where + ". The Object-derived class of argument " + itos(errorarg + 1) + " (" + _get_var_type(argptrs[errorarg]) + ") is not a subclass of the expected argument class."; } else #endif // DEBUG_ENABLED { err_text = "Invalid type in " + p_where + ". Cannot convert argument " + itos(errorarg + 1) + " from " + Variant::get_type_name(argptrs[errorarg]->get_type()) + " to " + Variant::get_type_name(p_err.expected) + "."; } } else if (p_err.error == Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS) { err_text = "Invalid call to " + p_where + ". Expected " + itos(p_err.argument) + " arguments."; } else if (p_err.error == Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS) { err_text = "Invalid call to " + p_where + ". Expected " + itos(p_err.argument) + " arguments."; } else if (p_err.error == Variant::CallError::CALL_ERROR_INVALID_METHOD) { err_text = "Invalid call. Nonexistent " + p_where + "."; } else if (p_err.error == Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL) { err_text = "Attempt to call " + p_where + " on a null instance."; } else { err_text = "Bug, call error: #" + itos(p_err.error); } return err_text; } #if defined(__GNUC__) #define OPCODES_TABLE \ static const void *switch_table_ops[] = { \ &&OPCODE_OPERATOR, \ &&OPCODE_EXTENDS_TEST, \ &&OPCODE_IS_BUILTIN, \ &&OPCODE_SET, \ &&OPCODE_GET, \ &&OPCODE_SET_NAMED, \ &&OPCODE_GET_NAMED, \ &&OPCODE_SET_MEMBER, \ &&OPCODE_GET_MEMBER, \ &&OPCODE_ASSIGN, \ &&OPCODE_ASSIGN_TRUE, \ &&OPCODE_ASSIGN_FALSE, \ &&OPCODE_ASSIGN_TYPED_BUILTIN, \ &&OPCODE_ASSIGN_TYPED_NATIVE, \ &&OPCODE_ASSIGN_TYPED_SCRIPT, \ &&OPCODE_CAST_TO_BUILTIN, \ &&OPCODE_CAST_TO_NATIVE, \ &&OPCODE_CAST_TO_SCRIPT, \ &&OPCODE_CONSTRUCT, \ &&OPCODE_CONSTRUCT_ARRAY, \ &&OPCODE_CONSTRUCT_DICTIONARY, \ &&OPCODE_CALL, \ &&OPCODE_CALL_RETURN, \ &&OPCODE_CALL_BUILT_IN, \ &&OPCODE_CALL_SELF, \ &&OPCODE_CALL_SELF_BASE, \ &&OPCODE_YIELD, \ &&OPCODE_YIELD_SIGNAL, \ &&OPCODE_YIELD_RESUME, \ &&OPCODE_JUMP, \ &&OPCODE_JUMP_IF, \ &&OPCODE_JUMP_IF_NOT, \ &&OPCODE_JUMP_TO_DEF_ARGUMENT, \ &&OPCODE_RETURN, \ &&OPCODE_ITERATE_BEGIN, \ &&OPCODE_ITERATE, \ &&OPCODE_ASSERT, \ &&OPCODE_BREAKPOINT, \ &&OPCODE_LINE, \ &&OPCODE_END \ }; #define OPCODE(m_op) \ m_op: #define OPCODE_WHILE(m_test) #define OPCODES_END \ OPSEXIT: #define OPCODES_OUT \ OPSOUT: #define DISPATCH_OPCODE goto *switch_table_ops[_code_ptr[ip]] #define OPCODE_SWITCH(m_test) DISPATCH_OPCODE; #define OPCODE_BREAK goto OPSEXIT #define OPCODE_OUT goto OPSOUT #else #define OPCODES_TABLE #define OPCODE(m_op) case m_op: #define OPCODE_WHILE(m_test) while (m_test) #define OPCODES_END #define OPCODES_OUT #define DISPATCH_OPCODE continue #define OPCODE_SWITCH(m_test) switch (m_test) #define OPCODE_BREAK break #define OPCODE_OUT break #endif Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state) { OPCODES_TABLE; if (!_code_ptr) { return Variant(); } r_err.error = Variant::CallError::CALL_OK; Variant self; Variant retvalue; Variant *stack = NULL; Variant **call_args; int defarg = 0; #ifdef DEBUG_ENABLED //GDScriptLanguage::get_singleton()->calls++; #endif uint32_t alloca_size = 0; GDScript *script; int ip = 0; int line = _initial_line; if (p_state) { //use existing (supplied) state (yielded) stack = (Variant *)p_state->stack.ptr(); call_args = (Variant **)&p_state->stack.ptr()[sizeof(Variant) * p_state->stack_size]; //ptr() to avoid bounds check line = p_state->line; ip = p_state->ip; alloca_size = p_state->stack.size(); script = p_state->script.ptr(); p_instance = p_state->instance; defarg = p_state->defarg; self = p_state->self; //stack[p_state->result_pos]=p_state->result; //assign stack with result } else { if (p_argcount != _argument_count) { if (p_argcount > _argument_count) { r_err.error = Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS; r_err.argument = _argument_count; return Variant(); } else if (p_argcount < _argument_count - _default_arg_count) { r_err.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; r_err.argument = _argument_count - _default_arg_count; return Variant(); } else { defarg = _argument_count - p_argcount; } } alloca_size = sizeof(Variant *) * _call_size + sizeof(Variant) * _stack_size; if (alloca_size) { uint8_t *aptr = (uint8_t *)alloca(alloca_size); if (_stack_size) { stack = (Variant *)aptr; for (int i = 0; i < p_argcount; i++) { if (!argument_types[i].has_type) { memnew_placement(&stack[i], Variant(*p_args[i])); continue; } if (!argument_types[i].is_type(*p_args[i], true)) { if (argument_types[i].is_type(Variant(), true)) { memnew_placement(&stack[i], Variant); continue; } else { r_err.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; r_err.argument = i; r_err.expected = argument_types[i].kind == GDScriptDataType::BUILTIN ? argument_types[i].builtin_type : Variant::OBJECT; return Variant(); } } if (argument_types[i].kind == GDScriptDataType::BUILTIN) { Variant arg = Variant::construct(argument_types[i].builtin_type, &p_args[i], 1, r_err); memnew_placement(&stack[i], Variant(arg)); } else { memnew_placement(&stack[i], Variant(*p_args[i])); } } for (int i = p_argcount; i < _stack_size; i++) { memnew_placement(&stack[i], Variant); } } else { stack = NULL; } if (_call_size) { call_args = (Variant **)&aptr[sizeof(Variant) * _stack_size]; } else { call_args = NULL; } } else { stack = NULL; call_args = NULL; } if (p_instance) { if (p_instance->base_ref && static_cast(p_instance->owner)->is_referenced()) { self = REF(static_cast(p_instance->owner)); } else { self = p_instance->owner; } script = p_instance->script.ptr(); } else { script = _script; } } String err_text; #ifdef DEBUG_ENABLED if (ScriptDebugger::get_singleton()) GDScriptLanguage::get_singleton()->enter_function(p_instance, this, stack, &ip, &line); #define GD_ERR_BREAK(m_cond) \ { \ if (unlikely(m_cond)) { \ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition ' " _STR(m_cond) " ' is true. Breaking..:"); \ OPCODE_BREAK; \ } \ } #define CHECK_SPACE(m_space) \ GD_ERR_BREAK((ip + m_space) > _code_size) #define GET_VARIANT_PTR(m_v, m_code_ofs) \ Variant *m_v; \ m_v = _get_variant(_code_ptr[ip + m_code_ofs], p_instance, script, self, stack, err_text); \ if (unlikely(!m_v)) \ OPCODE_BREAK; #else #define GD_ERR_BREAK(m_cond) #define CHECK_SPACE(m_space) #define GET_VARIANT_PTR(m_v, m_code_ofs) \ Variant *m_v; \ m_v = _get_variant(_code_ptr[ip + m_code_ofs], p_instance, script, self, stack, err_text); #endif #ifdef DEBUG_ENABLED uint64_t function_start_time = 0; uint64_t function_call_time = 0; if (GDScriptLanguage::get_singleton()->profiling) { function_start_time = OS::get_singleton()->get_ticks_usec(); function_call_time = 0; profile.call_count++; profile.frame_call_count++; } bool exit_ok = false; bool yielded = false; #endif #ifdef DEBUG_ENABLED OPCODE_WHILE(ip < _code_size) { int last_opcode = _code_ptr[ip]; #else OPCODE_WHILE(true) { #endif OPCODE_SWITCH(_code_ptr[ip]) { OPCODE(OPCODE_OPERATOR) { CHECK_SPACE(5); bool valid; Variant::Operator op = (Variant::Operator)_code_ptr[ip + 1]; GD_ERR_BREAK(op >= Variant::OP_MAX); GET_VARIANT_PTR(a, 2); GET_VARIANT_PTR(b, 3); GET_VARIANT_PTR(dst, 4); #ifdef DEBUG_ENABLED Variant ret; Variant::evaluate(op, *a, *b, ret, valid); #else Variant::evaluate(op, *a, *b, *dst, valid); #endif #ifdef DEBUG_ENABLED if (!valid) { if (ret.get_type() == Variant::STRING) { //return a string when invalid with the error err_text = ret; err_text += " in operator '" + Variant::get_operator_name(op) + "'."; } else { err_text = "Invalid operands '" + Variant::get_type_name(a->get_type()) + "' and '" + Variant::get_type_name(b->get_type()) + "' in operator '" + Variant::get_operator_name(op) + "'."; } OPCODE_BREAK; } *dst = ret; #endif ip += 5; } DISPATCH_OPCODE; OPCODE(OPCODE_EXTENDS_TEST) { CHECK_SPACE(4); GET_VARIANT_PTR(a, 1); GET_VARIANT_PTR(b, 2); GET_VARIANT_PTR(dst, 3); #ifdef DEBUG_ENABLED if (b->get_type() != Variant::OBJECT || b->operator Object *() == NULL) { err_text = "Right operand of 'is' is not a class."; OPCODE_BREAK; } #endif bool extends_ok = false; if (a->get_type() == Variant::OBJECT && a->operator Object *() != NULL) { Object *obj_A = *a; Object *obj_B = *b; #ifdef DEBUG_ENABLED if (!ObjectDB::instance_validate(obj_A)) { err_text = "Left operand of 'is' was already freed."; OPCODE_BREAK; } #endif // DEBUG_ENABLED GDScript *scr_B = Object::cast_to(obj_B); if (scr_B) { //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. if (obj_A->get_script_instance() && obj_A->get_script_instance()->get_language() == GDScriptLanguage::get_singleton()) { GDScript *cmp = static_cast(obj_A->get_script_instance()->get_script().ptr()); //bool found=false; while (cmp) { if (cmp == scr_B) { //inherits from script, all ok extends_ok = true; break; } cmp = cmp->_base; } } } else { GDScriptNativeClass *nc = Object::cast_to(obj_B); #ifdef DEBUG_ENABLED if (!nc) { err_text = "Right operand of 'is' is not a class (type: '" + obj_B->get_class() + "')."; OPCODE_BREAK; } #endif extends_ok = ClassDB::is_parent_class(obj_A->get_class_name(), nc->get_name()); } } *dst = extends_ok; ip += 4; } 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); GET_VARIANT_PTR(dst, 1); GET_VARIANT_PTR(index, 2); GET_VARIANT_PTR(value, 3); bool valid; dst->set(*index, *value, &valid); #ifdef DEBUG_ENABLED if (!valid) { String v = index->operator String(); if (v != "") { v = "'" + v + "'"; } else { v = "of type '" + _get_var_type(index) + "'"; } err_text = "Invalid set index " + v + " (on base: '" + _get_var_type(dst) + "') with value of type '" + _get_var_type(value) + "'"; OPCODE_BREAK; } #endif ip += 4; } DISPATCH_OPCODE; OPCODE(OPCODE_GET) { CHECK_SPACE(3); GET_VARIANT_PTR(src, 1); GET_VARIANT_PTR(index, 2); GET_VARIANT_PTR(dst, 3); bool valid; #ifdef DEBUG_ENABLED //allow better error message in cases where src and dst are the same stack position Variant ret = src->get(*index, &valid); #else *dst = src->get(*index, &valid); #endif #ifdef DEBUG_ENABLED if (!valid) { String v = index->operator String(); if (v != "") { v = "'" + v + "'"; } else { v = "of type '" + _get_var_type(index) + "'"; } err_text = "Invalid get index " + v + " (on base: '" + _get_var_type(src) + "')."; OPCODE_BREAK; } *dst = ret; #endif ip += 4; } DISPATCH_OPCODE; OPCODE(OPCODE_SET_NAMED) { CHECK_SPACE(3); GET_VARIANT_PTR(dst, 1); GET_VARIANT_PTR(value, 3); int indexname = _code_ptr[ip + 2]; GD_ERR_BREAK(indexname < 0 || indexname >= _global_names_count); const StringName *index = &_global_names_ptr[indexname]; bool valid; dst->set_named(*index, *value, &valid); #ifdef DEBUG_ENABLED if (!valid) { String err_type; err_text = "Invalid set index '" + String(*index) + "' (on base: '" + _get_var_type(dst) + "') with value of type '" + _get_var_type(value) + "'."; OPCODE_BREAK; } #endif ip += 4; } DISPATCH_OPCODE; OPCODE(OPCODE_GET_NAMED) { CHECK_SPACE(4); GET_VARIANT_PTR(src, 1); GET_VARIANT_PTR(dst, 3); int indexname = _code_ptr[ip + 2]; GD_ERR_BREAK(indexname < 0 || indexname >= _global_names_count); const StringName *index = &_global_names_ptr[indexname]; bool valid; #ifdef DEBUG_ENABLED //allow better error message in cases where src and dst are the same stack position Variant ret = src->get_named(*index, &valid); #else *dst = src->get_named(*index, &valid); #endif #ifdef DEBUG_ENABLED if (!valid) { if (src->has_method(*index)) { err_text = "Invalid get index '" + index->operator String() + "' (on base: '" + _get_var_type(src) + "'). Did you mean '." + index->operator String() + "()' or funcref(obj, \"" + index->operator String() + "\") ?"; } else { err_text = "Invalid get index '" + index->operator String() + "' (on base: '" + _get_var_type(src) + "')."; } OPCODE_BREAK; } *dst = ret; #endif ip += 4; } DISPATCH_OPCODE; OPCODE(OPCODE_SET_MEMBER) { CHECK_SPACE(3); int indexname = _code_ptr[ip + 1]; GD_ERR_BREAK(indexname < 0 || indexname >= _global_names_count); const StringName *index = &_global_names_ptr[indexname]; GET_VARIANT_PTR(src, 2); bool valid; #ifndef DEBUG_ENABLED ClassDB::set_property(p_instance->owner, *index, *src, &valid); #else bool ok = ClassDB::set_property(p_instance->owner, *index, *src, &valid); if (!ok) { err_text = "Internal error setting property: " + String(*index); OPCODE_BREAK; } else if (!valid) { err_text = "Error setting property '" + String(*index) + "' with value of type " + Variant::get_type_name(src->get_type()) + "."; OPCODE_BREAK; } #endif ip += 3; } DISPATCH_OPCODE; OPCODE(OPCODE_GET_MEMBER) { CHECK_SPACE(3); int indexname = _code_ptr[ip + 1]; GD_ERR_BREAK(indexname < 0 || indexname >= _global_names_count); const StringName *index = &_global_names_ptr[indexname]; GET_VARIANT_PTR(dst, 2); #ifndef DEBUG_ENABLED ClassDB::get_property(p_instance->owner, *index, *dst); #else bool ok = ClassDB::get_property(p_instance->owner, *index, *dst); if (!ok) { err_text = "Internal error getting property: " + String(*index); OPCODE_BREAK; } #endif ip += 3; } DISPATCH_OPCODE; OPCODE(OPCODE_ASSIGN) { CHECK_SPACE(3); GET_VARIANT_PTR(dst, 1); GET_VARIANT_PTR(src, 2); *dst = *src; ip += 3; } DISPATCH_OPCODE; OPCODE(OPCODE_ASSIGN_TRUE) { CHECK_SPACE(2); GET_VARIANT_PTR(dst, 1); *dst = true; ip += 2; } DISPATCH_OPCODE; OPCODE(OPCODE_ASSIGN_FALSE) { CHECK_SPACE(2); GET_VARIANT_PTR(dst, 1); *dst = false; ip += 2; } DISPATCH_OPCODE; OPCODE(OPCODE_ASSIGN_TYPED_BUILTIN) { CHECK_SPACE(4); GET_VARIANT_PTR(dst, 2); GET_VARIANT_PTR(src, 3); Variant::Type var_type = (Variant::Type)_code_ptr[ip + 1]; GD_ERR_BREAK(var_type < 0 || var_type >= Variant::VARIANT_MAX); if (src->get_type() != var_type) { #ifdef DEBUG_ENABLED if (Variant::can_convert_strict(src->get_type(), var_type)) { #endif // DEBUG_ENABLED Variant::CallError ce; *dst = Variant::construct(var_type, const_cast(&src), 1, ce); } else { #ifdef DEBUG_ENABLED err_text = "Trying to assign value of type '" + Variant::get_type_name(src->get_type()) + "' to a variable of type '" + Variant::get_type_name(var_type) + "'."; OPCODE_BREAK; } } else { #endif // DEBUG_ENABLED *dst = *src; } ip += 4; } DISPATCH_OPCODE; OPCODE(OPCODE_ASSIGN_TYPED_NATIVE) { CHECK_SPACE(4); GET_VARIANT_PTR(dst, 2); GET_VARIANT_PTR(src, 3); #ifdef DEBUG_ENABLED GET_VARIANT_PTR(type, 1); GDScriptNativeClass *nc = Object::cast_to(type->operator Object *()); GD_ERR_BREAK(!nc); 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()) + "' to a variable of type '" + nc->get_name() + "'."; OPCODE_BREAK; } Object *src_obj = src->operator Object *(); if (src_obj && !ClassDB::is_parent_class(src_obj->get_class_name(), nc->get_name())) { err_text = "Trying to assign value of type '" + src_obj->get_class_name() + "' to a variable of type '" + nc->get_name() + "'."; OPCODE_BREAK; } #endif // DEBUG_ENABLED *dst = *src; ip += 4; } DISPATCH_OPCODE; OPCODE(OPCODE_ASSIGN_TYPED_SCRIPT) { CHECK_SPACE(4); GET_VARIANT_PTR(dst, 2); GET_VARIANT_PTR(src, 3); #ifdef DEBUG_ENABLED GET_VARIANT_PTR(type, 1); Script *base_type = Object::cast_to