summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-11-16 22:12:22 +0100
committerGitHub <noreply@github.com>2017-11-16 22:12:22 +0100
commitab3cd9713841bc4e7f55851198f2e465c6151b63 (patch)
treed98e2e158ec7839ba6c04116822e7cdc910da93b
parentbb1d1912ea73592670f75a6ec89845766dabb4b0 (diff)
parent4cfc29611e21811065d024a6de1685418e60111e (diff)
Merge pull request #12969 from akien-mga/refactor-gd-prefix
GDScript: Refactor "GD" class prefix to "GDScript"
-rw-r--r--doc/classes/@GDScript.xml4
-rw-r--r--main/tests/test_gdscript.cpp298
-rw-r--r--modules/gdscript/config.py4
-rw-r--r--modules/gdscript/doc_classes/GDScriptFunctionState.xml (renamed from modules/gdscript/doc_classes/GDFunctionState.xml)4
-rw-r--r--modules/gdscript/doc_classes/GDScriptNativeClass.xml (renamed from modules/gdscript/doc_classes/GDNativeClass.xml)2
-rw-r--r--modules/gdscript/gdscript.cpp (renamed from modules/gdscript/gd_script.cpp)128
-rw-r--r--modules/gdscript/gdscript.h (renamed from modules/gdscript/gd_script.h)63
-rw-r--r--modules/gdscript/gdscript_compiler.cpp (renamed from modules/gdscript/gd_compiler.cpp)557
-rw-r--r--modules/gdscript/gdscript_compiler.h (renamed from modules/gdscript/gd_compiler.h)46
-rw-r--r--modules/gdscript/gdscript_editor.cpp (renamed from modules/gdscript/gd_editor.cpp)460
-rw-r--r--modules/gdscript/gdscript_function.cpp (renamed from modules/gdscript/gd_function.cpp)78
-rw-r--r--modules/gdscript/gdscript_function.h (renamed from modules/gdscript/gd_function.h)40
-rw-r--r--modules/gdscript/gdscript_functions.cpp (renamed from modules/gdscript/gd_functions.cpp)19
-rw-r--r--modules/gdscript/gdscript_functions.h (renamed from modules/gdscript/gd_functions.h)10
-rw-r--r--modules/gdscript/gdscript_parser.cpp (renamed from modules/gdscript/gd_parser.cpp)695
-rw-r--r--modules/gdscript/gdscript_parser.h (renamed from modules/gdscript/gd_parser.h)22
-rw-r--r--modules/gdscript/gdscript_tokenizer.cpp (renamed from modules/gdscript/gd_tokenizer.cpp)192
-rw-r--r--modules/gdscript/gdscript_tokenizer.h (renamed from modules/gdscript/gd_tokenizer.h)30
-rw-r--r--modules/gdscript/register_types.cpp5
19 files changed, 1330 insertions, 1327 deletions
diff --git a/doc/classes/@GDScript.xml b/doc/classes/@GDScript.xml
index 3f2d0c71e7..49ec412ba0 100644
--- a/doc/classes/@GDScript.xml
+++ b/doc/classes/@GDScript.xml
@@ -1103,14 +1103,14 @@
</description>
</method>
<method name="yield">
- <return type="GDFunctionState">
+ <return type="GDScriptFunctionState">
</return>
<argument index="0" name="object" type="Object">
</argument>
<argument index="1" name="signal" type="String">
</argument>
<description>
- 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.
</description>
</method>
diff --git a/main/tests/test_gdscript.cpp b/main/tests/test_gdscript.cpp
index bcf4278bde..b41b5f6452 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<const GDParser::IdentifierNode *>(p_expr);
+ const GDScriptParser::IdentifierNode *id_node = static_cast<const GDScriptParser::IdentifierNode *>(p_expr);
txt = id_node->name;
} break;
- case GDParser::Node::TYPE_CONSTANT: {
- const GDParser::ConstantNode *c_node = static_cast<const GDParser::ConstantNode *>(p_expr);
+ case GDScriptParser::Node::TYPE_CONSTANT: {
+ const GDScriptParser::ConstantNode *c_node = static_cast<const GDScriptParser::ConstantNode *>(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<const GDParser::ArrayNode *>(p_expr);
+ case GDScriptParser::Node::TYPE_ARRAY: {
+ const GDScriptParser::ArrayNode *arr_node = static_cast<const GDScriptParser::ArrayNode *>(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<const GDParser::DictionaryNode *>(p_expr);
+ case GDScriptParser::Node::TYPE_DICTIONARY: {
+ const GDScriptParser::DictionaryNode *dict_node = static_cast<const GDScriptParser::DictionaryNode *>(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<const GDParser::OperatorNode *>(p_expr);
+ const GDScriptParser::OperatorNode *c_node = static_cast<const GDScriptParser::OperatorNode *>(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<const GDParser::BuiltInFunctionNode *>(nfunc);
- func_name = GDFunctions::get_func_name(bif_node->function);
+ const GDScriptParser::BuiltInFunctionNode *bif_node = static_cast<const GDScriptParser::BuiltInFunctionNode *>(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<const GDParser::TypeNode *>(nfunc);
+ const GDScriptParser::TypeNode *t_node = static_cast<const GDScriptParser::TypeNode *>(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<const GDParser::ControlFlowNode *>(statement);
+ const GDScriptParser::ControlFlowNode *cf_node = static_cast<const GDScriptParser::ControlFlowNode *>(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<const GDParser::LocalVarNode *>(statement);
+ const GDScriptParser::LocalVarNode *lv_node = static_cast<const GDScriptParser::LocalVarNode *>(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<String> &p_code) {
+static void _parser_show_class(const GDScriptParser::ClassNode *p_class, int p_indent, const Vector<String> &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<GDScript> &p_script, const GDFunction &func, int p_addr) {
+static String _disassemble_addr(const Ref<GDScript> &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<GDScript> &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<GDScript> &p_script, const GDFunction
static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String> &p_code) {
- const Map<StringName, GDFunction *> &mf = p_class->debug_get_member_functions();
+ const Map<StringName, GDScriptFunction *> &mf = p_class->debug_get_member_functions();
- for (const Map<StringName, GDFunction *>::Element *E = mf.front(); E; E = E->next()) {
+ for (const Map<StringName, GDScriptFunction *>::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<GDScript> &p_class, const Vector<String
switch (code[ip]) {
- case GDFunction::OPCODE_OPERATOR: {
+ case GDScriptFunction::OPCODE_OPERATOR: {
int op = code[ip + 1];
txt += "op ";
@@ -583,7 +583,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr += 5;
} break;
- case GDFunction::OPCODE_SET: {
+ case GDScriptFunction::OPCODE_SET: {
txt += "set ";
txt += DADDR(1);
@@ -594,7 +594,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr += 4;
} break;
- case GDFunction::OPCODE_GET: {
+ case GDScriptFunction::OPCODE_GET: {
txt += " get ";
txt += DADDR(3);
@@ -606,7 +606,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr += 4;
} break;
- case GDFunction::OPCODE_SET_NAMED: {
+ case GDScriptFunction::OPCODE_SET_NAMED: {
txt += " set_named ";
txt += DADDR(1);
@@ -617,7 +617,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr += 4;
} break;
- case GDFunction::OPCODE_GET_NAMED: {
+ case GDScriptFunction::OPCODE_GET_NAMED: {
txt += " get_named ";
txt += DADDR(3);
@@ -629,7 +629,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr += 4;
} break;
- case GDFunction::OPCODE_SET_MEMBER: {
+ case GDScriptFunction::OPCODE_SET_MEMBER: {
txt += " set_member ";
txt += "[\"";
@@ -639,7 +639,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr += 3;
} break;
- case GDFunction::OPCODE_GET_MEMBER: {
+ case GDScriptFunction::OPCODE_GET_MEMBER: {
txt += " get_member ";
txt += DADDR(2);
@@ -650,7 +650,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr += 3;
} break;
- case GDFunction::OPCODE_ASSIGN: {
+ case GDScriptFunction::OPCODE_ASSIGN: {
txt += " assign ";
txt += DADDR(1);
@@ -659,7 +659,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr += 3;
} break;
- case GDFunction::OPCODE_ASSIGN_TRUE: {
+ case GDScriptFunction::OPCODE_ASSIGN_TRUE: {
txt += " assign ";
txt += DADDR(1);
@@ -667,7 +667,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr += 2;
} break;
- case GDFunction::OPCODE_ASSIGN_FALSE: {
+ case GDScriptFunction::OPCODE_ASSIGN_FALSE: {
txt += " assign ";
txt += DADDR(1);
@@ -675,7 +675,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr += 2;
} break;
- case GDFunction::OPCODE_CONSTRUCT: {
+ case GDScriptFunction::OPCODE_CONSTRUCT: {
Variant::Type t = Variant::Type(code[ip + 1]);
int argc = code[ip + 2];
@@ -696,7 +696,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr = 4 + argc;
} break;
- case GDFunction::OPCODE_CONSTRUCT_ARRAY: {
+ case GDScriptFunction::OPCODE_CONSTRUCT_ARRAY: {
int argc = code[ip + 1];
txt += " make_array ";
@@ -714,7 +714,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr += 3 + argc;
} break;
- case GDFunction::OPCODE_CONSTRUCT_DICTIONARY: {
+ case GDScriptFunction::OPCODE_CONSTRUCT_DICTIONARY: {
int argc = code[ip + 1];
txt += " make_dict ";
@@ -735,10 +735,10 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
} break;
- case GDFunction::OPCODE_CALL:
- case GDFunction::OPCODE_CALL_RETURN: {
+ case GDScriptFunction::OPCODE_CALL:
+ case GDScriptFunction::OPCODE_CALL_RETURN: {
- bool ret = code[ip] == GDFunction::OPCODE_CALL_RETURN;
+ bool ret = code[ip] == GDScriptFunction::OPCODE_CALL_RETURN;
if (ret)
txt += " call-ret ";
@@ -764,14 +764,14 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr = 5 + argc;
} break;
- case GDFunction::OPCODE_CALL_BUILT_IN: {
+ case GDScriptFunction::OPCODE_CALL_BUILT_IN: {
txt += " call-built-in ";
int argc = code[ip + 2];
txt += DADDR(3 + argc) + "=";
- txt += GDFunctions::get_func_name(GDFunctions::Function(code[ip + 1]));
+ txt += GDScriptFunctions::get_func_name(GDScriptFunctions::Function(code[ip + 1]));
txt += "(";
for (int i = 0; i < argc; i++) {
@@ -784,7 +784,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr = 4 + argc;
} break;
- case GDFunction::OPCODE_CALL_SELF_BASE: {
+ case GDScriptFunction::OPCODE_CALL_SELF_BASE: {
txt += " call-self-base ";
@@ -804,13 +804,13 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr = 4 + argc;
} break;
- case GDFunction::OPCODE_YIELD: {
+ case GDScriptFunction::OPCODE_YIELD: {
txt += " yield ";
incr = 1;
} break;
- case GDFunction::OPCODE_YIELD_SIGNAL: {
+ case GDScriptFunction::OPCODE_YIELD_SIGNAL: {
txt += " yield_signal ";
txt += DADDR(1);
@@ -818,13 +818,13 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
txt += DADDR(2);
incr = 3;
} break;
- case GDFunction::OPCODE_YIELD_RESUME: {
+ case GDScriptFunction::OPCODE_YIELD_RESUME: {
txt += " yield resume: ";
txt += DADDR(1);
incr = 2;
} break;
- case GDFunction::OPCODE_JUMP: {
+ case GDScriptFunction::OPCODE_JUMP: {
txt += " jump ";
txt += itos(code[ip + 1]);
@@ -832,7 +832,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr = 2;
} break;
- case GDFunction::OPCODE_JUMP_IF: {
+ case GDScriptFunction::OPCODE_JUMP_IF: {
txt += " jump-if ";
txt += DADDR(1);
@@ -841,7 +841,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr = 3;
} break;
- case GDFunction::OPCODE_JUMP_IF_NOT: {
+ case GDScriptFunction::OPCODE_JUMP_IF_NOT: {
txt += " jump-if-not ";
txt += DADDR(1);
@@ -850,12 +850,12 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr = 3;
} break;
- case GDFunction::OPCODE_JUMP_TO_DEF_ARGUMENT: {
+ case GDScriptFunction::OPCODE_JUMP_TO_DEF_ARGUMENT: {
txt += " jump-to-default-argument ";
incr = 1;
} break;
- case GDFunction::OPCODE_RETURN: {
+ case GDScriptFunction::OPCODE_RETURN: {
txt += " return ";
txt += DADDR(1);
@@ -863,19 +863,19 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr = 2;
} break;
- case GDFunction::OPCODE_ITERATE_BEGIN: {
+ case GDScriptFunction::OPCODE_ITERATE_BEGIN: {
txt += " for-init " + DADDR(4) + " in " + DADDR(2) + " counter " + DADDR(1) + " end " + itos(code[ip + 3]);
incr += 5;
} break;
- case GDFunction::OPCODE_ITERATE: {
+ case GDScriptFunction::OPCODE_ITERATE: {
txt += " for-loop " + DADDR(4) + " in " + DADDR(2) + " counter " + DADDR(1) + " end " + itos(code[ip + 3]);
incr += 5;
} break;
- case GDFunction::OPCODE_LINE: {
+ case GDScriptFunction::OPCODE_LINE: {
int line = code[ip + 1] - 1;
if (line >= 0 && line < p_code.size())
@@ -884,12 +884,12 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
txt = "";
incr += 2;
} break;
- case GDFunction::OPCODE_END: {
+ case GDScriptFunction::OPCODE_END: {
txt += " end";
incr += 1;
} break;
- case GDFunction::OPCODE_ASSERT: {
+ case GDScriptFunction::OPCODE_ASSERT: {
txt += " assert ";
txt += DADDR(1);
@@ -952,15 +952,15 @@ MainLoop *test(TestType p_type) {
if (p_type == TEST_TOKENIZER) {
- GDTokenizerText tk;
+ GDScriptTokenizerText tk;
tk.set_code(code);
int line = -1;
- while (tk.get_token() != GDTokenizer::TK_EOF) {
+ while (tk.get_token() != GDScriptTokenizer::TK_EOF) {
String text;
- if (tk.get_token() == GDTokenizer::TK_IDENTIFIER)
+ if (tk.get_token() == GDScriptTokenizer::TK_IDENTIFIER)
text = "'" + tk.get_token_identifier() + "' (identifier)";
- else if (tk.get_token() == GDTokenizer::TK_CONSTANT) {
+ else if (tk.get_token() == GDScriptTokenizer::TK_CONSTANT) {
Variant c = tk.get_token_constant();
if (c.get_type() == Variant::STRING)
text = "\"" + String(c) + "\"";
@@ -968,12 +968,12 @@ MainLoop *test(TestType p_type) {
text = c;
text = text + " (" + Variant::get_type_name(c.get_type()) + " constant)";
- } else if (tk.get_token() == GDTokenizer::TK_ERROR)
+ } else if (tk.get_token() == GDScriptTokenizer::TK_ERROR)
text = "ERROR: " + tk.get_token_error();
- else if (tk.get_token() == GDTokenizer::TK_NEWLINE)
+ else if (tk.get_token() == GDScriptTokenizer::TK_NEWLINE)
text = "newline (" + itos(tk.get_token_line()) + ") + indent: " + itos(tk.get_token_line_indent());
- else if (tk.get_token() == GDTokenizer::TK_BUILT_IN_FUNC)
- text = "'" + String(GDFunctions::get_func_name(tk.get_token_built_in_func())) + "' (built-in function)";
+ else if (tk.get_token() == GDScriptTokenizer::TK_BUILT_IN_FUNC)
+ text = "'" + String(GDScriptFunctions::get_func_name(tk.get_token_built_in_func())) + "' (built-in function)";
else
text = tk.get_token_name(tk.get_token());
@@ -995,7 +995,7 @@ MainLoop *test(TestType p_type) {
if (p_type == TEST_PARSER) {
- GDParser parser;
+ GDScriptParser parser;
Error err = parser.parse(code);
if (err) {
print_line("Parse Error:\n" + itos(parser.get_error_line()) + ":" + itos(parser.get_error_column()) + ":" + parser.get_error());
@@ -1003,16 +1003,16 @@ MainLoop *test(TestType p_type) {
return NULL;
}
- const GDParser::Node *root = parser.get_parse_tree();
- ERR_FAIL_COND_V(root->type != GDParser::Node::TYPE_CLASS, NULL);
- const GDParser::ClassNode *cnode = static_cast<const GDParser::ClassNode *>(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<const GDScriptParser::ClassNode *>(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<uint8_t> buf = GDTokenizerBuffer::parse_code_string(code);
+ Vector<uint8_t> 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 6e8994d643..6496b59d75 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/GDScriptFunctionState.xml
index e1aafa8a5b..2df4e7c217 100644
--- a/modules/gdscript/doc_classes/GDFunctionState.xml
+++ b/modules/gdscript/doc_classes/GDScriptFunctionState.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GDFunctionState" inherits="Reference" category="Core" version="3.0-alpha">
+<class name="GDScriptFunctionState" inherits="Reference" category="Core" version="3.0-alpha">
<brief_description>
State of a function call after yielding.
</brief_description>
@@ -18,7 +18,7 @@
</argument>
<description>
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.
+ 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.
</description>
</method>
<method name="resume">
diff --git a/modules/gdscript/doc_classes/GDNativeClass.xml b/modules/gdscript/doc_classes/GDScriptNativeClass.xml
index 95789e1b63..4514a78469 100644
--- a/modules/gdscript/doc_classes/GDNativeClass.xml
+++ b/modules/gdscript/doc_classes/GDScriptNativeClass.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GDNativeClass" inherits="Reference" category="Core" version="3.0-alpha">
+<class name="GDScriptNativeClass" inherits="Reference" category="Core" version="3.0-alpha">
<brief_description>
</brief_description>
<description>
diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gdscript.cpp
index e5d834c9e7..55ea8a5f24 100644
--- a/modules/gdscript/gd_script.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_script.cpp */
+/* gdscript.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,10 +27,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "gd_script.h"
+#include "gdscript.h"
#include "engine.h"
-#include "gd_compiler.h"
+#include "gdscript_compiler.h"
#include "global_constants.h"
#include "io/file_access_encrypted.h"
#include "os/file_access.h"
@@ -39,12 +39,12 @@
///////////////////////////
-GDNativeClass::GDNativeClass(const StringName &p_name) {
+GDScriptNativeClass::GDScriptNativeClass(const StringName &p_name) {
name = p_name;
}
-bool GDNativeClass::_get(const StringName &p_name, Variant &r_ret) const {
+bool GDScriptNativeClass::_get(const StringName &p_name, Variant &r_ret) const {
bool ok;
int v = ClassDB::get_integer_constant(name, p_name, &ok);
@@ -57,12 +57,12 @@ bool GDNativeClass::_get(const StringName &p_name, Variant &r_ret) const {
}
}
-void GDNativeClass::_bind_methods() {
+void GDScriptNativeClass::_bind_methods() {
- ClassDB::bind_method(D_METHOD("new"), &GDNativeClass::_new);
+ ClassDB::bind_method(D_METHOD("new"), &GDScriptNativeClass::_new);
}
-Variant GDNativeClass::_new() {
+Variant GDScriptNativeClass::_new() {
Object *o = instance();
if (!o) {
@@ -78,16 +78,16 @@ Variant GDNativeClass::_new() {
}
}
-Object *GDNativeClass::instance() {
+Object *GDScriptNativeClass::instance() {
return ClassDB::instance(name);
}
-GDInstance *GDScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error) {
+GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error) {
/* STEP 1, CREATE */
- GDInstance *instance = memnew(GDInstance);
+ GDScriptInstance *instance = memnew(GDScriptInstance);
instance->base_ref = p_isref;
instance->members.resize(member_indices.size());
instance->script = Ref<GDScript>(this);
@@ -163,7 +163,7 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Variant::CallErro
ref = REF(r);
}
- GDInstance *instance = _create_instance(p_args, p_argcount, owner, r != NULL, r_error);
+ GDScriptInstance *instance = _create_instance(p_args, p_argcount, owner, r != NULL, r_error);
if (!instance) {
if (ref.is_null()) {
memdelete(owner); //no owner, sorry
@@ -218,7 +218,7 @@ void GDScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) {
void GDScript::get_script_method_list(List<MethodInfo> *p_list) const {
- for (const Map<StringName, GDFunction *>::Element *E = member_functions.front(); E; E = E->next()) {
+ for (const Map<StringName, GDScriptFunction *>::Element *E = member_functions.front(); E; E = E->next()) {
MethodInfo mi;
mi.name = E->key();
for (int i = 0; i < E->get()->get_argument_count(); i++) {
@@ -272,7 +272,7 @@ bool GDScript::has_method(const StringName &p_method) const {
MethodInfo GDScript::get_method_info(const StringName &p_method) const {
- const Map<StringName, GDFunction *>::Element *E = member_functions.find(p_method);
+ const Map<StringName, GDScriptFunction *>::Element *E = member_functions.find(p_method);
if (!E)
return MethodInfo();
@@ -420,15 +420,15 @@ bool GDScript::_update_exports() {
if (basedir != "")
basedir = basedir.get_base_dir();
- GDParser parser;
+ GDScriptParser parser;
Error err = parser.parse(source, basedir, true, path);
if (err == OK) {
- const GDParser::Node *root = parser.get_parse_tree();
- ERR_FAIL_COND_V(root->type != GDParser::Node::TYPE_CLASS, false);
+ const GDScriptParser::Node *root = parser.get_parse_tree();
+ ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, false);
- const GDParser::ClassNode *c = static_cast<const GDParser::ClassNode *>(root);
+ const GDScriptParser::ClassNode *c = static_cast<const GDScriptParser::ClassNode *>(root);
if (base_cache.is_valid()) {
base_cache->inheriters_cache.erase(get_instance_id());
@@ -572,7 +572,7 @@ Error GDScript::reload(bool p_keep_state) {
}
valid = false;
- GDParser parser;
+ GDScriptParser parser;
Error err = parser.parse(source, basedir, false, path);
if (err) {
if (ScriptDebugger::get_singleton()) {
@@ -584,7 +584,7 @@ Error GDScript::reload(bool p_keep_state) {
bool can_run = ScriptServer::is_scripting_enabled() || parser.is_tool_script();
- GDCompiler compiler;
+ GDScriptCompiler compiler;
err = compiler.compile(&parser, this, p_keep_state);
if (err) {
@@ -620,7 +620,7 @@ Variant GDScript::call(const StringName &p_method, const Variant **p_args, int p
GDScript *top = this;
while (top) {
- Map<StringName, GDFunction *>::Element *E = top->member_functions.find(p_method);
+ Map<StringName, GDScriptFunction *>::Element *E = top->member_functions.find(p_method);
if (E) {
if (!E->get()->is_static()) {
@@ -699,7 +699,7 @@ void GDScript::_bind_methods() {
Vector<uint8_t> GDScript::get_as_byte_code() const {
- GDTokenizerBuffer tokenizer;
+ GDScriptTokenizerBuffer tokenizer;
return tokenizer.parse_code_string(source);
};
@@ -739,14 +739,14 @@ Error GDScript::load_byte_code(const String &p_path) {
basedir = basedir.get_base_dir();
valid = false;
- GDParser parser;
+ GDScriptParser parser;
Error err = parser.parse_bytecode(bytecode, basedir, get_path());
if (err) {
_err_print_error("GDScript::load_byte_code", path.empty() ? "built-in" : (const char *)path.utf8().get_data(), parser.get_error_line(), ("Parse Error: " + parser.get_error()).utf8().get_data(), ERR_HANDLER_SCRIPT);
ERR_FAIL_V(ERR_PARSE_ERROR);
}
- GDCompiler compiler;
+ GDScriptCompiler compiler;
err = compiler.compile(&parser, this);
if (err) {
@@ -799,7 +799,7 @@ Error GDScript::load_source_code(const String &p_path) {
return OK;
}
-const Map<StringName, GDFunction *> &GDScript::debug_get_member_functions() const {
+const Map<StringName, GDScriptFunction *> &GDScript::debug_get_member_functions() const {
return member_functions;
}
@@ -886,7 +886,7 @@ GDScript::GDScript()
}
GDScript::~GDScript() {
- for (Map<StringName, GDFunction *>::Element *E = member_functions.front(); E; E = E->next()) {
+ for (Map<StringName, GDScriptFunction *>::Element *E = member_functions.front(); E; E = E->next()) {
memdelete(E->get());
}
@@ -910,7 +910,7 @@ GDScript::~GDScript() {
// INSTANCE //
//////////////////////////////
-bool GDInstance::set(const StringName &p_name, const Variant &p_value) {
+bool GDScriptInstance::set(const StringName &p_name, const Variant &p_value) {
//member
{
@@ -932,7 +932,7 @@ bool GDInstance::set(const StringName &p_name, const Variant &p_value) {
GDScript *sptr = script.ptr();
while (sptr) {
- Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._set);
+ Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._set);
if (E) {
Variant name = p_name;
@@ -949,7 +949,7 @@ bool GDInstance::set(const StringName &p_name, const Variant &p_value) {
return false;
}
-bool GDInstance::get(const StringName &p_name, Variant &r_ret) const {
+bool GDScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
const GDScript *sptr = script.ptr();
while (sptr) {
@@ -959,7 +959,7 @@ bool GDInstance::get(const StringName &p_name, Variant &r_ret) const {
if (E) {
if (E->get().getter) {
Variant::CallError err;
- r_ret = const_cast<GDInstance *>(this)->call(E->get().getter, NULL, 0, err);
+ r_ret = const_cast<GDScriptInstance *>(this)->call(E->get().getter, NULL, 0, err);
if (err.error == Variant::CallError::CALL_OK) {
return true;
}
@@ -983,14 +983,14 @@ bool GDInstance::get(const StringName &p_name, Variant &r_ret) const {
}
{
- const Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get);
+ const Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get);
if (E) {
Variant name = p_name;
const Variant *args[1] = { &name };
Variant::CallError err;
- Variant ret = const_cast<GDFunction *>(E->get())->call(const_cast<GDInstance *>(this), (const Variant **)args, 1, err);
+ Variant ret = const_cast<GDScriptFunction *>(E->get())->call(const_cast<GDScriptInstance *>(this), (const Variant **)args, 1, err);
if (err.error == Variant::CallError::CALL_OK && ret.get_type() != Variant::NIL) {
r_ret = ret;
return true;
@@ -1003,7 +1003,7 @@ bool GDInstance::get(const StringName &p_name, Variant &r_ret) const {
return false;
}
-Variant::Type GDInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const {
+Variant::Type GDScriptInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const {
const GDScript *sptr = script.ptr();
while (sptr) {
@@ -1021,7 +1021,7 @@ Variant::Type GDInstance::get_property_type(const StringName &p_name, bool *r_is
return Variant::NIL;
}
-void GDInstance::get_property_list(List<PropertyInfo> *p_properties) const {
+void GDScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const {
// exported members, not doen yet!
const GDScript *sptr = script.ptr();
@@ -1029,11 +1029,11 @@ void GDInstance::get_property_list(List<PropertyInfo> *p_properties) const {
while (sptr) {
- const Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get_property_list);
+ const Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get_property_list);
if (E) {
Variant::CallError err;
- Variant ret = const_cast<GDFunction *>(E->get())->call(const_cast<GDInstance *>(this), NULL, 0, err);
+ Variant ret = const_cast<GDScriptFunction *>(E->get())->call(const_cast<GDScriptInstance *>(this), NULL, 0, err);
if (err.error == Variant::CallError::CALL_OK) {
if (ret.get_type() != Variant::ARRAY) {
@@ -1092,12 +1092,12 @@ void GDInstance::get_property_list(List<PropertyInfo> *p_properties) const {
}
}
-void GDInstance::get_method_list(List<MethodInfo> *p_list) const {
+void GDScriptInstance::get_method_list(List<MethodInfo> *p_list) const {
const GDScript *sptr = script.ptr();
while (sptr) {
- for (Map<StringName, GDFunction *>::Element *E = sptr->member_functions.front(); E; E = E->next()) {
+ for (Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.front(); E; E = E->next()) {
MethodInfo mi;
mi.name = E->key();
@@ -1110,11 +1110,11 @@ void GDInstance::get_method_list(List<MethodInfo> *p_list) const {
}
}
-bool GDInstance::has_method(const StringName &p_method) const {
+bool GDScriptInstance::has_method(const StringName &p_method) const {
const GDScript *sptr = script.ptr();
while (sptr) {
- const Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(p_method);
+ const Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(p_method);
if (E)
return true;
sptr = sptr->_base;
@@ -1122,13 +1122,13 @@ bool GDInstance::has_method(const StringName &p_method) const {
return false;
}
-Variant GDInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant GDScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
//printf("calling %ls:%i method %ls\n", script->get_path().c_str(), -1, String(p_method).c_str());
GDScript *sptr = script.ptr();
while (sptr) {
- Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(p_method);
+ Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(p_method);
if (E) {
return E->get()->call(this, p_args, p_argcount, r_error);
}
@@ -1138,13 +1138,13 @@ Variant GDInstance::call(const StringName &p_method, const Variant **p_args, int
return Variant();
}
-void GDInstance::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) {
+void GDScriptInstance::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) {
GDScript *sptr = script.ptr();
Variant::CallError ce;
while (sptr) {
- Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(p_method);
+ Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(p_method);
if (E) {
E->get()->call(this, p_args, p_argcount, ce);
}
@@ -1152,27 +1152,27 @@ void GDInstance::call_multilevel(const StringName &p_method, const Variant **p_a
}
}
-void GDInstance::_ml_call_reversed(GDScript *sptr, const StringName &p_method, const Variant **p_args, int p_argcount) {
+void GDScriptInstance::_ml_call_reversed(GDScript *sptr, const StringName &p_method, const Variant **p_args, int p_argcount) {
if (sptr->_base)
_ml_call_reversed(sptr->_base, p_method, p_args, p_argcount);
Variant::CallError ce;
- Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(p_method);
+ Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(p_method);
if (E) {
E->get()->call(this, p_args, p_argcount, ce);
}
}
-void GDInstance::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) {
+void GDScriptInstance::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) {
if (script.ptr()) {
_ml_call_reversed(script.ptr(), p_method, p_args, p_argcount);
}
}
-void GDInstance::notification(int p_notification) {
+void GDScriptInstance::notification(int p_notification) {
//notification is not virtual, it gets called at ALL levels just like in C.
Variant value = p_notification;
@@ -1180,7 +1180,7 @@ void GDInstance::notification(int p_notification) {
GDScript *sptr = script.ptr();
while (sptr) {
- Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._notification);
+ Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._notification);
if (E) {
Variant::CallError err;
E->get()->call(this, args, 1, err);
@@ -1192,22 +1192,22 @@ void GDInstance::notification(int p_notification) {
}
}
-Ref<Script> GDInstance::get_script() const {
+Ref<Script> GDScriptInstance::get_script() const {
return script;
}
-ScriptLanguage *GDInstance::get_language() {
+ScriptLanguage *GDScriptInstance::get_language() {
return GDScriptLanguage::get_singleton();
}
-GDInstance::RPCMode GDInstance::get_rpc_mode(const StringName &p_method) const {
+GDScriptInstance::RPCMode GDScriptInstance::get_rpc_mode(const StringName &p_method) const {
const GDScript *cscript = script.ptr();
while (cscript) {
- const Map<StringName, GDFunction *>::Element *E = cscript->member_functions.find(p_method);
+ const Map<StringName, GDScriptFunction *>::Element *E = cscript->member_functions.find(p_method);
if (E) {
if (E->get()->get_rpc_mode() != RPC_MODE_DISABLED) {
@@ -1220,7 +1220,7 @@ GDInstance::RPCMode GDInstance::get_rpc_mode(const StringName &p_method) const {
return RPC_MODE_DISABLED;
}
-GDInstance::RPCMode GDInstance::get_rset_mode(const StringName &p_variable) const {
+GDScriptInstance::RPCMode GDScriptInstance::get_rset_mode(const StringName &p_variable) const {
const GDScript *cscript = script.ptr();
@@ -1238,7 +1238,7 @@ GDInstance::RPCMode GDInstance::get_rset_mode(const StringName &p_variable) cons
return RPC_MODE_DISABLED;
}
-void GDInstance::reload_members() {
+void GDScriptInstance::reload_members() {
#ifdef DEBUG_ENABLED
@@ -1269,12 +1269,12 @@ void GDInstance::reload_members() {
#endif
}
-GDInstance::GDInstance() {
+GDScriptInstance::GDScriptInstance() {
owner = NULL;
base_ref = false;
}
-GDInstance::~GDInstance() {
+GDScriptInstance::~GDScriptInstance() {
if (script.is_valid() && owner) {
#ifndef NO_THREADS
GDScriptLanguage::singleton->lock->lock();
@@ -1342,7 +1342,7 @@ void GDScriptLanguage::init() {
if (globals.has(n))
continue;
- Ref<GDNativeClass> nc = memnew(GDNativeClass(E->get()));
+ Ref<GDScriptNativeClass> nc = memnew(GDScriptNativeClass(E->get()));
_add_global(n, nc);
}
@@ -1379,7 +1379,7 @@ void GDScriptLanguage::profiling_start() {
lock->lock();
}
- SelfList<GDFunction> *elem = function_list.first();
+ SelfList<GDScriptFunction> *elem = function_list.first();
while (elem) {
elem->self()->profile.call_count = 0;
elem->self()->profile.self_time = 0;
@@ -1424,7 +1424,7 @@ int GDScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_arr,
lock->lock();
}
- SelfList<GDFunction> *elem = function_list.first();
+ SelfList<GDScriptFunction> *elem = function_list.first();
while (elem) {
if (current >= p_info_max)
break;
@@ -1454,7 +1454,7 @@ int GDScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_
lock->lock();
}
- SelfList<GDFunction> *elem = function_list.first();
+ SelfList<GDScriptFunction> *elem = function_list.first();
while (elem) {
if (current >= p_info_max)
break;
@@ -1668,7 +1668,7 @@ void GDScriptLanguage::frame() {
lock->lock();
}
- SelfList<GDFunction> *elem = function_list.first();
+ SelfList<GDScriptFunction> *elem = function_list.first();
while (elem) {
elem->self()->profile.last_frame_call_count = elem->self()->profile.frame_call_count;
elem->self()->profile.last_frame_self_time = elem->self()->profile.frame_self_time;
@@ -1753,8 +1753,8 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const {
w++;
}
- for (int i = 0; i < GDFunctions::FUNC_MAX; i++) {
- p_words->push_back(GDFunctions::get_func_name(GDFunctions::Function(i)));
+ for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) {
+ p_words->push_back(GDScriptFunctions::get_func_name(GDScriptFunctions::Function(i)));
}
}
diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gdscript.h
index e0d142014a..3f6f431938 100644
--- a/modules/gdscript/gd_script.h
+++ b/modules/gdscript/gdscript.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_script.h */
+/* gdscript.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,16 +27,17 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GD_SCRIPT_H
-#define GD_SCRIPT_H
+#ifndef GDSCRIPT_H
+#define GDSCRIPT_H
-#include "gd_function.h"
+#include "gdscript_function.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "script_language.h"
-class GDNativeClass : public Reference {
- GDCLASS(GDNativeClass, Reference);
+class GDScriptNativeClass : public Reference {
+
+ GDCLASS(GDScriptNativeClass, Reference);
StringName name;
@@ -48,7 +49,7 @@ public:
_FORCE_INLINE_ const StringName &get_name() const { return name; }
Variant _new();
Object *instance();
- GDNativeClass(const StringName &p_name);
+ GDScriptNativeClass(const StringName &p_name);
};
class GDScript : public Script {
@@ -64,21 +65,21 @@ class GDScript : public Script {
ScriptInstance::RPCMode rpc_mode;
};
- friend class GDInstance;
- friend class GDFunction;
- friend class GDCompiler;
- friend class GDFunctions;
+ friend class GDScriptInstance;
+ friend class GDScriptFunction;
+ friend class GDScriptCompiler;
+ friend class GDScriptFunctions;
friend class GDScriptLanguage;
Variant _static_ref; //used for static call
- Ref<GDNativeClass> native;
+ Ref<GDScriptNativeClass> native;
Ref<GDScript> base;
GDScript *_base; //fast pointer access
GDScript *_owner; //for subclasses
Set<StringName> members; //members are just indices to the instanced script.
Map<StringName, Variant> constants;
- Map<StringName, GDFunction *> member_functions;
+ Map<StringName, GDScriptFunction *> member_functions;
Map<StringName, MemberInfo> member_indices; //members are just indices to the instanced script.
Map<StringName, Ref<GDScript> > subclasses;
Map<StringName, Vector<StringName> > _signals;
@@ -99,7 +100,7 @@ class GDScript : public Script {
#endif
Map<StringName, PropertyInfo> member_info;
- GDFunction *initializer; //direct pointer to _init , faster to locate
+ GDScriptFunction *initializer; //direct pointer to _init , faster to locate
int subclass_count;
Set<Object *> instances;
@@ -109,7 +110,7 @@ class GDScript : public Script {
String name;
SelfList<GDScript> script_list;
- GDInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error);
+ GDScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error);
void _set_subclass_path(Ref<GDScript> &p_sc, const String &p_path);
@@ -143,8 +144,8 @@ public:
const Map<StringName, Ref<GDScript> > &get_subclasses() const { return subclasses; }
const Map<StringName, Variant> &get_constants() const { return constants; }
const Set<StringName> &get_members() const { return members; }
- const Map<StringName, GDFunction *> &get_member_functions() const { return member_functions; }
- const Ref<GDNativeClass> &get_native() const { return native; }
+ const Map<StringName, GDScriptFunction *> &get_member_functions() const { return member_functions; }
+ const Ref<GDScriptNativeClass> &get_native() const { return native; }
virtual bool has_script_signal(const StringName &p_signal) const;
virtual void get_script_signal_list(List<MethodInfo> *r_signals) const;
@@ -153,7 +154,7 @@ public:
Ref<GDScript> get_base() const;
const Map<StringName, MemberInfo> &debug_get_member_indices() const { return member_indices; }
- const Map<StringName, GDFunction *> &debug_get_member_functions() const; //this is debug only
+ const Map<StringName, GDScriptFunction *> &debug_get_member_functions() const; //this is debug only
StringName debug_get_member_by_index(int p_idx) const;
Variant _new(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
@@ -201,11 +202,11 @@ public:
~GDScript();
};
-class GDInstance : public ScriptInstance {
+class GDScriptInstance : public ScriptInstance {
friend class GDScript;
- friend class GDFunction;
- friend class GDFunctions;
- friend class GDCompiler;
+ friend class GDScriptFunction;
+ friend class GDScriptFunctions;
+ friend class GDScriptCompiler;
Object *owner;
Ref<GDScript> script;
@@ -246,8 +247,8 @@ public:
virtual RPCMode get_rpc_mode(const StringName &p_method) const;
virtual RPCMode get_rset_mode(const StringName &p_variable) const;
- GDInstance();
- ~GDInstance();
+ GDScriptInstance();
+ ~GDScriptInstance();
};
class GDScriptLanguage : public ScriptLanguage {
@@ -261,8 +262,8 @@ class GDScriptLanguage : public ScriptLanguage {
struct CallLevel {
Variant *stack;
- GDFunction *function;
- GDInstance *instance;
+ GDScriptFunction *function;
+ GDScriptInstance *instance;
int *ip;
int *line;
};
@@ -276,16 +277,16 @@ class GDScriptLanguage : public ScriptLanguage {
void _add_global(const StringName &p_name, const Variant &p_value);
- friend class GDInstance;
+ friend class GDScriptInstance;
Mutex *lock;
friend class GDScript;
SelfList<GDScript>::List script_list;
- friend class GDFunction;
+ friend class GDScriptFunction;
- SelfList<GDFunction>::List function_list;
+ SelfList<GDScriptFunction>::List function_list;
bool profiling;
uint64_t script_frame_time;
@@ -295,7 +296,7 @@ public:
bool debug_break(const String &p_error, bool p_allow_continue = true);
bool debug_break_parse(const String &p_file, int p_line, const String &p_error);
- _FORCE_INLINE_ void enter_function(GDInstance *p_instance, GDFunction *p_function, Variant *p_stack, int *p_ip, int *p_line) {
+ _FORCE_INLINE_ void enter_function(GDScriptInstance *p_instance, GDScriptFunction *p_function, Variant *p_stack, int *p_ip, int *p_line) {
if (Thread::get_main_id() != Thread::get_caller_id())
return; //no support for other threads than main for now
@@ -446,4 +447,4 @@ public:
virtual bool recognize(const RES &p_resource) const;
};
-#endif // GD_SCRIPT_H
+#endif // GDSCRIPT_H
diff --git a/modules/gdscript/gd_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index 7036a708e5..3121a61436 100644
--- a/modules/gdscript/gd_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_compiler.cpp */
+/* gdscript_compiler.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,10 +27,11 @@
/* 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"
+#include "gdscript_compiler.h"
-bool GDCompiler::_is_class_member_property(CodeGen &codegen, const StringName &p_name) {
+#include "gdscript.h"
+
+bool GDScriptCompiler::_is_class_member_property(CodeGen &codegen, const StringName &p_name) {
if (!codegen.function_node || codegen.function_node->_static)
return false;
@@ -38,10 +39,10 @@ bool GDCompiler::_is_class_member_property(CodeGen &codegen, const StringName &p
return _is_class_member_property(codegen.script, p_name);
}
-bool GDCompiler::_is_class_member_property(GDScript *owner, const StringName &p_name) {
+bool GDScriptCompiler::_is_class_member_property(GDScript *owner, const StringName &p_name) {
GDScript *scr = owner;
- GDNativeClass *nc = NULL;
+ GDScriptNativeClass *nc = NULL;
while (scr) {
if (scr->native.is_valid())
@@ -54,7 +55,7 @@ bool GDCompiler::_is_class_member_property(GDScript *owner, const StringName &p_
return ClassDB::has_property(nc->get_name(), p_name);
}
-void GDCompiler::_set_error(const String &p_error, const GDParser::Node *p_node) {
+void GDScriptCompiler::_set_error(const String &p_error, const GDScriptParser::Node *p_node) {
if (error != "")
return;
@@ -69,7 +70,7 @@ void GDCompiler::_set_error(const String &p_error, const GDParser::Node *p_node)
}
}
-bool GDCompiler::_create_unary_operator(CodeGen &codegen, const GDParser::OperatorNode *on, Variant::Operator op, int p_stack_level) {
+bool GDScriptCompiler::_create_unary_operator(CodeGen &codegen, const GDScriptParser::OperatorNode *on, Variant::Operator op, int p_stack_level) {
ERR_FAIL_COND_V(on->arguments.size() != 1, false);
@@ -77,29 +78,29 @@ bool GDCompiler::_create_unary_operator(CodeGen &codegen, const GDParser::Operat
if (src_address_a < 0)
return false;
- codegen.opcodes.push_back(GDFunction::OPCODE_OPERATOR); // perform operator
+ codegen.opcodes.push_back(GDScriptFunction::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)
+ //codegen.opcodes.push_back(GDScriptFunction::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) {
+bool GDScriptCompiler::_create_binary_operator(CodeGen &codegen, const GDScriptParser::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)
+ if (src_address_a & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::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(GDScriptFunction::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)
@@ -107,14 +108,14 @@ bool GDCompiler::_create_binary_operator(CodeGen &codegen, const GDParser::Opera
}
/*
-int GDCompiler::_parse_subexpression(CodeGen& codegen,const GDParser::Node *p_expression) {
+int GDScriptCompiler::_parse_subexpression(CodeGen& codegen,const GDScriptParser::Node *p_expression) {
int ret = _parse_expression(codegen,p_expression);
if (ret<0)
return ret;
- if (ret&(GDFunction::ADDR_TYPE_STACK<<GDFunction::ADDR_BITS)) {
+ if (ret&(GDScriptFunction::ADDR_TYPE_STACK<<GDScriptFunction::ADDR_BITS)) {
codegen.stack_level++;
codegen.check_max_stack_level();
//stack was used, keep value
@@ -124,24 +125,24 @@ int GDCompiler::_parse_subexpression(CodeGen& codegen,const GDParser::Node *p_ex
}
*/
-int GDCompiler::_parse_assign_right_expression(CodeGen &codegen, const GDParser::OperatorNode *p_expression, int p_stack_level) {
+int GDScriptCompiler::_parse_assign_right_expression(CodeGen &codegen, const GDScriptParser::OperatorNode *p_expression, int p_stack_level) {
Variant::Operator var_op = Variant::OP_MAX;
switch (p_expression->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: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_ADD: var_op = Variant::OP_ADD; break;
+ case GDScriptParser::OperatorNode::OP_ASSIGN_SUB: var_op = Variant::OP_SUBTRACT; break;
+ case GDScriptParser::OperatorNode::OP_ASSIGN_MUL: var_op = Variant::OP_MULTIPLY; break;
+ case GDScriptParser::OperatorNode::OP_ASSIGN_DIV: var_op = Variant::OP_DIVIDE; break;
+ case GDScriptParser::OperatorNode::OP_ASSIGN_MOD: var_op = Variant::OP_MODULE; break;
+ case GDScriptParser::OperatorNode::OP_ASSIGN_SHIFT_LEFT: var_op = Variant::OP_SHIFT_LEFT; break;
+ case GDScriptParser::OperatorNode::OP_ASSIGN_SHIFT_RIGHT: var_op = Variant::OP_SHIFT_RIGHT; break;
+ case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_AND: var_op = Variant::OP_BIT_AND; break;
+ case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_OR: var_op = Variant::OP_BIT_OR; break;
+ case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_XOR: var_op = Variant::OP_BIT_XOR; break;
+ case GDScriptParser::OperatorNode::OP_INIT_ASSIGN:
+ case GDScriptParser::OperatorNode::OP_ASSIGN: {
//none
} break;
@@ -151,7 +152,7 @@ int GDCompiler::_parse_assign_right_expression(CodeGen &codegen, const GDParser:
}
}
- bool initializer = p_expression->op == GDParser::OperatorNode::OP_INIT_ASSIGN;
+ bool initializer = p_expression->op == GDScriptParser::OperatorNode::OP_INIT_ASSIGN;
if (var_op == Variant::OP_MAX) {
@@ -161,32 +162,32 @@ int GDCompiler::_parse_assign_right_expression(CodeGen &codegen, const GDParser:
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);
+ int dst_addr = (p_stack_level) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::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) {
+int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::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: {
+ case GDScriptParser::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<const GDParser::IdentifierNode *>(p_expression);
+ const GDScriptParser::IdentifierNode *in = static_cast<const GDScriptParser::IdentifierNode *>(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(GDScriptFunction::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);
+ int dst_addr = (p_stack_level) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::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;
@@ -196,7 +197,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (!p_initializer && codegen.stack_identifiers.has(identifier)) {
int pos = codegen.stack_identifiers[identifier];
- return pos | (GDFunction::ADDR_TYPE_STACK_VARIABLE << GDFunction::ADDR_BITS);
+ return pos | (GDScriptFunction::ADDR_TYPE_STACK_VARIABLE << GDScriptFunction::ADDR_BITS);
}
//TRY MEMBERS!
if (!codegen.function_node || !codegen.function_node->_static) {
@@ -206,7 +207,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
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)
+ return idx | (GDScriptFunction::ADDR_TYPE_MEMBER << GDScriptFunction::ADDR_BITS); //argument (stack root)
}
}
@@ -216,14 +217,14 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
while (owner) {
GDScript *scr = owner;
- GDNativeClass *nc = NULL;
+ GDScriptNativeClass *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)
+ return idx | (GDScriptFunction::ADDR_TYPE_CLASS_CONSTANT << GDScriptFunction::ADDR_BITS); //argument (stack root)
}
if (scr->native.is_valid())
nc = scr->native.ptr();
@@ -249,7 +250,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
idx = codegen.constant_map[key];
}
- return idx | (GDFunction::ADDR_TYPE_LOCAL_CONSTANT << GDFunction::ADDR_BITS); //make it a local constant (faster access)
+ return idx | (GDScriptFunction::ADDR_TYPE_LOCAL_CONSTANT << GDScriptFunction::ADDR_BITS); //make it a local constant (faster access)
}
}
@@ -261,14 +262,14 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
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<<GDFunction::ADDR_BITS); //make it a local constant (faster access)
+ return idx|(GDScriptFunction::ADDR_TYPE_LOCAL_CONSTANT<<GDScriptFunction::ADDR_BITS); //make it a local constant (faster access)
}*/
if (GDScriptLanguage::get_singleton()->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)
+ return idx | (GDScriptFunction::ADDR_TYPE_GLOBAL << GDScriptFunction::ADDR_BITS); //argument (stack root)
}
//not found, error
@@ -278,9 +279,9 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
return -1;
} break;
- case GDParser::Node::TYPE_CONSTANT: {
+ case GDScriptParser::Node::TYPE_CONSTANT: {
//return constant
- const GDParser::ConstantNode *cn = static_cast<const GDParser::ConstantNode *>(p_expression);
+ const GDScriptParser::ConstantNode *cn = static_cast<const GDScriptParser::ConstantNode *>(p_expression);
int idx;
@@ -293,20 +294,20 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
idx = codegen.constant_map[cn->value];
}
- return idx | (GDFunction::ADDR_TYPE_LOCAL_CONSTANT << GDFunction::ADDR_BITS); //argument (stack root)
+ return idx | (GDScriptFunction::ADDR_TYPE_LOCAL_CONSTANT << GDScriptFunction::ADDR_BITS); //argument (stack root)
} break;
- case GDParser::Node::TYPE_SELF: {
+ case GDScriptParser::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);
+ return (GDScriptFunction::ADDR_TYPE_SELF << GDScriptFunction::ADDR_BITS);
} break;
- case GDParser::Node::TYPE_ARRAY: {
+ case GDScriptParser::Node::TYPE_ARRAY: {
- const GDParser::ArrayNode *an = static_cast<const GDParser::ArrayNode *>(p_expression);
+ const GDScriptParser::ArrayNode *an = static_cast<const GDScriptParser::ArrayNode *>(p_expression);
Vector<int> values;
int slevel = p_stack_level;
@@ -316,7 +317,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
int ret = _parse_expression(codegen, an->elements[i], slevel);
if (ret < 0)
return ret;
- if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
+ if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -324,20 +325,20 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
values.push_back(ret);
}
- codegen.opcodes.push_back(GDFunction::OPCODE_CONSTRUCT_ARRAY);
+ codegen.opcodes.push_back(GDScriptFunction::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);
+ int dst_addr = (p_stack_level) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::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: {
+ case GDScriptParser::Node::TYPE_DICTIONARY: {
- const GDParser::DictionaryNode *dn = static_cast<const GDParser::DictionaryNode *>(p_expression);
+ const GDScriptParser::DictionaryNode *dn = static_cast<const GDScriptParser::DictionaryNode *>(p_expression);
Vector<int> values;
int slevel = p_stack_level;
@@ -347,7 +348,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
int ret = _parse_expression(codegen, dn->elements[i].key, slevel);
if (ret < 0)
return ret;
- if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
+ if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -357,7 +358,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
ret = _parse_expression(codegen, dn->elements[i].value, slevel);
if (ret < 0)
return ret;
- if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
+ if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -365,29 +366,29 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
values.push_back(ret);
}
- codegen.opcodes.push_back(GDFunction::OPCODE_CONSTRUCT_DICTIONARY);
+ codegen.opcodes.push_back(GDScriptFunction::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);
+ int dst_addr = (p_stack_level) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::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: {
+ case GDScriptParser::Node::TYPE_OPERATOR: {
//hell breaks loose
- const GDParser::OperatorNode *on = static_cast<const GDParser::OperatorNode *>(p_expression);
+ const GDScriptParser::OperatorNode *on = static_cast<const GDScriptParser::OperatorNode *>(p_expression);
switch (on->op) {
//call/constructor operator
- case GDParser::OperatorNode::OP_PARENT_CALL: {
+ case GDScriptParser::OperatorNode::OP_PARENT_CALL: {
ERR_FAIL_COND_V(on->arguments.size() < 1, -1);
- const GDParser::IdentifierNode *in = (const GDParser::IdentifierNode *)on->arguments[0];
+ const GDScriptParser::IdentifierNode *in = (const GDScriptParser::IdentifierNode *)on->arguments[0];
Vector<int> arguments;
int slevel = p_stack_level;
@@ -396,7 +397,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
int ret = _parse_expression(codegen, on->arguments[i], slevel);
if (ret < 0)
return ret;
- if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
+ if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -404,7 +405,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
}
//push call bytecode
- codegen.opcodes.push_back(GDFunction::OPCODE_CALL_SELF_BASE); // basic type constructor
+ codegen.opcodes.push_back(GDScriptFunction::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
@@ -413,13 +414,13 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
codegen.opcodes.push_back(arguments[i]); //arguments
} break;
- case GDParser::OperatorNode::OP_CALL: {
+ case GDScriptParser::OperatorNode::OP_CALL: {
- if (on->arguments[0]->type == GDParser::Node::TYPE_TYPE) {
+ if (on->arguments[0]->type == GDScriptParser::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];
+ const GDScriptParser::TypeNode *tn = (const GDScriptParser::TypeNode *)on->arguments[0];
int vtype = tn->vtype;
Vector<int> arguments;
@@ -429,7 +430,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
int ret = _parse_expression(codegen, on->arguments[i], slevel);
if (ret < 0)
return ret;
- if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
+ if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -437,14 +438,14 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
}
//push call bytecode
- codegen.opcodes.push_back(GDFunction::OPCODE_CONSTRUCT); // basic type constructor
+ codegen.opcodes.push_back(GDScriptFunction::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) {
+ } else if (on->arguments[0]->type == GDScriptParser::Node::TYPE_BUILT_IN_FUNCTION) {
//built in function
ERR_FAIL_COND_V(on->arguments.size() < 1, -1);
@@ -457,7 +458,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (ret < 0)
return ret;
- if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
+ if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -465,8 +466,8 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
arguments.push_back(ret);
}
- codegen.opcodes.push_back(GDFunction::OPCODE_CALL_BUILT_IN);
- codegen.opcodes.push_back(static_cast<const GDParser::BuiltInFunctionNode *>(on->arguments[0])->function);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_CALL_BUILT_IN);
+ codegen.opcodes.push_back(static_cast<const GDScriptParser::BuiltInFunctionNode *>(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++)
@@ -476,9 +477,9 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
//regular function
ERR_FAIL_COND_V(on->arguments.size() < 2, -1);
- const GDParser::Node *instance = on->arguments[0];
+ const GDScriptParser::Node *instance = on->arguments[0];
- if (instance->type == GDParser::Node::TYPE_SELF) {
+ if (instance->type == GDScriptParser::Node::TYPE_SELF) {
//room for optimization
}
@@ -489,16 +490,16 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
int ret;
- if (i == 0 && on->arguments[i]->type == GDParser::Node::TYPE_SELF && codegen.function_node && codegen.function_node->_static) {
+ if (i == 0 && on->arguments[i]->type == GDScriptParser::Node::TYPE_SELF && codegen.function_node && codegen.function_node->_static) {
//static call to self
- ret = (GDFunction::ADDR_TYPE_CLASS << GDFunction::ADDR_BITS);
+ ret = (GDScriptFunction::ADDR_TYPE_CLASS << GDScriptFunction::ADDR_BITS);
} else if (i == 1) {
- if (on->arguments[i]->type != GDParser::Node::TYPE_IDENTIFIER) {
+ if (on->arguments[i]->type != GDScriptParser::Node::TYPE_IDENTIFIER) {
_set_error("Attempt to call a non-identifier.", on);
return -1;
}
- GDParser::IdentifierNode *id = static_cast<GDParser::IdentifierNode *>(on->arguments[i]);
+ GDScriptParser::IdentifierNode *id = static_cast<GDScriptParser::IdentifierNode *>(on->arguments[i]);
ret = codegen.get_name_map_pos(id->name);
} else {
@@ -506,7 +507,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
ret = _parse_expression(codegen, on->arguments[i], slevel);
if (ret < 0)
return ret;
- if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
+ if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -514,14 +515,14 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
arguments.push_back(ret);
}
- codegen.opcodes.push_back(p_root ? GDFunction::OPCODE_CALL : GDFunction::OPCODE_CALL_RETURN); // perform operator
+ codegen.opcodes.push_back(p_root ? GDScriptFunction::OPCODE_CALL : GDScriptFunction::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: {
+ case GDScriptParser::OperatorNode::OP_YIELD: {
ERR_FAIL_COND_V(on->arguments.size() && on->arguments.size() != 2, -1);
@@ -532,7 +533,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
int ret = _parse_expression(codegen, on->arguments[i], slevel);
if (ret < 0)
return ret;
- if (ret & (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS)) {
+ if (ret & (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS)) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -540,22 +541,22 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
}
//push call bytecode
- codegen.opcodes.push_back(arguments.size() == 0 ? GDFunction::OPCODE_YIELD : GDFunction::OPCODE_YIELD_SIGNAL); // basic type constructor
+ codegen.opcodes.push_back(arguments.size() == 0 ? GDScriptFunction::OPCODE_YIELD : GDScriptFunction::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);
+ codegen.opcodes.push_back(GDScriptFunction::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: {
+ case GDScriptParser::OperatorNode::OP_INDEX:
+ case GDScriptParser::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);
+ bool named = (on->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED);
int from = _parse_expression(codegen, on->arguments[0], slevel);
if (from < 0)
@@ -563,14 +564,14 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
int index;
if (named) {
- if (on->arguments[0]->type == GDParser::Node::TYPE_SELF && codegen.script && codegen.function_node && !codegen.function_node->_static) {
+ if (on->arguments[0]->type == GDScriptParser::Node::TYPE_SELF && codegen.script && codegen.function_node && !codegen.function_node->_static) {
- GDParser::IdentifierNode *identifier = static_cast<GDParser::IdentifierNode *>(on->arguments[1]);
+ GDScriptParser::IdentifierNode *identifier = static_cast<GDScriptParser::IdentifierNode *>(on->arguments[1]);
const Map<StringName, GDScript::MemberInfo>::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<GDParser::IdentifierNode *>(on->arguments[1])->name;
+ String n = static_cast<GDScriptParser::IdentifierNode *>(on->arguments[1])->name;
_set_error("Must use '" + n + "' instead of 'self." + n + "' in getter.", on);
return -1;
}
@@ -578,23 +579,23 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
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);
+ return (MI->get().index) | (GDScriptFunction::ADDR_TYPE_MEMBER << GDScriptFunction::ADDR_BITS);
}
}
- index = codegen.get_name_map_pos(static_cast<GDParser::IdentifierNode *>(on->arguments[1])->name);
+ index = codegen.get_name_map_pos(static_cast<GDScriptParser::IdentifierNode *>(on->arguments[1])->name);
} else {
- if (on->arguments[1]->type == GDParser::Node::TYPE_CONSTANT && static_cast<const GDParser::ConstantNode *>(on->arguments[1])->value.get_type() == Variant::STRING) {
+ if (on->arguments[1]->type == GDScriptParser::Node::TYPE_CONSTANT && static_cast<const GDScriptParser::ConstantNode *>(on->arguments[1])->value.get_type() == Variant::STRING) {
//also, somehow, named (speed up anyway)
- StringName name = static_cast<const GDParser::ConstantNode *>(on->arguments[1])->value;
+ StringName name = static_cast<const GDScriptParser::ConstantNode *>(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) {
+ if (from & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -605,19 +606,19 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
}
}
- codegen.opcodes.push_back(named ? GDFunction::OPCODE_GET_NAMED : GDFunction::OPCODE_GET); // perform operator
+ codegen.opcodes.push_back(named ? GDScriptFunction::OPCODE_GET_NAMED : GDScriptFunction::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: {
+ case GDScriptParser::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(GDScriptFunction::OPCODE_JUMP_IF_NOT);
codegen.opcodes.push_back(res);
int jump_fail_pos = codegen.opcodes.size();
codegen.opcodes.push_back(0);
@@ -626,31 +627,31 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (res < 0)
return res;
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF_NOT);
+ codegen.opcodes.push_back(GDScriptFunction::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(GDScriptFunction::OPCODE_ASSIGN_TRUE);
+ codegen.opcodes.push_back(p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
+ codegen.opcodes.push_back(GDScriptFunction::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;
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSIGN_FALSE);
+ codegen.opcodes.push_back(p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
+ return p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS;
} break;
- case GDParser::OperatorNode::OP_OR: {
+ case GDScriptParser::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(GDScriptFunction::OPCODE_JUMP_IF);
codegen.opcodes.push_back(res);
int jump_success_pos = codegen.opcodes.size();
codegen.opcodes.push_back(0);
@@ -659,32 +660,32 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (res < 0)
return res;
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF);
+ codegen.opcodes.push_back(GDScriptFunction::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(GDScriptFunction::OPCODE_ASSIGN_FALSE);
+ codegen.opcodes.push_back(p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
+ codegen.opcodes.push_back(GDScriptFunction::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;
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSIGN_TRUE);
+ codegen.opcodes.push_back(p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
+ return p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS;
} break;
// ternary operators
- case GDParser::OperatorNode::OP_TERNARY_IF: {
+ case GDScriptParser::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(GDScriptFunction::OPCODE_JUMP_IF_NOT);
codegen.opcodes.push_back(res);
int jump_fail_pos = codegen.opcodes.size();
codegen.opcodes.push_back(0);
@@ -694,10 +695,10 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
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(GDScriptFunction::OPCODE_ASSIGN);
+ codegen.opcodes.push_back(p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
codegen.opcodes.push_back(res);
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
int jump_past_pos = codegen.opcodes.size();
codegen.opcodes.push_back(0);
@@ -706,116 +707,116 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
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(GDScriptFunction::OPCODE_ASSIGN);
+ codegen.opcodes.push_back(p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::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;
+ return p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS;
} break;
//unary operators
- case GDParser::OperatorNode::OP_NEG: {
+ case GDScriptParser::OperatorNode::OP_NEG: {
if (!_create_unary_operator(codegen, on, Variant::OP_NEGATE, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_NOT: {
+ case GDScriptParser::OperatorNode::OP_NOT: {
if (!_create_unary_operator(codegen, on, Variant::OP_NOT, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_BIT_INVERT: {
+ case GDScriptParser::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: {
+ 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;
//binary operators (in precedence order)
- case GDParser::OperatorNode::OP_IN: {
+ case GDScriptParser::OperatorNode::OP_IN: {
if (!_create_binary_operator(codegen, on, Variant::OP_IN, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_EQUAL: {
+ case GDScriptParser::OperatorNode::OP_EQUAL: {
if (!_create_binary_operator(codegen, on, Variant::OP_EQUAL, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_NOT_EQUAL: {
+ case GDScriptParser::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: {
+ case GDScriptParser::OperatorNode::OP_LESS: {
if (!_create_binary_operator(codegen, on, Variant::OP_LESS, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_LESS_EQUAL: {
+ case GDScriptParser::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: {
+ case GDScriptParser::OperatorNode::OP_GREATER: {
if (!_create_binary_operator(codegen, on, Variant::OP_GREATER, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_GREATER_EQUAL: {
+ case GDScriptParser::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: {
+ case GDScriptParser::OperatorNode::OP_ADD: {
if (!_create_binary_operator(codegen, on, Variant::OP_ADD, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_SUB: {
+ case GDScriptParser::OperatorNode::OP_SUB: {
if (!_create_binary_operator(codegen, on, Variant::OP_SUBTRACT, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_MUL: {
+ case GDScriptParser::OperatorNode::OP_MUL: {
if (!_create_binary_operator(codegen, on, Variant::OP_MULTIPLY, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_DIV: {
+ case GDScriptParser::OperatorNode::OP_DIV: {
if (!_create_binary_operator(codegen, on, Variant::OP_DIVIDE, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_MOD: {
+ case GDScriptParser::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: {
+ //case GDScriptParser::OperatorNode::OP_SHIFT_LEFT: { if (!_create_binary_operator(codegen,on,Variant::OP_SHIFT_LEFT,p_stack_level)) return -1;} break;
+ //case GDScriptParser::OperatorNode::OP_SHIFT_RIGHT: { if (!_create_binary_operator(codegen,on,Variant::OP_SHIFT_RIGHT,p_stack_level)) return -1;} break;
+ case GDScriptParser::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: {
+ case GDScriptParser::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: {
+ case GDScriptParser::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: {
+ case GDScriptParser::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: {
+ case GDScriptParser::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: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_ADD:
+ case GDScriptParser::OperatorNode::OP_ASSIGN_SUB:
+ case GDScriptParser::OperatorNode::OP_ASSIGN_MUL:
+ case GDScriptParser::OperatorNode::OP_ASSIGN_DIV:
+ case GDScriptParser::OperatorNode::OP_ASSIGN_MOD:
+ case GDScriptParser::OperatorNode::OP_ASSIGN_SHIFT_LEFT:
+ case GDScriptParser::OperatorNode::OP_ASSIGN_SHIFT_RIGHT:
+ case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_AND:
+ case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_OR:
+ case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_XOR:
+ case GDScriptParser::OperatorNode::OP_INIT_ASSIGN:
+ case GDScriptParser::OperatorNode::OP_ASSIGN: {
ERR_FAIL_COND_V(on->arguments.size() != 2, -1);
- if (on->arguments[0]->type == GDParser::Node::TYPE_OPERATOR && (static_cast<GDParser::OperatorNode *>(on->arguments[0])->op == GDParser::OperatorNode::OP_INDEX || static_cast<GDParser::OperatorNode *>(on->arguments[0])->op == GDParser::OperatorNode::OP_INDEX_NAMED)) {
+ if (on->arguments[0]->type == GDScriptParser::Node::TYPE_OPERATOR && (static_cast<GDScriptParser::OperatorNode *>(on->arguments[0])->op == GDScriptParser::OperatorNode::OP_INDEX || static_cast<GDScriptParser::OperatorNode *>(on->arguments[0])->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED)) {
//SET (chained) MODE!!
#ifdef DEBUG_ENABLED
- if (static_cast<GDParser::OperatorNode *>(on->arguments[0])->op == GDParser::OperatorNode::OP_INDEX_NAMED) {
- const GDParser::OperatorNode *inon = static_cast<GDParser::OperatorNode *>(on->arguments[0]);
+ if (static_cast<GDScriptParser::OperatorNode *>(on->arguments[0])->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED) {
+ const GDScriptParser::OperatorNode *inon = static_cast<GDScriptParser::OperatorNode *>(on->arguments[0]);
- if (inon->arguments[0]->type == GDParser::Node::TYPE_SELF && codegen.script && codegen.function_node && !codegen.function_node->_static) {
+ if (inon->arguments[0]->type == GDScriptParser::Node::TYPE_SELF && codegen.script && codegen.function_node && !codegen.function_node->_static) {
- const Map<StringName, GDScript::MemberInfo>::Element *MI = codegen.script->member_indices.find(static_cast<GDParser::IdentifierNode *>(inon->arguments[1])->name);
+ const Map<StringName, GDScript::MemberInfo>::Element *MI = codegen.script->member_indices.find(static_cast<GDScriptParser::IdentifierNode *>(inon->arguments[1])->name);
if (MI && MI->get().setter == codegen.function_node->name) {
- String n = static_cast<GDParser::IdentifierNode *>(inon->arguments[1])->name;
+ String n = static_cast<GDScriptParser::IdentifierNode *>(inon->arguments[1])->name;
_set_error("Must use '" + n + "' instead of 'self." + n + "' in setter.", inon);
return -1;
}
@@ -825,34 +826,34 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
int slevel = p_stack_level;
- GDParser::OperatorNode *op = static_cast<GDParser::OperatorNode *>(on->arguments[0]);
+ GDScriptParser::OperatorNode *op = static_cast<GDScriptParser::OperatorNode *>(on->arguments[0]);
/* Find chain of sets */
StringName assign_property;
- List<GDParser::OperatorNode *> chain;
+ List<GDScriptParser::OperatorNode *> chain;
{
//create get/set chain
- GDParser::OperatorNode *n = op;
+ GDScriptParser::OperatorNode *n = op;
while (true) {
chain.push_back(n);
- if (n->arguments[0]->type != GDParser::Node::TYPE_OPERATOR) {
+ if (n->arguments[0]->type != GDScriptParser::Node::TYPE_OPERATOR) {
//check for a built-in property
- if (n->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER) {
+ if (n->arguments[0]->type == GDScriptParser::Node::TYPE_IDENTIFIER) {
- GDParser::IdentifierNode *identifier = static_cast<GDParser::IdentifierNode *>(n->arguments[0]);
+ GDScriptParser::IdentifierNode *identifier = static_cast<GDScriptParser::IdentifierNode *>(n->arguments[0]);
if (_is_class_member_property(codegen, identifier->name)) {
assign_property = identifier->name;
}
}
break;
}
- n = static_cast<GDParser::OperatorNode *>(n->arguments[0]);
- if (n->op != GDParser::OperatorNode::OP_INDEX && n->op != GDParser::OperatorNode::OP_INDEX_NAMED)
+ n = static_cast<GDScriptParser::OperatorNode *>(n->arguments[0]);
+ if (n->op != GDScriptParser::OperatorNode::OP_INDEX && n->op != GDScriptParser::OperatorNode::OP_INDEX_NAMED)
break;
}
}
@@ -867,7 +868,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
//print_line("retval: "+itos(retval));
- if (retval & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
+ if (retval & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -881,30 +882,30 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
// in Node2D
setchain.push_back(prev_pos);
setchain.push_back(codegen.get_name_map_pos(assign_property));
- setchain.push_back(GDFunction::OPCODE_SET_MEMBER);
+ setchain.push_back(GDScriptFunction::OPCODE_SET_MEMBER);
}
- for (List<GDParser::OperatorNode *>::Element *E = chain.back(); E; E = E->prev()) {
+ for (List<GDScriptParser::OperatorNode *>::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;
+ bool named = E->get()->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED;
int key_idx;
if (named) {
- key_idx = codegen.get_name_map_pos(static_cast<const GDParser::IdentifierNode *>(E->get()->arguments[1])->name);
+ key_idx = codegen.get_name_map_pos(static_cast<const GDScriptParser::IdentifierNode *>(E->get()->arguments[1])->name);
//printf("named key %x\n",key_idx);
} else {
- if (prev_pos & (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS)) {
+ if (prev_pos & (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS)) {
slevel++;
codegen.alloc_stack(slevel);
}
- GDParser::Node *key = E->get()->arguments[1];
+ GDScriptParser::Node *key = E->get()->arguments[1];
key_idx = _parse_expression(codegen, key, slevel);
//printf("expr key %x\n",key_idx);
@@ -914,12 +915,12 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (key_idx < 0) //error
return key_idx;
- codegen.opcodes.push_back(named ? GDFunction::OPCODE_GET_NAMED : GDFunction::OPCODE_GET);
+ codegen.opcodes.push_back(named ? GDScriptFunction::OPCODE_GET_NAMED : GDScriptFunction::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;
+ int dst_pos = (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) | slevel;
codegen.opcodes.push_back(dst_pos);
@@ -928,7 +929,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
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);
+ setchain.push_back(named ? GDScriptFunction::OPCODE_SET_NAMED : GDScriptFunction::OPCODE_SET);
prev_pos = dst_pos;
}
@@ -938,9 +939,9 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
int set_index;
bool named = false;
- if (static_cast<const GDParser::OperatorNode *>(op)->op == GDParser::OperatorNode::OP_INDEX_NAMED) {
+ if (static_cast<const GDScriptParser::OperatorNode *>(op)->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED) {
- set_index = codegen.get_name_map_pos(static_cast<const GDParser::IdentifierNode *>(op->arguments[1])->name);
+ set_index = codegen.get_name_map_pos(static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[1])->name);
named = true;
} else {
@@ -951,7 +952,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (set_index < 0) //error
return set_index;
- if (set_index & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
+ if (set_index & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -960,7 +961,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (set_value < 0) //error
return set_value;
- codegen.opcodes.push_back(named ? GDFunction::OPCODE_SET_NAMED : GDFunction::OPCODE_SET);
+ codegen.opcodes.push_back(named ? GDScriptFunction::OPCODE_SET_NAMED : GDScriptFunction::OPCODE_SET);
codegen.opcodes.push_back(prev_pos);
codegen.opcodes.push_back(set_index);
codegen.opcodes.push_back(set_value);
@@ -972,7 +973,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
return retval;
- } else if (on->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER && _is_class_member_property(codegen, static_cast<GDParser::IdentifierNode *>(on->arguments[0])->name)) {
+ } else if (on->arguments[0]->type == GDScriptParser::Node::TYPE_IDENTIFIER && _is_class_member_property(codegen, static_cast<GDScriptParser::IdentifierNode *>(on->arguments[0])->name)) {
//assignment to member property
int slevel = p_stack_level;
@@ -981,24 +982,24 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (src_address < 0)
return -1;
- StringName name = static_cast<GDParser::IdentifierNode *>(on->arguments[0])->name;
+ StringName name = static_cast<GDScriptParser::IdentifierNode *>(on->arguments[0])->name;
- codegen.opcodes.push_back(GDFunction::OPCODE_SET_MEMBER);
+ codegen.opcodes.push_back(GDScriptFunction::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;
+ return GDScriptFunction::ADDR_TYPE_NIL << GDScriptFunction::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);
+ int dst_address_a = _parse_expression(codegen, on->arguments[0], slevel, false, on->op == GDScriptParser::OperatorNode::OP_INIT_ASSIGN);
if (dst_address_a < 0)
return -1;
- if (dst_address_a & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
+ if (dst_address_a & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -1007,14 +1008,14 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (src_address_b < 0)
return -1;
- codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN); // perform operator
+ codegen.opcodes.push_back(GDScriptFunction::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: {
+ case GDScriptParser::OperatorNode::OP_IS: {
ERR_FAIL_COND_V(on->arguments.size() != 2, false);
@@ -1024,14 +1025,14 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (src_address_a < 0)
return -1;
- if (src_address_a & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS)
+ if (src_address_a & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::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(GDScriptFunction::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)
@@ -1044,7 +1045,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
} break;
}
- int dst_addr = (p_stack_level) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
+ int dst_addr = (p_stack_level) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::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;
@@ -1060,7 +1061,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
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) {
+Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::BlockNode *p_block, int p_stack_level, int p_break_addr, int p_continue_addr) {
codegen.push_stack_identifiers();
int new_identifiers = 0;
@@ -1068,28 +1069,28 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
for (int i = 0; i < p_block->statements.size(); i++) {
- const GDParser::Node *s = p_block->statements[i];
+ const GDScriptParser::Node *s = p_block->statements[i];
switch (s->type) {
- case GDParser::Node::TYPE_NEWLINE: {
+ case GDScriptParser::Node::TYPE_NEWLINE: {
#ifdef DEBUG_ENABLED
- const GDParser::NewLineNode *nl = static_cast<const GDParser::NewLineNode *>(s);
- codegen.opcodes.push_back(GDFunction::OPCODE_LINE);
+ const GDScriptParser::NewLineNode *nl = static_cast<const GDScriptParser::NewLineNode *>(s);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_LINE);
codegen.opcodes.push_back(nl->line);
codegen.current_line = nl->line;
#endif
} break;
- case GDParser::Node::TYPE_CONTROL_FLOW: {
+ case GDScriptParser::Node::TYPE_CONTROL_FLOW: {
// try subblocks
- const GDParser::ControlFlowNode *cf = static_cast<const GDParser::ControlFlowNode *>(s);
+ const GDScriptParser::ControlFlowNode *cf = static_cast<const GDScriptParser::ControlFlowNode *>(s);
switch (cf->cf_type) {
- case GDParser::ControlFlowNode::CF_MATCH: {
- GDParser::MatchNode *match = cf->match;
+ case GDScriptParser::ControlFlowNode::CF_MATCH: {
+ GDScriptParser::MatchNode *match = cf->match;
- GDParser::IdentifierNode *id = memnew(GDParser::IdentifierNode);
+ GDScriptParser::IdentifierNode *id = memnew(GDScriptParser::IdentifierNode);
id->name = "#match_value";
// var #match_value
@@ -1098,8 +1099,8 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
codegen.alloc_stack(p_stack_level);
new_identifiers++;
- GDParser::OperatorNode *op = memnew(GDParser::OperatorNode);
- op->op = GDParser::OperatorNode::OP_ASSIGN;
+ GDScriptParser::OperatorNode *op = memnew(GDScriptParser::OperatorNode);
+ op->op = GDScriptParser::OperatorNode::OP_ASSIGN;
op->arguments.push_back(id);
op->arguments.push_back(match->val_to_match);
@@ -1109,14 +1110,14 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
}
// break address
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(GDScriptFunction::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(GDScriptFunction::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];
+ GDScriptParser::MatchNode::CompiledPatternBranch branch = match->compiled_pattern_branches[j];
// jump over continue
// jump unconditionally
@@ -1127,11 +1128,11 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
return ERR_PARSE_ERROR;
}
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF);
+ codegen.opcodes.push_back(GDScriptFunction::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(GDScriptFunction::OPCODE_JUMP);
codegen.opcodes.push_back(0);
Error err = _parse_block(codegen, branch.body, p_stack_level, p_break_addr, continue_addr);
@@ -1139,7 +1140,7 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
return ERR_PARSE_ERROR;
}
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
codegen.opcodes.push_back(break_addr);
codegen.opcodes[continue_addr + 1] = codegen.opcodes.size();
@@ -1149,10 +1150,10 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
} break;
- case GDParser::ControlFlowNode::CF_IF: {
+ case GDScriptParser::ControlFlowNode::CF_IF: {
#ifdef DEBUG_ENABLED
- codegen.opcodes.push_back(GDFunction::OPCODE_LINE);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_LINE);
codegen.opcodes.push_back(cf->line);
codegen.current_line = cf->line;
#endif
@@ -1160,7 +1161,7 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
if (ret < 0)
return ERR_PARSE_ERROR;
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF_NOT);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF_NOT);
codegen.opcodes.push_back(ret);
int else_addr = codegen.opcodes.size();
codegen.opcodes.push_back(0); //temporary
@@ -1171,7 +1172,7 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
if (cf->body_else) {
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
int end_addr = codegen.opcodes.size();
codegen.opcodes.push_back(0);
codegen.opcodes[else_addr] = codegen.opcodes.size();
@@ -1187,42 +1188,42 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
}
} break;
- case GDParser::ControlFlowNode::CF_FOR: {
+ case GDScriptParser::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);
+ int iterator_pos = (slevel++) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
+ int counter_pos = (slevel++) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
+ int container_pos = (slevel++) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
codegen.alloc_stack(slevel);
codegen.push_stack_identifiers();
- codegen.add_stack_identifier(static_cast<const GDParser::IdentifierNode *>(cf->arguments[0])->name, iter_stack_pos);
+ codegen.add_stack_identifier(static_cast<const GDScriptParser::IdentifierNode *>(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(GDScriptFunction::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(GDScriptFunction::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(GDScriptFunction::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(GDScriptFunction::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(GDScriptFunction::OPCODE_ITERATE);
codegen.opcodes.push_back(counter_pos);
codegen.opcodes.push_back(container_pos);
codegen.opcodes.push_back(break_pos);
@@ -1232,52 +1233,52 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
if (err)
return err;
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(GDScriptFunction::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: {
+ case GDScriptParser::ControlFlowNode::CF_WHILE: {
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(GDScriptFunction::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(GDScriptFunction::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(GDScriptFunction::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(GDScriptFunction::OPCODE_JUMP);
codegen.opcodes.push_back(continue_addr);
codegen.opcodes[break_addr + 1] = codegen.opcodes.size();
} break;
- case GDParser::ControlFlowNode::CF_SWITCH: {
+ case GDScriptParser::ControlFlowNode::CF_SWITCH: {
} break;
- case GDParser::ControlFlowNode::CF_BREAK: {
+ case GDScriptParser::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(GDScriptFunction::OPCODE_JUMP);
codegen.opcodes.push_back(p_break_addr);
} break;
- case GDParser::ControlFlowNode::CF_CONTINUE: {
+ case GDScriptParser::ControlFlowNode::CF_CONTINUE: {
if (p_continue_addr < 0) {
@@ -1285,11 +1286,11 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
return ERR_COMPILATION_FAILED;
}
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
codegen.opcodes.push_back(p_continue_addr);
} break;
- case GDParser::ControlFlowNode::CF_RETURN: {
+ case GDScriptParser::ControlFlowNode::CF_RETURN: {
int ret;
@@ -1301,38 +1302,38 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
} else {
- ret = GDFunction::ADDR_TYPE_NIL << GDFunction::ADDR_BITS;
+ ret = GDScriptFunction::ADDR_TYPE_NIL << GDScriptFunction::ADDR_BITS;
}
- codegen.opcodes.push_back(GDFunction::OPCODE_RETURN);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_RETURN);
codegen.opcodes.push_back(ret);
} break;
}
} break;
- case GDParser::Node::TYPE_ASSERT: {
+ case GDScriptParser::Node::TYPE_ASSERT: {
#ifdef DEBUG_ENABLED
// try subblocks
- const GDParser::AssertNode *as = static_cast<const GDParser::AssertNode *>(s);
+ const GDScriptParser::AssertNode *as = static_cast<const GDScriptParser::AssertNode *>(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(GDScriptFunction::OPCODE_ASSERT);
codegen.opcodes.push_back(ret);
#endif
} break;
- case GDParser::Node::TYPE_BREAKPOINT: {
+ case GDScriptParser::Node::TYPE_BREAKPOINT: {
#ifdef DEBUG_ENABLED
// try subblocks
- codegen.opcodes.push_back(GDFunction::OPCODE_BREAKPOINT);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_BREAKPOINT);
#endif
} break;
- case GDParser::Node::TYPE_LOCAL_VAR: {
+ case GDScriptParser::Node::TYPE_LOCAL_VAR: {
- const GDParser::LocalVarNode *lv = static_cast<const GDParser::LocalVarNode *>(s);
+ const GDScriptParser::LocalVarNode *lv = static_cast<const GDScriptParser::LocalVarNode *>(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);
@@ -1356,7 +1357,7 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
return OK;
}
-Error GDCompiler::_parse_function(GDScript *p_script, const GDParser::ClassNode *p_class, const GDParser::FunctionNode *p_func, bool p_for_ready) {
+Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser::ClassNode *p_class, const GDScriptParser::FunctionNode *p_func, bool p_for_ready) {
Vector<int> bytecode;
CodeGen codegen;
@@ -1397,10 +1398,10 @@ Error GDCompiler::_parse_function(GDScript *p_script, const GDParser::ClassNode
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(GDScriptFunction::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);
+ codegen.opcodes.push_back((GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) | 0);
}
Error err = _parse_block(codegen, p_class->initializer, stack_level);
if (err)
@@ -1426,7 +1427,7 @@ Error GDCompiler::_parse_function(GDScript *p_script, const GDParser::ClassNode
if (p_func->default_values.size()) {
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_TO_DEF_ARGUMENT);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_TO_DEF_ARGUMENT);
defarg_addr.push_back(codegen.opcodes.size());
for (int i = 0; i < p_func->default_values.size(); i++) {
@@ -1449,15 +1450,15 @@ Error GDCompiler::_parse_function(GDScript *p_script, const GDParser::ClassNode
func_name = "_init";
}
- codegen.opcodes.push_back(GDFunction::OPCODE_END);
+ codegen.opcodes.push_back(GDScriptFunction::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];
+ p_script->member_functions[func_name] = memnew(GDScriptFunction);
+ GDScriptFunction *gdfunc = p_script->member_functions[func_name];
//}
if (p_func) {
@@ -1579,7 +1580,7 @@ Error GDCompiler::_parse_function(GDScript *p_script, const GDParser::ClassNode
return OK;
}
-Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDParser::ClassNode *p_class, bool p_keep_state) {
+Error GDScriptCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDScriptParser::ClassNode *p_class, bool p_keep_state) {
Map<StringName, Ref<GDScript> > old_subclasses;
@@ -1587,12 +1588,12 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
old_subclasses = p_script->subclasses;
}
- p_script->native = Ref<GDNativeClass>();
+ p_script->native = Ref<GDScriptNativeClass>();
p_script->base = Ref<GDScript>();
p_script->_base = NULL;
p_script->members.clear();
p_script->constants.clear();
- for (Map<StringName, GDFunction *>::Element *E = p_script->member_functions.front(); E; E = E->next()) {
+ for (Map<StringName, GDScriptFunction *>::Element *E = p_script->member_functions.front(); E; E = E->next()) {
memdelete(E->get());
}
p_script->member_functions.clear();
@@ -1606,7 +1607,7 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
p_script->tool = p_class->tool;
p_script->name = p_class->name;
- Ref<GDNativeClass> native;
+ Ref<GDScriptNativeClass> native;
if (p_class->extends_used) {
//do inheritance
@@ -1801,14 +1802,14 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
for (int i = 0; i < p_class->constant_expressions.size(); i++) {
StringName name = p_class->constant_expressions[i].identifier;
- ERR_CONTINUE(p_class->constant_expressions[i].expression->type != GDParser::Node::TYPE_CONSTANT);
+ ERR_CONTINUE(p_class->constant_expressions[i].expression->type != GDScriptParser::Node::TYPE_CONSTANT);
if (_is_class_member_property(p_script, name)) {
_set_error("Member '" + name + "' already exists as a class property.", p_class);
return ERR_ALREADY_EXISTS;
}
- GDParser::ConstantNode *constant = static_cast<GDParser::ConstantNode *>(p_class->constant_expressions[i].expression);
+ GDScriptParser::ConstantNode *constant = static_cast<GDScriptParser::ConstantNode *>(p_class->constant_expressions[i].expression);
p_script->constants.insert(name, constant->value);
//p_script->constants[constant->value].make_const();
@@ -1917,7 +1918,7 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
for (int i = 0; i < p_class->variables.size(); i++) {
if (p_class->variables[i].setter) {
- const Map<StringName, GDFunction *>::Element *E = p_script->get_member_functions().find(p_class->variables[i].setter);
+ const Map<StringName, GDScriptFunction *>::Element *E = p_script->get_member_functions().find(p_class->variables[i].setter);
if (!E) {
_set_error("Setter function '" + String(p_class->variables[i].setter) + "' not found in class.", NULL);
err_line = p_class->variables[i].line;
@@ -1934,7 +1935,7 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
}
}
if (p_class->variables[i].getter) {
- const Map<StringName, GDFunction *>::Element *E = p_script->get_member_functions().find(p_class->variables[i].getter);
+ const Map<StringName, GDScriptFunction *>::Element *E = p_script->get_member_functions().find(p_class->variables[i].getter);
if (!E) {
_set_error("Getter function '" + String(p_class->variables[i].getter) + "' not found in class.", NULL);
err_line = p_class->variables[i].line;
@@ -1970,7 +1971,7 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
//re-create as an instance
p_script->placeholders.erase(psi); //remove placeholder
- GDInstance *instance = memnew(GDInstance);
+ GDScriptInstance *instance = memnew(GDScriptInstance);
instance->base_ref = Object::cast_to<Reference>(E->get());
instance->members.resize(p_script->member_indices.size());
instance->script = Ref<GDScript>(p_script);
@@ -1994,7 +1995,7 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
#endif
} else {
- GDInstance *gi = static_cast<GDInstance *>(si);
+ GDScriptInstance *gi = static_cast<GDScriptInstance *>(si);
gi->reload_members();
}
@@ -2007,18 +2008,18 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
return OK;
}
-Error GDCompiler::compile(const GDParser *p_parser, GDScript *p_script, bool p_keep_state) {
+Error GDScriptCompiler::compile(const GDScriptParser *p_parser, GDScript *p_script, bool p_keep_state) {
err_line = -1;
err_column = -1;
error = "";
parser = p_parser;
- const GDParser::Node *root = parser->get_parse_tree();
- ERR_FAIL_COND_V(root->type != GDParser::Node::TYPE_CLASS, ERR_INVALID_DATA);
+ const GDScriptParser::Node *root = parser->get_parse_tree();
+ ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, ERR_INVALID_DATA);
source = p_script->get_path();
- Error err = _parse_class(p_script, NULL, static_cast<const GDParser::ClassNode *>(root), p_keep_state);
+ Error err = _parse_class(p_script, NULL, static_cast<const GDScriptParser::ClassNode *>(root), p_keep_state);
if (err)
return err;
@@ -2026,18 +2027,18 @@ Error GDCompiler::compile(const GDParser *p_parser, GDScript *p_script, bool p_k
return OK;
}
-String GDCompiler::get_error() const {
+String GDScriptCompiler::get_error() const {
return error;
}
-int GDCompiler::get_error_line() const {
+int GDScriptCompiler::get_error_line() const {
return err_line;
}
-int GDCompiler::get_error_column() const {
+int GDScriptCompiler::get_error_column() const {
return err_column;
}
-GDCompiler::GDCompiler() {
+GDScriptCompiler::GDScriptCompiler() {
}
diff --git a/modules/gdscript/gd_compiler.h b/modules/gdscript/gdscript_compiler.h
index ac713ae75b..6e0457ba30 100644
--- a/modules/gdscript/gd_compiler.h
+++ b/modules/gdscript/gdscript_compiler.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_compiler.h */
+/* gdscript_compiler.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,26 +27,26 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GD_COMPILER_H
-#define GD_COMPILER_H
+#ifndef GDSCRIPT_COMPILER_H
+#define GDSCRIPT_COMPILER_H
-#include "gd_parser.h"
-#include "gd_script.h"
+#include "gdscript.h"
+#include "gdscript_parser.h"
-class GDCompiler {
+class GDScriptCompiler {
- const GDParser *parser;
+ const GDScriptParser *parser;
struct CodeGen {
GDScript *script;
- const GDParser::ClassNode *class_node;
- const GDParser::FunctionNode *function_node;
+ const GDScriptParser::ClassNode *class_node;
+ const GDScriptParser::FunctionNode *function_node;
bool debug_stack;
List<Map<StringName, int> > stack_id_stack;
Map<StringName, int> stack_identifiers;
- List<GDFunction::StackDebug> stack_debug;
+ List<GDScriptFunction::StackDebug> stack_debug;
List<Map<StringName, int> > block_identifier_stack;
Map<StringName, int> block_identifiers;
@@ -54,7 +54,7 @@ class GDCompiler {
stack_identifiers[p_id] = p_stackpos;
if (debug_stack) {
block_identifiers[p_id] = p_stackpos;
- GDFunction::StackDebug sd;
+ GDScriptFunction::StackDebug sd;
sd.added = true;
sd.line = current_line;
sd.identifier = p_id;
@@ -79,7 +79,7 @@ class GDCompiler {
if (debug_stack) {
for (Map<StringName, int>::Element *E = block_identifiers.front(); E; E = E->next()) {
- GDFunction::StackDebug sd;
+ GDScriptFunction::StackDebug sd;
sd.added = false;
sd.identifier = E->key();
sd.line = current_line;
@@ -129,29 +129,29 @@ class GDCompiler {
bool _is_class_member_property(CodeGen &codegen, const StringName &p_name);
bool _is_class_member_property(GDScript *owner, const StringName &p_name);
- void _set_error(const String &p_error, const GDParser::Node *p_node);
+ void _set_error(const String &p_error, const GDScriptParser::Node *p_node);
- bool _create_unary_operator(CodeGen &codegen, const GDParser::OperatorNode *on, Variant::Operator op, int p_stack_level);
- bool _create_binary_operator(CodeGen &codegen, const GDParser::OperatorNode *on, Variant::Operator op, int p_stack_level, bool p_initializer = false);
+ bool _create_unary_operator(CodeGen &codegen, const GDScriptParser::OperatorNode *on, Variant::Operator op, int p_stack_level);
+ bool _create_binary_operator(CodeGen &codegen, const GDScriptParser::OperatorNode *on, Variant::Operator op, int p_stack_level, bool p_initializer = false);
- int _parse_assign_right_expression(CodeGen &codegen, const GDParser::OperatorNode *p_expression, int p_stack_level);
- int _parse_expression(CodeGen &codegen, const GDParser::Node *p_expression, int p_stack_level, bool p_root = false, bool p_initializer = false);
- Error _parse_block(CodeGen &codegen, const GDParser::BlockNode *p_block, int p_stack_level = 0, int p_break_addr = -1, int p_continue_addr = -1);
- Error _parse_function(GDScript *p_script, const GDParser::ClassNode *p_class, const GDParser::FunctionNode *p_func, bool p_for_ready = false);
- Error _parse_class(GDScript *p_script, GDScript *p_owner, const GDParser::ClassNode *p_class, bool p_keep_state);
+ int _parse_assign_right_expression(CodeGen &codegen, const GDScriptParser::OperatorNode *p_expression, int p_stack_level);
+ int _parse_expression(CodeGen &codegen, const GDScriptParser::Node *p_expression, int p_stack_level, bool p_root = false, bool p_initializer = false);
+ Error _parse_block(CodeGen &codegen, const GDScriptParser::BlockNode *p_block, int p_stack_level = 0, int p_break_addr = -1, int p_continue_addr = -1);
+ Error _parse_function(GDScript *p_script, const GDScriptParser::ClassNode *p_class, const GDScriptParser::FunctionNode *p_func, bool p_for_ready = false);
+ Error _parse_class(GDScript *p_script, GDScript *p_owner, const GDScriptParser::ClassNode *p_class, bool p_keep_state);
int err_line;
int err_column;
StringName source;
String error;
public:
- Error compile(const GDParser *p_parser, GDScript *p_script, bool p_keep_state = false);
+ Error compile(const GDScriptParser *p_parser, GDScript *p_script, bool p_keep_state = false);
String get_error() const;
int get_error_line() const;
int get_error_column() const;
- GDCompiler();
+ GDScriptCompiler();
};
-#endif // COMPILER_H
+#endif // GDSCRIPT_COMPILER_H
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 9b7201f5f7..a74b8a8483 100644
--- a/modules/gdscript/gd_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_editor.cpp */
+/* gdscript_editor.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,10 +27,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "gd_script.h"
+#include "gdscript.h"
#include "editor/editor_settings.h"
-#include "gd_compiler.h"
+#include "gdscript_compiler.h"
#include "global_constants.h"
#include "os/file_access.h"
#include "project_settings.h"
@@ -92,7 +92,7 @@ void GDScriptLanguage::make_template(const String &p_class_name, const String &p
bool GDScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions) const {
- GDParser parser;
+ GDScriptParser parser;
Error err = parser.parse(p_script, p_path.get_base_dir(), true, p_path);
if (err) {
@@ -102,10 +102,10 @@ bool GDScriptLanguage::validate(const String &p_script, int &r_line_error, int &
return false;
} else {
- const GDParser::Node *root = parser.get_parse_tree();
- ERR_FAIL_COND_V(root->type != GDParser::Node::TYPE_CLASS, false);
+ const GDScriptParser::Node *root = parser.get_parse_tree();
+ ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, false);
- const GDParser::ClassNode *cl = static_cast<const GDParser::ClassNode *>(root);
+ const GDScriptParser::ClassNode *cl = static_cast<const GDScriptParser::ClassNode *>(root);
Map<int, String> funcs;
for (int i = 0; i < cl->functions.size(); i++) {
@@ -138,16 +138,16 @@ bool GDScriptLanguage::supports_builtin_mode() const {
int GDScriptLanguage::find_function(const String &p_function, const String &p_code) const {
- GDTokenizerText tokenizer;
+ GDScriptTokenizerText tokenizer;
tokenizer.set_code(p_code);
int indent = 0;
- while (tokenizer.get_token() != GDTokenizer::TK_EOF && tokenizer.get_token() != GDTokenizer::TK_ERROR) {
+ while (tokenizer.get_token() != GDScriptTokenizer::TK_EOF && tokenizer.get_token() != GDScriptTokenizer::TK_ERROR) {
- if (tokenizer.get_token() == GDTokenizer::TK_NEWLINE) {
+ if (tokenizer.get_token() == GDScriptTokenizer::TK_NEWLINE) {
indent = tokenizer.get_token_line_indent();
}
- //print_line("TOKEN: "+String(GDTokenizer::get_token_name(tokenizer.get_token())));
- if (indent == 0 && tokenizer.get_token() == GDTokenizer::TK_PR_FUNCTION && tokenizer.get_token(1) == GDTokenizer::TK_IDENTIFIER) {
+ //print_line("TOKEN: "+String(GDScriptTokenizer::get_token_name(tokenizer.get_token())));
+ if (indent == 0 && tokenizer.get_token() == GDScriptTokenizer::TK_PR_FUNCTION && tokenizer.get_token(1) == GDScriptTokenizer::TK_IDENTIFIER) {
String identifier = tokenizer.get_token_identifier(1);
if (identifier == p_function) {
@@ -155,7 +155,7 @@ int GDScriptLanguage::find_function(const String &p_function, const String &p_co
}
}
tokenizer.advance();
- //print_line("NEXT: "+String(GDTokenizer::get_token_name(tokenizer.get_token())));
+ //print_line("NEXT: "+String(GDScriptTokenizer::get_token_name(tokenizer.get_token())));
}
return -1;
}
@@ -245,7 +245,7 @@ void GDScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p
ERR_FAIL_INDEX(p_level, _debug_call_stack_pos);
int l = _debug_call_stack_pos - p_level - 1;
- GDFunction *f = _call_stack[l].function;
+ GDScriptFunction *f = _call_stack[l].function;
List<Pair<StringName, int> > locals;
@@ -264,7 +264,7 @@ void GDScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *
ERR_FAIL_INDEX(p_level, _debug_call_stack_pos);
int l = _debug_call_stack_pos - p_level - 1;
- GDInstance *instance = _call_stack[l].instance;
+ GDScriptInstance *instance = _call_stack[l].instance;
if (!instance)
return;
@@ -298,9 +298,9 @@ void GDScriptLanguage::get_recognized_extensions(List<String> *p_extensions) con
void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const {
- for (int i = 0; i < GDFunctions::FUNC_MAX; i++) {
+ for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) {
- p_functions->push_back(GDFunctions::get_info(GDFunctions::Function(i)));
+ p_functions->push_back(GDScriptFunctions::get_info(GDScriptFunctions::Function(i)));
}
//not really "functions", but..
@@ -318,7 +318,7 @@ void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const
mi.arguments.push_back(PropertyInfo(Variant::STRING, "signal"));
mi.default_arguments.push_back(Variant::NIL);
mi.default_arguments.push_back(Variant::STRING);
- mi.return_val = PropertyInfo(Variant::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, "GDFunctionState");
+ mi.return_val = PropertyInfo(Variant::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, "GDScriptFunctionState");
p_functions->push_back(mi);
}
{
@@ -372,7 +372,7 @@ String GDScriptLanguage::make_function(const String &p_class, const String &p_na
#if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED)
-struct GDCompletionIdentifier {
+struct GDScriptCompletionIdentifier {
String enumeration;
StringName obj_type;
@@ -381,17 +381,17 @@ struct GDCompletionIdentifier {
Variant value; //im case there is a value, also return it
};
-static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant, bool p_allow_gdnative_class = false) {
+static GDScriptCompletionIdentifier _get_type_from_variant(const Variant &p_variant, bool p_allow_gdnative_class = false) {
- GDCompletionIdentifier t;
+ GDScriptCompletionIdentifier t;
t.type = p_variant.get_type();
t.value = p_variant;
if (p_variant.get_type() == Variant::OBJECT) {
Object *obj = p_variant;
if (obj) {
- if (p_allow_gdnative_class && Object::cast_to<GDNativeClass>(obj)) {
- t.obj_type = Object::cast_to<GDNativeClass>(obj)->get_name();
+ if (p_allow_gdnative_class && Object::cast_to<GDScriptNativeClass>(obj)) {
+ t.obj_type = Object::cast_to<GDScriptNativeClass>(obj)->get_name();
t.value = Variant();
} else {
@@ -402,9 +402,9 @@ static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant, b
return t;
}
-static GDCompletionIdentifier _get_type_from_pinfo(const PropertyInfo &p_info) {
+static GDScriptCompletionIdentifier _get_type_from_pinfo(const PropertyInfo &p_info) {
- GDCompletionIdentifier t;
+ GDScriptCompletionIdentifier t;
t.type = p_info.type;
if (p_info.hint == PROPERTY_HINT_RESOURCE_TYPE) {
t.obj_type = p_info.hint_string;
@@ -412,23 +412,23 @@ static GDCompletionIdentifier _get_type_from_pinfo(const PropertyInfo &p_info) {
return t;
}
-struct GDCompletionContext {
+struct GDScriptCompletionContext {
- const GDParser::ClassNode *_class;
- const GDParser::FunctionNode *function;
- const GDParser::BlockNode *block;
+ const GDScriptParser::ClassNode *_class;
+ const GDScriptParser::FunctionNode *function;
+ const GDScriptParser::BlockNode *block;
Object *base;
String base_path;
};
-static Ref<Reference> _get_parent_class(GDCompletionContext &context) {
+static Ref<Reference> _get_parent_class(GDScriptCompletionContext &context) {
if (context._class->extends_used) {
//do inheritance
String path = context._class->extends_file;
Ref<GDScript> script;
- Ref<GDNativeClass> native;
+ Ref<GDScriptNativeClass> native;
if (path != "") {
//path (and optionally subclasses)
@@ -498,17 +498,17 @@ static Ref<Reference> _get_parent_class(GDCompletionContext &context) {
return Ref<Reference>();
}
-static GDCompletionIdentifier _get_native_class(GDCompletionContext &context) {
+static GDScriptCompletionIdentifier _get_native_class(GDScriptCompletionContext &context) {
//eeh...
- GDCompletionIdentifier id;
+ GDScriptCompletionIdentifier id;
id.type = Variant::NIL;
REF pc = _get_parent_class(context);
if (!pc.is_valid()) {
return id;
}
- Ref<GDNativeClass> nc = pc;
+ Ref<GDScriptNativeClass> nc = pc;
Ref<GDScript> s = pc;
if (s.is_null() && nc.is_null()) {
@@ -529,28 +529,28 @@ static GDCompletionIdentifier _get_native_class(GDCompletionContext &context) {
return id;
}
-static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type, bool p_for_indexing);
+static bool _guess_identifier_type(GDScriptCompletionContext &context, int p_line, const StringName &p_identifier, GDScriptCompletionIdentifier &r_type, bool p_for_indexing);
-static bool _guess_expression_type(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, GDCompletionIdentifier &r_type, bool p_for_indexing = false) {
+static bool _guess_expression_type(GDScriptCompletionContext &context, const GDScriptParser::Node *p_node, int p_line, GDScriptCompletionIdentifier &r_type, bool p_for_indexing = false) {
- if (p_node->type == GDParser::Node::TYPE_CONSTANT) {
+ if (p_node->type == GDScriptParser::Node::TYPE_CONSTANT) {
- const GDParser::ConstantNode *cn = static_cast<const GDParser::ConstantNode *>(p_node);
+ const GDScriptParser::ConstantNode *cn = static_cast<const GDScriptParser::ConstantNode *>(p_node);
r_type = _get_type_from_variant(cn->value);
return true;
- } else if (p_node->type == GDParser::Node::TYPE_DICTIONARY) {
+ } else if (p_node->type == GDScriptParser::Node::TYPE_DICTIONARY) {
r_type.type = Variant::DICTIONARY;
//what the heck, fill it anyway
- const GDParser::DictionaryNode *an = static_cast<const GDParser::DictionaryNode *>(p_node);
+ const GDScriptParser::DictionaryNode *an = static_cast<const GDScriptParser::DictionaryNode *>(p_node);
Dictionary d;
for (int i = 0; i < an->elements.size(); i++) {
- GDCompletionIdentifier k;
+ GDScriptCompletionIdentifier k;
if (_guess_expression_type(context, an->elements[i].key, p_line, k) && k.value.get_type() != Variant::NIL) {
- GDCompletionIdentifier v;
+ GDScriptCompletionIdentifier v;
if (_guess_expression_type(context, an->elements[i].value, p_line, v)) {
d[k.value] = v.value;
}
@@ -558,15 +558,15 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
}
r_type.value = d;
return true;
- } else if (p_node->type == GDParser::Node::TYPE_ARRAY) {
+ } else if (p_node->type == GDScriptParser::Node::TYPE_ARRAY) {
r_type.type = Variant::ARRAY;
//what the heck, fill it anyway
- const GDParser::ArrayNode *an = static_cast<const GDParser::ArrayNode *>(p_node);
+ const GDScriptParser::ArrayNode *an = static_cast<const GDScriptParser::ArrayNode *>(p_node);
Array arr;
arr.resize(an->elements.size());
for (int i = 0; i < an->elements.size(); i++) {
- GDCompletionIdentifier ci;
+ GDScriptCompletionIdentifier ci;
if (_guess_expression_type(context, an->elements[i], p_line, ci)) {
arr[i] = ci.value;
}
@@ -574,44 +574,44 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
r_type.value = arr;
return true;
- } else if (p_node->type == GDParser::Node::TYPE_BUILT_IN_FUNCTION) {
+ } else if (p_node->type == GDScriptParser::Node::TYPE_BUILT_IN_FUNCTION) {
- MethodInfo mi = GDFunctions::get_info(static_cast<const GDParser::BuiltInFunctionNode *>(p_node)->function);
+ MethodInfo mi = GDScriptFunctions::get_info(static_cast<const GDScriptParser::BuiltInFunctionNode *>(p_node)->function);
r_type = _get_type_from_pinfo(mi.return_val);
return true;
- } else if (p_node->type == GDParser::Node::TYPE_IDENTIFIER) {
+ } else if (p_node->type == GDScriptParser::Node::TYPE_IDENTIFIER) {
- return _guess_identifier_type(context, p_line - 1, static_cast<const GDParser::IdentifierNode *>(p_node)->name, r_type, p_for_indexing);
- } else if (p_node->type == GDParser::Node::TYPE_SELF) {
+ return _guess_identifier_type(context, p_line - 1, static_cast<const GDScriptParser::IdentifierNode *>(p_node)->name, r_type, p_for_indexing);
+ } else if (p_node->type == GDScriptParser::Node::TYPE_SELF) {
//eeh...
r_type = _get_native_class(context);
return r_type.type != Variant::NIL;
- } else if (p_node->type == GDParser::Node::TYPE_OPERATOR) {
+ } else if (p_node->type == GDScriptParser::Node::TYPE_OPERATOR) {
- const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(p_node);
- if (op->op == GDParser::OperatorNode::OP_CALL) {
+ const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(p_node);
+ if (op->op == GDScriptParser::OperatorNode::OP_CALL) {
- if (op->arguments[0]->type == GDParser::Node::TYPE_TYPE) {
+ if (op->arguments[0]->type == GDScriptParser::Node::TYPE_TYPE) {
- const GDParser::TypeNode *tn = static_cast<const GDParser::TypeNode *>(op->arguments[0]);
+ const GDScriptParser::TypeNode *tn = static_cast<const GDScriptParser::TypeNode *>(op->arguments[0]);
r_type.type = tn->vtype;
return true;
- } else if (op->arguments[0]->type == GDParser::Node::TYPE_BUILT_IN_FUNCTION) {
+ } else if (op->arguments[0]->type == GDScriptParser::Node::TYPE_BUILT_IN_FUNCTION) {
- const GDParser::BuiltInFunctionNode *bin = static_cast<const GDParser::BuiltInFunctionNode *>(op->arguments[0]);
+ const GDScriptParser::BuiltInFunctionNode *bin = static_cast<const GDScriptParser::BuiltInFunctionNode *>(op->arguments[0]);
return _guess_expression_type(context, bin, p_line, r_type);
- } else if (op->arguments.size() > 1 && op->arguments[1]->type == GDParser::Node::TYPE_IDENTIFIER) {
+ } else if (op->arguments.size() > 1 && op->arguments[1]->type == GDScriptParser::Node::TYPE_IDENTIFIER) {
- StringName id = static_cast<const GDParser::IdentifierNode *>(op->arguments[1])->name;
+ StringName id = static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[1])->name;
- if (op->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER && String(id) == "new") {
+ if (op->arguments[0]->type == GDScriptParser::Node::TYPE_IDENTIFIER && String(id) == "new") {
//shortcut
- StringName identifier = static_cast<const GDParser::IdentifierNode *>(op->arguments[0])->name;
+ StringName identifier = static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[0])->name;
if (ClassDB::class_exists(identifier)) {
r_type.type = Variant::OBJECT;
@@ -621,7 +621,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
}
}
- GDCompletionIdentifier base;
+ GDScriptCompletionIdentifier base;
if (!_guess_expression_type(context, op->arguments[0], p_line, base))
return false;
@@ -630,8 +630,8 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
if (id.operator String() == "new" && base.value.get_type() == Variant::OBJECT) {
Object *obj = base.value;
- if (obj && Object::cast_to<GDNativeClass>(obj)) {
- GDNativeClass *gdnc = Object::cast_to<GDNativeClass>(obj);
+ if (obj && Object::cast_to<GDScriptNativeClass>(obj)) {
+ GDScriptNativeClass *gdnc = Object::cast_to<GDScriptNativeClass>(obj);
r_type.type = Variant::OBJECT;
r_type.value = Variant();
r_type.obj_type = gdnc->get_name();
@@ -662,7 +662,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
bool all_valid = true;
Vector<Variant> args;
for (int i = 2; i < op->arguments.size(); i++) {
- GDCompletionIdentifier arg;
+ GDScriptCompletionIdentifier arg;
if (_guess_expression_type(context, op->arguments[i], p_line, arg)) {
if (arg.value.get_type() != Variant::NIL && arg.value.get_type() != Variant::OBJECT) { // calling with object seems dangerous, i don' t know
@@ -785,15 +785,15 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
}
}
}
- } else if (op->op == GDParser::OperatorNode::OP_INDEX || op->op == GDParser::OperatorNode::OP_INDEX_NAMED) {
+ } else if (op->op == GDScriptParser::OperatorNode::OP_INDEX || op->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED) {
- GDCompletionIdentifier p1;
- GDCompletionIdentifier p2;
+ GDScriptCompletionIdentifier p1;
+ GDScriptCompletionIdentifier p2;
- if (op->op == GDParser::OperatorNode::OP_INDEX_NAMED) {
+ if (op->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED) {
- if (op->arguments[1]->type == GDParser::Node::TYPE_IDENTIFIER) {
- String id = static_cast<const GDParser::IdentifierNode *>(op->arguments[1])->name;
+ if (op->arguments[1]->type == GDScriptParser::Node::TYPE_IDENTIFIER) {
+ String id = static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[1])->name;
p2.type = Variant::STRING;
p2.value = id;
}
@@ -807,9 +807,9 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
}
}
- if (op->arguments[0]->type == GDParser::Node::TYPE_ARRAY) {
+ if (op->arguments[0]->type == GDScriptParser::Node::TYPE_ARRAY) {
- const GDParser::ArrayNode *an = static_cast<const GDParser::ArrayNode *>(op->arguments[0]);
+ const GDScriptParser::ArrayNode *an = static_cast<const GDScriptParser::ArrayNode *>(op->arguments[0]);
if (p2.value.is_num()) {
int index = p2.value;
if (index < 0 || index >= an->elements.size())
@@ -817,16 +817,16 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
return _guess_expression_type(context, an->elements[index], p_line, r_type);
}
- } else if (op->arguments[0]->type == GDParser::Node::TYPE_DICTIONARY) {
+ } else if (op->arguments[0]->type == GDScriptParser::Node::TYPE_DICTIONARY) {
- const GDParser::DictionaryNode *dn = static_cast<const GDParser::DictionaryNode *>(op->arguments[0]);
+ const GDScriptParser::DictionaryNode *dn = static_cast<const GDScriptParser::DictionaryNode *>(op->arguments[0]);
if (p2.value.get_type() == Variant::NIL)
return false;
for (int i = 0; i < dn->elements.size(); i++) {
- GDCompletionIdentifier k;
+ GDScriptCompletionIdentifier k;
if (!_guess_expression_type(context, dn->elements[i].key, p_line, k)) {
@@ -858,9 +858,9 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
StringName base_type = p1.obj_type;
- if (p1.obj_type == "GDNativeClass") {
+ if (p1.obj_type == "GDScriptNativeClass") {
//native enum
- Ref<GDNativeClass> gdn = p1.value;
+ Ref<GDScriptNativeClass> gdn = p1.value;
if (gdn.is_valid()) {
base_type = gdn->get_name();
@@ -921,24 +921,24 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
Variant::Operator vop = Variant::OP_MAX;
switch (op->op) {
- case GDParser::OperatorNode::OP_ADD: vop = Variant::OP_ADD; break;
- case GDParser::OperatorNode::OP_SUB: vop = Variant::OP_SUBTRACT; break;
- case GDParser::OperatorNode::OP_MUL: vop = Variant::OP_MULTIPLY; break;
- case GDParser::OperatorNode::OP_DIV: vop = Variant::OP_DIVIDE; break;
- case GDParser::OperatorNode::OP_MOD: vop = Variant::OP_MODULE; break;
- case GDParser::OperatorNode::OP_SHIFT_LEFT: vop = Variant::OP_SHIFT_LEFT; break;
- case GDParser::OperatorNode::OP_SHIFT_RIGHT: vop = Variant::OP_SHIFT_RIGHT; break;
- case GDParser::OperatorNode::OP_BIT_AND: vop = Variant::OP_BIT_AND; break;
- case GDParser::OperatorNode::OP_BIT_OR: vop = Variant::OP_BIT_OR; break;
- case GDParser::OperatorNode::OP_BIT_XOR: vop = Variant::OP_BIT_XOR; break;
+ case GDScriptParser::OperatorNode::OP_ADD: vop = Variant::OP_ADD; break;
+ case GDScriptParser::OperatorNode::OP_SUB: vop = Variant::OP_SUBTRACT; break;
+ case GDScriptParser::OperatorNode::OP_MUL: vop = Variant::OP_MULTIPLY; break;
+ case GDScriptParser::OperatorNode::OP_DIV: vop = Variant::OP_DIVIDE; break;
+ case GDScriptParser::OperatorNode::OP_MOD: vop = Variant::OP_MODULE; break;
+ case GDScriptParser::OperatorNode::OP_SHIFT_LEFT: vop = Variant::OP_SHIFT_LEFT; break;
+ case GDScriptParser::OperatorNode::OP_SHIFT_RIGHT: vop = Variant::OP_SHIFT_RIGHT; break;
+ case GDScriptParser::OperatorNode::OP_BIT_AND: vop = Variant::OP_BIT_AND; break;
+ case GDScriptParser::OperatorNode::OP_BIT_OR: vop = Variant::OP_BIT_OR; break;
+ case GDScriptParser::OperatorNode::OP_BIT_XOR: vop = Variant::OP_BIT_XOR; break;
default: {}
}
if (vop == Variant::OP_MAX)
return false;
- GDCompletionIdentifier p1;
- GDCompletionIdentifier p2;
+ GDScriptCompletionIdentifier p1;
+ GDScriptCompletionIdentifier p2;
if (op->arguments[0]) {
if (!_guess_expression_type(context, op->arguments[0], p_line, p1)) {
@@ -985,15 +985,15 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
return false;
}
-static bool _guess_identifier_type_in_block(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type) {
+static bool _guess_identifier_type_in_block(GDScriptCompletionContext &context, int p_line, const StringName &p_identifier, GDScriptCompletionIdentifier &r_type) {
- if (context.block->if_condition && context.block->if_condition->type == GDParser::Node::TYPE_OPERATOR && static_cast<const GDParser::OperatorNode *>(context.block->if_condition)->op == GDParser::OperatorNode::OP_IS) {
+ if (context.block->if_condition && context.block->if_condition->type == GDScriptParser::Node::TYPE_OPERATOR && static_cast<const GDScriptParser::OperatorNode *>(context.block->if_condition)->op == GDScriptParser::OperatorNode::OP_IS) {
//is used, check if identifier is in there! this helps resolve in blocks that are (if (identifier is value)): which are very common..
//super dirty hack, but very useful
//credit: Zylann
//TODO: this could be hacked to detect ANDed conditions too..
- const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(context.block->if_condition);
- if (op->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER && static_cast<const GDParser::IdentifierNode *>(op->arguments[0])->name == p_identifier) {
+ const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(context.block->if_condition);
+ if (op->arguments[0]->type == GDScriptParser::Node::TYPE_IDENTIFIER && static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[0])->name == p_identifier) {
//bingo
if (_guess_expression_type(context, op->arguments[1], op->line, r_type)) {
return true;
@@ -1001,7 +1001,7 @@ static bool _guess_identifier_type_in_block(GDCompletionContext &context, int p_
}
}
- GDCompletionIdentifier gdi = _get_native_class(context);
+ GDScriptCompletionIdentifier gdi = _get_native_class(context);
if (gdi.obj_type != StringName()) {
bool valid;
Variant::Type t = ClassDB::get_property_type(gdi.obj_type, p_identifier, &valid);
@@ -1027,7 +1027,7 @@ static bool _guess_identifier_type_in_block(GDCompletionContext &context, int p_
}
}
- const GDParser::Node *last_assign = NULL;
+ const GDScriptParser::Node *last_assign = NULL;
int last_assign_line = -1;
for (int i = 0; i < context.block->statements.size(); i++) {
@@ -1035,9 +1035,9 @@ static bool _guess_identifier_type_in_block(GDCompletionContext &context, int p_
if (context.block->statements[i]->line > p_line)
continue;
- if (context.block->statements[i]->type == GDParser::BlockNode::TYPE_LOCAL_VAR) {
+ if (context.block->statements[i]->type == GDScriptParser::BlockNode::TYPE_LOCAL_VAR) {
- const GDParser::LocalVarNode *lv = static_cast<const GDParser::LocalVarNode *>(context.block->statements[i]);
+ const GDScriptParser::LocalVarNode *lv = static_cast<const GDScriptParser::LocalVarNode *>(context.block->statements[i]);
if (lv->assign && lv->name == p_identifier) {
@@ -1046,13 +1046,13 @@ static bool _guess_identifier_type_in_block(GDCompletionContext &context, int p_
}
}
- if (context.block->statements[i]->type == GDParser::BlockNode::TYPE_OPERATOR) {
- const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(context.block->statements[i]);
- if (op->op == GDParser::OperatorNode::OP_ASSIGN) {
+ if (context.block->statements[i]->type == GDScriptParser::BlockNode::TYPE_OPERATOR) {
+ const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(context.block->statements[i]);
+ if (op->op == GDScriptParser::OperatorNode::OP_ASSIGN) {
- if (op->arguments.size() && op->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER) {
+ if (op->arguments.size() && op->arguments[0]->type == GDScriptParser::Node::TYPE_IDENTIFIER) {
- const GDParser::IdentifierNode *id = static_cast<const GDParser::IdentifierNode *>(op->arguments[0]);
+ const GDScriptParser::IdentifierNode *id = static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[0]);
if (id->name == p_identifier) {
@@ -1073,9 +1073,9 @@ static bool _guess_identifier_type_in_block(GDCompletionContext &context, int p_
return false;
}
-static bool _guess_identifier_from_assignment_in_function(GDCompletionContext &context, int p_src_line, const StringName &p_identifier, const StringName &p_function, GDCompletionIdentifier &r_type) {
+static bool _guess_identifier_from_assignment_in_function(GDScriptCompletionContext &context, int p_src_line, const StringName &p_identifier, const StringName &p_function, GDScriptCompletionIdentifier &r_type) {
- const GDParser::FunctionNode *func = NULL;
+ const GDScriptParser::FunctionNode *func = NULL;
for (int i = 0; i < context._class->functions.size(); i++) {
if (context._class->functions[i]->name == p_function) {
func = context._class->functions[i];
@@ -1092,13 +1092,13 @@ static bool _guess_identifier_from_assignment_in_function(GDCompletionContext &c
break;
}
- if (func->body->statements[i]->type == GDParser::BlockNode::TYPE_OPERATOR) {
- const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(func->body->statements[i]);
- if (op->op == GDParser::OperatorNode::OP_ASSIGN) {
+ if (func->body->statements[i]->type == GDScriptParser::BlockNode::TYPE_OPERATOR) {
+ const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(func->body->statements[i]);
+ if (op->op == GDScriptParser::OperatorNode::OP_ASSIGN) {
- if (op->arguments.size() && op->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER) {
+ if (op->arguments.size() && op->arguments[0]->type == GDScriptParser::Node::TYPE_IDENTIFIER) {
- const GDParser::IdentifierNode *id = static_cast<const GDParser::IdentifierNode *>(op->arguments[0]);
+ const GDScriptParser::IdentifierNode *id = static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[0]);
if (id->name == p_identifier) {
@@ -1112,15 +1112,15 @@ static bool _guess_identifier_from_assignment_in_function(GDCompletionContext &c
return false;
}
-static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type, bool p_for_indexing) {
+static bool _guess_identifier_type(GDScriptCompletionContext &context, int p_line, const StringName &p_identifier, GDScriptCompletionIdentifier &r_type, bool p_for_indexing) {
//go to block first
- const GDParser::BlockNode *block = context.block;
+ const GDScriptParser::BlockNode *block = context.block;
while (block) {
- GDCompletionContext c = context;
+ GDScriptCompletionContext c = context;
c.block = block;
if (_guess_identifier_type_in_block(c, p_line, p_identifier, r_type)) {
@@ -1144,7 +1144,7 @@ static bool _guess_identifier_type(GDCompletionContext &context, int p_line, con
}
if (argindex != -1) {
- GDCompletionIdentifier id = _get_native_class(context);
+ GDScriptCompletionIdentifier id = _get_native_class(context);
if (id.type == Variant::OBJECT && id.obj_type != StringName()) {
//this kinda sucks but meh
@@ -1182,8 +1182,8 @@ static bool _guess_identifier_type(GDCompletionContext &context, int p_line, con
if (context._class->constant_expressions[i].identifier == p_identifier) {
- ERR_FAIL_COND_V(context._class->constant_expressions[i].expression->type != GDParser::Node::TYPE_CONSTANT, false);
- r_type = _get_type_from_variant(static_cast<const GDParser::ConstantNode *>(context._class->constant_expressions[i].expression)->value);
+ ERR_FAIL_COND_V(context._class->constant_expressions[i].expression->type != GDScriptParser::Node::TYPE_CONSTANT, false);
+ r_type = _get_type_from_variant(static_cast<const GDScriptParser::ConstantNode *>(context._class->constant_expressions[i].expression)->value);
return true;
}
}
@@ -1275,7 +1275,7 @@ static bool _guess_identifier_type(GDCompletionContext &context, int p_line, con
return false;
}
-static void _find_identifiers_in_block(GDCompletionContext &context, int p_line, bool p_only_functions, Set<String> &result) {
+static void _find_identifiers_in_block(GDScriptCompletionContext &context, int p_line, bool p_only_functions, Set<String> &result) {
if (p_only_functions)
return;
@@ -1285,15 +1285,15 @@ static void _find_identifiers_in_block(GDCompletionContext &context, int p_line,
if (context.block->statements[i]->line > p_line)
continue;
- if (context.block->statements[i]->type == GDParser::BlockNode::TYPE_LOCAL_VAR) {
+ if (context.block->statements[i]->type == GDScriptParser::BlockNode::TYPE_LOCAL_VAR) {
- const GDParser::LocalVarNode *lv = static_cast<const GDParser::LocalVarNode *>(context.block->statements[i]);
+ const GDScriptParser::LocalVarNode *lv = static_cast<const GDScriptParser::LocalVarNode *>(context.block->statements[i]);
result.insert(lv->name.operator String());
}
}
}
-static void _find_identifiers_in_class(GDCompletionContext &context, bool p_static, bool p_only_functions, Set<String> &result) {
+static void _find_identifiers_in_class(GDScriptCompletionContext &context, bool p_static, bool p_only_functions, Set<String> &result) {
if (!p_static && !p_only_functions) {
@@ -1336,7 +1336,7 @@ static void _find_identifiers_in_class(GDCompletionContext &context, bool p_stat
while (true) {
Ref<GDScript> script = base;
- Ref<GDNativeClass> nc = base;
+ Ref<GDScriptNativeClass> nc = base;
if (script.is_valid()) {
if (!p_static && !p_only_functions) {
@@ -1351,7 +1351,7 @@ static void _find_identifiers_in_class(GDCompletionContext &context, bool p_stat
}
}
- for (const Map<StringName, GDFunction *>::Element *E = script->get_member_functions().front(); E; E = E->next()) {
+ for (const Map<StringName, GDScriptFunction *>::Element *E = script->get_member_functions().front(); E; E = E->next()) {
if (!p_static || E->get()->is_static()) {
if (E->get()->get_argument_count())
result.insert(E->key().operator String() + "(");
@@ -1410,13 +1410,13 @@ static void _find_identifiers_in_class(GDCompletionContext &context, bool p_stat
}
}
-static void _find_identifiers(GDCompletionContext &context, int p_line, bool p_only_functions, Set<String> &result) {
+static void _find_identifiers(GDScriptCompletionContext &context, int p_line, bool p_only_functions, Set<String> &result) {
- const GDParser::BlockNode *block = context.block;
+ const GDScriptParser::BlockNode *block = context.block;
if (context.function) {
- const GDParser::FunctionNode *f = context.function;
+ const GDScriptParser::FunctionNode *f = context.function;
for (int i = 0; i < f->arguments.size(); i++) {
result.insert(f->arguments[i].operator String());
@@ -1425,19 +1425,19 @@ static void _find_identifiers(GDCompletionContext &context, int p_line, bool p_o
while (block) {
- GDCompletionContext c = context;
+ GDScriptCompletionContext c = context;
c.block = block;
_find_identifiers_in_block(c, p_line, p_only_functions, result);
block = block->parent_block;
}
- const GDParser::ClassNode *clss = context._class;
+ const GDScriptParser::ClassNode *clss = context._class;
bool _static = context.function && context.function->_static;
while (clss) {
- GDCompletionContext c = context;
+ GDScriptCompletionContext c = context;
c._class = clss;
c.block = NULL;
c.function = NULL;
@@ -1445,9 +1445,9 @@ static void _find_identifiers(GDCompletionContext &context, int p_line, bool p_o
clss = clss->owner;
}
- for (int i = 0; i < GDFunctions::FUNC_MAX; i++) {
+ for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) {
- result.insert(GDFunctions::get_func_name(GDFunctions::Function(i)));
+ result.insert(GDScriptFunctions::get_func_name(GDScriptFunctions::Function(i)));
}
static const char *_type_names[Variant::VARIANT_MAX] = {
@@ -1501,7 +1501,7 @@ static String _get_visual_datatype(const PropertyInfo &p_info, bool p_isarg = tr
return Variant::get_type_name(p_info.type);
}
-static void _make_function_hint(const GDParser::FunctionNode *p_func, int p_argidx, String &arghint) {
+static void _make_function_hint(const GDScriptParser::FunctionNode *p_func, int p_argidx, String &arghint) {
arghint = "func " + p_func->name + "(";
for (int i = 0; i < p_func->arguments.size(); i++) {
@@ -1521,11 +1521,11 @@ static void _make_function_hint(const GDParser::FunctionNode *p_func, int p_argi
if (defidx >= 0 && defidx < p_func->default_values.size()) {
- if (p_func->default_values[defidx]->type == GDParser::Node::TYPE_OPERATOR) {
+ if (p_func->default_values[defidx]->type == GDScriptParser::Node::TYPE_OPERATOR) {
- const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(p_func->default_values[defidx]);
- if (op->op == GDParser::OperatorNode::OP_ASSIGN) {
- const GDParser::ConstantNode *cn = static_cast<const GDParser::ConstantNode *>(op->arguments[1]);
+ const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(p_func->default_values[defidx]);
+ if (op->op == GDScriptParser::OperatorNode::OP_ASSIGN) {
+ const GDScriptParser::ConstantNode *cn = static_cast<const GDScriptParser::ConstantNode *>(op->arguments[1]);
arghint += "=" + cn->value.get_construct_string();
}
} else {
@@ -1553,7 +1553,7 @@ void get_directory_contents(EditorFileSystemDirectory *p_dir, Set<String> &r_lis
}
}
-static void _find_type_arguments(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, const StringName &p_method, const GDCompletionIdentifier &id, int p_argidx, Set<String> &result, bool &r_forced, String &arghint) {
+static void _find_type_arguments(GDScriptCompletionContext &context, const GDScriptParser::Node *p_node, int p_line, const StringName &p_method, const GDScriptCompletionIdentifier &id, int p_argidx, Set<String> &result, bool &r_forced, String &arghint) {
//print_line("find type arguments?");
if (id.type == Variant::OBJECT && id.obj_type != StringName()) {
@@ -1572,7 +1572,7 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
if (scr) {
while (scr) {
- for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
+ for (const Map<StringName, GDScriptFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
if (E->get()->is_static() && p_method == E->get()->get_name()) {
arghint = "static func " + String(p_method) + "(";
for (int i = 0; i < E->get()->get_argument_count(); i++) {
@@ -1629,7 +1629,7 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
if (code != "") {
//if there is code, parse it. This way is slower but updates in real-time
- GDParser p;
+ GDScriptParser p;
//Error parse(const String& p_code, const String& p_base_path="", bool p_just_validate=false,const String& p_self_path="",bool p_for_completion=false);
Error err = p.parse(scr->get_source_code(), scr->get_path().get_base_dir(), true, "", false);
@@ -1637,13 +1637,13 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
if (err == OK) {
//print_line("checking the functions...");
//only if ok, otherwise use what is cached on the script
- //GDParser::ClassNode *base = p.
- const GDParser::Node *root = p.get_parse_tree();
- ERR_FAIL_COND(root->type != GDParser::Node::TYPE_CLASS);
+ //GDScriptParser::ClassNode *base = p.
+ const GDScriptParser::Node *root = p.get_parse_tree();
+ ERR_FAIL_COND(root->type != GDScriptParser::Node::TYPE_CLASS);
- const GDParser::ClassNode *cl = static_cast<const GDParser::ClassNode *>(root);
+ const GDScriptParser::ClassNode *cl = static_cast<const GDScriptParser::ClassNode *>(root);
- const GDParser::FunctionNode *func = NULL;
+ const GDScriptParser::FunctionNode *func = NULL;
bool st = false;
for (int i = 0; i < cl->functions.size(); i++) {
@@ -1681,10 +1681,10 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
int defidx = deffrom - i;
- if (defidx >= 0 && defidx < func->default_values.size() && func->default_values[defidx]->type == GDParser::Node::TYPE_OPERATOR) {
- const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(func->default_values[defidx]);
- if (op->op == GDParser::OperatorNode::OP_ASSIGN) {
- const GDParser::ConstantNode *cn = static_cast<const GDParser::ConstantNode *>(op->arguments[1]);
+ if (defidx >= 0 && defidx < func->default_values.size() && func->default_values[defidx]->type == GDScriptParser::Node::TYPE_OPERATOR) {
+ const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(func->default_values[defidx]);
+ if (op->op == GDScriptParser::OperatorNode::OP_ASSIGN) {
+ const GDScriptParser::ConstantNode *cn = static_cast<const GDScriptParser::ConstantNode *>(op->arguments[1]);
arghint += "=" + cn->value.get_construct_string();
}
}
@@ -1705,7 +1705,7 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
if (code == "") {
- for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
+ for (const Map<StringName, GDScriptFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
if (p_method == E->get()->get_name()) {
arghint = "func " + String(p_method) + "(";
for (int i = 0; i < E->get()->get_argument_count(); i++) {
@@ -1814,8 +1814,8 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
}
/*if (p_argidx==2) {
- ERR_FAIL_COND(p_node->type!=GDParser::Node::TYPE_OPERATOR);
- const GDParser::OperatorNode *op=static_cast<const GDParser::OperatorNode *>(p_node);
+ ERR_FAIL_COND(p_node->type!=GDScriptParser::Node::TYPE_OPERATOR);
+ const GDScriptParser::OperatorNode *op=static_cast<const GDScriptParser::OperatorNode *>(p_node);
if (op->arguments.size()>)
}*/
@@ -1890,30 +1890,30 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
}
}
-static void _find_call_arguments(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, int p_argidx, Set<String> &result, bool &r_forced, String &arghint) {
+static void _find_call_arguments(GDScriptCompletionContext &context, const GDScriptParser::Node *p_node, int p_line, int p_argidx, Set<String> &result, bool &r_forced, String &arghint) {
- if (!p_node || p_node->type != GDParser::Node::TYPE_OPERATOR) {
+ if (!p_node || p_node->type != GDScriptParser::Node::TYPE_OPERATOR) {
return;
}
- const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(p_node);
+ const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(p_node);
- if (op->op != GDParser::OperatorNode::OP_CALL) {
+ if (op->op != GDScriptParser::OperatorNode::OP_CALL) {
return;
}
- if (op->arguments[0]->type == GDParser::Node::TYPE_BUILT_IN_FUNCTION) {
+ if (op->arguments[0]->type == GDScriptParser::Node::TYPE_BUILT_IN_FUNCTION) {
//complete built-in function
- const GDParser::BuiltInFunctionNode *fn = static_cast<const GDParser::BuiltInFunctionNode *>(op->arguments[0]);
- MethodInfo mi = GDFunctions::get_info(fn->function);
+ const GDScriptParser::BuiltInFunctionNode *fn = static_cast<const GDScriptParser::BuiltInFunctionNode *>(op->arguments[0]);
+ MethodInfo mi = GDScriptFunctions::get_info(fn->function);
if (mi.name == "load" && bool(EditorSettings::get_singleton()->get("text_editor/completion/complete_file_paths"))) {
get_directory_contents(EditorFileSystem::get_singleton()->get_filesystem(), result);
}
- arghint = _get_visual_datatype(mi.return_val, false) + " " + GDFunctions::get_func_name(fn->function) + String("(");
+ arghint = _get_visual_datatype(mi.return_val, false) + " " + GDScriptFunctions::get_func_name(fn->function) + String("(");
for (int i = 0; i < mi.arguments.size(); i++) {
if (i > 0)
arghint += ", ";
@@ -1931,9 +1931,9 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N
arghint += " ";
arghint += ")";
- } else if (op->arguments[0]->type == GDParser::Node::TYPE_TYPE) {
+ } else if (op->arguments[0]->type == GDScriptParser::Node::TYPE_TYPE) {
//complete constructor
- const GDParser::TypeNode *tn = static_cast<const GDParser::TypeNode *>(op->arguments[0]);
+ const GDScriptParser::TypeNode *tn = static_cast<const GDScriptParser::TypeNode *>(op->arguments[0]);
List<MethodInfo> mil;
Variant::get_constructor_list(tn->vtype, &mil);
@@ -1964,11 +1964,11 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N
arghint += ")";
}
- } else if (op->arguments.size() >= 2 && op->arguments[1]->type == GDParser::Node::TYPE_IDENTIFIER) {
+ } else if (op->arguments.size() >= 2 && op->arguments[1]->type == GDScriptParser::Node::TYPE_IDENTIFIER) {
//make sure identifier exists...
- const GDParser::IdentifierNode *id = static_cast<const GDParser::IdentifierNode *>(op->arguments[1]);
- if (op->arguments[0]->type == GDParser::Node::TYPE_SELF) {
+ const GDScriptParser::IdentifierNode *id = static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[1]);
+ if (op->arguments[0]->type == GDScriptParser::Node::TYPE_SELF) {
//self, look up
for (int i = 0; i < context._class->static_functions.size(); i++) {
@@ -1993,10 +1993,10 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N
while (true) {
Ref<GDScript> script = base;
- Ref<GDNativeClass> nc = base;
+ Ref<GDScriptNativeClass> nc = base;
if (script.is_valid()) {
- for (const Map<StringName, GDFunction *>::Element *E = script->get_member_functions().front(); E; E = E->next()) {
+ for (const Map<StringName, GDScriptFunction *>::Element *E = script->get_member_functions().front(); E; E = E->next()) {
if (E->key() == id->name) {
@@ -2038,7 +2038,7 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N
if (!(context.function && context.function->_static)) {
- GDCompletionIdentifier ci;
+ GDScriptCompletionIdentifier ci;
ci.type = Variant::OBJECT;
ci.obj_type = nc->get_name();
if (!context._class->owner)
@@ -2063,7 +2063,7 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N
} else {
//indexed lookup
- GDCompletionIdentifier ci;
+ GDScriptCompletionIdentifier ci;
if (_guess_expression_type(context, op->arguments[0], p_line, ci)) {
_find_type_arguments(context, p_node, p_line, id->name, ci, p_argidx, result, r_forced, arghint);
@@ -2075,13 +2075,13 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N
Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, bool &r_forced, String &r_call_hint) {
- GDParser p;
+ GDScriptParser p;
p.parse(p_code, p_base_path, false, "", true);
bool isfunction = false;
Set<String> options;
r_forced = false;
- GDCompletionContext context;
+ GDScriptCompletionContext context;
context._class = p.get_completion_class();
context.block = p.get_completion_block();
context.function = p.get_completion_function();
@@ -2090,9 +2090,9 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
switch (p.get_completion_type()) {
- case GDParser::COMPLETION_NONE: {
+ case GDScriptParser::COMPLETION_NONE: {
} break;
- case GDParser::COMPLETION_BUILT_IN_TYPE_CONSTANT: {
+ case GDScriptParser::COMPLETION_BUILT_IN_TYPE_CONSTANT: {
List<StringName> constants;
Variant::get_numeric_constants_for_type(p.get_completion_built_in_constant(), &constants);
for (List<StringName>::Element *E = constants.front(); E; E = E->next()) {
@@ -2100,16 +2100,16 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
}
} break;
- case GDParser::COMPLETION_FUNCTION:
+ case GDScriptParser::COMPLETION_FUNCTION:
isfunction = true;
- case GDParser::COMPLETION_IDENTIFIER: {
+ case GDScriptParser::COMPLETION_IDENTIFIER: {
_find_identifiers(context, p.get_completion_line(), isfunction, options);
} break;
- case GDParser::COMPLETION_PARENT_FUNCTION: {
+ case GDScriptParser::COMPLETION_PARENT_FUNCTION: {
} break;
- case GDParser::COMPLETION_GET_NODE: {
+ case GDScriptParser::COMPLETION_GET_NODE: {
if (p_owner) {
List<String> opts;
@@ -2130,20 +2130,20 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
}
}
} break;
- case GDParser::COMPLETION_METHOD:
+ case GDScriptParser::COMPLETION_METHOD:
isfunction = true;
- case GDParser::COMPLETION_INDEX: {
+ case GDScriptParser::COMPLETION_INDEX: {
- const GDParser::Node *node = p.get_completion_node();
- if (node->type != GDParser::Node::TYPE_OPERATOR)
+ const GDScriptParser::Node *node = p.get_completion_node();
+ if (node->type != GDScriptParser::Node::TYPE_OPERATOR)
break;
- GDCompletionIdentifier t;
- if (_guess_expression_type(context, static_cast<const GDParser::OperatorNode *>(node)->arguments[0], p.get_completion_line(), t, true)) {
+ GDScriptCompletionIdentifier t;
+ if (_guess_expression_type(context, static_cast<const GDScriptParser::OperatorNode *>(node)->arguments[0], p.get_completion_line(), t, true)) {
- if (t.type == Variant::OBJECT && t.obj_type == "GDNativeClass") {
+ if (t.type == Variant::OBJECT && t.obj_type == "GDScriptNativeClass") {
//native enum
- Ref<GDNativeClass> gdn = t.value;
+ Ref<GDScriptNativeClass> gdn = t.value;
if (gdn.is_valid()) {
StringName cn = gdn->get_name();
List<String> cnames;
@@ -2179,7 +2179,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
options.insert(E->key());
}
}
- for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
+ for (const Map<StringName, GDScriptFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
if (E->get()->is_static())
options.insert(E->key());
}
@@ -2210,17 +2210,17 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
if (code != "") {
//if there is code, parse it. This way is slower but updates in real-time
- GDParser p;
+ GDScriptParser p;
Error err = p.parse(scr->get_source_code(), scr->get_path().get_base_dir(), true, "", false);
if (err == OK) {
//only if ok, otherwise use what is cached on the script
- //GDParser::ClassNode *base = p.
- const GDParser::Node *root = p.get_parse_tree();
- ERR_FAIL_COND_V(root->type != GDParser::Node::TYPE_CLASS, ERR_PARSE_ERROR);
+ //GDScriptParser::ClassNode *base = p.
+ const GDScriptParser::Node *root = p.get_parse_tree();
+ ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, ERR_PARSE_ERROR);
- const GDParser::ClassNode *cl = static_cast<const GDParser::ClassNode *>(root);
+ const GDScriptParser::ClassNode *cl = static_cast<const GDScriptParser::ClassNode *>(root);
for (int i = 0; i < cl->functions.size(); i++) {
@@ -2262,7 +2262,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
options.insert(E->key());
}
}
- for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
+ for (const Map<StringName, GDScriptFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
if (E->get()->get_argument_count())
options.insert(String(E->key()) + "()");
else
@@ -2341,13 +2341,13 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
}
} break;
- case GDParser::COMPLETION_CALL_ARGUMENTS: {
+ case GDScriptParser::COMPLETION_CALL_ARGUMENTS: {
_find_call_arguments(context, p.get_completion_node(), p.get_completion_line(), p.get_completion_argument_index(), options, r_forced, r_call_hint);
} break;
- case GDParser::COMPLETION_VIRTUAL_FUNC: {
+ case GDScriptParser::COMPLETION_VIRTUAL_FUNC: {
- GDCompletionIdentifier cid = _get_native_class(context);
+ GDScriptCompletionIdentifier cid = _get_native_class(context);
if (cid.obj_type != StringName()) {
List<MethodInfo> vm;
@@ -2376,11 +2376,11 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
}
}
} break;
- case GDParser::COMPLETION_YIELD: {
+ case GDScriptParser::COMPLETION_YIELD: {
- const GDParser::Node *node = p.get_completion_node();
+ const GDScriptParser::Node *node = p.get_completion_node();
- GDCompletionIdentifier t;
+ GDScriptCompletionIdentifier t;
if (!_guess_expression_type(context, node, p.get_completion_line(), t))
break;
@@ -2395,15 +2395,15 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
}
} break;
- case GDParser::COMPLETION_RESOURCE_PATH: {
+ case GDScriptParser::COMPLETION_RESOURCE_PATH: {
if (EditorSettings::get_singleton()->get("text_editor/completion/complete_file_paths"))
get_directory_contents(EditorFileSystem::get_singleton()->get_filesystem(), options);
} break;
- case GDParser::COMPLETION_ASSIGN: {
+ case GDScriptParser::COMPLETION_ASSIGN: {
#if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED)
- GDCompletionIdentifier ci;
+ GDScriptCompletionIdentifier ci;
if (_guess_expression_type(context, p.get_completion_node(), p.get_completion_line(), ci)) {
String enumeration = ci.enumeration;
@@ -2556,8 +2556,8 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
}
- for (int i = 0; i < GDFunctions::FUNC_MAX; i++) {
- if (GDFunctions::get_func_name(GDFunctions::Function(i)) == p_symbol) {
+ for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) {
+ if (GDScriptFunctions::get_func_name(GDScriptFunctions::Function(i)) == p_symbol) {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_METHOD;
r_result.class_name = "@GDScript";
r_result.class_member = p_symbol;
@@ -2565,13 +2565,13 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
}
- GDParser p;
+ GDScriptParser p;
p.parse(p_code, p_base_path, false, "", true);
- if (p.get_completion_type() == GDParser::COMPLETION_NONE)
+ if (p.get_completion_type() == GDScriptParser::COMPLETION_NONE)
return ERR_CANT_RESOLVE;
- GDCompletionContext context;
+ GDScriptCompletionContext context;
context._class = p.get_completion_class();
context.block = p.get_completion_block();
@@ -2582,10 +2582,10 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
switch (p.get_completion_type()) {
- case GDParser::COMPLETION_GET_NODE:
- case GDParser::COMPLETION_NONE: {
+ case GDScriptParser::COMPLETION_GET_NODE:
+ case GDScriptParser::COMPLETION_NONE: {
} break;
- case GDParser::COMPLETION_BUILT_IN_TYPE_CONSTANT: {
+ case GDScriptParser::COMPLETION_BUILT_IN_TYPE_CONSTANT: {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT;
r_result.class_name = Variant::get_type_name(p.get_completion_built_in_constant());
@@ -2593,7 +2593,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
return OK;
} break;
- case GDParser::COMPLETION_FUNCTION: {
+ case GDScriptParser::COMPLETION_FUNCTION: {
if (context._class && context._class->functions.size()) {
for (int i = 0; i < context._class->functions.size(); i++) {
@@ -2618,7 +2618,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
parent = parent->get_base();
}
- GDCompletionIdentifier identifier = _get_native_class(context);
+ GDScriptCompletionIdentifier identifier = _get_native_class(context);
print_line("identifier: " + String(identifier.obj_type));
if (ClassDB::has_method(identifier.obj_type, p_symbol)) {
@@ -2630,7 +2630,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
} break;
- case GDParser::COMPLETION_IDENTIFIER: {
+ case GDScriptParser::COMPLETION_IDENTIFIER: {
//check if a function
if (p.get_completion_identifier_is_function()) {
@@ -2657,7 +2657,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
parent = parent->get_base();
}
- GDCompletionIdentifier identifier = _get_native_class(context);
+ GDScriptCompletionIdentifier identifier = _get_native_class(context);
if (ClassDB::has_method(identifier.obj_type, p_symbol)) {
@@ -2668,7 +2668,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
} else {
- GDCompletionIdentifier gdi = _get_native_class(context);
+ GDScriptCompletionIdentifier gdi = _get_native_class(context);
if (gdi.obj_type != StringName()) {
bool valid;
Variant::Type t = ClassDB::get_property_type(gdi.obj_type, p_symbol, &valid);
@@ -2680,7 +2680,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
}
- const GDParser::BlockNode *block = context.block;
+ const GDScriptParser::BlockNode *block = context.block;
//search in blocks going up (local var?)
while (block) {
@@ -2689,9 +2689,9 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
if (block->statements[i]->line > p.get_completion_line())
continue;
- if (block->statements[i]->type == GDParser::BlockNode::TYPE_LOCAL_VAR) {
+ if (block->statements[i]->type == GDScriptParser::BlockNode::TYPE_LOCAL_VAR) {
- const GDParser::LocalVarNode *lv = static_cast<const GDParser::LocalVarNode *>(block->statements[i]);
+ const GDScriptParser::LocalVarNode *lv = static_cast<const GDScriptParser::LocalVarNode *>(block->statements[i]);
if (lv->assign && lv->name == p_symbol) {
@@ -2782,9 +2782,9 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
if (value.get_type() == Variant::OBJECT) {
Object *obj = value;
if (obj) {
- if (Object::cast_to<GDNativeClass>(obj)) {
+ if (Object::cast_to<GDScriptNativeClass>(obj)) {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;
- r_result.class_name = Object::cast_to<GDNativeClass>(obj)->get_name();
+ r_result.class_name = Object::cast_to<GDScriptNativeClass>(obj)->get_name();
} else {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;
r_result.class_name = obj->get_class();
@@ -2806,23 +2806,23 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
} break;
- case GDParser::COMPLETION_PARENT_FUNCTION: {
+ case GDScriptParser::COMPLETION_PARENT_FUNCTION: {
} break;
- case GDParser::COMPLETION_METHOD:
+ case GDScriptParser::COMPLETION_METHOD:
isfunction = true;
- case GDParser::COMPLETION_INDEX: {
+ case GDScriptParser::COMPLETION_INDEX: {
- const GDParser::Node *node = p.get_completion_node();
- if (node->type != GDParser::Node::TYPE_OPERATOR)
+ const GDScriptParser::Node *node = p.get_completion_node();
+ if (node->type != GDScriptParser::Node::TYPE_OPERATOR)
break;
- GDCompletionIdentifier t;
- if (_guess_expression_type(context, static_cast<const GDParser::OperatorNode *>(node)->arguments[0], p.get_completion_line(), t)) {
+ GDScriptCompletionIdentifier t;
+ if (_guess_expression_type(context, static_cast<const GDScriptParser::OperatorNode *>(node)->arguments[0], p.get_completion_line(), t)) {
- if (t.type == Variant::OBJECT && t.obj_type == "GDNativeClass") {
+ if (t.type == Variant::OBJECT && t.obj_type == "GDScriptNativeClass") {
//native enum
- Ref<GDNativeClass> gdn = t.value;
+ Ref<GDScriptNativeClass> gdn = t.value;
if (gdn.is_valid()) {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT;
r_result.class_name = gdn->get_name();
@@ -2914,13 +2914,13 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
} break;
- case GDParser::COMPLETION_CALL_ARGUMENTS: {
+ case GDScriptParser::COMPLETION_CALL_ARGUMENTS: {
return ERR_CANT_RESOLVE;
} break;
- case GDParser::COMPLETION_VIRTUAL_FUNC: {
+ case GDScriptParser::COMPLETION_VIRTUAL_FUNC: {
- GDCompletionIdentifier cid = _get_native_class(context);
+ GDScriptCompletionIdentifier cid = _get_native_class(context);
if (cid.obj_type != StringName()) {
List<MethodInfo> vm;
@@ -2937,7 +2937,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
}
} break;
- case GDParser::COMPLETION_YIELD: {
+ case GDScriptParser::COMPLETION_YIELD: {
return ERR_CANT_RESOLVE;
diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gdscript_function.cpp
index 1a46ad324a..765a76fec4 100644
--- a/modules/gdscript/gd_function.cpp
+++ b/modules/gdscript/gdscript_function.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_function.cpp */
+/* gdscript_function.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,13 +27,13 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "gd_function.h"
+#include "gdscript_function.h"
-#include "gd_functions.h"
-#include "gd_script.h"
+#include "gdscript.h"
+#include "gdscript_functions.h"
#include "os/os.h"
-Variant *GDFunction::_get_variant(int p_address, GDInstance *p_instance, GDScript *p_script, Variant &self, Variant *p_stack, String &r_error) const {
+Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_instance, GDScript *p_script, Variant &self, Variant *p_stack, String &r_error) const {
int address = p_address & ADDR_MASK;
@@ -85,7 +85,7 @@ Variant *GDFunction::_get_variant(int p_address, GDInstance *p_instance, GDScrip
o = o->_owner;
}
- ERR_EXPLAIN("GDCompiler bug..");
+ ERR_EXPLAIN("GDScriptCompiler bug..");
ERR_FAIL_V(NULL);
} break;
case ADDR_TYPE_LOCAL_CONSTANT: {
@@ -117,7 +117,7 @@ Variant *GDFunction::_get_variant(int p_address, GDInstance *p_instance, GDScrip
return NULL;
}
-String GDFunction::_get_call_error(const Variant::CallError &p_err, const String &p_where, const Variant **argptrs) const {
+String GDScriptFunction::_get_call_error(const Variant::CallError &p_err, const String &p_where, const Variant **argptrs) const {
String err_text;
@@ -231,7 +231,7 @@ static String _get_var_type(const Variant *p_type) {
#define OPCODE_OUT break
#endif
-Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state) {
+Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state) {
OPCODES_TABLE;
@@ -479,7 +479,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
} else {
- GDNativeClass *nc = Object::cast_to<GDNativeClass>(obj_B);
+ GDScriptNativeClass *nc = Object::cast_to<GDScriptNativeClass>(obj_B);
#ifdef DEBUG_ENABLED
if (!nc) {
@@ -851,7 +851,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
CHECK_SPACE(4);
- GDFunctions::Function func = GDFunctions::Function(_code_ptr[ip + 1]);
+ GDScriptFunctions::Function func = GDScriptFunctions::Function(_code_ptr[ip + 1]);
int argc = _code_ptr[ip + 2];
GD_ERR_BREAK(argc < 0);
@@ -868,12 +868,12 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
Variant::CallError err;
- GDFunctions::call(func, (const Variant **)argptrs, argc, *dst, err);
+ GDScriptFunctions::call(func, (const Variant **)argptrs, argc, *dst, err);
#ifdef DEBUG_ENABLED
if (err.error != Variant::CallError::CALL_OK) {
- String methodstr = GDFunctions::get_func_name(func);
+ String methodstr = GDScriptFunctions::get_func_name(func);
if (dst->get_type() == Variant::STRING) {
//call provided error string
err_text = "Error calling built-in function '" + methodstr + "': " + String(*dst);
@@ -921,7 +921,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
const GDScript *gds = _script;
- const Map<StringName, GDFunction *>::Element *E = NULL;
+ const Map<StringName, GDScriptFunction *>::Element *E = NULL;
while (gds->base.ptr()) {
gds = gds->base.ptr();
E = gds->member_functions.find(*methodname);
@@ -979,7 +979,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
CHECK_SPACE(2);
}
- Ref<GDFunctionState> gdfs = memnew(GDFunctionState);
+ Ref<GDScriptFunctionState> gdfs = memnew(GDScriptFunctionState);
gdfs->function = this;
gdfs->state.stack.resize(alloca_size);
@@ -1321,43 +1321,43 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
return retvalue;
}
-const int *GDFunction::get_code() const {
+const int *GDScriptFunction::get_code() const {
return _code_ptr;
}
-int GDFunction::get_code_size() const {
+int GDScriptFunction::get_code_size() const {
return _code_size;
}
-Variant GDFunction::get_constant(int p_idx) const {
+Variant GDScriptFunction::get_constant(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, constants.size(), "<errconst>");
return constants[p_idx];
}
-StringName GDFunction::get_global_name(int p_idx) const {
+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 GDFunction::get_default_argument_count() const {
+int GDScriptFunction::get_default_argument_count() const {
return default_arguments.size();
}
-int GDFunction::get_default_argument_addr(int p_idx) const {
+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];
}
-StringName GDFunction::get_name() const {
+StringName GDScriptFunction::get_name() const {
return name;
}
-int GDFunction::get_max_stack_size() const {
+int GDScriptFunction::get_max_stack_size() const {
return _stack_size;
}
@@ -1380,7 +1380,7 @@ struct _GDFKCS {
}
};
-void GDFunction::debug_get_stack_member_state(int p_line, List<Pair<StringName, int> > *r_stackvars) const {
+void GDScriptFunction::debug_get_stack_member_state(int p_line, List<Pair<StringName, int> > *r_stackvars) const {
int oc = 0;
Map<StringName, _GDFKC> sdmap;
@@ -1432,7 +1432,7 @@ void GDFunction::debug_get_stack_member_state(int p_line, List<Pair<StringName,
}
}
-GDFunction::GDFunction()
+GDScriptFunction::GDScriptFunction()
: function_list(this) {
_stack_size = 0;
@@ -1464,7 +1464,7 @@ GDFunction::GDFunction()
#endif
}
-GDFunction::~GDFunction() {
+GDScriptFunction::~GDScriptFunction() {
#ifdef DEBUG_ENABLED
if (GDScriptLanguage::get_singleton()->lock) {
GDScriptLanguage::get_singleton()->lock->lock();
@@ -1479,7 +1479,7 @@ GDFunction::~GDFunction() {
/////////////////////
-Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant GDScriptFunctionState::_signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
#ifdef DEBUG_ENABLED
if (state.instance_id && !ObjectDB::get_instance(state.instance_id)) {
@@ -1514,7 +1514,7 @@ Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount
arg = extra_args;
}
- Ref<GDFunctionState> self = *p_args[p_argcount - 1];
+ Ref<GDScriptFunctionState> self = *p_args[p_argcount - 1];
if (self.is_null()) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
@@ -1528,10 +1528,10 @@ Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount
bool completed = true;
- // If the return value is a GDFunctionState reference,
+ // If the return value is a GDScriptFunctionState reference,
// then the function did yield again after resuming.
if (ret.is_ref()) {
- GDFunctionState *gdfs = Object::cast_to<GDFunctionState>(ret);
+ GDScriptFunctionState *gdfs = Object::cast_to<GDScriptFunctionState>(ret);
if (gdfs && gdfs->function == function)
completed = false;
}
@@ -1546,7 +1546,7 @@ Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount
return ret;
}
-bool GDFunctionState::is_valid(bool p_extended_check) const {
+bool GDScriptFunctionState::is_valid(bool p_extended_check) const {
if (function == NULL)
return false;
@@ -1563,7 +1563,7 @@ bool GDFunctionState::is_valid(bool p_extended_check) const {
return true;
}
-Variant GDFunctionState::resume(const Variant &p_arg) {
+Variant GDScriptFunctionState::resume(const Variant &p_arg) {
ERR_FAIL_COND_V(!function, Variant());
#ifdef DEBUG_ENABLED
@@ -1584,10 +1584,10 @@ Variant GDFunctionState::resume(const Variant &p_arg) {
bool completed = true;
- // If the return value is a GDFunctionState reference,
+ // If the return value is a GDScriptFunctionState reference,
// then the function did yield again after resuming.
if (ret.is_ref()) {
- GDFunctionState *gdfs = Object::cast_to<GDFunctionState>(ret);
+ GDScriptFunctionState *gdfs = Object::cast_to<GDScriptFunctionState>(ret);
if (gdfs && gdfs->function == function)
completed = false;
}
@@ -1602,21 +1602,21 @@ Variant GDFunctionState::resume(const Variant &p_arg) {
return ret;
}
-void GDFunctionState::_bind_methods() {
+void GDScriptFunctionState::_bind_methods() {
- ClassDB::bind_method(D_METHOD("resume", "arg"), &GDFunctionState::resume, DEFVAL(Variant()));
- ClassDB::bind_method(D_METHOD("is_valid", "extended_check"), &GDFunctionState::is_valid, DEFVAL(false));
- ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "_signal_callback", &GDFunctionState::_signal_callback, MethodInfo("_signal_callback"));
+ 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"));
ADD_SIGNAL(MethodInfo("completed", PropertyInfo(Variant::NIL, "result", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT)));
}
-GDFunctionState::GDFunctionState() {
+GDScriptFunctionState::GDScriptFunctionState() {
function = NULL;
}
-GDFunctionState::~GDFunctionState() {
+GDScriptFunctionState::~GDScriptFunctionState() {
if (function != NULL) {
//never called, deinitialize stack
diff --git a/modules/gdscript/gd_function.h b/modules/gdscript/gdscript_function.h
index bf5ff5f8da..03fd5d52dc 100644
--- a/modules/gdscript/gd_function.h
+++ b/modules/gdscript/gdscript_function.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_function.h */
+/* gdscript_function.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,8 +27,8 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GD_FUNCTION_H
-#define GD_FUNCTION_H
+#ifndef GDSCRIPT_FUNCTION_H
+#define GDSCRIPT_FUNCTION_H
#include "os/thread.h"
#include "pair.h"
@@ -38,10 +38,10 @@
#include "string_db.h"
#include "variant.h"
-class GDInstance;
+class GDScriptInstance;
class GDScript;
-class GDFunction {
+class GDScriptFunction {
public:
enum Opcode {
OPCODE_OPERATOR,
@@ -111,7 +111,7 @@ public:
};
private:
- friend class GDCompiler;
+ friend class GDScriptCompiler;
StringName source;
@@ -145,12 +145,12 @@ private:
List<StackDebug> stack_debug;
- _FORCE_INLINE_ Variant *_get_variant(int p_address, GDInstance *p_instance, GDScript *p_script, Variant &self, Variant *p_stack, String &r_error) const;
+ _FORCE_INLINE_ Variant *_get_variant(int p_address, GDScriptInstance *p_instance, GDScript *p_script, Variant &self, Variant *p_stack, String &r_error) const;
_FORCE_INLINE_ String _get_call_error(const Variant::CallError &p_err, const String &p_where, const Variant **argptrs) const;
friend class GDScriptLanguage;
- SelfList<GDFunction> function_list;
+ SelfList<GDScriptFunction> function_list;
#ifdef DEBUG_ENABLED
CharString func_cname;
const char *_func_cname;
@@ -176,7 +176,7 @@ public:
ObjectID instance_id; //by debug only
ObjectID script_id;
- GDInstance *instance;
+ GDScriptInstance *instance;
Vector<uint8_t> stack;
int stack_size;
Variant self;
@@ -219,19 +219,19 @@ public:
return default_arguments[p_idx];
}
- Variant call(GDInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state = NULL);
+ Variant call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state = NULL);
_FORCE_INLINE_ ScriptInstance::RPCMode get_rpc_mode() const { return rpc_mode; }
- GDFunction();
- ~GDFunction();
+ GDScriptFunction();
+ ~GDScriptFunction();
};
-class GDFunctionState : public Reference {
+class GDScriptFunctionState : public Reference {
- GDCLASS(GDFunctionState, Reference);
- friend class GDFunction;
- GDFunction *function;
- GDFunction::CallState state;
+ GDCLASS(GDScriptFunctionState, Reference);
+ friend class GDScriptFunction;
+ GDScriptFunction *function;
+ GDScriptFunction::CallState state;
Variant _signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
protected:
@@ -240,8 +240,8 @@ protected:
public:
bool is_valid(bool p_extended_check = false) const;
Variant resume(const Variant &p_arg = Variant());
- GDFunctionState();
- ~GDFunctionState();
+ GDScriptFunctionState();
+ ~GDScriptFunctionState();
};
-#endif // GD_FUNCTION_H
+#endif // GDSCRIPT_FUNCTION_H
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gdscript_functions.cpp
index b43ec409a1..467dbf3e56 100644
--- a/modules/gdscript/gd_functions.cpp
+++ b/modules/gdscript/gdscript_functions.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_functions.cpp */
+/* gdscript_functions.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,10 +27,11 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "gd_functions.h"
+#include "gdscript_functions.h"
+
#include "class_db.h"
#include "func_ref.h"
-#include "gd_script.h"
+#include "gdscript.h"
#include "io/json.h"
#include "io/marshalls.h"
#include "math_funcs.h"
@@ -38,7 +39,7 @@
#include "reference.h"
#include "variant_parser.h"
-const char *GDFunctions::get_func_name(Function p_func) {
+const char *GDScriptFunctions::get_func_name(Function p_func) {
ERR_FAIL_INDEX_V(p_func, FUNC_MAX, "");
@@ -123,7 +124,7 @@ const char *GDFunctions::get_func_name(Function p_func) {
return _names[p_func];
}
-void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count, Variant &r_ret, Variant::CallError &r_error) {
+void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_count, Variant &r_ret, Variant::CallError &r_error) {
r_error.error = Variant::CallError::CALL_OK;
#ifdef DEBUG_ENABLED
@@ -899,7 +900,7 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count,
return;
} else {
- GDInstance *ins = static_cast<GDInstance *>(obj->get_script_instance());
+ GDScriptInstance *ins = static_cast<GDScriptInstance *>(obj->get_script_instance());
Ref<GDScript> base = ins->get_script();
if (base.is_null()) {
@@ -1030,7 +1031,7 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count,
r_ret = gdscr->_new(NULL, 0, r_error);
- GDInstance *ins = static_cast<GDInstance *>(static_cast<Object *>(r_ret)->get_script_instance());
+ GDScriptInstance *ins = static_cast<GDScriptInstance *>(static_cast<Object *>(r_ret)->get_script_instance());
Ref<GDScript> gd_ref = ins->get_script();
for (Map<StringName, GDScript::MemberInfo>::Element *E = gd_ref->member_indices.front(); E; E = E->next()) {
@@ -1254,7 +1255,7 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count,
}
}
-bool GDFunctions::is_deterministic(Function p_func) {
+bool GDScriptFunctions::is_deterministic(Function p_func) {
//man i couldn't have chosen a worse function name,
//way too controversial..
@@ -1317,7 +1318,7 @@ bool GDFunctions::is_deterministic(Function p_func) {
return false;
}
-MethodInfo GDFunctions::get_info(Function p_func) {
+MethodInfo GDScriptFunctions::get_info(Function p_func) {
#ifdef TOOLS_ENABLED
//using a switch, so the compiler generates a jumptable
diff --git a/modules/gdscript/gd_functions.h b/modules/gdscript/gdscript_functions.h
index 0de09f2e71..ecbede83a8 100644
--- a/modules/gdscript/gd_functions.h
+++ b/modules/gdscript/gdscript_functions.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_functions.h */
+/* gdscript_functions.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,12 +27,12 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GD_FUNCTIONS_H
-#define GD_FUNCTIONS_H
+#ifndef GDSCRIPT_FUNCTIONS_H
+#define GDSCRIPT_FUNCTIONS_H
#include "variant.h"
-class GDFunctions {
+class GDScriptFunctions {
public:
enum Function {
MATH_SIN,
@@ -120,4 +120,4 @@ public:
static MethodInfo get_info(Function p_func);
};
-#endif // GD_FUNCTIONS_H
+#endif // GDSCRIPT_FUNCTIONS_H
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index d7e83c3a33..29b9865b1d 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_parser.cpp */
+/* gdscript_parser.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,15 +27,16 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "gd_parser.h"
-#include "gd_script.h"
+#include "gdscript_parser.h"
+
+#include "gdscript.h"
#include "io/resource_loader.h"
#include "os/file_access.h"
#include "print_string.h"
#include "script_language.h"
template <class T>
-T *GDParser::alloc_node() {
+T *GDScriptParser::alloc_node() {
T *t = memnew(T);
@@ -50,21 +51,21 @@ T *GDParser::alloc_node() {
return t;
}
-bool GDParser::_end_statement() {
+bool GDScriptParser::_end_statement() {
- if (tokenizer->get_token() == GDTokenizer::TK_SEMICOLON) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_SEMICOLON) {
tokenizer->advance();
return true; //handle next
- } else if (tokenizer->get_token() == GDTokenizer::TK_NEWLINE || tokenizer->get_token() == GDTokenizer::TK_EOF) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE || tokenizer->get_token() == GDScriptTokenizer::TK_EOF) {
return true; //will be handled properly
}
return false;
}
-bool GDParser::_enter_indent_block(BlockNode *p_block) {
+bool GDScriptParser::_enter_indent_block(BlockNode *p_block) {
- if (tokenizer->get_token() != GDTokenizer::TK_COLON) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_COLON) {
// report location at the previous token (on the previous line)
int error_line = tokenizer->get_token_line(-1);
int error_column = tokenizer->get_token_column(-1);
@@ -73,7 +74,7 @@ bool GDParser::_enter_indent_block(BlockNode *p_block) {
}
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_NEWLINE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_NEWLINE) {
// be more python-like
int current = tab_level.back()->get();
@@ -85,10 +86,10 @@ bool GDParser::_enter_indent_block(BlockNode *p_block) {
while (true) {
- if (tokenizer->get_token() != GDTokenizer::TK_NEWLINE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_NEWLINE) {
return false; //wtf
- } else if (tokenizer->get_token(1) != GDTokenizer::TK_NEWLINE) {
+ } else if (tokenizer->get_token(1) != GDScriptTokenizer::TK_NEWLINE) {
int indent = tokenizer->get_token_line_indent();
int current = tab_level.back()->get();
@@ -113,9 +114,9 @@ bool GDParser::_enter_indent_block(BlockNode *p_block) {
}
}
-bool GDParser::_parse_arguments(Node *p_parent, Vector<Node *> &p_args, bool p_static, bool p_can_codecomplete) {
+bool GDScriptParser::_parse_arguments(Node *p_parent, Vector<Node *> &p_args, bool p_static, bool p_can_codecomplete) {
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
tokenizer->advance();
} else {
@@ -124,10 +125,10 @@ bool GDParser::_parse_arguments(Node *p_parent, Vector<Node *> &p_args, bool p_s
while (true) {
- if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) {
_make_completable_call(argidx);
completion_node = p_parent;
- } else if (tokenizer->get_token() == GDTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING && tokenizer->get_token(1) == GDTokenizer::TK_CURSOR) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING && tokenizer->get_token(1) == GDScriptTokenizer::TK_CURSOR) {
//completing a string argument..
completion_cursor = tokenizer->get_token_constant();
@@ -143,13 +144,13 @@ bool GDParser::_parse_arguments(Node *p_parent, Vector<Node *> &p_args, bool p_s
p_args.push_back(arg);
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
tokenizer->advance();
break;
- } else if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
- if (tokenizer->get_token(1) == GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token(1) == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expression expected");
return false;
@@ -169,7 +170,7 @@ bool GDParser::_parse_arguments(Node *p_parent, Vector<Node *> &p_args, bool p_s
return true;
}
-void GDParser::_make_completable_call(int p_arg) {
+void GDScriptParser::_make_completable_call(int p_arg) {
completion_cursor = StringName();
completion_type = COMPLETION_CALL_ARGUMENTS;
@@ -182,14 +183,14 @@ void GDParser::_make_completable_call(int p_arg) {
tokenizer->advance();
}
-bool GDParser::_get_completable_identifier(CompletionType p_type, StringName &identifier) {
+bool GDScriptParser::_get_completable_identifier(CompletionType p_type, StringName &identifier) {
identifier = StringName();
if (tokenizer->is_token_literal()) {
identifier = tokenizer->get_token_literal();
tokenizer->advance();
}
- if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) {
completion_cursor = identifier;
completion_type = p_type;
@@ -206,7 +207,7 @@ bool GDParser::_get_completable_identifier(CompletionType p_type, StringName &id
tokenizer->advance();
}
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_OPEN) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
completion_ident_is_call = true;
}
return true;
@@ -215,7 +216,7 @@ bool GDParser::_get_completable_identifier(CompletionType p_type, StringName &id
return false;
}
-GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool p_allow_assign, bool p_parsing_constant) {
+GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_static, bool p_allow_assign, bool p_parsing_constant) {
//Vector<Node*> expressions;
//Vector<OperatorNode::Operator> operators;
@@ -234,12 +235,12 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
if (parenthesis > 0) {
//remove empty space (only allowed if inside parenthesis
- while (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) {
+ while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
tokenizer->advance();
}
}
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_OPEN) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
//subexpression ()
tokenizer->advance();
parenthesis++;
@@ -248,7 +249,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
if (!subexpr)
return NULL;
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ')' in expression");
return NULL;
@@ -256,7 +257,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
tokenizer->advance();
expr = subexpr;
- } else if (tokenizer->get_token() == GDTokenizer::TK_DOLLAR) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_DOLLAR) {
tokenizer->advance();
String path;
@@ -267,7 +268,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
while (!done) {
switch (tokenizer->get_token()) {
- case GDTokenizer::TK_CURSOR: {
+ case GDScriptTokenizer::TK_CURSOR: {
completion_cursor = StringName();
completion_type = COMPLETION_GET_NODE;
completion_class = current_class;
@@ -279,7 +280,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
completion_found = true;
tokenizer->advance();
} break;
- case GDTokenizer::TK_CONSTANT: {
+ case GDScriptTokenizer::TK_CONSTANT: {
if (!need_identifier) {
done = true;
@@ -296,7 +297,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
need_identifier = false;
} break;
- case GDTokenizer::TK_OP_DIV: {
+ case GDScriptTokenizer::TK_OP_DIV: {
if (need_identifier) {
done = true;
@@ -344,56 +345,56 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
expr = op;
- } else if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) {
tokenizer->advance();
continue; //no point in cursor in the middle of expression
- } else if (tokenizer->get_token() == GDTokenizer::TK_CONSTANT) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT) {
//constant defined by tokenizer
ConstantNode *constant = alloc_node<ConstantNode>();
constant->value = tokenizer->get_token_constant();
tokenizer->advance();
expr = constant;
- } else if (tokenizer->get_token() == GDTokenizer::TK_CONST_PI) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONST_PI) {
//constant defined by tokenizer
ConstantNode *constant = alloc_node<ConstantNode>();
constant->value = Math_PI;
tokenizer->advance();
expr = constant;
- } else if (tokenizer->get_token() == GDTokenizer::TK_CONST_TAU) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONST_TAU) {
//constant defined by tokenizer
ConstantNode *constant = alloc_node<ConstantNode>();
constant->value = Math_TAU;
tokenizer->advance();
expr = constant;
- } else if (tokenizer->get_token() == GDTokenizer::TK_CONST_INF) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONST_INF) {
//constant defined by tokenizer
ConstantNode *constant = alloc_node<ConstantNode>();
constant->value = Math_INF;
tokenizer->advance();
expr = constant;
- } else if (tokenizer->get_token() == GDTokenizer::TK_CONST_NAN) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONST_NAN) {
//constant defined by tokenizer
ConstantNode *constant = alloc_node<ConstantNode>();
constant->value = Math_NAN;
tokenizer->advance();
expr = constant;
- } else if (tokenizer->get_token() == GDTokenizer::TK_PR_PRELOAD) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_PRELOAD) {
//constant defined by tokenizer
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_OPEN) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
_set_error("Expected '(' after 'preload'");
return NULL;
}
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) {
completion_cursor = StringName();
completion_node = p_parent;
completion_type = COMPLETION_RESOURCE_PATH;
@@ -473,7 +474,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
}
}
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ')' after 'preload' path");
return NULL;
}
@@ -483,12 +484,12 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
constant->value = res;
expr = constant;
- } else if (tokenizer->get_token() == GDTokenizer::TK_PR_YIELD) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_YIELD) {
//constant defined by tokenizer
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_OPEN) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
_set_error("Expected '(' after 'yield'");
return NULL;
}
@@ -498,11 +499,11 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
OperatorNode *yield = alloc_node<OperatorNode>();
yield->op = OperatorNode::OP_YIELD;
- while (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) {
+ while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
tokenizer->advance();
}
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
expr = yield;
tokenizer->advance();
} else {
@@ -514,14 +515,14 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
return NULL;
yield->arguments.push_back(object);
- if (tokenizer->get_token() != GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
_set_error("Expected ',' after first argument of 'yield'");
return NULL;
}
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) {
completion_cursor = StringName();
completion_node = object;
@@ -540,7 +541,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
return NULL;
yield->arguments.push_back(signal);
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ')' after second argument of 'yield'");
return NULL;
}
@@ -552,7 +553,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
expr = yield;
}
- } else if (tokenizer->get_token() == GDTokenizer::TK_SELF) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_SELF) {
if (p_static) {
_set_error("'self'' not allowed in static function or constant expression");
@@ -562,7 +563,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
SelfNode *self = alloc_node<SelfNode>();
tokenizer->advance();
expr = self;
- } else if (tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_TYPE && tokenizer->get_token(1) == GDTokenizer::TK_PERIOD) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE && tokenizer->get_token(1) == GDScriptTokenizer::TK_PERIOD) {
Variant::Type bi_type = tokenizer->get_token_type();
tokenizer->advance(2);
@@ -589,20 +590,20 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
cn->value = Variant::get_numeric_constant_value(bi_type, identifier);
expr = cn;
- } else if (tokenizer->get_token(1) == GDTokenizer::TK_PARENTHESIS_OPEN && tokenizer->is_token_literal()) {
+ } else if (tokenizer->get_token(1) == GDScriptTokenizer::TK_PARENTHESIS_OPEN && tokenizer->is_token_literal()) {
// We check with is_token_literal, as this allows us to use match/sync/etc. as a name
//function or constructor
OperatorNode *op = alloc_node<OperatorNode>();
op->op = OperatorNode::OP_CALL;
- if (tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_TYPE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE) {
TypeNode *tn = alloc_node<TypeNode>();
tn->vtype = tokenizer->get_token_type();
op->arguments.push_back(tn);
tokenizer->advance(2);
- } else if (tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_FUNC) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_FUNC) {
BuiltInFunctionNode *bn = alloc_node<BuiltInFunctionNode>();
bn->function = tokenizer->get_token_built_in_func();
@@ -623,7 +624,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
tokenizer->advance(1);
}
- if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) {
_make_completable_call(0);
completion_node = op;
}
@@ -668,7 +669,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
expr = id;
}
- } else if (tokenizer->get_token() == GDTokenizer::TK_OP_ADD || tokenizer->get_token() == GDTokenizer::TK_OP_SUB || tokenizer->get_token() == GDTokenizer::TK_OP_NOT || tokenizer->get_token() == GDTokenizer::TK_OP_BIT_INVERT) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ADD || tokenizer->get_token() == GDScriptTokenizer::TK_OP_SUB || tokenizer->get_token() == GDScriptTokenizer::TK_OP_NOT || tokenizer->get_token() == GDScriptTokenizer::TK_OP_BIT_INVERT) {
//single prefix operators like !expr +expr -expr ++expr --expr
alloc_node<OperatorNode>();
@@ -676,16 +677,16 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
e.is_op = true;
switch (tokenizer->get_token()) {
- case GDTokenizer::TK_OP_ADD: e.op = OperatorNode::OP_POS; break;
- case GDTokenizer::TK_OP_SUB: e.op = OperatorNode::OP_NEG; break;
- case GDTokenizer::TK_OP_NOT: e.op = OperatorNode::OP_NOT; break;
- case GDTokenizer::TK_OP_BIT_INVERT: e.op = OperatorNode::OP_BIT_INVERT; break;
+ case GDScriptTokenizer::TK_OP_ADD: e.op = OperatorNode::OP_POS; break;
+ case GDScriptTokenizer::TK_OP_SUB: e.op = OperatorNode::OP_NEG; break;
+ case GDScriptTokenizer::TK_OP_NOT: e.op = OperatorNode::OP_NOT; break;
+ case GDScriptTokenizer::TK_OP_BIT_INVERT: e.op = OperatorNode::OP_BIT_INVERT; break;
default: {}
}
tokenizer->advance();
- if (e.op != OperatorNode::OP_NOT && tokenizer->get_token() == GDTokenizer::TK_OP_NOT) {
+ if (e.op != OperatorNode::OP_NOT && tokenizer->get_token() == GDScriptTokenizer::TK_OP_NOT) {
_set_error("Misplaced 'not'.");
return NULL;
}
@@ -700,7 +701,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
op->arguments.push_back(subexpr);
expr=op;*/
- } else if (tokenizer->get_token() == GDTokenizer::TK_BRACKET_OPEN) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BRACKET_OPEN) {
// array
tokenizer->advance();
@@ -709,18 +710,18 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
while (true) {
- if (tokenizer->get_token() == GDTokenizer::TK_EOF) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_EOF) {
_set_error("Unterminated array");
return NULL;
- } else if (tokenizer->get_token() == GDTokenizer::TK_BRACKET_CLOSE) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BRACKET_CLOSE) {
tokenizer->advance();
break;
- } else if (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
tokenizer->advance(); //ignore newline
- } else if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
if (!expecting_comma) {
_set_error("expression or ']' expected");
return NULL;
@@ -743,7 +744,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
}
expr = arr;
- } else if (tokenizer->get_token() == GDTokenizer::TK_CURLY_BRACKET_OPEN) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_OPEN) {
// array
tokenizer->advance();
@@ -765,12 +766,12 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
while (true) {
- if (tokenizer->get_token() == GDTokenizer::TK_EOF) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_EOF) {
_set_error("Unterminated dictionary");
return NULL;
- } else if (tokenizer->get_token() == GDTokenizer::TK_CURLY_BRACKET_CLOSE) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) {
if (expecting == DICT_EXPECT_COLON) {
_set_error("':' expected");
@@ -782,10 +783,10 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
}
tokenizer->advance();
break;
- } else if (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
tokenizer->advance(); //ignore newline
- } else if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
if (expecting == DICT_EXPECT_KEY) {
_set_error("key or '}' expected");
@@ -803,7 +804,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
expecting = DICT_EXPECT_KEY;
tokenizer->advance(); //ignore newline
- } else if (tokenizer->get_token() == GDTokenizer::TK_COLON) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_COLON) {
if (expecting == DICT_EXPECT_KEY) {
_set_error("key or '}' expected");
@@ -833,7 +834,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
if (expecting == DICT_EXPECT_KEY) {
- if (tokenizer->is_token_literal() && tokenizer->get_token(1) == GDTokenizer::TK_OP_ASSIGN) {
+ if (tokenizer->is_token_literal() && tokenizer->get_token(1) == GDScriptTokenizer::TK_OP_ASSIGN) {
// We check with is_token_literal, as this allows us to use match/sync/etc. as a name
//lua style identifier, easier to write
ConstantNode *cn = alloc_node<ConstantNode>();
@@ -856,8 +857,8 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
return NULL;
expecting = DICT_EXPECT_COMMA;
- if (key->type == GDParser::Node::TYPE_CONSTANT) {
- Variant const &keyName = static_cast<const GDParser::ConstantNode *>(key)->value;
+ if (key->type == GDScriptParser::Node::TYPE_CONSTANT) {
+ Variant const &keyName = static_cast<const GDScriptParser::ConstantNode *>(key)->value;
if (keys.has(keyName)) {
_set_error("Duplicate key found in Dictionary literal");
@@ -877,7 +878,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
expr = dict;
- } else if (tokenizer->get_token() == GDTokenizer::TK_PERIOD && (tokenizer->is_token_literal(1) || tokenizer->get_token(1) == GDTokenizer::TK_CURSOR) && tokenizer->get_token(2) == GDTokenizer::TK_PARENTHESIS_OPEN) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_PERIOD && (tokenizer->is_token_literal(1) || tokenizer->get_token(1) == GDScriptTokenizer::TK_CURSOR) && tokenizer->get_token(2) == GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
// We check with is_token_literal, as this allows us to use match/sync/etc. as a name
// parent call
@@ -914,7 +915,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
}
if (!expr) {
- ERR_EXPLAIN("GDParser bug, couldn't figure out what expression is..");
+ ERR_EXPLAIN("GDScriptParser bug, couldn't figure out what expression is..");
ERR_FAIL_COND_V(!expr, NULL);
}
@@ -926,15 +927,15 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
//expressions can be indexed any number of times
- if (tokenizer->get_token() == GDTokenizer::TK_PERIOD) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PERIOD) {
//indexing using "."
- if (tokenizer->get_token(1) != GDTokenizer::TK_CURSOR && !tokenizer->is_token_literal(1)) {
+ if (tokenizer->get_token(1) != GDScriptTokenizer::TK_CURSOR && !tokenizer->is_token_literal(1)) {
// We check with is_token_literal, as this allows us to use match/sync/etc. as a name
_set_error("Expected identifier as member");
return NULL;
- } else if (tokenizer->get_token(2) == GDTokenizer::TK_PARENTHESIS_OPEN) {
+ } else if (tokenizer->get_token(2) == GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
//call!!
OperatorNode *op = alloc_node<OperatorNode>();
op->op = OperatorNode::OP_CALL;
@@ -942,10 +943,10 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
tokenizer->advance();
IdentifierNode *id = alloc_node<IdentifierNode>();
- if (tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_FUNC) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_FUNC) {
//small hack so built in funcs don't obfuscate methods
- id->name = GDFunctions::get_func_name(tokenizer->get_token_built_in_func());
+ id->name = GDScriptFunctions::get_func_name(tokenizer->get_token_built_in_func());
tokenizer->advance();
} else {
@@ -962,7 +963,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
op->arguments.push_back(id); // call func
//get arguments
tokenizer->advance(1);
- if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) {
_make_completable_call(0);
completion_node = op;
}
@@ -997,7 +998,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
expr = op;
}
- } else if (tokenizer->get_token() == GDTokenizer::TK_BRACKET_OPEN) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BRACKET_OPEN) {
//indexing using "[]"
OperatorNode *op = alloc_node<OperatorNode>();
op->op = OperatorNode::OP_INDEX;
@@ -1009,7 +1010,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
return NULL;
}
- if (tokenizer->get_token() != GDTokenizer::TK_BRACKET_CLOSE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_BRACKET_CLOSE) {
_set_error("Expected ']'");
return NULL;
}
@@ -1029,7 +1030,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
if (parenthesis > 0) {
//remove empty space (only allowed if inside parenthesis
- while (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) {
+ while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
tokenizer->advance();
}
}
@@ -1054,29 +1055,29 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
switch (tokenizer->get_token()) { //see operator
- case GDTokenizer::TK_OP_IN: op = OperatorNode::OP_IN; break;
- case GDTokenizer::TK_OP_EQUAL: op = OperatorNode::OP_EQUAL; break;
- case GDTokenizer::TK_OP_NOT_EQUAL: op = OperatorNode::OP_NOT_EQUAL; break;
- case GDTokenizer::TK_OP_LESS: op = OperatorNode::OP_LESS; break;
- case GDTokenizer::TK_OP_LESS_EQUAL: op = OperatorNode::OP_LESS_EQUAL; break;
- case GDTokenizer::TK_OP_GREATER: op = OperatorNode::OP_GREATER; break;
- case GDTokenizer::TK_OP_GREATER_EQUAL: op = OperatorNode::OP_GREATER_EQUAL; break;
- case GDTokenizer::TK_OP_AND: op = OperatorNode::OP_AND; break;
- case GDTokenizer::TK_OP_OR: op = OperatorNode::OP_OR; break;
- case GDTokenizer::TK_OP_ADD: op = OperatorNode::OP_ADD; break;
- case GDTokenizer::TK_OP_SUB: op = OperatorNode::OP_SUB; break;
- case GDTokenizer::TK_OP_MUL: op = OperatorNode::OP_MUL; break;
- case GDTokenizer::TK_OP_DIV: op = OperatorNode::OP_DIV; break;
- case GDTokenizer::TK_OP_MOD:
+ case GDScriptTokenizer::TK_OP_IN: op = OperatorNode::OP_IN; break;
+ case GDScriptTokenizer::TK_OP_EQUAL: op = OperatorNode::OP_EQUAL; break;
+ case GDScriptTokenizer::TK_OP_NOT_EQUAL: op = OperatorNode::OP_NOT_EQUAL; break;
+ case GDScriptTokenizer::TK_OP_LESS: op = OperatorNode::OP_LESS; break;
+ case GDScriptTokenizer::TK_OP_LESS_EQUAL: op = OperatorNode::OP_LESS_EQUAL; break;
+ case GDScriptTokenizer::TK_OP_GREATER: op = OperatorNode::OP_GREATER; break;
+ case GDScriptTokenizer::TK_OP_GREATER_EQUAL: op = OperatorNode::OP_GREATER_EQUAL; break;
+ case GDScriptTokenizer::TK_OP_AND: op = OperatorNode::OP_AND; break;
+ case GDScriptTokenizer::TK_OP_OR: op = OperatorNode::OP_OR; break;
+ case GDScriptTokenizer::TK_OP_ADD: op = OperatorNode::OP_ADD; break;
+ case GDScriptTokenizer::TK_OP_SUB: op = OperatorNode::OP_SUB; break;
+ case GDScriptTokenizer::TK_OP_MUL: op = OperatorNode::OP_MUL; break;
+ case GDScriptTokenizer::TK_OP_DIV: op = OperatorNode::OP_DIV; break;
+ case GDScriptTokenizer::TK_OP_MOD:
op = OperatorNode::OP_MOD;
break;
- //case GDTokenizer::TK_OP_NEG: op=OperatorNode::OP_NEG ; break;
- case GDTokenizer::TK_OP_SHIFT_LEFT: op = OperatorNode::OP_SHIFT_LEFT; break;
- case GDTokenizer::TK_OP_SHIFT_RIGHT: op = OperatorNode::OP_SHIFT_RIGHT; break;
- case GDTokenizer::TK_OP_ASSIGN: {
+ //case GDScriptTokenizer::TK_OP_NEG: op=OperatorNode::OP_NEG ; break;
+ case GDScriptTokenizer::TK_OP_SHIFT_LEFT: op = OperatorNode::OP_SHIFT_LEFT; break;
+ case GDScriptTokenizer::TK_OP_SHIFT_RIGHT: op = OperatorNode::OP_SHIFT_RIGHT; break;
+ case GDScriptTokenizer::TK_OP_ASSIGN: {
_VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN;
- if (tokenizer->get_token(1) == GDTokenizer::TK_CURSOR) {
+ if (tokenizer->get_token(1) == GDScriptTokenizer::TK_CURSOR) {
//code complete assignment
completion_type = COMPLETION_ASSIGN;
completion_node = expr;
@@ -1089,22 +1090,22 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
}
} break;
- case GDTokenizer::TK_OP_ASSIGN_ADD: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_ADD; break;
- case GDTokenizer::TK_OP_ASSIGN_SUB: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_SUB; break;
- case GDTokenizer::TK_OP_ASSIGN_MUL: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_MUL; break;
- case GDTokenizer::TK_OP_ASSIGN_DIV: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_DIV; break;
- case GDTokenizer::TK_OP_ASSIGN_MOD: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_MOD; break;
- case GDTokenizer::TK_OP_ASSIGN_SHIFT_LEFT: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_SHIFT_LEFT; break;
- case GDTokenizer::TK_OP_ASSIGN_SHIFT_RIGHT: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_SHIFT_RIGHT; break;
- case GDTokenizer::TK_OP_ASSIGN_BIT_AND: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_BIT_AND; break;
- case GDTokenizer::TK_OP_ASSIGN_BIT_OR: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_BIT_OR; break;
- case GDTokenizer::TK_OP_ASSIGN_BIT_XOR: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_BIT_XOR; break;
- case GDTokenizer::TK_OP_BIT_AND: op = OperatorNode::OP_BIT_AND; break;
- case GDTokenizer::TK_OP_BIT_OR: op = OperatorNode::OP_BIT_OR; break;
- case GDTokenizer::TK_OP_BIT_XOR: op = OperatorNode::OP_BIT_XOR; break;
- case GDTokenizer::TK_PR_IS: op = OperatorNode::OP_IS; break;
- case GDTokenizer::TK_CF_IF: op = OperatorNode::OP_TERNARY_IF; break;
- case GDTokenizer::TK_CF_ELSE: op = OperatorNode::OP_TERNARY_ELSE; break;
+ case GDScriptTokenizer::TK_OP_ASSIGN_ADD: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_ADD; break;
+ case GDScriptTokenizer::TK_OP_ASSIGN_SUB: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_SUB; break;
+ case GDScriptTokenizer::TK_OP_ASSIGN_MUL: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_MUL; break;
+ case GDScriptTokenizer::TK_OP_ASSIGN_DIV: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_DIV; break;
+ case GDScriptTokenizer::TK_OP_ASSIGN_MOD: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_MOD; break;
+ case GDScriptTokenizer::TK_OP_ASSIGN_SHIFT_LEFT: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_SHIFT_LEFT; break;
+ case GDScriptTokenizer::TK_OP_ASSIGN_SHIFT_RIGHT: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_SHIFT_RIGHT; break;
+ case GDScriptTokenizer::TK_OP_ASSIGN_BIT_AND: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_BIT_AND; break;
+ case GDScriptTokenizer::TK_OP_ASSIGN_BIT_OR: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_BIT_OR; break;
+ case GDScriptTokenizer::TK_OP_ASSIGN_BIT_XOR: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_BIT_XOR; break;
+ case GDScriptTokenizer::TK_OP_BIT_AND: op = OperatorNode::OP_BIT_AND; break;
+ case GDScriptTokenizer::TK_OP_BIT_OR: op = OperatorNode::OP_BIT_OR; break;
+ case GDScriptTokenizer::TK_OP_BIT_XOR: op = OperatorNode::OP_BIT_XOR; break;
+ case GDScriptTokenizer::TK_PR_IS: op = OperatorNode::OP_IS; break;
+ case GDScriptTokenizer::TK_CF_IF: op = OperatorNode::OP_TERNARY_IF; break;
+ case GDScriptTokenizer::TK_CF_ELSE: op = OperatorNode::OP_TERNARY_ELSE; break;
default: valid = false; break;
}
@@ -1212,7 +1213,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
case OperatorNode::OP_ASSIGN_BIT_XOR: priority = 15; break;
default: {
- _set_error("GDParser bug, invalid operator in expression: " + itos(expression[i].op));
+ _set_error("GDScriptParser bug, invalid operator in expression: " + itos(expression[i].op));
return NULL;
}
}
@@ -1358,7 +1359,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
return expression[0].node;
}
-GDParser::Node *GDParser::_reduce_expression(Node *p_node, bool p_to_const) {
+GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to_const) {
switch (p_node->type) {
@@ -1455,7 +1456,7 @@ GDParser::Node *GDParser::_reduce_expression(Node *p_node, bool p_to_const) {
} else if (op->op == OperatorNode::OP_CALL) {
//can reduce base type constructors
- if ((op->arguments[0]->type == Node::TYPE_TYPE || (op->arguments[0]->type == Node::TYPE_BUILT_IN_FUNCTION && GDFunctions::is_deterministic(static_cast<BuiltInFunctionNode *>(op->arguments[0])->function))) && last_not_constant == 0) {
+ if ((op->arguments[0]->type == Node::TYPE_TYPE || (op->arguments[0]->type == Node::TYPE_BUILT_IN_FUNCTION && GDScriptFunctions::is_deterministic(static_cast<BuiltInFunctionNode *>(op->arguments[0])->function))) && last_not_constant == 0) {
//native type constructor or intrinsic function
const Variant **vptr = NULL;
@@ -1480,8 +1481,8 @@ GDParser::Node *GDParser::_reduce_expression(Node *p_node, bool p_to_const) {
v = Variant::construct(tn->vtype, vptr, ptrs.size(), ce);
} else {
- GDFunctions::Function func = static_cast<BuiltInFunctionNode *>(op->arguments[0])->function;
- GDFunctions::call(func, vptr, ptrs.size(), v, ce);
+ GDScriptFunctions::Function func = static_cast<BuiltInFunctionNode *>(op->arguments[0])->function;
+ GDScriptFunctions::call(func, vptr, ptrs.size(), v, ce);
}
if (ce.error != Variant::CallError::CALL_OK) {
@@ -1492,8 +1493,8 @@ GDParser::Node *GDParser::_reduce_expression(Node *p_node, bool p_to_const) {
errwhere = "'" + Variant::get_type_name(tn->vtype) + "'' constructor";
} else {
- GDFunctions::Function func = static_cast<BuiltInFunctionNode *>(op->arguments[0])->function;
- errwhere = String("'") + GDFunctions::get_func_name(func) + "'' intrinsic function";
+ GDScriptFunctions::Function func = static_cast<BuiltInFunctionNode *>(op->arguments[0])->function;
+ errwhere = String("'") + GDScriptFunctions::get_func_name(func) + "'' intrinsic function";
}
switch (ce.error) {
@@ -1743,7 +1744,7 @@ GDParser::Node *GDParser::_reduce_expression(Node *p_node, bool p_to_const) {
}
}
-GDParser::Node *GDParser::_parse_and_reduce_expression(Node *p_parent, bool p_static, bool p_reduce_const, bool p_allow_assign) {
+GDScriptParser::Node *GDScriptParser::_parse_and_reduce_expression(Node *p_parent, bool p_static, bool p_reduce_const, bool p_allow_assign) {
Node *expr = _parse_expression(p_parent, p_static, p_allow_assign, p_reduce_const);
if (!expr || error_set)
@@ -1754,58 +1755,58 @@ GDParser::Node *GDParser::_parse_and_reduce_expression(Node *p_parent, bool p_st
return expr;
}
-bool GDParser::_recover_from_completion() {
+bool GDScriptParser::_recover_from_completion() {
if (!completion_found) {
return false; //can't recover if no completion
}
//skip stuff until newline
- while (tokenizer->get_token() != GDTokenizer::TK_NEWLINE && tokenizer->get_token() != GDTokenizer::TK_EOF && tokenizer->get_token() != GDTokenizer::TK_ERROR) {
+ while (tokenizer->get_token() != GDScriptTokenizer::TK_NEWLINE && tokenizer->get_token() != GDScriptTokenizer::TK_EOF && tokenizer->get_token() != GDScriptTokenizer::TK_ERROR) {
tokenizer->advance();
}
completion_found = false;
error_set = false;
- if (tokenizer->get_token() == GDTokenizer::TK_ERROR) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_ERROR) {
error_set = true;
}
return true;
}
-GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) {
+GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) {
PatternNode *pattern = alloc_node<PatternNode>();
- GDTokenizer::Token token = tokenizer->get_token();
+ GDScriptTokenizer::Token token = tokenizer->get_token();
if (error_set)
return NULL;
- if (token == GDTokenizer::TK_EOF) {
+ if (token == GDScriptTokenizer::TK_EOF) {
return NULL;
}
switch (token) {
// array
- case GDTokenizer::TK_BRACKET_OPEN: {
+ case GDScriptTokenizer::TK_BRACKET_OPEN: {
tokenizer->advance();
- pattern->pt_type = GDParser::PatternNode::PT_ARRAY;
+ pattern->pt_type = GDScriptParser::PatternNode::PT_ARRAY;
while (true) {
- if (tokenizer->get_token() == GDTokenizer::TK_BRACKET_CLOSE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_BRACKET_CLOSE) {
tokenizer->advance();
break;
}
- if (tokenizer->get_token() == GDTokenizer::TK_PERIOD && tokenizer->get_token(1) == GDTokenizer::TK_PERIOD) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PERIOD && tokenizer->get_token(1) == GDScriptTokenizer::TK_PERIOD) {
// match everything
tokenizer->advance(2);
PatternNode *sub_pattern = alloc_node<PatternNode>();
- sub_pattern->pt_type = GDParser::PatternNode::PT_IGNORE_REST;
+ sub_pattern->pt_type = GDScriptParser::PatternNode::PT_IGNORE_REST;
pattern->array.push_back(sub_pattern);
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA && tokenizer->get_token(1) == GDTokenizer::TK_BRACKET_CLOSE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA && tokenizer->get_token(1) == GDScriptTokenizer::TK_BRACKET_CLOSE) {
tokenizer->advance(2);
break;
- } else if (tokenizer->get_token() == GDTokenizer::TK_BRACKET_CLOSE) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BRACKET_CLOSE) {
tokenizer->advance(1);
break;
} else {
@@ -1821,10 +1822,10 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) {
pattern->array.push_back(sub_pattern);
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
continue;
- } else if (tokenizer->get_token() == GDTokenizer::TK_BRACKET_CLOSE) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BRACKET_CLOSE) {
tokenizer->advance();
break;
} else {
@@ -1834,33 +1835,33 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) {
}
} break;
// bind
- case GDTokenizer::TK_PR_VAR: {
+ case GDScriptTokenizer::TK_PR_VAR: {
tokenizer->advance();
- pattern->pt_type = GDParser::PatternNode::PT_BIND;
+ pattern->pt_type = GDScriptParser::PatternNode::PT_BIND;
pattern->bind = tokenizer->get_token_identifier();
tokenizer->advance();
} break;
// dictionary
- case GDTokenizer::TK_CURLY_BRACKET_OPEN: {
+ case GDScriptTokenizer::TK_CURLY_BRACKET_OPEN: {
tokenizer->advance();
- pattern->pt_type = GDParser::PatternNode::PT_DICTIONARY;
+ pattern->pt_type = GDScriptParser::PatternNode::PT_DICTIONARY;
while (true) {
- if (tokenizer->get_token() == GDTokenizer::TK_CURLY_BRACKET_CLOSE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) {
tokenizer->advance();
break;
}
- if (tokenizer->get_token() == GDTokenizer::TK_PERIOD && tokenizer->get_token(1) == GDTokenizer::TK_PERIOD) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PERIOD && tokenizer->get_token(1) == GDScriptTokenizer::TK_PERIOD) {
// match everything
tokenizer->advance(2);
PatternNode *sub_pattern = alloc_node<PatternNode>();
sub_pattern->pt_type = PatternNode::PT_IGNORE_REST;
pattern->array.push_back(sub_pattern);
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA && tokenizer->get_token(1) == GDTokenizer::TK_CURLY_BRACKET_CLOSE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA && tokenizer->get_token(1) == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) {
tokenizer->advance(2);
break;
- } else if (tokenizer->get_token() == GDTokenizer::TK_CURLY_BRACKET_CLOSE) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) {
tokenizer->advance(1);
break;
} else {
@@ -1875,12 +1876,12 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) {
return NULL;
}
- if (key->type != GDParser::Node::TYPE_CONSTANT) {
+ if (key->type != GDScriptParser::Node::TYPE_CONSTANT) {
_set_error("Not a constant expression as key");
return NULL;
}
- if (tokenizer->get_token() == GDTokenizer::TK_COLON) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COLON) {
tokenizer->advance();
PatternNode *value = _parse_pattern(p_static);
@@ -1894,10 +1895,10 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) {
pattern->dictionary.insert(static_cast<ConstantNode *>(key), NULL);
}
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
continue;
- } else if (tokenizer->get_token() == GDTokenizer::TK_CURLY_BRACKET_CLOSE) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) {
tokenizer->advance();
break;
} else {
@@ -1906,7 +1907,7 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) {
}
}
} break;
- case GDTokenizer::TK_WILDCARD: {
+ case GDScriptTokenizer::TK_WILDCARD: {
tokenizer->advance();
pattern->pt_type = PatternNode::PT_WILDCARD;
} break;
@@ -1950,15 +1951,15 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) {
return pattern;
}
-void GDParser::_parse_pattern_block(BlockNode *p_block, Vector<PatternBranchNode *> &p_branches, bool p_static) {
+void GDScriptParser::_parse_pattern_block(BlockNode *p_block, Vector<PatternBranchNode *> &p_branches, bool p_static) {
int indent_level = tab_level.back()->get();
while (true) {
- while (tokenizer->get_token() == GDTokenizer::TK_NEWLINE && _parse_newline())
+ while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE && _parse_newline())
;
- // GDTokenizer::Token token = tokenizer->get_token();
+ // GDScriptTokenizer::Token token = tokenizer->get_token();
if (error_set)
return;
@@ -1977,7 +1978,7 @@ void GDParser::_parse_pattern_block(BlockNode *p_block, Vector<PatternBranchNode
return;
}
- while (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ while (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
branch->patterns.push_back(_parse_pattern(p_static));
if (!branch->patterns[branch->patterns.size() - 1]) {
@@ -2003,13 +2004,13 @@ void GDParser::_parse_pattern_block(BlockNode *p_block, Vector<PatternBranchNode
}
}
-void GDParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_match, Node *&p_resulting_node, Map<StringName, Node *> &p_bindings) {
+void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_match, Node *&p_resulting_node, Map<StringName, Node *> &p_bindings) {
switch (p_pattern->pt_type) {
case PatternNode::PT_CONSTANT: {
// typecheck
BuiltInFunctionNode *typeof_node = alloc_node<BuiltInFunctionNode>();
- typeof_node->function = GDFunctions::TYPE_OF;
+ typeof_node->function = GDScriptFunctions::TYPE_OF;
OperatorNode *typeof_match_value = alloc_node<OperatorNode>();
typeof_match_value->op = OperatorNode::OP_CALL;
@@ -2064,7 +2065,7 @@ void GDParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_match,
{
// typecheck
BuiltInFunctionNode *typeof_node = alloc_node<BuiltInFunctionNode>();
- typeof_node->function = GDFunctions::TYPE_OF;
+ typeof_node->function = GDScriptFunctions::TYPE_OF;
OperatorNode *typeof_match_value = alloc_node<OperatorNode>();
typeof_match_value->op = OperatorNode::OP_CALL;
@@ -2143,7 +2144,7 @@ void GDParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_match,
{
// typecheck
BuiltInFunctionNode *typeof_node = alloc_node<BuiltInFunctionNode>();
- typeof_node->function = GDFunctions::TYPE_OF;
+ typeof_node->function = GDScriptFunctions::TYPE_OF;
OperatorNode *typeof_match_value = alloc_node<OperatorNode>();
typeof_match_value->op = OperatorNode::OP_CALL;
@@ -2241,7 +2242,7 @@ void GDParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_match,
}
}
-void GDParser::_transform_match_statment(BlockNode *p_block, MatchNode *p_match_statement) {
+void GDScriptParser::_transform_match_statment(BlockNode *p_block, MatchNode *p_match_statement) {
IdentifierNode *id = alloc_node<IdentifierNode>();
id->name = "#match_value";
@@ -2305,7 +2306,7 @@ void GDParser::_transform_match_statment(BlockNode *p_block, MatchNode *p_match_
}
}
-void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
+void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
int indent_level = tab_level.back()->get();
@@ -2328,7 +2329,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
}
is_first_line = false;
- GDTokenizer::Token token = tokenizer->get_token();
+ GDScriptTokenizer::Token token = tokenizer->get_token();
if (error_set)
return;
@@ -2347,15 +2348,15 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
switch (token) {
- case GDTokenizer::TK_EOF:
+ case GDScriptTokenizer::TK_EOF:
p_block->end_line = tokenizer->get_token_line();
- case GDTokenizer::TK_ERROR: {
+ case GDScriptTokenizer::TK_ERROR: {
return; //go back
//end of file!
} break;
- case GDTokenizer::TK_NEWLINE: {
+ case GDScriptTokenizer::TK_NEWLINE: {
if (!_parse_newline()) {
if (!error_set) {
@@ -2370,19 +2371,19 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
p_block->statements.push_back(nl);
} break;
- case GDTokenizer::TK_CF_PASS: {
- if (tokenizer->get_token(1) != GDTokenizer::TK_SEMICOLON && tokenizer->get_token(1) != GDTokenizer::TK_NEWLINE && tokenizer->get_token(1) != GDTokenizer::TK_EOF) {
+ case GDScriptTokenizer::TK_CF_PASS: {
+ if (tokenizer->get_token(1) != GDScriptTokenizer::TK_SEMICOLON && tokenizer->get_token(1) != GDScriptTokenizer::TK_NEWLINE && tokenizer->get_token(1) != GDScriptTokenizer::TK_EOF) {
_set_error("Expected ';' or <NewLine>.");
return;
}
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_SEMICOLON) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_SEMICOLON) {
// Ignore semicolon after 'pass'
tokenizer->advance();
}
} break;
- case GDTokenizer::TK_PR_VAR: {
+ case GDScriptTokenizer::TK_PR_VAR: {
//variale declaration and (eventual) initialization
tokenizer->advance();
@@ -2421,7 +2422,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
Node *assigned = NULL;
- if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ASSIGN) {
tokenizer->advance();
Node *subexpr = _parse_and_reduce_expression(p_block, p_static);
@@ -2459,7 +2460,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
}
} break;
- case GDTokenizer::TK_CF_IF: {
+ case GDScriptTokenizer::TK_CF_IF: {
tokenizer->advance();
@@ -2498,7 +2499,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
while (true) {
- while (tokenizer->get_token() == GDTokenizer::TK_NEWLINE && _parse_newline())
+ while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE && _parse_newline())
;
if (tab_level.back()->get() < indent_level) { //not at current indent level
@@ -2506,7 +2507,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
return;
}
- if (tokenizer->get_token() == GDTokenizer::TK_CF_ELIF) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_CF_ELIF) {
if (tab_level.back()->get() > indent_level) {
@@ -2552,7 +2553,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
if (error_set)
return;
- } else if (tokenizer->get_token() == GDTokenizer::TK_CF_ELSE) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CF_ELSE) {
if (tab_level.back()->get() > indent_level) {
_set_error("Invalid indent");
@@ -2582,7 +2583,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
}
} break;
- case GDTokenizer::TK_CF_WHILE: {
+ case GDScriptTokenizer::TK_CF_WHILE: {
tokenizer->advance();
Node *condition = _parse_and_reduce_expression(p_block, p_static);
@@ -2615,7 +2616,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
return;
p_block->statements.push_back(cf_while);
} break;
- case GDTokenizer::TK_CF_FOR: {
+ case GDScriptTokenizer::TK_CF_FOR: {
tokenizer->advance();
@@ -2629,7 +2630,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_OP_IN) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_OP_IN) {
_set_error("'in' expected after identifier");
return;
}
@@ -2647,7 +2648,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
if (container->type == Node::TYPE_OPERATOR) {
OperatorNode *op = static_cast<OperatorNode *>(container);
- if (op->op == OperatorNode::OP_CALL && op->arguments[0]->type == Node::TYPE_BUILT_IN_FUNCTION && static_cast<BuiltInFunctionNode *>(op->arguments[0])->function == GDFunctions::GEN_RANGE) {
+ if (op->op == OperatorNode::OP_CALL && op->arguments[0]->type == Node::TYPE_BUILT_IN_FUNCTION && static_cast<BuiltInFunctionNode *>(op->arguments[0])->function == GDScriptFunctions::GEN_RANGE) {
//iterating a range, so see if range() can be optimized without allocating memory, by replacing it by vectors (which can work as iterable too!)
Vector<Node *> args;
@@ -2733,7 +2734,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
return;
p_block->statements.push_back(cf_for);
} break;
- case GDTokenizer::TK_CF_CONTINUE: {
+ case GDScriptTokenizer::TK_CF_CONTINUE: {
tokenizer->advance();
ControlFlowNode *cf_continue = alloc_node<ControlFlowNode>();
@@ -2744,7 +2745,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
return;
}
} break;
- case GDTokenizer::TK_CF_BREAK: {
+ case GDScriptTokenizer::TK_CF_BREAK: {
tokenizer->advance();
ControlFlowNode *cf_break = alloc_node<ControlFlowNode>();
@@ -2755,13 +2756,13 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
return;
}
} break;
- case GDTokenizer::TK_CF_RETURN: {
+ case GDScriptTokenizer::TK_CF_RETURN: {
tokenizer->advance();
ControlFlowNode *cf_return = alloc_node<ControlFlowNode>();
cf_return->cf_type = ControlFlowNode::CF_RETURN;
- if (tokenizer->get_token() == GDTokenizer::TK_SEMICOLON || tokenizer->get_token() == GDTokenizer::TK_NEWLINE || tokenizer->get_token() == GDTokenizer::TK_EOF) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_SEMICOLON || tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE || tokenizer->get_token() == GDScriptTokenizer::TK_EOF) {
//expect end of statement
p_block->statements.push_back(cf_return);
if (!_end_statement()) {
@@ -2785,7 +2786,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
}
} break;
- case GDTokenizer::TK_CF_MATCH: {
+ case GDScriptTokenizer::TK_CF_MATCH: {
tokenizer->advance();
@@ -2825,7 +2826,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
_end_statement();
} break;
- case GDTokenizer::TK_PR_ASSERT: {
+ case GDScriptTokenizer::TK_PR_ASSERT: {
tokenizer->advance();
Node *condition = _parse_and_reduce_expression(p_block, p_static);
@@ -2844,7 +2845,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
return;
}
} break;
- case GDTokenizer::TK_PR_BREAKPOINT: {
+ case GDScriptTokenizer::TK_PR_BREAKPOINT: {
tokenizer->advance();
BreakpointNode *bn = alloc_node<BreakpointNode>();
@@ -2872,9 +2873,9 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
} break;
/*
- case GDTokenizer::TK_CF_LOCAL: {
+ case GDScriptTokenizer::TK_CF_LOCAL: {
- if (tokenizer->get_token(1)!=GDTokenizer::TK_SEMICOLON && tokenizer->get_token(1)!=GDTokenizer::TK_NEWLINE ) {
+ if (tokenizer->get_token(1)!=GDScriptTokenizer::TK_SEMICOLON && tokenizer->get_token(1)!=GDScriptTokenizer::TK_NEWLINE ) {
_set_error("Expected ';' or <NewLine>.");
}
@@ -2885,9 +2886,9 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
}
}
-bool GDParser::_parse_newline() {
+bool GDScriptParser::_parse_newline() {
- if (tokenizer->get_token(1) != GDTokenizer::TK_EOF && tokenizer->get_token(1) != GDTokenizer::TK_NEWLINE) {
+ if (tokenizer->get_token(1) != GDScriptTokenizer::TK_EOF && tokenizer->get_token(1) != GDScriptTokenizer::TK_NEWLINE) {
int indent = tokenizer->get_token_line_indent();
int current_indent = tab_level.back()->get();
@@ -2926,7 +2927,7 @@ bool GDParser::_parse_newline() {
return true;
}
-void GDParser::_parse_extends(ClassNode *p_class) {
+void GDScriptParser::_parse_extends(ClassNode *p_class) {
if (p_class->extends_used) {
@@ -2944,14 +2945,14 @@ void GDParser::_parse_extends(ClassNode *p_class) {
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_TYPE && tokenizer->get_token_type() == Variant::OBJECT) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE && tokenizer->get_token_type() == Variant::OBJECT) {
p_class->extends_class.push_back(Variant::get_type_name(Variant::OBJECT));
tokenizer->advance();
return;
}
// see if inheritance happens from a file
- if (tokenizer->get_token() == GDTokenizer::TK_CONSTANT) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT) {
Variant constant = tokenizer->get_token_constant();
if (constant.get_type() != Variant::STRING) {
@@ -2963,14 +2964,14 @@ void GDParser::_parse_extends(ClassNode *p_class) {
p_class->extends_file = constant;
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_PERIOD) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PERIOD) {
return;
} else
tokenizer->advance();
}
while (true) {
- if (tokenizer->get_token() != GDTokenizer::TK_IDENTIFIER) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_IDENTIFIER) {
_set_error("Invalid 'extends' syntax, expected string constant (path) and/or identifier (parent class).");
return;
@@ -2980,18 +2981,18 @@ void GDParser::_parse_extends(ClassNode *p_class) {
p_class->extends_class.push_back(identifier);
tokenizer->advance(1);
- if (tokenizer->get_token() != GDTokenizer::TK_PERIOD)
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PERIOD)
return;
}
}
-void GDParser::_parse_class(ClassNode *p_class) {
+void GDScriptParser::_parse_class(ClassNode *p_class) {
int indent_level = tab_level.back()->get();
while (true) {
- GDTokenizer::Token token = tokenizer->get_token();
+ GDScriptTokenizer::Token token = tokenizer->get_token();
if (error_set)
return;
@@ -3002,13 +3003,13 @@ void GDParser::_parse_class(ClassNode *p_class) {
switch (token) {
- case GDTokenizer::TK_EOF:
+ case GDScriptTokenizer::TK_EOF:
p_class->end_line = tokenizer->get_token_line();
- case GDTokenizer::TK_ERROR: {
+ case GDScriptTokenizer::TK_ERROR: {
return; //go back
//end of file!
} break;
- case GDTokenizer::TK_NEWLINE: {
+ case GDScriptTokenizer::TK_NEWLINE: {
if (!_parse_newline()) {
if (!error_set) {
p_class->end_line = tokenizer->get_token_line();
@@ -3016,7 +3017,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
return;
}
} break;
- case GDTokenizer::TK_PR_EXTENDS: {
+ case GDScriptTokenizer::TK_PR_EXTENDS: {
_parse_extends(p_class);
if (error_set)
@@ -3027,7 +3028,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
}
} break;
- case GDTokenizer::TK_PR_TOOL: {
+ case GDScriptTokenizer::TK_PR_TOOL: {
if (p_class->tool) {
@@ -3039,13 +3040,13 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
} break;
- case GDTokenizer::TK_PR_CLASS: {
+ case GDScriptTokenizer::TK_PR_CLASS: {
//class inside class :D
StringName name;
StringName extends;
- if (tokenizer->get_token(1) != GDTokenizer::TK_IDENTIFIER) {
+ if (tokenizer->get_token(1) != GDScriptTokenizer::TK_IDENTIFIER) {
_set_error("'class' syntax: 'class <Name>:' or 'class <Name> extends <BaseClass>:'");
return;
@@ -3063,7 +3064,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
p_class->subclasses.push_back(newclass);
- if (tokenizer->get_token() == GDTokenizer::TK_PR_EXTENDS) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_EXTENDS) {
_parse_extends(newclass);
if (error_set)
@@ -3081,26 +3082,26 @@ void GDParser::_parse_class(ClassNode *p_class) {
} break;
/* this is for functions....
- case GDTokenizer::TK_CF_PASS: {
+ case GDScriptTokenizer::TK_CF_PASS: {
tokenizer->advance(1);
} break;
*/
- case GDTokenizer::TK_PR_STATIC: {
+ case GDScriptTokenizer::TK_PR_STATIC: {
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_PR_FUNCTION) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) {
_set_error("Expected 'func'.");
return;
}
}; //fallthrough to function
- case GDTokenizer::TK_PR_FUNCTION: {
+ case GDScriptTokenizer::TK_PR_FUNCTION: {
bool _static = false;
pending_newline = -1;
- if (tokenizer->get_token(-1) == GDTokenizer::TK_PR_STATIC) {
+ if (tokenizer->get_token(-1) == GDScriptTokenizer::TK_PR_STATIC) {
_static = true;
}
@@ -3128,7 +3129,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
}
}
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_OPEN) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
_set_error("Expected '(' after identifier (syntax: 'func <identifier>([arguments]):' ).");
return;
@@ -3141,17 +3142,17 @@ void GDParser::_parse_class(ClassNode *p_class) {
int fnline = tokenizer->get_token_line();
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
//has arguments
bool defaulting = false;
while (true) {
- if (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
tokenizer->advance();
continue;
}
- if (tokenizer->get_token() == GDTokenizer::TK_PR_VAR) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_VAR) {
tokenizer->advance(); //var before the identifier is allowed
}
@@ -3167,7 +3168,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
- if (defaulting && tokenizer->get_token() != GDTokenizer::TK_OP_ASSIGN) {
+ if (defaulting && tokenizer->get_token() != GDScriptTokenizer::TK_OP_ASSIGN) {
_set_error("Default parameter expected.");
return;
@@ -3175,7 +3176,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
//tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ASSIGN) {
defaulting = true;
tokenizer->advance(1);
Node *defval = _parse_and_reduce_expression(p_class, _static);
@@ -3199,14 +3200,14 @@ void GDParser::_parse_class(ClassNode *p_class) {
default_values.push_back(on);
}
- while (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) {
+ while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
tokenizer->advance();
}
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
continue;
- } else if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ } else if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ',' or ')'.");
return;
@@ -3233,14 +3234,14 @@ void GDParser::_parse_class(ClassNode *p_class) {
id->name = "_init";
cparent->arguments.push_back(id);
- if (tokenizer->get_token() == GDTokenizer::TK_PERIOD) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PERIOD) {
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_OPEN) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
_set_error("expected '(' for parent constructor arguments.");
}
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
//has arguments
parenthesis++;
while (true) {
@@ -3248,10 +3249,10 @@ void GDParser::_parse_class(ClassNode *p_class) {
Node *arg = _parse_and_reduce_expression(p_class, _static);
cparent->arguments.push_back(arg);
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
continue;
- } else if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ } else if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ',' or ')'.");
return;
@@ -3266,7 +3267,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
}
} else {
- if (tokenizer->get_token() == GDTokenizer::TK_PERIOD) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PERIOD) {
_set_error("Parent constructor call found for a class without inheritance.");
return;
@@ -3303,7 +3304,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
//arguments
} break;
- case GDTokenizer::TK_PR_SIGNAL: {
+ case GDScriptTokenizer::TK_PR_SIGNAL: {
tokenizer->advance();
if (!tokenizer->is_token_literal()) {
@@ -3315,15 +3316,15 @@ void GDParser::_parse_class(ClassNode *p_class) {
sig.name = tokenizer->get_token_identifier();
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_OPEN) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
tokenizer->advance();
while (true) {
- if (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
tokenizer->advance();
continue;
}
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
tokenizer->advance();
break;
}
@@ -3336,13 +3337,13 @@ void GDParser::_parse_class(ClassNode *p_class) {
sig.arguments.push_back(tokenizer->get_token_identifier());
tokenizer->advance();
- while (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) {
+ while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
tokenizer->advance();
}
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
- } else if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ } else if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ',' or ')' after signal parameter identifier.");
return;
}
@@ -3356,14 +3357,14 @@ void GDParser::_parse_class(ClassNode *p_class) {
return;
}
} break;
- case GDTokenizer::TK_PR_EXPORT: {
+ case GDScriptTokenizer::TK_PR_EXPORT: {
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_OPEN) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_TYPE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE) {
Variant::Type type = tokenizer->get_token_type();
if (type == Variant::NIL) {
@@ -3376,17 +3377,17 @@ void GDParser::_parse_class(ClassNode *p_class) {
String hint_prefix = "";
- if (type == Variant::ARRAY && tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ if (type == Variant::ARRAY && tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
- while (tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_TYPE) {
+ while (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE) {
type = tokenizer->get_token_type();
tokenizer->advance();
if (type == Variant::ARRAY) {
hint_prefix += itos(Variant::ARRAY) + ":";
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
}
} else {
@@ -3396,7 +3397,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
}
}
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
// hint expected next!
tokenizer->advance();
@@ -3404,15 +3405,15 @@ void GDParser::_parse_class(ClassNode *p_class) {
case Variant::INT: {
- if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "FLAGS") {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "FLAGS") {
//current_export.hint=PROPERTY_HINT_ALL_FLAGS;
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
break;
}
- if (tokenizer->get_token() != GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
_set_error("Expected ')' or ',' in bit flags hint.");
return;
}
@@ -3423,7 +3424,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
bool first = true;
while (true) {
- if (tokenizer->get_token() != GDTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) {
current_export = PropertyInfo();
_set_error("Expected a string constant in named bit flags hint.");
return;
@@ -3438,10 +3439,10 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export.hint_string += c.xml_escape();
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE)
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE)
break;
- if (tokenizer->get_token() != GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
current_export = PropertyInfo();
_set_error("Expected ')' or ',' in named bit flags hint.");
return;
@@ -3452,13 +3453,13 @@ void GDParser::_parse_class(ClassNode *p_class) {
break;
}
- if (tokenizer->get_token() == GDTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING) {
//enumeration
current_export.hint = PROPERTY_HINT_ENUM;
bool first = true;
while (true) {
- if (tokenizer->get_token() != GDTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) {
current_export = PropertyInfo();
_set_error("Expected a string constant in enumeration hint.");
@@ -3474,10 +3475,10 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export.hint_string += c.xml_escape();
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE)
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE)
break;
- if (tokenizer->get_token() != GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
current_export = PropertyInfo();
_set_error("Expected ')' or ',' in enumeration hint.");
return;
@@ -3492,10 +3493,10 @@ void GDParser::_parse_class(ClassNode *p_class) {
}; //fallthrough to use the same
case Variant::REAL: {
- if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "EASE") {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "EASE") {
current_export.hint = PROPERTY_HINT_EXP_EASING;
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ')' in hint.");
return;
}
@@ -3503,14 +3504,14 @@ void GDParser::_parse_class(ClassNode *p_class) {
}
// range
- if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "EXP") {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "EXP") {
current_export.hint = PROPERTY_HINT_EXP_RANGE;
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE)
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE)
break;
- else if (tokenizer->get_token() != GDTokenizer::TK_COMMA) {
+ else if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
_set_error("Expected ')' or ',' in exponential range hint.");
return;
}
@@ -3520,11 +3521,11 @@ void GDParser::_parse_class(ClassNode *p_class) {
float sign = 1.0;
- if (tokenizer->get_token() == GDTokenizer::TK_OP_SUB) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_SUB) {
sign = -1;
tokenizer->advance();
}
- if (tokenizer->get_token() != GDTokenizer::TK_CONSTANT || !tokenizer->get_token_constant().is_num()) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || !tokenizer->get_token_constant().is_num()) {
current_export = PropertyInfo();
_set_error("Expected a range in numeric hint.");
@@ -3534,12 +3535,12 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export.hint_string = rtos(sign * double(tokenizer->get_token_constant()));
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
current_export.hint_string = "0," + current_export.hint_string;
break;
}
- if (tokenizer->get_token() != GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
current_export = PropertyInfo();
_set_error("Expected ',' or ')' in numeric range hint.");
@@ -3549,12 +3550,12 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
sign = 1.0;
- if (tokenizer->get_token() == GDTokenizer::TK_OP_SUB) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_SUB) {
sign = -1;
tokenizer->advance();
}
- if (tokenizer->get_token() != GDTokenizer::TK_CONSTANT || !tokenizer->get_token_constant().is_num()) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || !tokenizer->get_token_constant().is_num()) {
current_export = PropertyInfo();
_set_error("Expected a number as upper bound in numeric range hint.");
@@ -3564,10 +3565,10 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export.hint_string += "," + rtos(sign * double(tokenizer->get_token_constant()));
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE)
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE)
break;
- if (tokenizer->get_token() != GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
current_export = PropertyInfo();
_set_error("Expected ',' or ')' in numeric range hint.");
@@ -3576,12 +3577,12 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
sign = 1.0;
- if (tokenizer->get_token() == GDTokenizer::TK_OP_SUB) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_SUB) {
sign = -1;
tokenizer->advance();
}
- if (tokenizer->get_token() != GDTokenizer::TK_CONSTANT || !tokenizer->get_token_constant().is_num()) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || !tokenizer->get_token_constant().is_num()) {
current_export = PropertyInfo();
_set_error("Expected a number as step in numeric range hint.");
@@ -3594,13 +3595,13 @@ void GDParser::_parse_class(ClassNode *p_class) {
} break;
case Variant::STRING: {
- if (tokenizer->get_token() == GDTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING) {
//enumeration
current_export.hint = PROPERTY_HINT_ENUM;
bool first = true;
while (true) {
- if (tokenizer->get_token() != GDTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) {
current_export = PropertyInfo();
_set_error("Expected a string constant in enumeration hint.");
@@ -3615,10 +3616,10 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export.hint_string += c.xml_escape();
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE)
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE)
break;
- if (tokenizer->get_token() != GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
current_export = PropertyInfo();
_set_error("Expected ')' or ',' in enumeration hint.");
return;
@@ -3629,17 +3630,17 @@ void GDParser::_parse_class(ClassNode *p_class) {
break;
}
- if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "DIR") {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "DIR") {
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE)
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE)
current_export.hint = PROPERTY_HINT_DIR;
- else if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_IDENTIFIER || !(tokenizer->get_token_identifier() == "GLOBAL")) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_IDENTIFIER || !(tokenizer->get_token_identifier() == "GLOBAL")) {
_set_error("Expected 'GLOBAL' after comma in directory hint.");
return;
}
@@ -3650,7 +3651,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export.hint = PROPERTY_HINT_GLOBAL_DIR;
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ')' in hint.");
return;
}
@@ -3661,16 +3662,16 @@ void GDParser::_parse_class(ClassNode *p_class) {
break;
}
- if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "FILE") {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "FILE") {
current_export.hint = PROPERTY_HINT_FILE;
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "GLOBAL") {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "GLOBAL") {
if (!p_class->tool) {
_set_error("Global filesystem hints may only be used in tool scripts.");
@@ -3679,9 +3680,9 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export.hint = PROPERTY_HINT_GLOBAL_FILE;
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE)
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE)
break;
- else if (tokenizer->get_token() == GDTokenizer::TK_COMMA)
+ else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA)
tokenizer->advance();
else {
_set_error("Expected ')' or ',' in hint.");
@@ -3689,7 +3690,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
}
}
- if (tokenizer->get_token() != GDTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) {
if (current_export.hint == PROPERTY_HINT_GLOBAL_FILE)
_set_error("Expected string constant with filter");
@@ -3701,18 +3702,18 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
}
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ')' in hint.");
return;
}
break;
}
- if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "MULTILINE") {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "MULTILINE") {
current_export.hint = PROPERTY_HINT_MULTILINE_TEXT;
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ')' in hint.");
return;
}
@@ -3721,7 +3722,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
} break;
case Variant::COLOR: {
- if (tokenizer->get_token() != GDTokenizer::TK_IDENTIFIER) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_IDENTIFIER) {
current_export = PropertyInfo();
_set_error("Color type hint expects RGB or RGBA as hints");
@@ -3757,7 +3758,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export.hint = PROPERTY_HINT_NONE;
}
- } else if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER) {
String identifier = tokenizer->get_token_identifier();
if (!ClassDB::is_parent_class(identifier, "Resource")) {
@@ -3775,7 +3776,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
}
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
current_export = PropertyInfo();
_set_error("Expected ')' or ',' after export hint.");
@@ -3785,7 +3786,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
}
- if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR && tokenizer->get_token() != GDTokenizer::TK_PR_ONREADY && tokenizer->get_token() != GDTokenizer::TK_PR_REMOTE && tokenizer->get_token() != GDTokenizer::TK_PR_MASTER && tokenizer->get_token() != GDTokenizer::TK_PR_SLAVE && tokenizer->get_token() != GDTokenizer::TK_PR_SYNC) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_ONREADY && tokenizer->get_token() != GDScriptTokenizer::TK_PR_REMOTE && tokenizer->get_token() != GDScriptTokenizer::TK_PR_MASTER && tokenizer->get_token() != GDScriptTokenizer::TK_PR_SLAVE && tokenizer->get_token() != GDScriptTokenizer::TK_PR_SYNC) {
current_export = PropertyInfo();
_set_error("Expected 'var', 'onready', 'remote', 'master', 'slave' or 'sync'.");
@@ -3794,29 +3795,29 @@ void GDParser::_parse_class(ClassNode *p_class) {
continue;
} break;
- case GDTokenizer::TK_PR_ONREADY: {
+ case GDScriptTokenizer::TK_PR_ONREADY: {
//may be fallthrough from export, ignore if so
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR) {
_set_error("Expected 'var'.");
return;
}
continue;
} break;
- case GDTokenizer::TK_PR_REMOTE: {
+ case GDScriptTokenizer::TK_PR_REMOTE: {
//may be fallthrough from export, ignore if so
tokenizer->advance();
if (current_export.type) {
- if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR) {
_set_error("Expected 'var'.");
return;
}
} else {
- if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR && tokenizer->get_token() != GDTokenizer::TK_PR_FUNCTION) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) {
_set_error("Expected 'var' or 'func'.");
return;
}
@@ -3825,18 +3826,18 @@ void GDParser::_parse_class(ClassNode *p_class) {
continue;
} break;
- case GDTokenizer::TK_PR_MASTER: {
+ case GDScriptTokenizer::TK_PR_MASTER: {
//may be fallthrough from export, ignore if so
tokenizer->advance();
if (current_export.type) {
- if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR) {
_set_error("Expected 'var'.");
return;
}
} else {
- if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR && tokenizer->get_token() != GDTokenizer::TK_PR_FUNCTION) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) {
_set_error("Expected 'var' or 'func'.");
return;
}
@@ -3845,18 +3846,18 @@ void GDParser::_parse_class(ClassNode *p_class) {
rpc_mode = ScriptInstance::RPC_MODE_MASTER;
continue;
} break;
- case GDTokenizer::TK_PR_SLAVE: {
+ case GDScriptTokenizer::TK_PR_SLAVE: {
//may be fallthrough from export, ignore if so
tokenizer->advance();
if (current_export.type) {
- if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR) {
_set_error("Expected 'var'.");
return;
}
} else {
- if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR && tokenizer->get_token() != GDTokenizer::TK_PR_FUNCTION) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) {
_set_error("Expected 'var' or 'func'.");
return;
}
@@ -3865,11 +3866,11 @@ void GDParser::_parse_class(ClassNode *p_class) {
rpc_mode = ScriptInstance::RPC_MODE_SLAVE;
continue;
} break;
- case GDTokenizer::TK_PR_SYNC: {
+ case GDScriptTokenizer::TK_PR_SYNC: {
//may be fallthrough from export, ignore if so
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR && tokenizer->get_token() != GDTokenizer::TK_PR_FUNCTION) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) {
if (current_export.type)
_set_error("Expected 'var'.");
else
@@ -3880,17 +3881,17 @@ void GDParser::_parse_class(ClassNode *p_class) {
rpc_mode = ScriptInstance::RPC_MODE_SYNC;
continue;
} break;
- case GDTokenizer::TK_PR_VAR: {
+ case GDScriptTokenizer::TK_PR_VAR: {
//variale declaration and (eventual) initialization
ClassNode::Member member;
- bool autoexport = tokenizer->get_token(-1) == GDTokenizer::TK_PR_EXPORT;
+ bool autoexport = tokenizer->get_token(-1) == GDScriptTokenizer::TK_PR_EXPORT;
if (current_export.type != Variant::NIL) {
member._export = current_export;
current_export = PropertyInfo();
}
- bool onready = tokenizer->get_token(-1) == GDTokenizer::TK_PR_ONREADY;
+ bool onready = tokenizer->get_token(-1) == GDScriptTokenizer::TK_PR_ONREADY;
tokenizer->advance();
if (!tokenizer->is_token_literal(0, true)) {
@@ -3909,7 +3910,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
rpc_mode = ScriptInstance::RPC_MODE_DISABLED;
- if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ASSIGN) {
#ifdef DEBUG_ENABLED
int line = tokenizer->get_token_line();
@@ -4017,11 +4018,11 @@ void GDParser::_parse_class(ClassNode *p_class) {
}
}
- if (tokenizer->get_token() == GDTokenizer::TK_PR_SETGET) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_SETGET) {
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
//just comma means using only getter
if (!tokenizer->is_token_literal()) {
_set_error("Expected identifier for setter function after 'setget'.");
@@ -4032,7 +4033,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
}
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
//there is a getter
tokenizer->advance();
@@ -4052,7 +4053,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
return;
}
} break;
- case GDTokenizer::TK_PR_CONST: {
+ case GDScriptTokenizer::TK_PR_CONST: {
//variale declaration and (eventual) initialization
ClassNode::Constant constant;
@@ -4067,7 +4068,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
constant.identifier = tokenizer->get_token_literal();
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_OP_ASSIGN) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_OP_ASSIGN) {
_set_error("Constant expects assignment.");
return;
}
@@ -4095,7 +4096,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
}
} break;
- case GDTokenizer::TK_PR_ENUM: {
+ case GDScriptTokenizer::TK_PR_ENUM: {
//mutiple constant declarations..
int last_assign = -1; // Incremented by 1 right before the assingment.
@@ -4107,26 +4108,26 @@ void GDParser::_parse_class(ClassNode *p_class) {
enum_name = tokenizer->get_token_literal();
tokenizer->advance();
}
- if (tokenizer->get_token() != GDTokenizer::TK_CURLY_BRACKET_OPEN) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_CURLY_BRACKET_OPEN) {
_set_error("Expected '{' in enum declaration");
return;
}
tokenizer->advance();
while (true) {
- if (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
tokenizer->advance(); // Ignore newlines
- } else if (tokenizer->get_token() == GDTokenizer::TK_CURLY_BRACKET_CLOSE) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) {
tokenizer->advance();
break; // End of enum
} else if (!tokenizer->is_token_literal(0, true)) {
- if (tokenizer->get_token() == GDTokenizer::TK_EOF) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_EOF) {
_set_error("Unexpected end of file.");
} else {
- _set_error(String("Unexpected ") + GDTokenizer::get_token_name(tokenizer->get_token()) + ", expected identifier");
+ _set_error(String("Unexpected ") + GDScriptTokenizer::get_token_name(tokenizer->get_token()) + ", expected identifier");
}
return;
@@ -4137,7 +4138,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ASSIGN) {
tokenizer->advance();
Node *subexpr = _parse_and_reduce_expression(p_class, true, true);
@@ -4169,7 +4170,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
constant.expression = cn;
}
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
}
@@ -4198,7 +4199,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
} break;
- case GDTokenizer::TK_CONSTANT: {
+ case GDScriptTokenizer::TK_CONSTANT: {
if (tokenizer->get_token_constant().get_type() == Variant::STRING) {
tokenizer->advance();
// Ignore
@@ -4218,7 +4219,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
}
}
-void GDParser::_set_error(const String &p_error, int p_line, int p_column) {
+void GDScriptParser::_set_error(const String &p_error, int p_line, int p_column) {
if (error_set)
return; //allow no further errors
@@ -4229,21 +4230,21 @@ void GDParser::_set_error(const String &p_error, int p_line, int p_column) {
error_set = true;
}
-String GDParser::get_error() const {
+String GDScriptParser::get_error() const {
return error;
}
-int GDParser::get_error_line() const {
+int GDScriptParser::get_error_line() const {
return error_line;
}
-int GDParser::get_error_column() const {
+int GDScriptParser::get_error_column() const {
return error_column;
}
-Error GDParser::_parse(const String &p_base_path) {
+Error GDScriptParser::_parse(const String &p_base_path) {
base_path = p_base_path;
@@ -4259,7 +4260,7 @@ Error GDParser::_parse(const String &p_base_path) {
_parse_class(main_class);
- if (tokenizer->get_token() == GDTokenizer::TK_ERROR) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_ERROR) {
error_set = false;
_set_error("Parse Error: " + tokenizer->get_token_error());
}
@@ -4271,7 +4272,7 @@ Error GDParser::_parse(const String &p_base_path) {
return OK;
}
-Error GDParser::parse_bytecode(const Vector<uint8_t> &p_bytecode, const String &p_base_path, const String &p_self_path) {
+Error GDScriptParser::parse_bytecode(const Vector<uint8_t> &p_bytecode, const String &p_base_path, const String &p_self_path) {
for_completion = false;
validating = false;
@@ -4286,7 +4287,7 @@ Error GDParser::parse_bytecode(const Vector<uint8_t> &p_bytecode, const String &
current_function = NULL;
self_path = p_self_path;
- GDTokenizerBuffer *tb = memnew(GDTokenizerBuffer);
+ GDScriptTokenizerBuffer *tb = memnew(GDScriptTokenizerBuffer);
tb->set_code_buffer(p_bytecode);
tokenizer = tb;
Error ret = _parse(p_base_path);
@@ -4295,7 +4296,7 @@ Error GDParser::parse_bytecode(const Vector<uint8_t> &p_bytecode, const String &
return ret;
}
-Error GDParser::parse(const String &p_code, const String &p_base_path, bool p_just_validate, const String &p_self_path, bool p_for_completion) {
+Error GDScriptParser::parse(const String &p_code, const String &p_base_path, bool p_just_validate, const String &p_self_path, bool p_for_completion) {
completion_type = COMPLETION_NONE;
completion_node = NULL;
@@ -4309,7 +4310,7 @@ Error GDParser::parse(const String &p_code, const String &p_base_path, bool p_ju
current_function = NULL;
self_path = p_self_path;
- GDTokenizerText *tt = memnew(GDTokenizerText);
+ GDScriptTokenizerText *tt = memnew(GDScriptTokenizerText);
tt->set_code(p_code);
validating = p_just_validate;
@@ -4321,17 +4322,17 @@ Error GDParser::parse(const String &p_code, const String &p_base_path, bool p_ju
return ret;
}
-bool GDParser::is_tool_script() const {
+bool GDScriptParser::is_tool_script() const {
return (head && head->type == Node::TYPE_CLASS && static_cast<const ClassNode *>(head)->tool);
}
-const GDParser::Node *GDParser::get_parse_tree() const {
+const GDScriptParser::Node *GDScriptParser::get_parse_tree() const {
return head;
}
-void GDParser::clear() {
+void GDScriptParser::clear() {
while (list) {
@@ -4369,57 +4370,57 @@ void GDParser::clear() {
error = "";
}
-GDParser::CompletionType GDParser::get_completion_type() {
+GDScriptParser::CompletionType GDScriptParser::get_completion_type() {
return completion_type;
}
-StringName GDParser::get_completion_cursor() {
+StringName GDScriptParser::get_completion_cursor() {
return completion_cursor;
}
-int GDParser::get_completion_line() {
+int GDScriptParser::get_completion_line() {
return completion_line;
}
-Variant::Type GDParser::get_completion_built_in_constant() {
+Variant::Type GDScriptParser::get_completion_built_in_constant() {
return completion_built_in_constant;
}
-GDParser::Node *GDParser::get_completion_node() {
+GDScriptParser::Node *GDScriptParser::get_completion_node() {
return completion_node;
}
-GDParser::BlockNode *GDParser::get_completion_block() {
+GDScriptParser::BlockNode *GDScriptParser::get_completion_block() {
return completion_block;
}
-GDParser::ClassNode *GDParser::get_completion_class() {
+GDScriptParser::ClassNode *GDScriptParser::get_completion_class() {
return completion_class;
}
-GDParser::FunctionNode *GDParser::get_completion_function() {
+GDScriptParser::FunctionNode *GDScriptParser::get_completion_function() {
return completion_function;
}
-int GDParser::get_completion_argument_index() {
+int GDScriptParser::get_completion_argument_index() {
return completion_argument;
}
-int GDParser::get_completion_identifier_is_function() {
+int GDScriptParser::get_completion_identifier_is_function() {
return completion_ident_is_call;
}
-GDParser::GDParser() {
+GDScriptParser::GDScriptParser() {
head = NULL;
list = NULL;
@@ -4428,7 +4429,7 @@ GDParser::GDParser() {
clear();
}
-GDParser::~GDParser() {
+GDScriptParser::~GDScriptParser() {
clear();
}
diff --git a/modules/gdscript/gd_parser.h b/modules/gdscript/gdscript_parser.h
index 7e88fd9746..3c9c5ea02c 100644
--- a/modules/gdscript/gd_parser.h
+++ b/modules/gdscript/gdscript_parser.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_parser.h */
+/* gdscript_parser.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,16 +27,16 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GD_PARSER_H
-#define GD_PARSER_H
+#ifndef GDSCRIPT_PARSER_H
+#define GDSCRIPT_PARSER_H
-#include "gd_functions.h"
-#include "gd_tokenizer.h"
+#include "gdscript_functions.h"
+#include "gdscript_tokenizer.h"
#include "map.h"
#include "object.h"
#include "script_language.h"
-class GDParser {
+class GDScriptParser {
public:
struct Node {
@@ -166,7 +166,7 @@ public:
TypeNode() { type = TYPE_TYPE; }
};
struct BuiltInFunctionNode : public Node {
- GDFunctions::Function function;
+ GDScriptFunctions::Function function;
BuiltInFunctionNode() { type = TYPE_BUILT_IN_FUNCTION; }
};
@@ -448,7 +448,7 @@ public:
};
private:
- GDTokenizer *tokenizer;
+ GDScriptTokenizer *tokenizer;
Node *head;
Node *list;
@@ -540,8 +540,8 @@ public:
int get_completion_identifier_is_function();
void clear();
- GDParser();
- ~GDParser();
+ GDScriptParser();
+ ~GDScriptParser();
};
-#endif // PARSER_H
+#endif // GDSCRIPT_PARSER_H
diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp
index e241eacd4f..174bb02967 100644
--- a/modules/gdscript/gd_tokenizer.cpp
+++ b/modules/gdscript/gdscript_tokenizer.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_tokenizer.cpp */
+/* gdscript_tokenizer.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,14 +27,14 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "gd_tokenizer.h"
+#include "gdscript_tokenizer.h"
-#include "gd_functions.h"
+#include "gdscript_functions.h"
#include "io/marshalls.h"
#include "map.h"
#include "print_string.h"
-const char *GDTokenizer::token_names[TK_MAX] = {
+const char *GDScriptTokenizer::token_names[TK_MAX] = {
"Empty",
"Identifier",
"Constant",
@@ -170,68 +170,68 @@ static const _bit _type_list[] = {
};
struct _kws {
- GDTokenizer::Token token;
+ GDScriptTokenizer::Token token;
const char *text;
};
static const _kws _keyword_list[] = {
//ops
- { GDTokenizer::TK_OP_IN, "in" },
- { GDTokenizer::TK_OP_NOT, "not" },
- { GDTokenizer::TK_OP_OR, "or" },
- { GDTokenizer::TK_OP_AND, "and" },
+ { GDScriptTokenizer::TK_OP_IN, "in" },
+ { GDScriptTokenizer::TK_OP_NOT, "not" },
+ { GDScriptTokenizer::TK_OP_OR, "or" },
+ { GDScriptTokenizer::TK_OP_AND, "and" },
//func
- { GDTokenizer::TK_PR_FUNCTION, "func" },
- { GDTokenizer::TK_PR_CLASS, "class" },
- { GDTokenizer::TK_PR_EXTENDS, "extends" },
- { GDTokenizer::TK_PR_IS, "is" },
- { GDTokenizer::TK_PR_ONREADY, "onready" },
- { GDTokenizer::TK_PR_TOOL, "tool" },
- { GDTokenizer::TK_PR_STATIC, "static" },
- { GDTokenizer::TK_PR_EXPORT, "export" },
- { GDTokenizer::TK_PR_SETGET, "setget" },
- { GDTokenizer::TK_PR_VAR, "var" },
- { GDTokenizer::TK_PR_PRELOAD, "preload" },
- { GDTokenizer::TK_PR_ASSERT, "assert" },
- { GDTokenizer::TK_PR_YIELD, "yield" },
- { GDTokenizer::TK_PR_SIGNAL, "signal" },
- { GDTokenizer::TK_PR_BREAKPOINT, "breakpoint" },
- { GDTokenizer::TK_PR_REMOTE, "remote" },
- { GDTokenizer::TK_PR_MASTER, "master" },
- { GDTokenizer::TK_PR_SLAVE, "slave" },
- { GDTokenizer::TK_PR_SYNC, "sync" },
- { GDTokenizer::TK_PR_CONST, "const" },
- { GDTokenizer::TK_PR_ENUM, "enum" },
+ { GDScriptTokenizer::TK_PR_FUNCTION, "func" },
+ { GDScriptTokenizer::TK_PR_CLASS, "class" },
+ { GDScriptTokenizer::TK_PR_EXTENDS, "extends" },
+ { GDScriptTokenizer::TK_PR_IS, "is" },
+ { GDScriptTokenizer::TK_PR_ONREADY, "onready" },
+ { GDScriptTokenizer::TK_PR_TOOL, "tool" },
+ { GDScriptTokenizer::TK_PR_STATIC, "static" },
+ { GDScriptTokenizer::TK_PR_EXPORT, "export" },
+ { GDScriptTokenizer::TK_PR_SETGET, "setget" },
+ { GDScriptTokenizer::TK_PR_VAR, "var" },
+ { GDScriptTokenizer::TK_PR_PRELOAD, "preload" },
+ { GDScriptTokenizer::TK_PR_ASSERT, "assert" },
+ { GDScriptTokenizer::TK_PR_YIELD, "yield" },
+ { GDScriptTokenizer::TK_PR_SIGNAL, "signal" },
+ { GDScriptTokenizer::TK_PR_BREAKPOINT, "breakpoint" },
+ { GDScriptTokenizer::TK_PR_REMOTE, "remote" },
+ { GDScriptTokenizer::TK_PR_MASTER, "master" },
+ { GDScriptTokenizer::TK_PR_SLAVE, "slave" },
+ { GDScriptTokenizer::TK_PR_SYNC, "sync" },
+ { GDScriptTokenizer::TK_PR_CONST, "const" },
+ { GDScriptTokenizer::TK_PR_ENUM, "enum" },
//controlflow
- { GDTokenizer::TK_CF_IF, "if" },
- { GDTokenizer::TK_CF_ELIF, "elif" },
- { GDTokenizer::TK_CF_ELSE, "else" },
- { GDTokenizer::TK_CF_FOR, "for" },
- { GDTokenizer::TK_CF_WHILE, "while" },
- { GDTokenizer::TK_CF_DO, "do" },
- { GDTokenizer::TK_CF_SWITCH, "switch" },
- { GDTokenizer::TK_CF_CASE, "case" },
- { GDTokenizer::TK_CF_BREAK, "break" },
- { GDTokenizer::TK_CF_CONTINUE, "continue" },
- { GDTokenizer::TK_CF_RETURN, "return" },
- { GDTokenizer::TK_CF_MATCH, "match" },
- { GDTokenizer::TK_CF_PASS, "pass" },
- { GDTokenizer::TK_SELF, "self" },
- { GDTokenizer::TK_CONST_PI, "PI" },
- { GDTokenizer::TK_CONST_TAU, "TAU" },
- { GDTokenizer::TK_WILDCARD, "_" },
- { GDTokenizer::TK_CONST_INF, "INF" },
- { GDTokenizer::TK_CONST_NAN, "NAN" },
- { GDTokenizer::TK_ERROR, NULL }
+ { GDScriptTokenizer::TK_CF_IF, "if" },
+ { GDScriptTokenizer::TK_CF_ELIF, "elif" },
+ { GDScriptTokenizer::TK_CF_ELSE, "else" },
+ { GDScriptTokenizer::TK_CF_FOR, "for" },
+ { GDScriptTokenizer::TK_CF_WHILE, "while" },
+ { GDScriptTokenizer::TK_CF_DO, "do" },
+ { GDScriptTokenizer::TK_CF_SWITCH, "switch" },
+ { GDScriptTokenizer::TK_CF_CASE, "case" },
+ { GDScriptTokenizer::TK_CF_BREAK, "break" },
+ { GDScriptTokenizer::TK_CF_CONTINUE, "continue" },
+ { GDScriptTokenizer::TK_CF_RETURN, "return" },
+ { GDScriptTokenizer::TK_CF_MATCH, "match" },
+ { GDScriptTokenizer::TK_CF_PASS, "pass" },
+ { GDScriptTokenizer::TK_SELF, "self" },
+ { GDScriptTokenizer::TK_CONST_PI, "PI" },
+ { GDScriptTokenizer::TK_CONST_TAU, "TAU" },
+ { GDScriptTokenizer::TK_WILDCARD, "_" },
+ { GDScriptTokenizer::TK_CONST_INF, "INF" },
+ { GDScriptTokenizer::TK_CONST_NAN, "NAN" },
+ { GDScriptTokenizer::TK_ERROR, NULL }
};
-const char *GDTokenizer::get_token_name(Token p_token) {
+const char *GDScriptTokenizer::get_token_name(Token p_token) {
ERR_FAIL_INDEX_V(p_token, TK_MAX, "<error>");
return token_names[p_token];
}
-bool GDTokenizer::is_token_literal(int p_offset, bool variable_safe) const {
+bool GDScriptTokenizer::is_token_literal(int p_offset, bool variable_safe) const {
switch (get_token(p_offset)) {
// Can always be literal:
case TK_IDENTIFIER:
@@ -303,7 +303,7 @@ bool GDTokenizer::is_token_literal(int p_offset, bool variable_safe) const {
}
}
-StringName GDTokenizer::get_token_literal(int p_offset) const {
+StringName GDScriptTokenizer::get_token_literal(int p_offset) const {
Token token = get_token(p_offset);
switch (token) {
case TK_IDENTIFIER:
@@ -320,7 +320,7 @@ StringName GDTokenizer::get_token_literal(int p_offset) const {
}
} break; // Shouldn't get here, stuff happens
case TK_BUILT_IN_FUNC:
- return GDFunctions::get_func_name(get_token_built_in_func(p_offset));
+ return GDScriptFunctions::get_func_name(get_token_built_in_func(p_offset));
case TK_CONSTANT: {
const Variant value = get_token_constant(p_offset);
@@ -365,7 +365,7 @@ static bool _is_hex(CharType c) {
return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
}
-void GDTokenizerText::_make_token(Token p_type) {
+void GDScriptTokenizerText::_make_token(Token p_type) {
TokenData &tk = tk_rb[tk_rb_pos];
@@ -375,7 +375,7 @@ void GDTokenizerText::_make_token(Token p_type) {
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
}
-void GDTokenizerText::_make_identifier(const StringName &p_identifier) {
+void GDScriptTokenizerText::_make_identifier(const StringName &p_identifier) {
TokenData &tk = tk_rb[tk_rb_pos];
@@ -387,7 +387,7 @@ void GDTokenizerText::_make_identifier(const StringName &p_identifier) {
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
}
-void GDTokenizerText::_make_built_in_func(GDFunctions::Function p_func) {
+void GDScriptTokenizerText::_make_built_in_func(GDScriptFunctions::Function p_func) {
TokenData &tk = tk_rb[tk_rb_pos];
@@ -398,7 +398,7 @@ void GDTokenizerText::_make_built_in_func(GDFunctions::Function p_func) {
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
}
-void GDTokenizerText::_make_constant(const Variant &p_constant) {
+void GDScriptTokenizerText::_make_constant(const Variant &p_constant) {
TokenData &tk = tk_rb[tk_rb_pos];
@@ -410,7 +410,7 @@ void GDTokenizerText::_make_constant(const Variant &p_constant) {
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
}
-void GDTokenizerText::_make_type(const Variant::Type &p_type) {
+void GDScriptTokenizerText::_make_type(const Variant::Type &p_type) {
TokenData &tk = tk_rb[tk_rb_pos];
@@ -422,7 +422,7 @@ void GDTokenizerText::_make_type(const Variant::Type &p_type) {
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
}
-void GDTokenizerText::_make_error(const String &p_error) {
+void GDScriptTokenizerText::_make_error(const String &p_error) {
error_flag = true;
last_error = p_error;
@@ -435,7 +435,7 @@ void GDTokenizerText::_make_error(const String &p_error) {
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
}
-void GDTokenizerText::_make_newline(int p_spaces) {
+void GDScriptTokenizerText::_make_newline(int p_spaces) {
TokenData &tk = tk_rb[tk_rb_pos];
tk.type = TK_NEWLINE;
@@ -445,7 +445,7 @@ void GDTokenizerText::_make_newline(int p_spaces) {
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
}
-void GDTokenizerText::_advance() {
+void GDScriptTokenizerText::_advance() {
if (error_flag) {
//parser broke
@@ -966,11 +966,11 @@ void GDTokenizerText::_advance() {
//built in func?
- for (int i = 0; i < GDFunctions::FUNC_MAX; i++) {
+ for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) {
- if (str == GDFunctions::get_func_name(GDFunctions::Function(i))) {
+ if (str == GDScriptFunctions::get_func_name(GDScriptFunctions::Function(i))) {
- _make_built_in_func(GDFunctions::Function(i));
+ _make_built_in_func(GDScriptFunctions::Function(i));
found = true;
break;
}
@@ -1016,7 +1016,7 @@ void GDTokenizerText::_advance() {
}
}
-void GDTokenizerText::set_code(const String &p_code) {
+void GDScriptTokenizerText::set_code(const String &p_code) {
code = p_code;
len = p_code.length();
@@ -1035,7 +1035,7 @@ void GDTokenizerText::set_code(const String &p_code) {
_advance();
}
-GDTokenizerText::Token GDTokenizerText::get_token(int p_offset) const {
+GDScriptTokenizerText::Token GDScriptTokenizerText::get_token(int p_offset) const {
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, TK_ERROR);
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, TK_ERROR);
@@ -1043,7 +1043,7 @@ GDTokenizerText::Token GDTokenizerText::get_token(int p_offset) const {
return tk_rb[ofs].type;
}
-int GDTokenizerText::get_token_line(int p_offset) const {
+int GDScriptTokenizerText::get_token_line(int p_offset) const {
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, -1);
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, -1);
@@ -1051,7 +1051,7 @@ int GDTokenizerText::get_token_line(int p_offset) const {
return tk_rb[ofs].line;
}
-int GDTokenizerText::get_token_column(int p_offset) const {
+int GDScriptTokenizerText::get_token_column(int p_offset) const {
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, -1);
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, -1);
@@ -1059,7 +1059,7 @@ int GDTokenizerText::get_token_column(int p_offset) const {
return tk_rb[ofs].col;
}
-const Variant &GDTokenizerText::get_token_constant(int p_offset) const {
+const Variant &GDScriptTokenizerText::get_token_constant(int p_offset) const {
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, tk_rb[0].constant);
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, tk_rb[0].constant);
@@ -1068,7 +1068,7 @@ const Variant &GDTokenizerText::get_token_constant(int p_offset) const {
return tk_rb[ofs].constant;
}
-StringName GDTokenizerText::get_token_identifier(int p_offset) const {
+StringName GDScriptTokenizerText::get_token_identifier(int p_offset) const {
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, StringName());
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, StringName());
@@ -1078,17 +1078,17 @@ StringName GDTokenizerText::get_token_identifier(int p_offset) const {
return tk_rb[ofs].identifier;
}
-GDFunctions::Function GDTokenizerText::get_token_built_in_func(int p_offset) const {
+GDScriptFunctions::Function GDScriptTokenizerText::get_token_built_in_func(int p_offset) const {
- ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, GDFunctions::FUNC_MAX);
- ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, GDFunctions::FUNC_MAX);
+ ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, GDScriptFunctions::FUNC_MAX);
+ ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, GDScriptFunctions::FUNC_MAX);
int ofs = (TK_RB_SIZE + tk_rb_pos + p_offset - MAX_LOOKAHEAD - 1) % TK_RB_SIZE;
- ERR_FAIL_COND_V(tk_rb[ofs].type != TK_BUILT_IN_FUNC, GDFunctions::FUNC_MAX);
+ ERR_FAIL_COND_V(tk_rb[ofs].type != TK_BUILT_IN_FUNC, GDScriptFunctions::FUNC_MAX);
return tk_rb[ofs].func;
}
-Variant::Type GDTokenizerText::get_token_type(int p_offset) const {
+Variant::Type GDScriptTokenizerText::get_token_type(int p_offset) const {
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, Variant::NIL);
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, Variant::NIL);
@@ -1098,7 +1098,7 @@ Variant::Type GDTokenizerText::get_token_type(int p_offset) const {
return tk_rb[ofs].vtype;
}
-int GDTokenizerText::get_token_line_indent(int p_offset) const {
+int GDScriptTokenizerText::get_token_line_indent(int p_offset) const {
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, 0);
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, 0);
@@ -1108,7 +1108,7 @@ int GDTokenizerText::get_token_line_indent(int p_offset) const {
return tk_rb[ofs].constant;
}
-String GDTokenizerText::get_token_error(int p_offset) const {
+String GDScriptTokenizerText::get_token_error(int p_offset) const {
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, String());
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, String());
@@ -1118,7 +1118,7 @@ String GDTokenizerText::get_token_error(int p_offset) const {
return tk_rb[ofs].constant;
}
-void GDTokenizerText::advance(int p_amount) {
+void GDScriptTokenizerText::advance(int p_amount) {
ERR_FAIL_COND(p_amount <= 0);
for (int i = 0; i < p_amount; i++)
@@ -1129,7 +1129,7 @@ void GDTokenizerText::advance(int p_amount) {
#define BYTECODE_VERSION 12
-Error GDTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer) {
+Error GDScriptTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer) {
const uint8_t *buf = p_buffer.ptr();
int total_len = p_buffer.size();
@@ -1217,7 +1217,7 @@ Error GDTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer) {
return OK;
}
-Vector<uint8_t> GDTokenizerBuffer::parse_code_string(const String &p_code) {
+Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code) {
Vector<uint8_t> buf;
@@ -1226,7 +1226,7 @@ Vector<uint8_t> GDTokenizerBuffer::parse_code_string(const String &p_code) {
Map<uint32_t, int> line_map;
Vector<uint32_t> token_array;
- GDTokenizerText tt;
+ GDScriptTokenizerText tt;
tt.set_code(p_code);
int line = -1;
@@ -1375,17 +1375,17 @@ Vector<uint8_t> GDTokenizerBuffer::parse_code_string(const String &p_code) {
return buf;
}
-GDTokenizerBuffer::Token GDTokenizerBuffer::get_token(int p_offset) const {
+GDScriptTokenizerBuffer::Token GDScriptTokenizerBuffer::get_token(int p_offset) const {
int offset = token + p_offset;
if (offset < 0 || offset >= tokens.size())
return TK_EOF;
- return GDTokenizerBuffer::Token(tokens[offset] & TOKEN_MASK);
+ return GDScriptTokenizerBuffer::Token(tokens[offset] & TOKEN_MASK);
}
-StringName GDTokenizerBuffer::get_token_identifier(int p_offset) const {
+StringName GDScriptTokenizerBuffer::get_token_identifier(int p_offset) const {
int offset = token + p_offset;
@@ -1396,14 +1396,14 @@ StringName GDTokenizerBuffer::get_token_identifier(int p_offset) const {
return identifiers[identifier];
}
-GDFunctions::Function GDTokenizerBuffer::get_token_built_in_func(int p_offset) const {
+GDScriptFunctions::Function GDScriptTokenizerBuffer::get_token_built_in_func(int p_offset) const {
int offset = token + p_offset;
- ERR_FAIL_INDEX_V(offset, tokens.size(), GDFunctions::FUNC_MAX);
- return GDFunctions::Function(tokens[offset] >> TOKEN_BITS);
+ ERR_FAIL_INDEX_V(offset, tokens.size(), GDScriptFunctions::FUNC_MAX);
+ return GDScriptFunctions::Function(tokens[offset] >> TOKEN_BITS);
}
-Variant::Type GDTokenizerBuffer::get_token_type(int p_offset) const {
+Variant::Type GDScriptTokenizerBuffer::get_token_type(int p_offset) const {
int offset = token + p_offset;
ERR_FAIL_INDEX_V(offset, tokens.size(), Variant::NIL);
@@ -1411,7 +1411,7 @@ Variant::Type GDTokenizerBuffer::get_token_type(int p_offset) const {
return Variant::Type(tokens[offset] >> TOKEN_BITS);
}
-int GDTokenizerBuffer::get_token_line(int p_offset) const {
+int GDScriptTokenizerBuffer::get_token_line(int p_offset) const {
int offset = token + p_offset;
int pos = lines.find_nearest(offset);
@@ -1424,7 +1424,7 @@ int GDTokenizerBuffer::get_token_line(int p_offset) const {
uint32_t l = lines.getv(pos);
return l & TOKEN_LINE_MASK;
}
-int GDTokenizerBuffer::get_token_column(int p_offset) const {
+int GDScriptTokenizerBuffer::get_token_column(int p_offset) const {
int offset = token + p_offset;
int pos = lines.find_nearest(offset);
@@ -1436,13 +1436,13 @@ int GDTokenizerBuffer::get_token_column(int p_offset) const {
uint32_t l = lines.getv(pos);
return l >> TOKEN_LINE_BITS;
}
-int GDTokenizerBuffer::get_token_line_indent(int p_offset) const {
+int GDScriptTokenizerBuffer::get_token_line_indent(int p_offset) const {
int offset = token + p_offset;
ERR_FAIL_INDEX_V(offset, tokens.size(), 0);
return tokens[offset] >> TOKEN_BITS;
}
-const Variant &GDTokenizerBuffer::get_token_constant(int p_offset) const {
+const Variant &GDScriptTokenizerBuffer::get_token_constant(int p_offset) const {
int offset = token + p_offset;
ERR_FAIL_INDEX_V(offset, tokens.size(), nil);
@@ -1450,17 +1450,17 @@ const Variant &GDTokenizerBuffer::get_token_constant(int p_offset) const {
ERR_FAIL_INDEX_V(constant, (uint32_t)constants.size(), nil);
return constants[constant];
}
-String GDTokenizerBuffer::get_token_error(int p_offset) const {
+String GDScriptTokenizerBuffer::get_token_error(int p_offset) const {
ERR_FAIL_V(String());
}
-void GDTokenizerBuffer::advance(int p_amount) {
+void GDScriptTokenizerBuffer::advance(int p_amount) {
ERR_FAIL_INDEX(p_amount + token, tokens.size());
token += p_amount;
}
-GDTokenizerBuffer::GDTokenizerBuffer() {
+GDScriptTokenizerBuffer::GDScriptTokenizerBuffer() {
token = 0;
}
diff --git a/modules/gdscript/gd_tokenizer.h b/modules/gdscript/gdscript_tokenizer.h
index f4b579def4..d19367177b 100644
--- a/modules/gdscript/gd_tokenizer.h
+++ b/modules/gdscript/gdscript_tokenizer.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_tokenizer.h */
+/* gdscript_tokenizer.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,16 +27,16 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GD_TOKENIZER_H
-#define GD_TOKENIZER_H
+#ifndef GDSCRIPT_TOKENIZER_H
+#define GDSCRIPT_TOKENIZER_H
-#include "gd_functions.h"
+#include "gdscript_functions.h"
#include "string_db.h"
#include "ustring.h"
#include "variant.h"
#include "vmap.h"
-class GDTokenizer {
+class GDScriptTokenizer {
public:
enum Token {
@@ -156,7 +156,7 @@ public:
virtual const Variant &get_token_constant(int p_offset = 0) const = 0;
virtual Token get_token(int p_offset = 0) const = 0;
virtual StringName get_token_identifier(int p_offset = 0) const = 0;
- virtual GDFunctions::Function get_token_built_in_func(int p_offset = 0) const = 0;
+ virtual GDScriptFunctions::Function get_token_built_in_func(int p_offset = 0) const = 0;
virtual Variant::Type get_token_type(int p_offset = 0) const = 0;
virtual int get_token_line(int p_offset = 0) const = 0;
virtual int get_token_column(int p_offset = 0) const = 0;
@@ -164,10 +164,10 @@ public:
virtual String get_token_error(int p_offset = 0) const = 0;
virtual void advance(int p_amount = 1) = 0;
- virtual ~GDTokenizer(){};
+ virtual ~GDScriptTokenizer(){};
};
-class GDTokenizerText : public GDTokenizer {
+class GDScriptTokenizerText : public GDScriptTokenizer {
enum {
MAX_LOOKAHEAD = 4,
@@ -181,7 +181,7 @@ class GDTokenizerText : public GDTokenizer {
Variant constant; //for constant types
union {
Variant::Type vtype; //for type types
- GDFunctions::Function func; //function for built in functions
+ GDScriptFunctions::Function func; //function for built in functions
};
int line, col;
TokenData() {
@@ -194,7 +194,7 @@ class GDTokenizerText : public GDTokenizer {
void _make_token(Token p_type);
void _make_newline(int p_spaces = 0);
void _make_identifier(const StringName &p_identifier);
- void _make_built_in_func(GDFunctions::Function p_func);
+ void _make_built_in_func(GDScriptFunctions::Function p_func);
void _make_constant(const Variant &p_constant);
void _make_type(const Variant::Type &p_type);
void _make_error(const String &p_error);
@@ -216,7 +216,7 @@ public:
void set_code(const String &p_code);
virtual Token get_token(int p_offset = 0) const;
virtual StringName get_token_identifier(int p_offset = 0) const;
- virtual GDFunctions::Function get_token_built_in_func(int p_offset = 0) const;
+ virtual GDScriptFunctions::Function get_token_built_in_func(int p_offset = 0) const;
virtual Variant::Type get_token_type(int p_offset = 0) const;
virtual int get_token_line(int p_offset = 0) const;
virtual int get_token_column(int p_offset = 0) const;
@@ -226,7 +226,7 @@ public:
virtual void advance(int p_amount = 1);
};
-class GDTokenizerBuffer : public GDTokenizer {
+class GDScriptTokenizerBuffer : public GDScriptTokenizer {
enum {
@@ -249,7 +249,7 @@ public:
static Vector<uint8_t> parse_code_string(const String &p_code);
virtual Token get_token(int p_offset = 0) const;
virtual StringName get_token_identifier(int p_offset = 0) const;
- virtual GDFunctions::Function get_token_built_in_func(int p_offset = 0) const;
+ virtual GDScriptFunctions::Function get_token_built_in_func(int p_offset = 0) const;
virtual Variant::Type get_token_type(int p_offset = 0) const;
virtual int get_token_line(int p_offset = 0) const;
virtual int get_token_column(int p_offset = 0) const;
@@ -257,7 +257,7 @@ public:
virtual const Variant &get_token_constant(int p_offset = 0) const;
virtual String get_token_error(int p_offset = 0) const;
virtual void advance(int p_amount = 1);
- GDTokenizerBuffer();
+ GDScriptTokenizerBuffer();
};
-#endif // TOKENIZER_H
+#endif // GDSCRIPT_TOKENIZER_H
diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp
index 036274c8f2..1e007ddb0f 100644
--- a/modules/gdscript/register_types.cpp
+++ b/modules/gdscript/register_types.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "register_types.h"
-#include "gd_script.h"
+#include "gdscript.h"
#include "io/file_access_encrypted.h"
#include "io/resource_loader.h"
#include "os/file_access.h"
@@ -41,10 +41,9 @@ ResourceFormatSaverGDScript *resource_saver_gd = NULL;
void register_gdscript_types() {
ClassDB::register_class<GDScript>();
- ClassDB::register_virtual_class<GDFunctionState>();
+ ClassDB::register_virtual_class<GDScriptFunctionState>();
script_language_gd = memnew(GDScriptLanguage);
- //script_language_gd->init();
ScriptServer::register_language(script_language_gd);
resource_loader_gd = memnew(ResourceFormatLoaderGDScript);
ResourceLoader::add_resource_format_loader(resource_loader_gd);