From 4cfc29611e21811065d024a6de1685418e60111e Mon Sep 17 00:00:00 2001
From: Rémi Verschelde
Date: Thu, 16 Nov 2017 18:38:18 +0100
Subject: GDScript: Refactor "GD" class prefix to "GDScript"
---
doc/classes/@GDScript.xml | 4 +-
main/tests/test_gdscript.cpp | 298 +-
modules/gdscript/config.py | 4 +-
modules/gdscript/doc_classes/GDFunctionState.xml | 46 -
modules/gdscript/doc_classes/GDNativeClass.xml | 21 -
.../gdscript/doc_classes/GDScriptFunctionState.xml | 46 +
.../gdscript/doc_classes/GDScriptNativeClass.xml | 21 +
modules/gdscript/gd_compiler.cpp | 2043 ---------
modules/gdscript/gd_compiler.h | 157 -
modules/gdscript/gd_editor.cpp | 2950 -------------
modules/gdscript/gd_function.cpp | 1628 -------
modules/gdscript/gd_function.h | 247 --
modules/gdscript/gd_functions.cpp | 1766 --------
modules/gdscript/gd_functions.h | 123 -
modules/gdscript/gd_parser.cpp | 4434 -------------------
modules/gdscript/gd_parser.h | 547 ---
modules/gdscript/gd_script.cpp | 1911 ---------
modules/gdscript/gd_script.h | 449 --
modules/gdscript/gd_tokenizer.cpp | 1466 -------
modules/gdscript/gd_tokenizer.h | 263 --
modules/gdscript/gdscript.cpp | 1911 +++++++++
modules/gdscript/gdscript.h | 450 ++
modules/gdscript/gdscript_compiler.cpp | 2044 +++++++++
modules/gdscript/gdscript_compiler.h | 157 +
modules/gdscript/gdscript_editor.cpp | 2950 +++++++++++++
modules/gdscript/gdscript_function.cpp | 1628 +++++++
modules/gdscript/gdscript_function.h | 247 ++
modules/gdscript/gdscript_functions.cpp | 1767 ++++++++
modules/gdscript/gdscript_functions.h | 123 +
modules/gdscript/gdscript_parser.cpp | 4435 ++++++++++++++++++++
modules/gdscript/gdscript_parser.h | 547 +++
modules/gdscript/gdscript_tokenizer.cpp | 1466 +++++++
modules/gdscript/gdscript_tokenizer.h | 263 ++
modules/gdscript/register_types.cpp | 5 +-
34 files changed, 18210 insertions(+), 18207 deletions(-)
delete mode 100644 modules/gdscript/doc_classes/GDFunctionState.xml
delete mode 100644 modules/gdscript/doc_classes/GDNativeClass.xml
create mode 100644 modules/gdscript/doc_classes/GDScriptFunctionState.xml
create mode 100644 modules/gdscript/doc_classes/GDScriptNativeClass.xml
delete mode 100644 modules/gdscript/gd_compiler.cpp
delete mode 100644 modules/gdscript/gd_compiler.h
delete mode 100644 modules/gdscript/gd_editor.cpp
delete mode 100644 modules/gdscript/gd_function.cpp
delete mode 100644 modules/gdscript/gd_function.h
delete mode 100644 modules/gdscript/gd_functions.cpp
delete mode 100644 modules/gdscript/gd_functions.h
delete mode 100644 modules/gdscript/gd_parser.cpp
delete mode 100644 modules/gdscript/gd_parser.h
delete mode 100644 modules/gdscript/gd_script.cpp
delete mode 100644 modules/gdscript/gd_script.h
delete mode 100644 modules/gdscript/gd_tokenizer.cpp
delete mode 100644 modules/gdscript/gd_tokenizer.h
create mode 100644 modules/gdscript/gdscript.cpp
create mode 100644 modules/gdscript/gdscript.h
create mode 100644 modules/gdscript/gdscript_compiler.cpp
create mode 100644 modules/gdscript/gdscript_compiler.h
create mode 100644 modules/gdscript/gdscript_editor.cpp
create mode 100644 modules/gdscript/gdscript_function.cpp
create mode 100644 modules/gdscript/gdscript_function.h
create mode 100644 modules/gdscript/gdscript_functions.cpp
create mode 100644 modules/gdscript/gdscript_functions.h
create mode 100644 modules/gdscript/gdscript_parser.cpp
create mode 100644 modules/gdscript/gdscript_parser.h
create mode 100644 modules/gdscript/gdscript_tokenizer.cpp
create mode 100644 modules/gdscript/gdscript_tokenizer.h
diff --git a/doc/classes/@GDScript.xml b/doc/classes/@GDScript.xml
index 3f2d0c71e..49ec412ba 100644
--- a/doc/classes/@GDScript.xml
+++ b/doc/classes/@GDScript.xml
@@ -1103,14 +1103,14 @@
-
+
- Stops the function execution and returns the current state. Call [method GDFunctionState.resume] on the state to resume execution. This invalidates the state.
+ Stops the function execution and returns the current state. Call [method GDScriptFunctionState.resume] on the state to resume execution. This invalidates the state.
Returns anything that was passed to the resume function call. If passed an object and a signal, the execution is resumed when the object's signal is emitted.
diff --git a/main/tests/test_gdscript.cpp b/main/tests/test_gdscript.cpp
index bcf4278bd..b41b5f645 100644
--- a/main/tests/test_gdscript.cpp
+++ b/main/tests/test_gdscript.cpp
@@ -35,10 +35,10 @@
#ifdef GDSCRIPT_ENABLED
-#include "modules/gdscript/gd_compiler.h"
-#include "modules/gdscript/gd_parser.h"
-#include "modules/gdscript/gd_script.h"
-#include "modules/gdscript/gd_tokenizer.h"
+#include "modules/gdscript/gdscript.h"
+#include "modules/gdscript/gdscript_compiler.h"
+#include "modules/gdscript/gdscript_parser.h"
+#include "modules/gdscript/gdscript_tokenizer.h"
namespace TestGDScript {
@@ -52,7 +52,7 @@ static void _print_indent(int p_ident, const String &p_text) {
print_line(txt + p_text);
}
-static String _parser_extends(const GDParser::ClassNode *p_class) {
+static String _parser_extends(const GDScriptParser::ClassNode *p_class) {
String txt = "extends ";
if (String(p_class->extends_file) != "") {
@@ -72,29 +72,29 @@ static String _parser_extends(const GDParser::ClassNode *p_class) {
return txt;
}
-static String _parser_expr(const GDParser::Node *p_expr) {
+static String _parser_expr(const GDScriptParser::Node *p_expr) {
String txt;
switch (p_expr->type) {
- case GDParser::Node::TYPE_IDENTIFIER: {
+ case GDScriptParser::Node::TYPE_IDENTIFIER: {
- const GDParser::IdentifierNode *id_node = static_cast(p_expr);
+ const GDScriptParser::IdentifierNode *id_node = static_cast(p_expr);
txt = id_node->name;
} break;
- case GDParser::Node::TYPE_CONSTANT: {
- const GDParser::ConstantNode *c_node = static_cast(p_expr);
+ case GDScriptParser::Node::TYPE_CONSTANT: {
+ const GDScriptParser::ConstantNode *c_node = static_cast(p_expr);
if (c_node->value.get_type() == Variant::STRING)
txt = "\"" + String(c_node->value) + "\"";
else
txt = c_node->value;
} break;
- case GDParser::Node::TYPE_SELF: {
+ case GDScriptParser::Node::TYPE_SELF: {
txt = "self";
} break;
- case GDParser::Node::TYPE_ARRAY: {
- const GDParser::ArrayNode *arr_node = static_cast(p_expr);
+ case GDScriptParser::Node::TYPE_ARRAY: {
+ const GDScriptParser::ArrayNode *arr_node = static_cast(p_expr);
txt += "[";
for (int i = 0; i < arr_node->elements.size(); i++) {
@@ -104,51 +104,51 @@ static String _parser_expr(const GDParser::Node *p_expr) {
}
txt += "]";
} break;
- case GDParser::Node::TYPE_DICTIONARY: {
- const GDParser::DictionaryNode *dict_node = static_cast(p_expr);
+ case GDScriptParser::Node::TYPE_DICTIONARY: {
+ const GDScriptParser::DictionaryNode *dict_node = static_cast(p_expr);
txt += "{";
for (int i = 0; i < dict_node->elements.size(); i++) {
if (i > 0)
txt += ", ";
- const GDParser::DictionaryNode::Pair &p = dict_node->elements[i];
+ const GDScriptParser::DictionaryNode::Pair &p = dict_node->elements[i];
txt += _parser_expr(p.key);
txt += ":";
txt += _parser_expr(p.value);
}
txt += "}";
} break;
- case GDParser::Node::TYPE_OPERATOR: {
+ case GDScriptParser::Node::TYPE_OPERATOR: {
- const GDParser::OperatorNode *c_node = static_cast(p_expr);
+ const GDScriptParser::OperatorNode *c_node = static_cast(p_expr);
switch (c_node->op) {
- case GDParser::OperatorNode::OP_PARENT_CALL:
+ case GDScriptParser::OperatorNode::OP_PARENT_CALL:
txt += ".";
- case GDParser::OperatorNode::OP_CALL: {
+ case GDScriptParser::OperatorNode::OP_CALL: {
ERR_FAIL_COND_V(c_node->arguments.size() < 1, "");
String func_name;
- const GDParser::Node *nfunc = c_node->arguments[0];
+ const GDScriptParser::Node *nfunc = c_node->arguments[0];
int arg_ofs = 0;
- if (nfunc->type == GDParser::Node::TYPE_BUILT_IN_FUNCTION) {
+ if (nfunc->type == GDScriptParser::Node::TYPE_BUILT_IN_FUNCTION) {
- const GDParser::BuiltInFunctionNode *bif_node = static_cast(nfunc);
- func_name = GDFunctions::get_func_name(bif_node->function);
+ const GDScriptParser::BuiltInFunctionNode *bif_node = static_cast(nfunc);
+ func_name = GDScriptFunctions::get_func_name(bif_node->function);
arg_ofs = 1;
- } else if (nfunc->type == GDParser::Node::TYPE_TYPE) {
+ } else if (nfunc->type == GDScriptParser::Node::TYPE_TYPE) {
- const GDParser::TypeNode *t_node = static_cast(nfunc);
+ const GDScriptParser::TypeNode *t_node = static_cast(nfunc);
func_name = Variant::get_type_name(t_node->vtype);
arg_ofs = 1;
} else {
ERR_FAIL_COND_V(c_node->arguments.size() < 2, "");
nfunc = c_node->arguments[1];
- ERR_FAIL_COND_V(nfunc->type != GDParser::Node::TYPE_IDENTIFIER, "");
+ ERR_FAIL_COND_V(nfunc->type != GDScriptParser::Node::TYPE_IDENTIFIER, "");
- if (c_node->arguments[0]->type != GDParser::Node::TYPE_SELF)
+ if (c_node->arguments[0]->type != GDScriptParser::Node::TYPE_SELF)
func_name = _parser_expr(c_node->arguments[0]) + ".";
func_name += _parser_expr(nfunc);
@@ -159,7 +159,7 @@ static String _parser_expr(const GDParser::Node *p_expr) {
for (int i = arg_ofs; i < c_node->arguments.size(); i++) {
- const GDParser::Node *arg = c_node->arguments[i];
+ const GDScriptParser::Node *arg = c_node->arguments[i];
if (i > arg_ofs)
txt += ", ";
txt += _parser_expr(arg);
@@ -168,7 +168,7 @@ static String _parser_expr(const GDParser::Node *p_expr) {
txt += ")";
} break;
- case GDParser::OperatorNode::OP_INDEX: {
+ case GDScriptParser::OperatorNode::OP_INDEX: {
ERR_FAIL_COND_V(c_node->arguments.size() != 2, "");
@@ -176,125 +176,125 @@ static String _parser_expr(const GDParser::Node *p_expr) {
txt = _parser_expr(c_node->arguments[0]) + "[" + _parser_expr(c_node->arguments[1]) + "]";
} break;
- case GDParser::OperatorNode::OP_INDEX_NAMED: {
+ case GDScriptParser::OperatorNode::OP_INDEX_NAMED: {
ERR_FAIL_COND_V(c_node->arguments.size() != 2, "");
txt = _parser_expr(c_node->arguments[0]) + "." + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_NEG: {
+ case GDScriptParser::OperatorNode::OP_NEG: {
txt = "-" + _parser_expr(c_node->arguments[0]);
} break;
- case GDParser::OperatorNode::OP_NOT: {
+ case GDScriptParser::OperatorNode::OP_NOT: {
txt = "not " + _parser_expr(c_node->arguments[0]);
} break;
- case GDParser::OperatorNode::OP_BIT_INVERT: {
+ case GDScriptParser::OperatorNode::OP_BIT_INVERT: {
txt = "~" + _parser_expr(c_node->arguments[0]);
} break;
- case GDParser::OperatorNode::OP_PREINC: {
+ case GDScriptParser::OperatorNode::OP_PREINC: {
} break;
- case GDParser::OperatorNode::OP_PREDEC: {
+ case GDScriptParser::OperatorNode::OP_PREDEC: {
} break;
- case GDParser::OperatorNode::OP_INC: {
+ case GDScriptParser::OperatorNode::OP_INC: {
} break;
- case GDParser::OperatorNode::OP_DEC: {
+ case GDScriptParser::OperatorNode::OP_DEC: {
} break;
- case GDParser::OperatorNode::OP_IN: {
+ case GDScriptParser::OperatorNode::OP_IN: {
txt = _parser_expr(c_node->arguments[0]) + " in " + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_EQUAL: {
+ case GDScriptParser::OperatorNode::OP_EQUAL: {
txt = _parser_expr(c_node->arguments[0]) + "==" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_NOT_EQUAL: {
+ case GDScriptParser::OperatorNode::OP_NOT_EQUAL: {
txt = _parser_expr(c_node->arguments[0]) + "!=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_LESS: {
+ case GDScriptParser::OperatorNode::OP_LESS: {
txt = _parser_expr(c_node->arguments[0]) + "<" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_LESS_EQUAL: {
+ case GDScriptParser::OperatorNode::OP_LESS_EQUAL: {
txt = _parser_expr(c_node->arguments[0]) + "<=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_GREATER: {
+ case GDScriptParser::OperatorNode::OP_GREATER: {
txt = _parser_expr(c_node->arguments[0]) + ">" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_GREATER_EQUAL: {
+ case GDScriptParser::OperatorNode::OP_GREATER_EQUAL: {
txt = _parser_expr(c_node->arguments[0]) + ">=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_AND: {
+ case GDScriptParser::OperatorNode::OP_AND: {
txt = _parser_expr(c_node->arguments[0]) + " and " + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_OR: {
+ case GDScriptParser::OperatorNode::OP_OR: {
txt = _parser_expr(c_node->arguments[0]) + " or " + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ADD: {
+ case GDScriptParser::OperatorNode::OP_ADD: {
txt = _parser_expr(c_node->arguments[0]) + "+" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_SUB: {
+ case GDScriptParser::OperatorNode::OP_SUB: {
txt = _parser_expr(c_node->arguments[0]) + "-" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_MUL: {
+ case GDScriptParser::OperatorNode::OP_MUL: {
txt = _parser_expr(c_node->arguments[0]) + "*" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_DIV: {
+ case GDScriptParser::OperatorNode::OP_DIV: {
txt = _parser_expr(c_node->arguments[0]) + "/" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_MOD: {
+ case GDScriptParser::OperatorNode::OP_MOD: {
txt = _parser_expr(c_node->arguments[0]) + "%" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_SHIFT_LEFT: {
+ case GDScriptParser::OperatorNode::OP_SHIFT_LEFT: {
txt = _parser_expr(c_node->arguments[0]) + "<<" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_SHIFT_RIGHT: {
+ case GDScriptParser::OperatorNode::OP_SHIFT_RIGHT: {
txt = _parser_expr(c_node->arguments[0]) + ">>" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ASSIGN: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN: {
txt = _parser_expr(c_node->arguments[0]) + "=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ASSIGN_ADD: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_ADD: {
txt = _parser_expr(c_node->arguments[0]) + "+=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ASSIGN_SUB: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_SUB: {
txt = _parser_expr(c_node->arguments[0]) + "-=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ASSIGN_MUL: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_MUL: {
txt = _parser_expr(c_node->arguments[0]) + "*=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ASSIGN_DIV: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_DIV: {
txt = _parser_expr(c_node->arguments[0]) + "/=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ASSIGN_MOD: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_MOD: {
txt = _parser_expr(c_node->arguments[0]) + "%=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ASSIGN_SHIFT_LEFT: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_SHIFT_LEFT: {
txt = _parser_expr(c_node->arguments[0]) + "<<=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ASSIGN_SHIFT_RIGHT: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_SHIFT_RIGHT: {
txt = _parser_expr(c_node->arguments[0]) + ">>=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ASSIGN_BIT_AND: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_AND: {
txt = _parser_expr(c_node->arguments[0]) + "&=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ASSIGN_BIT_OR: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_OR: {
txt = _parser_expr(c_node->arguments[0]) + "|=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ASSIGN_BIT_XOR: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_XOR: {
txt = _parser_expr(c_node->arguments[0]) + "^=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_BIT_AND: {
+ case GDScriptParser::OperatorNode::OP_BIT_AND: {
txt = _parser_expr(c_node->arguments[0]) + "&" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_BIT_OR: {
+ case GDScriptParser::OperatorNode::OP_BIT_OR: {
txt = _parser_expr(c_node->arguments[0]) + "|" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_BIT_XOR: {
+ case GDScriptParser::OperatorNode::OP_BIT_XOR: {
txt = _parser_expr(c_node->arguments[0]) + "^" + _parser_expr(c_node->arguments[1]);
} break;
default: {}
}
} break;
- case GDParser::Node::TYPE_NEWLINE: {
+ case GDScriptParser::Node::TYPE_NEWLINE: {
//skippie
} break;
@@ -310,20 +310,20 @@ static String _parser_expr(const GDParser::Node *p_expr) {
//return "("+txt+")";
}
-static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent) {
+static void _parser_show_block(const GDScriptParser::BlockNode *p_block, int p_indent) {
for (int i = 0; i < p_block->statements.size(); i++) {
- const GDParser::Node *statement = p_block->statements[i];
+ const GDScriptParser::Node *statement = p_block->statements[i];
switch (statement->type) {
- case GDParser::Node::TYPE_CONTROL_FLOW: {
+ case GDScriptParser::Node::TYPE_CONTROL_FLOW: {
- const GDParser::ControlFlowNode *cf_node = static_cast(statement);
+ const GDScriptParser::ControlFlowNode *cf_node = static_cast(statement);
switch (cf_node->cf_type) {
- case GDParser::ControlFlowNode::CF_IF: {
+ case GDScriptParser::ControlFlowNode::CF_IF: {
ERR_FAIL_COND(cf_node->arguments.size() != 1);
String txt;
@@ -339,7 +339,7 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent)
}
} break;
- case GDParser::ControlFlowNode::CF_FOR: {
+ case GDScriptParser::ControlFlowNode::CF_FOR: {
ERR_FAIL_COND(cf_node->arguments.size() != 2);
String txt;
txt += "for ";
@@ -352,7 +352,7 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent)
_parser_show_block(cf_node->body, p_indent + 1);
} break;
- case GDParser::ControlFlowNode::CF_WHILE: {
+ case GDScriptParser::ControlFlowNode::CF_WHILE: {
ERR_FAIL_COND(cf_node->arguments.size() != 1);
String txt;
@@ -364,18 +364,18 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent)
_parser_show_block(cf_node->body, p_indent + 1);
} break;
- case GDParser::ControlFlowNode::CF_SWITCH: {
+ case GDScriptParser::ControlFlowNode::CF_SWITCH: {
} break;
- case GDParser::ControlFlowNode::CF_CONTINUE: {
+ case GDScriptParser::ControlFlowNode::CF_CONTINUE: {
_print_indent(p_indent, "continue");
} break;
- case GDParser::ControlFlowNode::CF_BREAK: {
+ case GDScriptParser::ControlFlowNode::CF_BREAK: {
_print_indent(p_indent, "break");
} break;
- case GDParser::ControlFlowNode::CF_RETURN: {
+ case GDScriptParser::ControlFlowNode::CF_RETURN: {
if (cf_node->arguments.size())
_print_indent(p_indent, "return " + _parser_expr(cf_node->arguments[0]));
@@ -385,9 +385,9 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent)
}
} break;
- case GDParser::Node::TYPE_LOCAL_VAR: {
+ case GDScriptParser::Node::TYPE_LOCAL_VAR: {
- const GDParser::LocalVarNode *lv_node = static_cast(statement);
+ const GDScriptParser::LocalVarNode *lv_node = static_cast(statement);
_print_indent(p_indent, "var " + String(lv_node->name));
} break;
default: {
@@ -398,7 +398,7 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent)
}
}
-static void _parser_show_function(const GDParser::FunctionNode *p_func, int p_indent, GDParser::BlockNode *p_initializer = NULL) {
+static void _parser_show_function(const GDScriptParser::FunctionNode *p_func, int p_indent, GDScriptParser::BlockNode *p_initializer = NULL) {
String txt;
if (p_func->_static)
@@ -434,7 +434,7 @@ static void _parser_show_function(const GDParser::FunctionNode *p_func, int p_in
_parser_show_block(p_func->body, p_indent + 1);
}
-static void _parser_show_class(const GDParser::ClassNode *p_class, int p_indent, const Vector &p_code) {
+static void _parser_show_class(const GDScriptParser::ClassNode *p_class, int p_indent, const Vector &p_code) {
if (p_indent == 0 && (String(p_class->extends_file) != "" || p_class->extends_class.size())) {
@@ -444,7 +444,7 @@ static void _parser_show_class(const GDParser::ClassNode *p_class, int p_indent,
for (int i = 0; i < p_class->subclasses.size(); i++) {
- const GDParser::ClassNode *subclass = p_class->subclasses[i];
+ const GDScriptParser::ClassNode *subclass = p_class->subclasses[i];
String line = "class " + subclass->name;
if (String(subclass->extends_file) != "" || subclass->extends_class.size())
line += " " + _parser_extends(subclass);
@@ -456,13 +456,13 @@ static void _parser_show_class(const GDParser::ClassNode *p_class, int p_indent,
for (int i = 0; i < p_class->constant_expressions.size(); i++) {
- const GDParser::ClassNode::Constant &constant = p_class->constant_expressions[i];
+ const GDScriptParser::ClassNode::Constant &constant = p_class->constant_expressions[i];
_print_indent(p_indent, "const " + String(constant.identifier) + "=" + _parser_expr(constant.expression));
}
for (int i = 0; i < p_class->variables.size(); i++) {
- const GDParser::ClassNode::Member &m = p_class->variables[i];
+ const GDScriptParser::ClassNode::Member &m = p_class->variables[i];
_print_indent(p_indent, "var " + String(m.identifier));
}
@@ -487,27 +487,27 @@ static void _parser_show_class(const GDParser::ClassNode *p_class, int p_indent,
print_line("\n");
}
-static String _disassemble_addr(const Ref &p_script, const GDFunction &func, int p_addr) {
+static String _disassemble_addr(const Ref &p_script, const GDScriptFunction &func, int p_addr) {
- int addr = p_addr & GDFunction::ADDR_MASK;
+ int addr = p_addr & GDScriptFunction::ADDR_MASK;
- switch (p_addr >> GDFunction::ADDR_BITS) {
+ switch (p_addr >> GDScriptFunction::ADDR_BITS) {
- case GDFunction::ADDR_TYPE_SELF: {
+ case GDScriptFunction::ADDR_TYPE_SELF: {
return "self";
} break;
- case GDFunction::ADDR_TYPE_CLASS: {
+ case GDScriptFunction::ADDR_TYPE_CLASS: {
return "class";
} break;
- case GDFunction::ADDR_TYPE_MEMBER: {
+ case GDScriptFunction::ADDR_TYPE_MEMBER: {
return "member(" + p_script->debug_get_member_by_index(addr) + ")";
} break;
- case GDFunction::ADDR_TYPE_CLASS_CONSTANT: {
+ case GDScriptFunction::ADDR_TYPE_CLASS_CONSTANT: {
return "class_const(" + func.get_global_name(addr) + ")";
} break;
- case GDFunction::ADDR_TYPE_LOCAL_CONSTANT: {
+ case GDScriptFunction::ADDR_TYPE_LOCAL_CONSTANT: {
Variant v = func.get_constant(addr);
String txt;
@@ -517,19 +517,19 @@ static String _disassemble_addr(const Ref &p_script, const GDFunction
txt = v;
return "const(" + txt + ")";
} break;
- case GDFunction::ADDR_TYPE_STACK: {
+ case GDScriptFunction::ADDR_TYPE_STACK: {
return "stack(" + itos(addr) + ")";
} break;
- case GDFunction::ADDR_TYPE_STACK_VARIABLE: {
+ case GDScriptFunction::ADDR_TYPE_STACK_VARIABLE: {
return "var_stack(" + itos(addr) + ")";
} break;
- case GDFunction::ADDR_TYPE_GLOBAL: {
+ case GDScriptFunction::ADDR_TYPE_GLOBAL: {
return "global(" + func.get_global_name(addr) + ")";
} break;
- case GDFunction::ADDR_TYPE_NIL: {
+ case GDScriptFunction::ADDR_TYPE_NIL: {
return "nil";
} break;
}
@@ -539,11 +539,11 @@ static String _disassemble_addr(const Ref &p_script, const GDFunction
static void _disassemble_class(const Ref &p_class, const Vector &p_code) {
- const Map &mf = p_class->debug_get_member_functions();
+ const Map &mf = p_class->debug_get_member_functions();
- for (const Map::Element *E = mf.front(); E; E = E->next()) {
+ for (const Map::Element *E = mf.front(); E; E = E->next()) {
- const GDFunction &func = *E->get();
+ const GDScriptFunction &func = *E->get();
const int *code = func.get_code();
int codelen = func.get_code_size();
String defargs;
@@ -568,7 +568,7 @@ static void _disassemble_class(const Ref &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector &p_class, const Vector= 0 && line < p_code.size())
@@ -884,12 +884,12 @@ static void _disassemble_class(const Ref &p_class, const Vectortype != GDParser::Node::TYPE_CLASS, NULL);
- const GDParser::ClassNode *cnode = static_cast(root);
+ const GDScriptParser::Node *root = parser.get_parse_tree();
+ ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, NULL);
+ const GDScriptParser::ClassNode *cnode = static_cast(root);
_parser_show_class(cnode, 0, lines);
}
if (p_type == TEST_COMPILER) {
- GDParser parser;
+ GDScriptParser parser;
Error err = parser.parse(code);
if (err) {
@@ -1023,7 +1023,7 @@ MainLoop *test(TestType p_type) {
GDScript *script = memnew(GDScript);
- GDCompiler gdc;
+ GDScriptCompiler gdc;
err = gdc.compile(&parser, script);
if (err) {
@@ -1046,7 +1046,7 @@ MainLoop *test(TestType p_type) {
} else if (p_type == TEST_BYTECODE) {
- Vector buf = GDTokenizerBuffer::parse_code_string(code);
+ Vector buf = GDScriptTokenizerBuffer::parse_code_string(code);
String dst = test.get_basename() + ".gdc";
FileAccess *fw = FileAccess::open(dst, FileAccess::WRITE);
fw->store_buffer(buf.ptr(), buf.size());
diff --git a/modules/gdscript/config.py b/modules/gdscript/config.py
index 6e8994d64..6496b59d7 100644
--- a/modules/gdscript/config.py
+++ b/modules/gdscript/config.py
@@ -6,9 +6,9 @@ def configure(env):
def get_doc_classes():
return [
- "GDFunctionState",
- "GDNativeClass",
"GDScript",
+ "GDScriptFunctionState",
+ "GDScriptNativeClass",
]
def get_doc_path():
diff --git a/modules/gdscript/doc_classes/GDFunctionState.xml b/modules/gdscript/doc_classes/GDFunctionState.xml
deleted file mode 100644
index e1aafa8a5..000000000
--- a/modules/gdscript/doc_classes/GDFunctionState.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
- State of a function call after yielding.
-
-
- Calling [method @GDScript.yield] within a function will cause that function to yield and return its current state as an object of this type. The yielded function call can then be resumed later by calling [method resume] on this state object.
-
-
-
-
-
-
-
-
-
-
-
-
- Check whether the function call may be resumed. This is not the case if the function state was already resumed.
- If [code]extended_check[/code] is enabled, it also checks if the associated script and object still exist. The extended check is done in debug mode as part of [method GDFunctionState.resume], but you can use this if you know you may be trying to resume without knowing for sure the object and/or script have survived up to that point.
-
-
-
-
-
-
-
-
- Resume execution of the yielded function call.
- If handed an argument, return the argument from the [method @GDScript.yield] call in the yielded function call. You can pass e.g. an [Array] to hand multiple arguments.
- This function returns what the resumed function call returns, possibly another function state if yielded again.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/modules/gdscript/doc_classes/GDNativeClass.xml b/modules/gdscript/doc_classes/GDNativeClass.xml
deleted file mode 100644
index 95789e1b6..000000000
--- a/modules/gdscript/doc_classes/GDNativeClass.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/modules/gdscript/doc_classes/GDScriptFunctionState.xml b/modules/gdscript/doc_classes/GDScriptFunctionState.xml
new file mode 100644
index 000000000..2df4e7c21
--- /dev/null
+++ b/modules/gdscript/doc_classes/GDScriptFunctionState.xml
@@ -0,0 +1,46 @@
+
+
+
+ State of a function call after yielding.
+
+
+ Calling [method @GDScript.yield] within a function will cause that function to yield and return its current state as an object of this type. The yielded function call can then be resumed later by calling [method resume] on this state object.
+
+
+
+
+
+
+
+
+
+
+
+
+ Check whether the function call may be resumed. This is not the case if the function state was already resumed.
+ If [code]extended_check[/code] is enabled, it also checks if the associated script and object still exist. The extended check is done in debug mode as part of [method GDScriptFunctionState.resume], but you can use this if you know you may be trying to resume without knowing for sure the object and/or script have survived up to that point.
+
+
+
+
+
+
+
+
+ Resume execution of the yielded function call.
+ If handed an argument, return the argument from the [method @GDScript.yield] call in the yielded function call. You can pass e.g. an [Array] to hand multiple arguments.
+ This function returns what the resumed function call returns, possibly another function state if yielded again.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/gdscript/doc_classes/GDScriptNativeClass.xml b/modules/gdscript/doc_classes/GDScriptNativeClass.xml
new file mode 100644
index 000000000..4514a7846
--- /dev/null
+++ b/modules/gdscript/doc_classes/GDScriptNativeClass.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/gdscript/gd_compiler.cpp b/modules/gdscript/gd_compiler.cpp
deleted file mode 100644
index 7036a708e..000000000
--- a/modules/gdscript/gd_compiler.cpp
+++ /dev/null
@@ -1,2043 +0,0 @@
-/*************************************************************************/
-/* gd_compiler.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 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 "gd_compiler.h"
-#include "gd_script.h"
-
-bool GDCompiler::_is_class_member_property(CodeGen &codegen, const StringName &p_name) {
-
- if (!codegen.function_node || codegen.function_node->_static)
- return false;
-
- return _is_class_member_property(codegen.script, p_name);
-}
-
-bool GDCompiler::_is_class_member_property(GDScript *owner, const StringName &p_name) {
-
- GDScript *scr = owner;
- GDNativeClass *nc = NULL;
- while (scr) {
-
- if (scr->native.is_valid())
- nc = scr->native.ptr();
- scr = scr->_base;
- }
-
- ERR_FAIL_COND_V(!nc, false);
-
- return ClassDB::has_property(nc->get_name(), p_name);
-}
-
-void GDCompiler::_set_error(const String &p_error, const GDParser::Node *p_node) {
-
- if (error != "")
- return;
-
- error = p_error;
- if (p_node) {
- err_line = p_node->line;
- err_column = p_node->column;
- } else {
- err_line = 0;
- err_column = 0;
- }
-}
-
-bool GDCompiler::_create_unary_operator(CodeGen &codegen, const GDParser::OperatorNode *on, Variant::Operator op, int p_stack_level) {
-
- ERR_FAIL_COND_V(on->arguments.size() != 1, false);
-
- int src_address_a = _parse_expression(codegen, on->arguments[0], p_stack_level);
- if (src_address_a < 0)
- return false;
-
- codegen.opcodes.push_back(GDFunction::OPCODE_OPERATOR); // perform operator
- codegen.opcodes.push_back(op); //which operator
- codegen.opcodes.push_back(src_address_a); // argument 1
- codegen.opcodes.push_back(src_address_a); // argument 2 (repeated)
- //codegen.opcodes.push_back(GDFunction::ADDR_TYPE_NIL); // argument 2 (unary only takes one parameter)
- return true;
-}
-
-bool GDCompiler::_create_binary_operator(CodeGen &codegen, const GDParser::OperatorNode *on, Variant::Operator op, int p_stack_level, bool p_initializer) {
-
- ERR_FAIL_COND_V(on->arguments.size() != 2, false);
-
- int src_address_a = _parse_expression(codegen, on->arguments[0], p_stack_level, false, p_initializer);
- if (src_address_a < 0)
- return false;
- if (src_address_a & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS)
- p_stack_level++; //uses stack for return, increase stack
-
- int src_address_b = _parse_expression(codegen, on->arguments[1], p_stack_level, false, p_initializer);
- if (src_address_b < 0)
- return false;
-
- codegen.opcodes.push_back(GDFunction::OPCODE_OPERATOR); // perform operator
- codegen.opcodes.push_back(op); //which operator
- codegen.opcodes.push_back(src_address_a); // argument 1
- codegen.opcodes.push_back(src_address_b); // argument 2 (unary only takes one parameter)
- return true;
-}
-
-/*
-int GDCompiler::_parse_subexpression(CodeGen& codegen,const GDParser::Node *p_expression) {
-
-
- int ret = _parse_expression(codegen,p_expression);
- if (ret<0)
- return ret;
-
- if (ret&(GDFunction::ADDR_TYPE_STACK<op) {
-
- case GDParser::OperatorNode::OP_ASSIGN_ADD: var_op = Variant::OP_ADD; break;
- case GDParser::OperatorNode::OP_ASSIGN_SUB: var_op = Variant::OP_SUBTRACT; break;
- case GDParser::OperatorNode::OP_ASSIGN_MUL: var_op = Variant::OP_MULTIPLY; break;
- case GDParser::OperatorNode::OP_ASSIGN_DIV: var_op = Variant::OP_DIVIDE; break;
- case GDParser::OperatorNode::OP_ASSIGN_MOD: var_op = Variant::OP_MODULE; break;
- case GDParser::OperatorNode::OP_ASSIGN_SHIFT_LEFT: var_op = Variant::OP_SHIFT_LEFT; break;
- case GDParser::OperatorNode::OP_ASSIGN_SHIFT_RIGHT: var_op = Variant::OP_SHIFT_RIGHT; break;
- case GDParser::OperatorNode::OP_ASSIGN_BIT_AND: var_op = Variant::OP_BIT_AND; break;
- case GDParser::OperatorNode::OP_ASSIGN_BIT_OR: var_op = Variant::OP_BIT_OR; break;
- case GDParser::OperatorNode::OP_ASSIGN_BIT_XOR: var_op = Variant::OP_BIT_XOR; break;
- case GDParser::OperatorNode::OP_INIT_ASSIGN:
- case GDParser::OperatorNode::OP_ASSIGN: {
-
- //none
- } break;
- default: {
-
- ERR_FAIL_V(-1);
- }
- }
-
- bool initializer = p_expression->op == GDParser::OperatorNode::OP_INIT_ASSIGN;
-
- if (var_op == Variant::OP_MAX) {
-
- return _parse_expression(codegen, p_expression->arguments[1], p_stack_level, false, initializer);
- }
-
- if (!_create_binary_operator(codegen, p_expression, var_op, p_stack_level, initializer))
- return -1;
-
- int dst_addr = (p_stack_level) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
- codegen.opcodes.push_back(dst_addr); // append the stack level as destination address of the opcode
- codegen.alloc_stack(p_stack_level);
- return dst_addr;
-}
-
-int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expression, int p_stack_level, bool p_root, bool p_initializer) {
-
- switch (p_expression->type) {
- //should parse variable declaration and adjust stack accordingly...
- case GDParser::Node::TYPE_IDENTIFIER: {
- //return identifier
- //wait, identifier could be a local variable or something else... careful here, must reference properly
- //as stack may be more interesting to work with
-
- //This could be made much simpler by just indexing "self", but done this way (with custom self-addressing modes) increases peformance a lot.
-
- const GDParser::IdentifierNode *in = static_cast(p_expression);
-
- StringName identifier = in->name;
-
- if (_is_class_member_property(codegen, identifier)) {
- //get property
- codegen.opcodes.push_back(GDFunction::OPCODE_GET_MEMBER); // perform operator
- codegen.opcodes.push_back(codegen.get_name_map_pos(identifier)); // argument 2 (unary only takes one parameter)
- int dst_addr = (p_stack_level) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
- codegen.opcodes.push_back(dst_addr); // append the stack level as destination address of the opcode
- codegen.alloc_stack(p_stack_level);
- return dst_addr;
- }
-
- // TRY STACK!
- if (!p_initializer && codegen.stack_identifiers.has(identifier)) {
-
- int pos = codegen.stack_identifiers[identifier];
- return pos | (GDFunction::ADDR_TYPE_STACK_VARIABLE << GDFunction::ADDR_BITS);
- }
- //TRY MEMBERS!
- if (!codegen.function_node || !codegen.function_node->_static) {
-
- // TRY MEMBER VARIABLES!
- //static function
- if (codegen.script->member_indices.has(identifier)) {
-
- int idx = codegen.script->member_indices[identifier].index;
- return idx | (GDFunction::ADDR_TYPE_MEMBER << GDFunction::ADDR_BITS); //argument (stack root)
- }
- }
-
- //TRY CLASS CONSTANTS
-
- GDScript *owner = codegen.script;
- while (owner) {
-
- GDScript *scr = owner;
- GDNativeClass *nc = NULL;
- while (scr) {
-
- if (scr->constants.has(identifier)) {
-
- //int idx=scr->constants[identifier];
- int idx = codegen.get_name_map_pos(identifier);
- return idx | (GDFunction::ADDR_TYPE_CLASS_CONSTANT << GDFunction::ADDR_BITS); //argument (stack root)
- }
- if (scr->native.is_valid())
- nc = scr->native.ptr();
- scr = scr->_base;
- }
-
- // CLASS C++ Integer Constant
-
- if (nc) {
-
- bool success = false;
- int constant = ClassDB::get_integer_constant(nc->get_name(), identifier, &success);
- if (success) {
- Variant key = constant;
- int idx;
-
- if (!codegen.constant_map.has(key)) {
-
- idx = codegen.constant_map.size();
- codegen.constant_map[key] = idx;
-
- } else {
- idx = codegen.constant_map[key];
- }
-
- return idx | (GDFunction::ADDR_TYPE_LOCAL_CONSTANT << GDFunction::ADDR_BITS); //make it a local constant (faster access)
- }
- }
-
- owner = owner->_owner;
- }
-
- /*
- handled in constants now
- if (codegen.script->subclasses.has(identifier)) {
- //same with a subclass, make it a local constant.
- int idx = codegen.get_constant_pos(codegen.script->subclasses[identifier]);
- return idx|(GDFunction::ADDR_TYPE_LOCAL_CONSTANT<get_global_map().has(identifier)) {
-
- int idx = GDScriptLanguage::get_singleton()->get_global_map()[identifier];
- return idx | (GDFunction::ADDR_TYPE_GLOBAL << GDFunction::ADDR_BITS); //argument (stack root)
- }
-
- //not found, error
-
- _set_error("Identifier not found: " + String(identifier), p_expression);
-
- return -1;
-
- } break;
- case GDParser::Node::TYPE_CONSTANT: {
- //return constant
- const GDParser::ConstantNode *cn = static_cast(p_expression);
-
- int idx;
-
- if (!codegen.constant_map.has(cn->value)) {
-
- idx = codegen.constant_map.size();
- codegen.constant_map[cn->value] = idx;
-
- } else {
- idx = codegen.constant_map[cn->value];
- }
-
- return idx | (GDFunction::ADDR_TYPE_LOCAL_CONSTANT << GDFunction::ADDR_BITS); //argument (stack root)
-
- } break;
- case GDParser::Node::TYPE_SELF: {
- //return constant
- if (codegen.function_node && codegen.function_node->_static) {
- _set_error("'self' not present in static function!", p_expression);
- return -1;
- }
- return (GDFunction::ADDR_TYPE_SELF << GDFunction::ADDR_BITS);
- } break;
- case GDParser::Node::TYPE_ARRAY: {
-
- const GDParser::ArrayNode *an = static_cast(p_expression);
- Vector values;
-
- int slevel = p_stack_level;
-
- for (int i = 0; i < an->elements.size(); i++) {
-
- int ret = _parse_expression(codegen, an->elements[i], slevel);
- if (ret < 0)
- return ret;
- if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
- slevel++;
- codegen.alloc_stack(slevel);
- }
-
- values.push_back(ret);
- }
-
- codegen.opcodes.push_back(GDFunction::OPCODE_CONSTRUCT_ARRAY);
- codegen.opcodes.push_back(values.size());
- for (int i = 0; i < values.size(); i++)
- codegen.opcodes.push_back(values[i]);
-
- int dst_addr = (p_stack_level) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
- codegen.opcodes.push_back(dst_addr); // append the stack level as destination address of the opcode
- codegen.alloc_stack(p_stack_level);
- return dst_addr;
-
- } break;
- case GDParser::Node::TYPE_DICTIONARY: {
-
- const GDParser::DictionaryNode *dn = static_cast(p_expression);
- Vector values;
-
- int slevel = p_stack_level;
-
- for (int i = 0; i < dn->elements.size(); i++) {
-
- int ret = _parse_expression(codegen, dn->elements[i].key, slevel);
- if (ret < 0)
- return ret;
- if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
- slevel++;
- codegen.alloc_stack(slevel);
- }
-
- values.push_back(ret);
-
- ret = _parse_expression(codegen, dn->elements[i].value, slevel);
- if (ret < 0)
- return ret;
- if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
- slevel++;
- codegen.alloc_stack(slevel);
- }
-
- values.push_back(ret);
- }
-
- codegen.opcodes.push_back(GDFunction::OPCODE_CONSTRUCT_DICTIONARY);
- codegen.opcodes.push_back(dn->elements.size());
- for (int i = 0; i < values.size(); i++)
- codegen.opcodes.push_back(values[i]);
-
- int dst_addr = (p_stack_level) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
- codegen.opcodes.push_back(dst_addr); // append the stack level as destination address of the opcode
- codegen.alloc_stack(p_stack_level);
- return dst_addr;
-
- } break;
- case GDParser::Node::TYPE_OPERATOR: {
- //hell breaks loose
-
- const GDParser::OperatorNode *on = static_cast(p_expression);
- switch (on->op) {
-
- //call/constructor operator
- case GDParser::OperatorNode::OP_PARENT_CALL: {
-
- ERR_FAIL_COND_V(on->arguments.size() < 1, -1);
-
- const GDParser::IdentifierNode *in = (const GDParser::IdentifierNode *)on->arguments[0];
-
- Vector arguments;
- int slevel = p_stack_level;
- for (int i = 1; i < on->arguments.size(); i++) {
-
- int ret = _parse_expression(codegen, on->arguments[i], slevel);
- if (ret < 0)
- return ret;
- if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
- slevel++;
- codegen.alloc_stack(slevel);
- }
- arguments.push_back(ret);
- }
-
- //push call bytecode
- codegen.opcodes.push_back(GDFunction::OPCODE_CALL_SELF_BASE); // basic type constructor
-
- codegen.opcodes.push_back(codegen.get_name_map_pos(in->name)); //instance
- codegen.opcodes.push_back(arguments.size()); //argument count
- codegen.alloc_call(arguments.size());
- for (int i = 0; i < arguments.size(); i++)
- codegen.opcodes.push_back(arguments[i]); //arguments
-
- } break;
- case GDParser::OperatorNode::OP_CALL: {
-
- if (on->arguments[0]->type == GDParser::Node::TYPE_TYPE) {
- //construct a basic type
- ERR_FAIL_COND_V(on->arguments.size() < 1, -1);
-
- const GDParser::TypeNode *tn = (const GDParser::TypeNode *)on->arguments[0];
- int vtype = tn->vtype;
-
- Vector arguments;
- int slevel = p_stack_level;
- for (int i = 1; i < on->arguments.size(); i++) {
-
- int ret = _parse_expression(codegen, on->arguments[i], slevel);
- if (ret < 0)
- return ret;
- if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
- slevel++;
- codegen.alloc_stack(slevel);
- }
- arguments.push_back(ret);
- }
-
- //push call bytecode
- codegen.opcodes.push_back(GDFunction::OPCODE_CONSTRUCT); // basic type constructor
- codegen.opcodes.push_back(vtype); //instance
- codegen.opcodes.push_back(arguments.size()); //argument count
- codegen.alloc_call(arguments.size());
- for (int i = 0; i < arguments.size(); i++)
- codegen.opcodes.push_back(arguments[i]); //arguments
-
- } else if (on->arguments[0]->type == GDParser::Node::TYPE_BUILT_IN_FUNCTION) {
- //built in function
-
- ERR_FAIL_COND_V(on->arguments.size() < 1, -1);
-
- Vector arguments;
- int slevel = p_stack_level;
- for (int i = 1; i < on->arguments.size(); i++) {
-
- int ret = _parse_expression(codegen, on->arguments[i], slevel);
- if (ret < 0)
- return ret;
-
- if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
- slevel++;
- codegen.alloc_stack(slevel);
- }
-
- arguments.push_back(ret);
- }
-
- codegen.opcodes.push_back(GDFunction::OPCODE_CALL_BUILT_IN);
- codegen.opcodes.push_back(static_cast(on->arguments[0])->function);
- codegen.opcodes.push_back(on->arguments.size() - 1);
- codegen.alloc_call(on->arguments.size() - 1);
- for (int i = 0; i < arguments.size(); i++)
- codegen.opcodes.push_back(arguments[i]);
-
- } else {
- //regular function
- ERR_FAIL_COND_V(on->arguments.size() < 2, -1);
-
- const GDParser::Node *instance = on->arguments[0];
-
- if (instance->type == GDParser::Node::TYPE_SELF) {
- //room for optimization
- }
-
- Vector arguments;
- int slevel = p_stack_level;
-
- for (int i = 0; i < on->arguments.size(); i++) {
-
- int ret;
-
- if (i == 0 && on->arguments[i]->type == GDParser::Node::TYPE_SELF && codegen.function_node && codegen.function_node->_static) {
- //static call to self
- ret = (GDFunction::ADDR_TYPE_CLASS << GDFunction::ADDR_BITS);
- } else if (i == 1) {
-
- if (on->arguments[i]->type != GDParser::Node::TYPE_IDENTIFIER) {
- _set_error("Attempt to call a non-identifier.", on);
- return -1;
- }
- GDParser::IdentifierNode *id = static_cast(on->arguments[i]);
- ret = codegen.get_name_map_pos(id->name);
-
- } else {
-
- ret = _parse_expression(codegen, on->arguments[i], slevel);
- if (ret < 0)
- return ret;
- if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
- slevel++;
- codegen.alloc_stack(slevel);
- }
- }
- arguments.push_back(ret);
- }
-
- codegen.opcodes.push_back(p_root ? GDFunction::OPCODE_CALL : GDFunction::OPCODE_CALL_RETURN); // perform operator
- codegen.opcodes.push_back(on->arguments.size() - 2);
- codegen.alloc_call(on->arguments.size() - 2);
- for (int i = 0; i < arguments.size(); i++)
- codegen.opcodes.push_back(arguments[i]);
- }
- } break;
- case GDParser::OperatorNode::OP_YIELD: {
-
- ERR_FAIL_COND_V(on->arguments.size() && on->arguments.size() != 2, -1);
-
- Vector arguments;
- int slevel = p_stack_level;
- for (int i = 0; i < on->arguments.size(); i++) {
-
- int ret = _parse_expression(codegen, on->arguments[i], slevel);
- if (ret < 0)
- return ret;
- if (ret & (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS)) {
- slevel++;
- codegen.alloc_stack(slevel);
- }
- arguments.push_back(ret);
- }
-
- //push call bytecode
- codegen.opcodes.push_back(arguments.size() == 0 ? GDFunction::OPCODE_YIELD : GDFunction::OPCODE_YIELD_SIGNAL); // basic type constructor
- for (int i = 0; i < arguments.size(); i++)
- codegen.opcodes.push_back(arguments[i]); //arguments
- codegen.opcodes.push_back(GDFunction::OPCODE_YIELD_RESUME);
- //next will be where to place the result :)
-
- } break;
-
- //indexing operator
- case GDParser::OperatorNode::OP_INDEX:
- case GDParser::OperatorNode::OP_INDEX_NAMED: {
-
- ERR_FAIL_COND_V(on->arguments.size() != 2, -1);
-
- int slevel = p_stack_level;
- bool named = (on->op == GDParser::OperatorNode::OP_INDEX_NAMED);
-
- int from = _parse_expression(codegen, on->arguments[0], slevel);
- if (from < 0)
- return from;
-
- int index;
- if (named) {
- if (on->arguments[0]->type == GDParser::Node::TYPE_SELF && codegen.script && codegen.function_node && !codegen.function_node->_static) {
-
- GDParser::IdentifierNode *identifier = static_cast(on->arguments[1]);
- const Map::Element *MI = codegen.script->member_indices.find(identifier->name);
-
-#ifdef DEBUG_ENABLED
- if (MI && MI->get().getter == codegen.function_node->name) {
- String n = static_cast(on->arguments[1])->name;
- _set_error("Must use '" + n + "' instead of 'self." + n + "' in getter.", on);
- return -1;
- }
-#endif
-
- if (MI && MI->get().getter == "") {
- // Faster than indexing self (as if no self. had been used)
- return (MI->get().index) | (GDFunction::ADDR_TYPE_MEMBER << GDFunction::ADDR_BITS);
- }
- }
-
- index = codegen.get_name_map_pos(static_cast(on->arguments[1])->name);
-
- } else {
-
- if (on->arguments[1]->type == GDParser::Node::TYPE_CONSTANT && static_cast(on->arguments[1])->value.get_type() == Variant::STRING) {
- //also, somehow, named (speed up anyway)
- StringName name = static_cast(on->arguments[1])->value;
- index = codegen.get_name_map_pos(name);
- named = true;
-
- } else {
- //regular indexing
- if (from & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
- slevel++;
- codegen.alloc_stack(slevel);
- }
-
- index = _parse_expression(codegen, on->arguments[1], slevel);
- if (index < 0)
- return index;
- }
- }
-
- codegen.opcodes.push_back(named ? GDFunction::OPCODE_GET_NAMED : GDFunction::OPCODE_GET); // perform operator
- codegen.opcodes.push_back(from); // argument 1
- codegen.opcodes.push_back(index); // argument 2 (unary only takes one parameter)
-
- } break;
- case GDParser::OperatorNode::OP_AND: {
-
- // AND operator with early out on failure
-
- int res = _parse_expression(codegen, on->arguments[0], p_stack_level);
- if (res < 0)
- return res;
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF_NOT);
- codegen.opcodes.push_back(res);
- int jump_fail_pos = codegen.opcodes.size();
- codegen.opcodes.push_back(0);
-
- res = _parse_expression(codegen, on->arguments[1], p_stack_level);
- if (res < 0)
- return res;
-
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF_NOT);
- codegen.opcodes.push_back(res);
- int jump_fail_pos2 = codegen.opcodes.size();
- codegen.opcodes.push_back(0);
-
- codegen.alloc_stack(p_stack_level); //it will be used..
- codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN_TRUE);
- codegen.opcodes.push_back(p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
- codegen.opcodes.push_back(codegen.opcodes.size() + 3);
- codegen.opcodes[jump_fail_pos] = codegen.opcodes.size();
- codegen.opcodes[jump_fail_pos2] = codegen.opcodes.size();
- codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN_FALSE);
- codegen.opcodes.push_back(p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
- return p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS;
-
- } break;
- case GDParser::OperatorNode::OP_OR: {
-
- // OR operator with early out on success
-
- int res = _parse_expression(codegen, on->arguments[0], p_stack_level);
- if (res < 0)
- return res;
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF);
- codegen.opcodes.push_back(res);
- int jump_success_pos = codegen.opcodes.size();
- codegen.opcodes.push_back(0);
-
- res = _parse_expression(codegen, on->arguments[1], p_stack_level);
- if (res < 0)
- return res;
-
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF);
- codegen.opcodes.push_back(res);
- int jump_success_pos2 = codegen.opcodes.size();
- codegen.opcodes.push_back(0);
-
- codegen.alloc_stack(p_stack_level); //it will be used..
- codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN_FALSE);
- codegen.opcodes.push_back(p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
- codegen.opcodes.push_back(codegen.opcodes.size() + 3);
- codegen.opcodes[jump_success_pos] = codegen.opcodes.size();
- codegen.opcodes[jump_success_pos2] = codegen.opcodes.size();
- codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN_TRUE);
- codegen.opcodes.push_back(p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
- return p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS;
-
- } break;
- // ternary operators
- case GDParser::OperatorNode::OP_TERNARY_IF: {
-
- // x IF a ELSE y operator with early out on failure
-
- int res = _parse_expression(codegen, on->arguments[0], p_stack_level);
- if (res < 0)
- return res;
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF_NOT);
- codegen.opcodes.push_back(res);
- int jump_fail_pos = codegen.opcodes.size();
- codegen.opcodes.push_back(0);
-
- res = _parse_expression(codegen, on->arguments[1], p_stack_level);
- if (res < 0)
- return res;
-
- codegen.alloc_stack(p_stack_level); //it will be used..
- codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN);
- codegen.opcodes.push_back(p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
- codegen.opcodes.push_back(res);
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
- int jump_past_pos = codegen.opcodes.size();
- codegen.opcodes.push_back(0);
-
- codegen.opcodes[jump_fail_pos] = codegen.opcodes.size();
- res = _parse_expression(codegen, on->arguments[2], p_stack_level);
- if (res < 0)
- return res;
-
- codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN);
- codegen.opcodes.push_back(p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
- codegen.opcodes.push_back(res);
-
- codegen.opcodes[jump_past_pos] = codegen.opcodes.size();
-
- return p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS;
-
- } break;
- //unary operators
- case GDParser::OperatorNode::OP_NEG: {
- if (!_create_unary_operator(codegen, on, Variant::OP_NEGATE, p_stack_level)) return -1;
- } break;
- case GDParser::OperatorNode::OP_NOT: {
- if (!_create_unary_operator(codegen, on, Variant::OP_NOT, p_stack_level)) return -1;
- } break;
- case GDParser::OperatorNode::OP_BIT_INVERT: {
- if (!_create_unary_operator(codegen, on, Variant::OP_BIT_NEGATE, p_stack_level)) return -1;
- } break;
- case GDParser::OperatorNode::OP_PREINC: {
- } break; //?
- case GDParser::OperatorNode::OP_PREDEC: {
- } break;
- case GDParser::OperatorNode::OP_INC: {
- } break;
- case GDParser::OperatorNode::OP_DEC: {
- } break;
- //binary operators (in precedence order)
- case GDParser::OperatorNode::OP_IN: {
- if (!_create_binary_operator(codegen, on, Variant::OP_IN, p_stack_level)) return -1;
- } break;
- case GDParser::OperatorNode::OP_EQUAL: {
- if (!_create_binary_operator(codegen, on, Variant::OP_EQUAL, p_stack_level)) return -1;
- } break;
- case GDParser::OperatorNode::OP_NOT_EQUAL: {
- if (!_create_binary_operator(codegen, on, Variant::OP_NOT_EQUAL, p_stack_level)) return -1;
- } break;
- case GDParser::OperatorNode::OP_LESS: {
- if (!_create_binary_operator(codegen, on, Variant::OP_LESS, p_stack_level)) return -1;
- } break;
- case GDParser::OperatorNode::OP_LESS_EQUAL: {
- if (!_create_binary_operator(codegen, on, Variant::OP_LESS_EQUAL, p_stack_level)) return -1;
- } break;
- case GDParser::OperatorNode::OP_GREATER: {
- if (!_create_binary_operator(codegen, on, Variant::OP_GREATER, p_stack_level)) return -1;
- } break;
- case GDParser::OperatorNode::OP_GREATER_EQUAL: {
- if (!_create_binary_operator(codegen, on, Variant::OP_GREATER_EQUAL, p_stack_level)) return -1;
- } break;
- case GDParser::OperatorNode::OP_ADD: {
- if (!_create_binary_operator(codegen, on, Variant::OP_ADD, p_stack_level)) return -1;
- } break;
- case GDParser::OperatorNode::OP_SUB: {
- if (!_create_binary_operator(codegen, on, Variant::OP_SUBTRACT, p_stack_level)) return -1;
- } break;
- case GDParser::OperatorNode::OP_MUL: {
- if (!_create_binary_operator(codegen, on, Variant::OP_MULTIPLY, p_stack_level)) return -1;
- } break;
- case GDParser::OperatorNode::OP_DIV: {
- if (!_create_binary_operator(codegen, on, Variant::OP_DIVIDE, p_stack_level)) return -1;
- } break;
- case GDParser::OperatorNode::OP_MOD: {
- if (!_create_binary_operator(codegen, on, Variant::OP_MODULE, p_stack_level)) return -1;
- } break;
- //case GDParser::OperatorNode::OP_SHIFT_LEFT: { if (!_create_binary_operator(codegen,on,Variant::OP_SHIFT_LEFT,p_stack_level)) return -1;} break;
- //case GDParser::OperatorNode::OP_SHIFT_RIGHT: { if (!_create_binary_operator(codegen,on,Variant::OP_SHIFT_RIGHT,p_stack_level)) return -1;} break;
- case GDParser::OperatorNode::OP_BIT_AND: {
- if (!_create_binary_operator(codegen, on, Variant::OP_BIT_AND, p_stack_level)) return -1;
- } break;
- case GDParser::OperatorNode::OP_BIT_OR: {
- if (!_create_binary_operator(codegen, on, Variant::OP_BIT_OR, p_stack_level)) return -1;
- } break;
- case GDParser::OperatorNode::OP_BIT_XOR: {
- if (!_create_binary_operator(codegen, on, Variant::OP_BIT_XOR, p_stack_level)) return -1;
- } break;
- //shift
- case GDParser::OperatorNode::OP_SHIFT_LEFT: {
- if (!_create_binary_operator(codegen, on, Variant::OP_SHIFT_LEFT, p_stack_level)) return -1;
- } break;
- case GDParser::OperatorNode::OP_SHIFT_RIGHT: {
- if (!_create_binary_operator(codegen, on, Variant::OP_SHIFT_RIGHT, p_stack_level)) return -1;
- } break;
- //assignment operators
- case GDParser::OperatorNode::OP_ASSIGN_ADD:
- case GDParser::OperatorNode::OP_ASSIGN_SUB:
- case GDParser::OperatorNode::OP_ASSIGN_MUL:
- case GDParser::OperatorNode::OP_ASSIGN_DIV:
- case GDParser::OperatorNode::OP_ASSIGN_MOD:
- case GDParser::OperatorNode::OP_ASSIGN_SHIFT_LEFT:
- case GDParser::OperatorNode::OP_ASSIGN_SHIFT_RIGHT:
- case GDParser::OperatorNode::OP_ASSIGN_BIT_AND:
- case GDParser::OperatorNode::OP_ASSIGN_BIT_OR:
- case GDParser::OperatorNode::OP_ASSIGN_BIT_XOR:
- case GDParser::OperatorNode::OP_INIT_ASSIGN:
- case GDParser::OperatorNode::OP_ASSIGN: {
-
- ERR_FAIL_COND_V(on->arguments.size() != 2, -1);
-
- if (on->arguments[0]->type == GDParser::Node::TYPE_OPERATOR && (static_cast(on->arguments[0])->op == GDParser::OperatorNode::OP_INDEX || static_cast(on->arguments[0])->op == GDParser::OperatorNode::OP_INDEX_NAMED)) {
-//SET (chained) MODE!!
-
-#ifdef DEBUG_ENABLED
- if (static_cast(on->arguments[0])->op == GDParser::OperatorNode::OP_INDEX_NAMED) {
- const GDParser::OperatorNode *inon = static_cast(on->arguments[0]);
-
- if (inon->arguments[0]->type == GDParser::Node::TYPE_SELF && codegen.script && codegen.function_node && !codegen.function_node->_static) {
-
- const Map::Element *MI = codegen.script->member_indices.find(static_cast(inon->arguments[1])->name);
- if (MI && MI->get().setter == codegen.function_node->name) {
- String n = static_cast(inon->arguments[1])->name;
- _set_error("Must use '" + n + "' instead of 'self." + n + "' in setter.", inon);
- return -1;
- }
- }
- }
-#endif
-
- int slevel = p_stack_level;
-
- GDParser::OperatorNode *op = static_cast(on->arguments[0]);
-
- /* Find chain of sets */
-
- StringName assign_property;
-
- List chain;
-
- {
- //create get/set chain
- GDParser::OperatorNode *n = op;
- while (true) {
-
- chain.push_back(n);
- if (n->arguments[0]->type != GDParser::Node::TYPE_OPERATOR) {
-
- //check for a built-in property
- if (n->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER) {
-
- GDParser::IdentifierNode *identifier = static_cast(n->arguments[0]);
- if (_is_class_member_property(codegen, identifier->name)) {
- assign_property = identifier->name;
- }
- }
- break;
- }
- n = static_cast(n->arguments[0]);
- if (n->op != GDParser::OperatorNode::OP_INDEX && n->op != GDParser::OperatorNode::OP_INDEX_NAMED)
- break;
- }
- }
-
- /* Chain of gets */
-
- //get at (potential) root stack pos, so it can be returned
- int prev_pos = _parse_expression(codegen, chain.back()->get()->arguments[0], slevel);
- if (prev_pos < 0)
- return prev_pos;
- int retval = prev_pos;
-
- //print_line("retval: "+itos(retval));
-
- if (retval & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
- slevel++;
- codegen.alloc_stack(slevel);
- }
-
- Vector setchain;
-
- if (assign_property != StringName()) {
-
- // recover and assign at the end, this allows stuff like
- // position.x+=2.0
- // in Node2D
- setchain.push_back(prev_pos);
- setchain.push_back(codegen.get_name_map_pos(assign_property));
- setchain.push_back(GDFunction::OPCODE_SET_MEMBER);
- }
-
- for (List::Element *E = chain.back(); E; E = E->prev()) {
-
- if (E == chain.front()) //ignore first
- break;
-
- bool named = E->get()->op == GDParser::OperatorNode::OP_INDEX_NAMED;
- int key_idx;
-
- if (named) {
-
- key_idx = codegen.get_name_map_pos(static_cast(E->get()->arguments[1])->name);
- //printf("named key %x\n",key_idx);
-
- } else {
-
- if (prev_pos & (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS)) {
- slevel++;
- codegen.alloc_stack(slevel);
- }
-
- GDParser::Node *key = E->get()->arguments[1];
- key_idx = _parse_expression(codegen, key, slevel);
- //printf("expr key %x\n",key_idx);
-
- //stack was raised here if retval was stack but..
- }
-
- if (key_idx < 0) //error
- return key_idx;
-
- codegen.opcodes.push_back(named ? GDFunction::OPCODE_GET_NAMED : GDFunction::OPCODE_GET);
- codegen.opcodes.push_back(prev_pos);
- codegen.opcodes.push_back(key_idx);
- slevel++;
- codegen.alloc_stack(slevel);
- int dst_pos = (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) | slevel;
-
- codegen.opcodes.push_back(dst_pos);
-
- //add in reverse order, since it will be reverted
-
- setchain.push_back(dst_pos);
- setchain.push_back(key_idx);
- setchain.push_back(prev_pos);
- setchain.push_back(named ? GDFunction::OPCODE_SET_NAMED : GDFunction::OPCODE_SET);
-
- prev_pos = dst_pos;
- }
-
- setchain.invert();
-
- int set_index;
- bool named = false;
-
- if (static_cast(op)->op == GDParser::OperatorNode::OP_INDEX_NAMED) {
-
- set_index = codegen.get_name_map_pos(static_cast(op->arguments[1])->name);
- named = true;
- } else {
-
- set_index = _parse_expression(codegen, op->arguments[1], slevel + 1);
- named = false;
- }
-
- if (set_index < 0) //error
- return set_index;
-
- if (set_index & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
- slevel++;
- codegen.alloc_stack(slevel);
- }
-
- int set_value = _parse_assign_right_expression(codegen, on, slevel + 1);
- if (set_value < 0) //error
- return set_value;
-
- codegen.opcodes.push_back(named ? GDFunction::OPCODE_SET_NAMED : GDFunction::OPCODE_SET);
- codegen.opcodes.push_back(prev_pos);
- codegen.opcodes.push_back(set_index);
- codegen.opcodes.push_back(set_value);
-
- for (int i = 0; i < setchain.size(); i++) {
-
- codegen.opcodes.push_back(setchain[i]);
- }
-
- return retval;
-
- } else if (on->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER && _is_class_member_property(codegen, static_cast(on->arguments[0])->name)) {
- //assignment to member property
-
- int slevel = p_stack_level;
-
- int src_address = _parse_assign_right_expression(codegen, on, slevel);
- if (src_address < 0)
- return -1;
-
- StringName name = static_cast(on->arguments[0])->name;
-
- codegen.opcodes.push_back(GDFunction::OPCODE_SET_MEMBER);
- codegen.opcodes.push_back(codegen.get_name_map_pos(name));
- codegen.opcodes.push_back(src_address);
-
- return GDFunction::ADDR_TYPE_NIL << GDFunction::ADDR_BITS;
- } else {
-
- //REGULAR ASSIGNMENT MODE!!
-
- int slevel = p_stack_level;
-
- int dst_address_a = _parse_expression(codegen, on->arguments[0], slevel, false, on->op == GDParser::OperatorNode::OP_INIT_ASSIGN);
- if (dst_address_a < 0)
- return -1;
-
- if (dst_address_a & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
- slevel++;
- codegen.alloc_stack(slevel);
- }
-
- int src_address_b = _parse_assign_right_expression(codegen, on, slevel);
- if (src_address_b < 0)
- return -1;
-
- codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN); // perform operator
- codegen.opcodes.push_back(dst_address_a); // argument 1
- codegen.opcodes.push_back(src_address_b); // argument 2 (unary only takes one parameter)
- return dst_address_a; //if anything, returns wathever was assigned or correct stack position
- }
-
- } break;
- case GDParser::OperatorNode::OP_IS: {
-
- ERR_FAIL_COND_V(on->arguments.size() != 2, false);
-
- int slevel = p_stack_level;
-
- int src_address_a = _parse_expression(codegen, on->arguments[0], slevel);
- if (src_address_a < 0)
- return -1;
-
- if (src_address_a & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS)
- slevel++; //uses stack for return, increase stack
-
- int src_address_b = _parse_expression(codegen, on->arguments[1], slevel);
- if (src_address_b < 0)
- return -1;
-
- codegen.opcodes.push_back(GDFunction::OPCODE_EXTENDS_TEST); // perform operator
- codegen.opcodes.push_back(src_address_a); // argument 1
- codegen.opcodes.push_back(src_address_b); // argument 2 (unary only takes one parameter)
-
- } break;
- default: {
-
- ERR_EXPLAIN("Bug in bytecode compiler, unexpected operator #" + itos(on->op) + " in parse tree while parsing expression.");
- ERR_FAIL_V(0); //unreachable code
-
- } break;
- }
-
- int dst_addr = (p_stack_level) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
- codegen.opcodes.push_back(dst_addr); // append the stack level as destination address of the opcode
- codegen.alloc_stack(p_stack_level);
- return dst_addr;
- } break;
- //TYPE_TYPE,
- default: {
-
- ERR_EXPLAIN("Bug in bytecode compiler, unexpected node in parse tree while parsing expression.");
- ERR_FAIL_V(-1); //unreachable code
- } break;
- }
-
- ERR_FAIL_V(-1); //unreachable code
-}
-
-Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_block, int p_stack_level, int p_break_addr, int p_continue_addr) {
-
- codegen.push_stack_identifiers();
- int new_identifiers = 0;
- codegen.current_line = p_block->line;
-
- for (int i = 0; i < p_block->statements.size(); i++) {
-
- const GDParser::Node *s = p_block->statements[i];
-
- switch (s->type) {
- case GDParser::Node::TYPE_NEWLINE: {
-#ifdef DEBUG_ENABLED
- const GDParser::NewLineNode *nl = static_cast(s);
- codegen.opcodes.push_back(GDFunction::OPCODE_LINE);
- codegen.opcodes.push_back(nl->line);
- codegen.current_line = nl->line;
-#endif
- } break;
- case GDParser::Node::TYPE_CONTROL_FLOW: {
- // try subblocks
-
- const GDParser::ControlFlowNode *cf = static_cast(s);
-
- switch (cf->cf_type) {
-
- case GDParser::ControlFlowNode::CF_MATCH: {
- GDParser::MatchNode *match = cf->match;
-
- GDParser::IdentifierNode *id = memnew(GDParser::IdentifierNode);
- id->name = "#match_value";
-
- // var #match_value
- // copied because there is no _parse_statement :(
- codegen.add_stack_identifier(id->name, p_stack_level++);
- codegen.alloc_stack(p_stack_level);
- new_identifiers++;
-
- GDParser::OperatorNode *op = memnew(GDParser::OperatorNode);
- op->op = GDParser::OperatorNode::OP_ASSIGN;
- op->arguments.push_back(id);
- op->arguments.push_back(match->val_to_match);
-
- int ret = _parse_expression(codegen, op, p_stack_level);
- if (ret < 0) {
- return ERR_PARSE_ERROR;
- }
-
- // break address
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
- codegen.opcodes.push_back(codegen.opcodes.size() + 3);
- int break_addr = codegen.opcodes.size();
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
- codegen.opcodes.push_back(0); // break addr
-
- for (int j = 0; j < match->compiled_pattern_branches.size(); j++) {
- GDParser::MatchNode::CompiledPatternBranch branch = match->compiled_pattern_branches[j];
-
- // jump over continue
- // jump unconditionally
- // continue address
- // compile the condition
- int ret = _parse_expression(codegen, branch.compiled_pattern, p_stack_level);
- if (ret < 0) {
- return ERR_PARSE_ERROR;
- }
-
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF);
- codegen.opcodes.push_back(ret);
- codegen.opcodes.push_back(codegen.opcodes.size() + 3);
- int continue_addr = codegen.opcodes.size();
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
- codegen.opcodes.push_back(0);
-
- Error err = _parse_block(codegen, branch.body, p_stack_level, p_break_addr, continue_addr);
- if (err) {
- return ERR_PARSE_ERROR;
- }
-
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
- codegen.opcodes.push_back(break_addr);
-
- codegen.opcodes[continue_addr + 1] = codegen.opcodes.size();
- }
-
- codegen.opcodes[break_addr + 1] = codegen.opcodes.size();
-
- } break;
-
- case GDParser::ControlFlowNode::CF_IF: {
-
-#ifdef DEBUG_ENABLED
- codegen.opcodes.push_back(GDFunction::OPCODE_LINE);
- codegen.opcodes.push_back(cf->line);
- codegen.current_line = cf->line;
-#endif
- int ret = _parse_expression(codegen, cf->arguments[0], p_stack_level, false);
- if (ret < 0)
- return ERR_PARSE_ERROR;
-
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF_NOT);
- codegen.opcodes.push_back(ret);
- int else_addr = codegen.opcodes.size();
- codegen.opcodes.push_back(0); //temporary
-
- Error err = _parse_block(codegen, cf->body, p_stack_level, p_break_addr, p_continue_addr);
- if (err)
- return err;
-
- if (cf->body_else) {
-
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
- int end_addr = codegen.opcodes.size();
- codegen.opcodes.push_back(0);
- codegen.opcodes[else_addr] = codegen.opcodes.size();
-
- Error err = _parse_block(codegen, cf->body_else, p_stack_level, p_break_addr, p_continue_addr);
- if (err)
- return err;
-
- codegen.opcodes[end_addr] = codegen.opcodes.size();
- } else {
- //end without else
- codegen.opcodes[else_addr] = codegen.opcodes.size();
- }
-
- } break;
- case GDParser::ControlFlowNode::CF_FOR: {
-
- int slevel = p_stack_level;
- int iter_stack_pos = slevel;
- int iterator_pos = (slevel++) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
- int counter_pos = (slevel++) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
- int container_pos = (slevel++) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
- codegen.alloc_stack(slevel);
-
- codegen.push_stack_identifiers();
- codegen.add_stack_identifier(static_cast(cf->arguments[0])->name, iter_stack_pos);
-
- int ret = _parse_expression(codegen, cf->arguments[1], slevel, false);
- if (ret < 0)
- return ERR_COMPILATION_FAILED;
-
- //assign container
- codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN);
- codegen.opcodes.push_back(container_pos);
- codegen.opcodes.push_back(ret);
-
- //begin loop
- codegen.opcodes.push_back(GDFunction::OPCODE_ITERATE_BEGIN);
- codegen.opcodes.push_back(counter_pos);
- codegen.opcodes.push_back(container_pos);
- codegen.opcodes.push_back(codegen.opcodes.size() + 4);
- codegen.opcodes.push_back(iterator_pos);
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP); //skip code for next
- codegen.opcodes.push_back(codegen.opcodes.size() + 8);
- //break loop
- int break_pos = codegen.opcodes.size();
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP); //skip code for next
- codegen.opcodes.push_back(0); //skip code for next
- //next loop
- int continue_pos = codegen.opcodes.size();
- codegen.opcodes.push_back(GDFunction::OPCODE_ITERATE);
- codegen.opcodes.push_back(counter_pos);
- codegen.opcodes.push_back(container_pos);
- codegen.opcodes.push_back(break_pos);
- codegen.opcodes.push_back(iterator_pos);
-
- Error err = _parse_block(codegen, cf->body, slevel, break_pos, continue_pos);
- if (err)
- return err;
-
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
- codegen.opcodes.push_back(continue_pos);
- codegen.opcodes[break_pos + 1] = codegen.opcodes.size();
-
- codegen.pop_stack_identifiers();
-
- } break;
- case GDParser::ControlFlowNode::CF_WHILE: {
-
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
- codegen.opcodes.push_back(codegen.opcodes.size() + 3);
- int break_addr = codegen.opcodes.size();
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
- codegen.opcodes.push_back(0);
- int continue_addr = codegen.opcodes.size();
-
- int ret = _parse_expression(codegen, cf->arguments[0], p_stack_level, false);
- if (ret < 0)
- return ERR_PARSE_ERROR;
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF_NOT);
- codegen.opcodes.push_back(ret);
- codegen.opcodes.push_back(break_addr);
- Error err = _parse_block(codegen, cf->body, p_stack_level, break_addr, continue_addr);
- if (err)
- return err;
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
- codegen.opcodes.push_back(continue_addr);
-
- codegen.opcodes[break_addr + 1] = codegen.opcodes.size();
-
- } break;
- case GDParser::ControlFlowNode::CF_SWITCH: {
-
- } break;
- case GDParser::ControlFlowNode::CF_BREAK: {
-
- if (p_break_addr < 0) {
-
- _set_error("'break'' not within loop", cf);
- return ERR_COMPILATION_FAILED;
- }
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
- codegen.opcodes.push_back(p_break_addr);
-
- } break;
- case GDParser::ControlFlowNode::CF_CONTINUE: {
-
- if (p_continue_addr < 0) {
-
- _set_error("'continue' not within loop", cf);
- return ERR_COMPILATION_FAILED;
- }
-
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
- codegen.opcodes.push_back(p_continue_addr);
-
- } break;
- case GDParser::ControlFlowNode::CF_RETURN: {
-
- int ret;
-
- if (cf->arguments.size()) {
-
- ret = _parse_expression(codegen, cf->arguments[0], p_stack_level, false);
- if (ret < 0)
- return ERR_PARSE_ERROR;
-
- } else {
-
- ret = GDFunction::ADDR_TYPE_NIL << GDFunction::ADDR_BITS;
- }
-
- codegen.opcodes.push_back(GDFunction::OPCODE_RETURN);
- codegen.opcodes.push_back(ret);
-
- } break;
- }
- } break;
- case GDParser::Node::TYPE_ASSERT: {
-#ifdef DEBUG_ENABLED
- // try subblocks
-
- const GDParser::AssertNode *as = static_cast(s);
-
- int ret = _parse_expression(codegen, as->condition, p_stack_level, false);
- if (ret < 0)
- return ERR_PARSE_ERROR;
-
- codegen.opcodes.push_back(GDFunction::OPCODE_ASSERT);
- codegen.opcodes.push_back(ret);
-#endif
- } break;
- case GDParser::Node::TYPE_BREAKPOINT: {
-#ifdef DEBUG_ENABLED
- // try subblocks
- codegen.opcodes.push_back(GDFunction::OPCODE_BREAKPOINT);
-#endif
- } break;
- case GDParser::Node::TYPE_LOCAL_VAR: {
-
- const GDParser::LocalVarNode *lv = static_cast(s);
-
- if (_is_class_member_property(codegen, lv->name)) {
- _set_error("Name for local variable '" + String(lv->name) + "' can't shadow class property of the same name.", lv);
- return ERR_ALREADY_EXISTS;
- }
-
- codegen.add_stack_identifier(lv->name, p_stack_level++);
- codegen.alloc_stack(p_stack_level);
- new_identifiers++;
-
- } break;
- default: {
- //expression
- int ret = _parse_expression(codegen, s, p_stack_level, true);
- if (ret < 0)
- return ERR_PARSE_ERROR;
- } break;
- }
- }
- codegen.pop_stack_identifiers();
- return OK;
-}
-
-Error GDCompiler::_parse_function(GDScript *p_script, const GDParser::ClassNode *p_class, const GDParser::FunctionNode *p_func, bool p_for_ready) {
-
- Vector bytecode;
- CodeGen codegen;
-
- codegen.class_node = p_class;
- codegen.script = p_script;
- codegen.function_node = p_func;
- codegen.stack_max = 0;
- codegen.current_line = 0;
- codegen.call_max = 0;
- codegen.debug_stack = ScriptDebugger::get_singleton() != NULL;
- Vector argnames;
-
- int stack_level = 0;
-
- if (p_func) {
- for (int i = 0; i < p_func->arguments.size(); i++) {
- if (_is_class_member_property(p_script, p_func->arguments[i])) {
- _set_error("Name for argument '" + String(p_func->arguments[i]) + "' can't shadow class property of the same name.", p_func);
- return ERR_ALREADY_EXISTS;
- }
- codegen.add_stack_identifier(p_func->arguments[i], i);
-#ifdef TOOLS_ENABLED
- argnames.push_back(p_func->arguments[i]);
-#endif
- }
- stack_level = p_func->arguments.size();
- }
-
- codegen.alloc_stack(stack_level);
-
- /* Parse initializer -if applies- */
-
- bool is_initializer = !p_for_ready && !p_func;
-
- if (is_initializer || (p_func && String(p_func->name) == "_init")) {
- //parse initializer for class members
- if (!p_func && p_class->extends_used && p_script->native.is_null()) {
-
- //call implicit parent constructor
- codegen.opcodes.push_back(GDFunction::OPCODE_CALL_SELF_BASE);
- codegen.opcodes.push_back(codegen.get_name_map_pos("_init"));
- codegen.opcodes.push_back(0);
- codegen.opcodes.push_back((GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) | 0);
- }
- Error err = _parse_block(codegen, p_class->initializer, stack_level);
- if (err)
- return err;
- is_initializer = true;
- }
-
- if (p_for_ready || (p_func && String(p_func->name) == "_ready")) {
- //parse initializer for class members
- if (p_class->ready->statements.size()) {
- Error err = _parse_block(codegen, p_class->ready, stack_level);
- if (err)
- return err;
- }
- }
-
- /* Parse default argument code -if applies- */
-
- Vector defarg_addr;
- StringName func_name;
-
- if (p_func) {
-
- if (p_func->default_values.size()) {
-
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_TO_DEF_ARGUMENT);
- defarg_addr.push_back(codegen.opcodes.size());
- for (int i = 0; i < p_func->default_values.size(); i++) {
-
- _parse_expression(codegen, p_func->default_values[i], stack_level, true);
- defarg_addr.push_back(codegen.opcodes.size());
- }
-
- defarg_addr.invert();
- }
-
- Error err = _parse_block(codegen, p_func->body, stack_level);
- if (err)
- return err;
-
- func_name = p_func->name;
- } else {
- if (p_for_ready)
- func_name = "_ready";
- else
- func_name = "_init";
- }
-
- codegen.opcodes.push_back(GDFunction::OPCODE_END);
-
- /*
- if (String(p_func->name)=="") { //initializer func
- gdfunc = &p_script->initializer;
- */
- //} else { //regular func
- p_script->member_functions[func_name] = memnew(GDFunction);
- GDFunction *gdfunc = p_script->member_functions[func_name];
- //}
-
- if (p_func) {
- gdfunc->_static = p_func->_static;
- gdfunc->rpc_mode = p_func->rpc_mode;
- }
-
-#ifdef TOOLS_ENABLED
- gdfunc->arg_names = argnames;
-#endif
- //constants
- if (codegen.constant_map.size()) {
- gdfunc->_constant_count = codegen.constant_map.size();
- gdfunc->constants.resize(codegen.constant_map.size());
- gdfunc->_constants_ptr = &gdfunc->constants[0];
- const Variant *K = NULL;
- while ((K = codegen.constant_map.next(K))) {
- int idx = codegen.constant_map[*K];
- gdfunc->constants[idx] = *K;
- }
- } else {
-
- gdfunc->_constants_ptr = NULL;
- gdfunc->_constant_count = 0;
- }
- //global names
- if (codegen.name_map.size()) {
-
- gdfunc->global_names.resize(codegen.name_map.size());
- gdfunc->_global_names_ptr = &gdfunc->global_names[0];
- for (Map::Element *E = codegen.name_map.front(); E; E = E->next()) {
-
- gdfunc->global_names[E->get()] = E->key();
- }
- gdfunc->_global_names_count = gdfunc->global_names.size();
-
- } else {
- gdfunc->_global_names_ptr = NULL;
- gdfunc->_global_names_count = 0;
- }
-
- if (codegen.opcodes.size()) {
-
- gdfunc->code = codegen.opcodes;
- gdfunc->_code_ptr = &gdfunc->code[0];
- gdfunc->_code_size = codegen.opcodes.size();
-
- } else {
-
- gdfunc->_code_ptr = NULL;
- gdfunc->_code_size = 0;
- }
-
- if (defarg_addr.size()) {
-
- gdfunc->default_arguments = defarg_addr;
- gdfunc->_default_arg_count = defarg_addr.size() - 1;
- gdfunc->_default_arg_ptr = &gdfunc->default_arguments[0];
- } else {
- gdfunc->_default_arg_count = 0;
- gdfunc->_default_arg_ptr = NULL;
- }
-
- gdfunc->_argument_count = p_func ? p_func->arguments.size() : 0;
- gdfunc->_stack_size = codegen.stack_max;
- gdfunc->_call_size = codegen.call_max;
- gdfunc->name = func_name;
-#ifdef DEBUG_ENABLED
- if (ScriptDebugger::get_singleton()) {
- String signature;
- //path
- if (p_script->get_path() != String())
- signature += p_script->get_path();
- //loc
- if (p_func) {
- signature += "::" + itos(p_func->body->line);
- } else {
- signature += "::0";
- }
-
- //function and class
-
- if (p_class->name) {
- signature += "::" + String(p_class->name) + "." + String(func_name);
- } else {
- signature += "::" + String(func_name);
- }
-
- gdfunc->profile.signature = signature;
- }
-#endif
- gdfunc->_script = p_script;
- gdfunc->source = source;
-
-#ifdef DEBUG_ENABLED
-
- {
- gdfunc->func_cname = (String(source) + " - " + String(func_name)).utf8();
- gdfunc->_func_cname = gdfunc->func_cname.get_data();
- }
-
-#endif
- if (p_func) {
- gdfunc->_initial_line = p_func->line;
-#ifdef TOOLS_ENABLED
-
- p_script->member_lines[func_name] = p_func->line;
-#endif
- } else {
- gdfunc->_initial_line = 0;
- }
-
- if (codegen.debug_stack)
- gdfunc->stack_debug = codegen.stack_debug;
-
- if (is_initializer)
- p_script->initializer = gdfunc;
-
- return OK;
-}
-
-Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDParser::ClassNode *p_class, bool p_keep_state) {
-
- Map > old_subclasses;
-
- if (p_keep_state) {
- old_subclasses = p_script->subclasses;
- }
-
- p_script->native = Ref();
- p_script->base = Ref();
- p_script->_base = NULL;
- p_script->members.clear();
- p_script->constants.clear();
- for (Map::Element *E = p_script->member_functions.front(); E; E = E->next()) {
- memdelete(E->get());
- }
- p_script->member_functions.clear();
- p_script->member_indices.clear();
- p_script->member_info.clear();
- p_script->_signals.clear();
- p_script->initializer = NULL;
-
- p_script->subclasses.clear();
- p_script->_owner = p_owner;
- p_script->tool = p_class->tool;
- p_script->name = p_class->name;
-
- Ref native;
-
- if (p_class->extends_used) {
- //do inheritance
- String path = p_class->extends_file;
-
- Ref script;
-
- if (path != "") {
- //path (and optionally subclasses)
-
- if (path.is_rel_path()) {
-
- String base;
-
- if (p_owner) {
- GDScript *current_class = p_owner;
- while (current_class != NULL) {
- base = current_class->get_path();
- if (base == "")
- current_class = current_class->_owner;
- else
- break;
- }
- } else {
- base = p_script->get_path();
- }
-
- if (base == "" || base.is_rel_path()) {
- _set_error("Could not resolve relative path for parent class: " + path, p_class);
- return ERR_FILE_NOT_FOUND;
- }
- path = base.get_base_dir().plus_file(path).simplify_path();
- }
- script = ResourceLoader::load(path);
- if (script.is_null()) {
- _set_error("Could not load base class: " + path, p_class);
- return ERR_FILE_NOT_FOUND;
- }
- if (!script->valid) {
-
- _set_error("Script not fully loaded (cyclic preload?): " + path, p_class);
- return ERR_BUSY;
- }
- //print_line("EXTENDS PATH: "+path+" script is "+itos(script.is_valid())+" indices is "+itos(script->member_indices.size())+" valid? "+itos(script->valid));
-
- if (p_class->extends_class.size()) {
-
- for (int i = 0; i < p_class->extends_class.size(); i++) {
-
- String sub = p_class->extends_class[i];
- if (script->subclasses.has(sub)) {
-
- Ref