mirror of
https://github.com/godotengine/godot.git
synced 2025-10-22 17:33:33 +00:00
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
This commit is contained in:
parent
64a63e0861
commit
b5e1e05ef2
1439 changed files with 1 additions and 34187 deletions
|
@ -35,12 +35,10 @@
|
|||
#include "gdscript_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 {
|
||||
|
||||
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)) {
|
||||
|
@ -51,7 +49,6 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta
|
|||
return &self;
|
||||
} break;
|
||||
case ADDR_TYPE_CLASS: {
|
||||
|
||||
return &static_ref;
|
||||
} break;
|
||||
case ADDR_TYPE_MEMBER: {
|
||||
|
@ -65,7 +62,6 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta
|
|||
return &p_instance->members.write[address];
|
||||
} break;
|
||||
case ADDR_TYPE_CLASS_CONSTANT: {
|
||||
|
||||
//todo change to index!
|
||||
GDScript *s = p_script;
|
||||
#ifdef DEBUG_ENABLED
|
||||
|
@ -76,7 +72,6 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta
|
|||
while (s) {
|
||||
GDScript *o = s;
|
||||
while (o) {
|
||||
|
||||
Map<StringName, Variant>::Element *E = o->constants.find(*sn);
|
||||
if (E) {
|
||||
return &E->get();
|
||||
|
@ -133,7 +128,6 @@ Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_insta
|
|||
|
||||
#ifdef DEBUG_ENABLED
|
||||
static String _get_var_type(const Variant *p_var) {
|
||||
|
||||
String basestr;
|
||||
|
||||
if (p_var->get_type() == Variant::OBJECT) {
|
||||
|
@ -160,7 +154,6 @@ static String _get_var_type(const Variant *p_var) {
|
|||
#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) {
|
||||
|
@ -258,11 +251,9 @@ String GDScriptFunction::_get_call_error(const Variant::CallError &p_err, const
|
|||
#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();
|
||||
}
|
||||
|
||||
|
@ -300,22 +291,17 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
//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;
|
||||
}
|
||||
}
|
||||
|
@ -323,11 +309,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
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) {
|
||||
|
@ -361,10 +345,8 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
}
|
||||
|
||||
if (_call_size) {
|
||||
|
||||
call_args = (Variant **)&aptr[sizeof(Variant) * _stack_size];
|
||||
} else {
|
||||
|
||||
call_args = NULL;
|
||||
}
|
||||
|
||||
|
@ -439,9 +421,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
#endif
|
||||
|
||||
OPCODE_SWITCH(_code_ptr[ip]) {
|
||||
|
||||
OPCODE(OPCODE_OPERATOR) {
|
||||
|
||||
CHECK_SPACE(5);
|
||||
|
||||
bool valid;
|
||||
|
@ -461,7 +441,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
#endif
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (!valid) {
|
||||
|
||||
if (ret.get_type() == Variant::STRING) {
|
||||
//return a string when invalid with the error
|
||||
err_text = ret;
|
||||
|
@ -478,7 +457,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_EXTENDS_TEST) {
|
||||
|
||||
CHECK_SPACE(4);
|
||||
|
||||
GET_VARIANT_PTR(a, 1);
|
||||
|
@ -487,7 +465,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
|
||||
#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;
|
||||
}
|
||||
|
@ -512,11 +489,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
//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<GDScript *>(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;
|
||||
|
@ -528,12 +503,10 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
}
|
||||
|
||||
} else {
|
||||
|
||||
GDScriptNativeClass *nc = Object::cast_to<GDScriptNativeClass>(obj_B);
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (!nc) {
|
||||
|
||||
err_text = "Right operand of 'is' is not a class (type: '" + obj_B->get_class() + "').";
|
||||
OPCODE_BREAK;
|
||||
}
|
||||
|
@ -548,7 +521,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_IS_BUILTIN) {
|
||||
|
||||
CHECK_SPACE(4);
|
||||
|
||||
GET_VARIANT_PTR(value, 1);
|
||||
|
@ -563,7 +535,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_SET) {
|
||||
|
||||
CHECK_SPACE(3);
|
||||
|
||||
GET_VARIANT_PTR(dst, 1);
|
||||
|
@ -590,7 +561,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_GET) {
|
||||
|
||||
CHECK_SPACE(3);
|
||||
|
||||
GET_VARIANT_PTR(src, 1);
|
||||
|
@ -623,7 +593,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_SET_NAMED) {
|
||||
|
||||
CHECK_SPACE(3);
|
||||
|
||||
GET_VARIANT_PTR(dst, 1);
|
||||
|
@ -649,7 +618,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_GET_NAMED) {
|
||||
|
||||
CHECK_SPACE(4);
|
||||
|
||||
GET_VARIANT_PTR(src, 1);
|
||||
|
@ -684,7 +652,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_SET_MEMBER) {
|
||||
|
||||
CHECK_SPACE(3);
|
||||
int indexname = _code_ptr[ip + 1];
|
||||
GD_ERR_BREAK(indexname < 0 || indexname >= _global_names_count);
|
||||
|
@ -709,7 +676,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_GET_MEMBER) {
|
||||
|
||||
CHECK_SPACE(3);
|
||||
int indexname = _code_ptr[ip + 1];
|
||||
GD_ERR_BREAK(indexname < 0 || indexname >= _global_names_count);
|
||||
|
@ -730,7 +696,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_ASSIGN) {
|
||||
|
||||
CHECK_SPACE(3);
|
||||
GET_VARIANT_PTR(dst, 1);
|
||||
GET_VARIANT_PTR(src, 2);
|
||||
|
@ -742,7 +707,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_ASSIGN_TRUE) {
|
||||
|
||||
CHECK_SPACE(2);
|
||||
GET_VARIANT_PTR(dst, 1);
|
||||
|
||||
|
@ -753,7 +717,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_ASSIGN_FALSE) {
|
||||
|
||||
CHECK_SPACE(2);
|
||||
GET_VARIANT_PTR(dst, 1);
|
||||
|
||||
|
@ -764,7 +727,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_ASSIGN_TYPED_BUILTIN) {
|
||||
|
||||
CHECK_SPACE(4);
|
||||
GET_VARIANT_PTR(dst, 2);
|
||||
GET_VARIANT_PTR(src, 3);
|
||||
|
@ -794,7 +756,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_ASSIGN_TYPED_NATIVE) {
|
||||
|
||||
CHECK_SPACE(4);
|
||||
GET_VARIANT_PTR(dst, 2);
|
||||
GET_VARIANT_PTR(src, 3);
|
||||
|
@ -823,7 +784,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_ASSIGN_TYPED_SCRIPT) {
|
||||
|
||||
CHECK_SPACE(4);
|
||||
GET_VARIANT_PTR(dst, 2);
|
||||
GET_VARIANT_PTR(src, 3);
|
||||
|
@ -840,7 +800,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
}
|
||||
|
||||
if (src->get_type() != Variant::NIL && src->operator Object *() != NULL) {
|
||||
|
||||
ScriptInstance *scr_inst = src->operator Object *()->get_script_instance();
|
||||
if (!scr_inst) {
|
||||
err_text = "Trying to assign value of type '" + src->operator Object *()->get_class_name() +
|
||||
|
@ -874,7 +833,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_CAST_TO_BUILTIN) {
|
||||
|
||||
CHECK_SPACE(4);
|
||||
Variant::Type to_type = (Variant::Type)_code_ptr[ip + 1];
|
||||
GET_VARIANT_PTR(src, 2);
|
||||
|
@ -897,7 +855,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_CAST_TO_NATIVE) {
|
||||
|
||||
CHECK_SPACE(4);
|
||||
GET_VARIANT_PTR(to_type, 1);
|
||||
GET_VARIANT_PTR(src, 2);
|
||||
|
@ -925,7 +882,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_CAST_TO_SCRIPT) {
|
||||
|
||||
CHECK_SPACE(4);
|
||||
GET_VARIANT_PTR(to_type, 1);
|
||||
GET_VARIANT_PTR(src, 2);
|
||||
|
@ -945,11 +901,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
bool valid = false;
|
||||
|
||||
if (src->get_type() != Variant::NIL && src->operator Object *() != NULL) {
|
||||
|
||||
ScriptInstance *scr_inst = src->operator Object *()->get_script_instance();
|
||||
|
||||
if (scr_inst) {
|
||||
|
||||
Script *src_type = src->operator Object *()->get_script_instance()->get_script().ptr();
|
||||
|
||||
while (src_type) {
|
||||
|
@ -973,7 +927,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_CONSTRUCT) {
|
||||
|
||||
CHECK_SPACE(2);
|
||||
Variant::Type t = Variant::Type(_code_ptr[ip + 1]);
|
||||
int argc = _code_ptr[ip + 2];
|
||||
|
@ -990,7 +943,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (err.error != Variant::CallError::CALL_OK) {
|
||||
|
||||
err_text = _get_call_error(err, "'" + Variant::get_type_name(t) + "' constructor", (const Variant **)argptrs);
|
||||
OPCODE_BREAK;
|
||||
}
|
||||
|
@ -1002,7 +954,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_CONSTRUCT_ARRAY) {
|
||||
|
||||
CHECK_SPACE(1);
|
||||
int argc = _code_ptr[ip + 1];
|
||||
Array array; //arrays are always shared
|
||||
|
@ -1023,7 +974,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_CONSTRUCT_DICTIONARY) {
|
||||
|
||||
CHECK_SPACE(1);
|
||||
int argc = _code_ptr[ip + 1];
|
||||
Dictionary dict; //arrays are always shared
|
||||
|
@ -1031,7 +981,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
CHECK_SPACE(argc * 2 + 2);
|
||||
|
||||
for (int i = 0; i < argc; i++) {
|
||||
|
||||
GET_VARIANT_PTR(k, 2 + i * 2 + 0);
|
||||
GET_VARIANT_PTR(v, 2 + i * 2 + 1);
|
||||
dict[*k] = *v;
|
||||
|
@ -1047,7 +996,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
|
||||
OPCODE(OPCODE_CALL_RETURN)
|
||||
OPCODE(OPCODE_CALL) {
|
||||
|
||||
CHECK_SPACE(4);
|
||||
bool call_ret = _code_ptr[ip] == OPCODE_CALL_RETURN;
|
||||
|
||||
|
@ -1078,11 +1026,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
#endif
|
||||
Variant::CallError err;
|
||||
if (call_ret) {
|
||||
|
||||
GET_VARIANT_PTR(ret, argc);
|
||||
base->call_ptr(*methodname, (const Variant **)argptrs, argc, ret, err);
|
||||
} else {
|
||||
|
||||
base->call_ptr(*methodname, (const Variant **)argptrs, argc, NULL, err);
|
||||
}
|
||||
#ifdef DEBUG_ENABLED
|
||||
|
@ -1091,7 +1037,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
}
|
||||
|
||||
if (err.error != Variant::CallError::CALL_OK) {
|
||||
|
||||
String methodstr = *methodname;
|
||||
String basestr = _get_var_type(base);
|
||||
|
||||
|
@ -1103,14 +1048,11 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
}
|
||||
}
|
||||
} else if (methodstr == "free") {
|
||||
|
||||
if (err.error == Variant::CallError::CALL_ERROR_INVALID_METHOD) {
|
||||
|
||||
if (base->is_ref()) {
|
||||
err_text = "Attempted to free a reference.";
|
||||
OPCODE_BREAK;
|
||||
} else if (base->get_type() == Variant::OBJECT) {
|
||||
|
||||
err_text = "Attempted to free a locked object (calling or emitting).";
|
||||
OPCODE_BREAK;
|
||||
}
|
||||
|
@ -1134,7 +1076,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_CALL_BUILT_IN) {
|
||||
|
||||
CHECK_SPACE(4);
|
||||
|
||||
GDScriptFunctions::Function func = GDScriptFunctions::Function(_code_ptr[ip + 1]);
|
||||
|
@ -1158,7 +1099,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (err.error != Variant::CallError::CALL_OK) {
|
||||
|
||||
String methodstr = GDScriptFunctions::get_func_name(func);
|
||||
if (dst->get_type() == Variant::STRING) {
|
||||
//call provided error string
|
||||
|
@ -1174,18 +1114,15 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_CALL_SELF) {
|
||||
|
||||
OPCODE_BREAK;
|
||||
}
|
||||
|
||||
OPCODE(OPCODE_CALL_SELF_BASE) {
|
||||
|
||||
CHECK_SPACE(2);
|
||||
int self_fun = _code_ptr[ip + 1];
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (self_fun < 0 || self_fun >= _global_names_count) {
|
||||
|
||||
err_text = "compiler bug, function name not found";
|
||||
OPCODE_BREAK;
|
||||
}
|
||||
|
@ -1218,12 +1155,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
Variant::CallError err;
|
||||
|
||||
if (E) {
|
||||
|
||||
*dst = E->get()->call(p_instance, (const Variant **)argptrs, argc, err);
|
||||
} else if (gds->native.ptr()) {
|
||||
|
||||
if (*methodname != GDScriptLanguage::get_singleton()->strings._init) {
|
||||
|
||||
MethodBind *mb = ClassDB::get_method(gds->native->get_name(), *methodname);
|
||||
if (!mb) {
|
||||
err.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
|
@ -1234,7 +1168,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
err.error = Variant::CallError::CALL_OK;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (*methodname != GDScriptLanguage::get_singleton()->strings._init) {
|
||||
err.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
|
||||
} else {
|
||||
|
@ -1243,7 +1176,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
}
|
||||
|
||||
if (err.error != Variant::CallError::CALL_OK) {
|
||||
|
||||
String methodstr = *methodname;
|
||||
err_text = _get_call_error(err, "function '" + methodstr + "'", (const Variant **)argptrs);
|
||||
|
||||
|
@ -1256,7 +1188,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
|
||||
OPCODE(OPCODE_YIELD)
|
||||
OPCODE(OPCODE_YIELD_SIGNAL) {
|
||||
|
||||
int ipofs = 1;
|
||||
if (_code_ptr[ip] == OPCODE_YIELD_SIGNAL) {
|
||||
CHECK_SPACE(4);
|
||||
|
@ -1330,7 +1261,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
}
|
||||
}
|
||||
if (signal.length() == 0) {
|
||||
|
||||
err_text = "Second argument of yield() is an empty string (for signal name).";
|
||||
OPCODE_BREAK;
|
||||
}
|
||||
|
@ -1353,7 +1283,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
}
|
||||
|
||||
OPCODE(OPCODE_YIELD_RESUME) {
|
||||
|
||||
CHECK_SPACE(2);
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (!p_state) {
|
||||
|
@ -1368,7 +1297,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_JUMP) {
|
||||
|
||||
CHECK_SPACE(2);
|
||||
int to = _code_ptr[ip + 1];
|
||||
|
||||
|
@ -1378,7 +1306,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_JUMP_IF) {
|
||||
|
||||
CHECK_SPACE(3);
|
||||
|
||||
GET_VARIANT_PTR(test, 1);
|
||||
|
@ -1396,7 +1323,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_JUMP_IF_NOT) {
|
||||
|
||||
CHECK_SPACE(3);
|
||||
|
||||
GET_VARIANT_PTR(test, 1);
|
||||
|
@ -1414,14 +1340,12 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_JUMP_TO_DEF_ARGUMENT) {
|
||||
|
||||
CHECK_SPACE(2);
|
||||
ip = _default_arg_ptr[defarg];
|
||||
}
|
||||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_RETURN) {
|
||||
|
||||
CHECK_SPACE(2);
|
||||
GET_VARIANT_PTR(r, 1);
|
||||
retvalue = *r;
|
||||
|
@ -1432,7 +1356,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
}
|
||||
|
||||
OPCODE(OPCODE_ITERATE_BEGIN) {
|
||||
|
||||
CHECK_SPACE(8); //space for this a regular iterate
|
||||
|
||||
GET_VARIANT_PTR(counter, 1);
|
||||
|
@ -1465,7 +1388,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
DISPATCH_OPCODE;
|
||||
|
||||
OPCODE(OPCODE_ITERATE) {
|
||||
|
||||
CHECK_SPACE(4);
|
||||
|
||||
GET_VARIANT_PTR(counter, 1);
|
||||
|
@ -1544,7 +1466,6 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
bool do_break = false;
|
||||
|
||||
if (ScriptDebugger::get_singleton()->get_lines_left() > 0) {
|
||||
|
||||
if (ScriptDebugger::get_singleton()->get_depth() <= 0)
|
||||
ScriptDebugger::get_singleton()->set_lines_left(ScriptDebugger::get_singleton()->get_lines_left() - 1);
|
||||
if (ScriptDebugger::get_singleton()->get_lines_left() <= 0)
|
||||
|
@ -1643,32 +1564,26 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
|||
}
|
||||
|
||||
const int *GDScriptFunction::get_code() const {
|
||||
|
||||
return _code_ptr;
|
||||
}
|
||||
int GDScriptFunction::get_code_size() const {
|
||||
|
||||
return _code_size;
|
||||
}
|
||||
|
||||
Variant GDScriptFunction::get_constant(int p_idx) const {
|
||||
|
||||
ERR_FAIL_INDEX_V(p_idx, constants.size(), "<errconst>");
|
||||
return constants[p_idx];
|
||||
}
|
||||
|
||||
StringName GDScriptFunction::get_global_name(int p_idx) const {
|
||||
|
||||
ERR_FAIL_INDEX_V(p_idx, global_names.size(), "<errgname>");
|
||||
return global_names[p_idx];
|
||||
}
|
||||
|
||||
int GDScriptFunction::get_default_argument_count() const {
|
||||
|
||||
return _default_arg_count;
|
||||
}
|
||||
int GDScriptFunction::get_default_argument_addr(int p_idx) const {
|
||||
|
||||
ERR_FAIL_INDEX_V(p_idx, default_arguments.size(), -1);
|
||||
return default_arguments[p_idx];
|
||||
}
|
||||
|
@ -1683,45 +1598,37 @@ GDScriptDataType GDScriptFunction::get_argument_type(int p_idx) const {
|
|||
}
|
||||
|
||||
StringName GDScriptFunction::get_name() const {
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
int GDScriptFunction::get_max_stack_size() const {
|
||||
|
||||
return _stack_size;
|
||||
}
|
||||
|
||||
struct _GDFKC {
|
||||
|
||||
int order;
|
||||
List<int> pos;
|
||||
};
|
||||
|
||||
struct _GDFKCS {
|
||||
|
||||
int order;
|
||||
StringName id;
|
||||
int pos;
|
||||
|
||||
bool operator<(const _GDFKCS &p_r) const {
|
||||
|
||||
return order < p_r.order;
|
||||
}
|
||||
};
|
||||
|
||||
void GDScriptFunction::debug_get_stack_member_state(int p_line, List<Pair<StringName, int>> *r_stackvars) const {
|
||||
|
||||
int oc = 0;
|
||||
Map<StringName, _GDFKC> sdmap;
|
||||
for (const List<StackDebug>::Element *E = stack_debug.front(); E; E = E->next()) {
|
||||
|
||||
const StackDebug &sd = E->get();
|
||||
if (sd.line > p_line)
|
||||
break;
|
||||
|
||||
if (sd.added) {
|
||||
|
||||
if (!sdmap.has(sd.identifier)) {
|
||||
_GDFKC d;
|
||||
d.order = oc++;
|
||||
|
@ -1732,7 +1639,6 @@ void GDScriptFunction::debug_get_stack_member_state(int p_line, List<Pair<String
|
|||
sdmap[sd.identifier].pos.push_back(sd.pos);
|
||||
}
|
||||
} else {
|
||||
|
||||
ERR_CONTINUE(!sdmap.has(sd.identifier));
|
||||
|
||||
sdmap[sd.identifier].pos.pop_back();
|
||||
|
@ -1743,7 +1649,6 @@ void GDScriptFunction::debug_get_stack_member_state(int p_line, List<Pair<String
|
|||
|
||||
List<_GDFKCS> stackpositions;
|
||||
for (Map<StringName, _GDFKC>::Element *E = sdmap.front(); E; E = E->next()) {
|
||||
|
||||
_GDFKCS spp;
|
||||
spp.id = E->key();
|
||||
spp.order = E->get().order;
|
||||
|
@ -1754,7 +1659,6 @@ void GDScriptFunction::debug_get_stack_member_state(int p_line, List<Pair<String
|
|||
stackpositions.sort();
|
||||
|
||||
for (List<_GDFKCS>::Element *E = stackpositions.front(); E; E = E->next()) {
|
||||
|
||||
Pair<StringName, int> p;
|
||||
p.first = E->get().id;
|
||||
p.second = E->get().pos;
|
||||
|
@ -1764,7 +1668,6 @@ void GDScriptFunction::debug_get_stack_member_state(int p_line, List<Pair<String
|
|||
|
||||
GDScriptFunction::GDScriptFunction() :
|
||||
function_list(this) {
|
||||
|
||||
_stack_size = 0;
|
||||
_call_size = 0;
|
||||
rpc_mode = MultiplayerAPI::RPC_MODE_DISABLED;
|
||||
|
@ -1800,7 +1703,6 @@ GDScriptFunction::~GDScriptFunction() {
|
|||
/////////////////////
|
||||
|
||||
Variant GDScriptFunctionState::_signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
|
||||
|
||||
Variant arg;
|
||||
r_error.error = Variant::CallError::CALL_OK;
|
||||
|
||||
|
@ -1833,7 +1735,6 @@ Variant GDScriptFunctionState::_signal_callback(const Variant **p_args, int p_ar
|
|||
}
|
||||
|
||||
bool GDScriptFunctionState::is_valid(bool p_extended_check) const {
|
||||
|
||||
if (function == NULL)
|
||||
return false;
|
||||
|
||||
|
@ -1855,7 +1756,6 @@ bool GDScriptFunctionState::is_valid(bool p_extended_check) const {
|
|||
}
|
||||
|
||||
Variant GDScriptFunctionState::resume(const Variant &p_arg) {
|
||||
|
||||
ERR_FAIL_COND_V(!function, Variant());
|
||||
{
|
||||
#ifndef NO_THREADS
|
||||
|
@ -1916,7 +1816,6 @@ Variant GDScriptFunctionState::resume(const Variant &p_arg) {
|
|||
}
|
||||
|
||||
void GDScriptFunctionState::_clear_stack() {
|
||||
|
||||
if (state.stack_size) {
|
||||
Variant *stack = (Variant *)state.stack.ptr();
|
||||
for (int i = 0; i < state.stack_size; i++)
|
||||
|
@ -1926,7 +1825,6 @@ void GDScriptFunctionState::_clear_stack() {
|
|||
}
|
||||
|
||||
void GDScriptFunctionState::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("resume", "arg"), &GDScriptFunctionState::resume, DEFVAL(Variant()));
|
||||
ClassDB::bind_method(D_METHOD("is_valid", "extended_check"), &GDScriptFunctionState::is_valid, DEFVAL(false));
|
||||
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "_signal_callback", &GDScriptFunctionState::_signal_callback, MethodInfo("_signal_callback"));
|
||||
|
@ -1937,12 +1835,10 @@ void GDScriptFunctionState::_bind_methods() {
|
|||
GDScriptFunctionState::GDScriptFunctionState() :
|
||||
scripts_list(this),
|
||||
instances_list(this) {
|
||||
|
||||
function = NULL;
|
||||
}
|
||||
|
||||
GDScriptFunctionState::~GDScriptFunctionState() {
|
||||
|
||||
_clear_stack();
|
||||
GDScriptLanguage::singleton->lock.lock();
|
||||
scripts_list.remove_from_list();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue