summaryrefslogtreecommitdiff
path: root/modules/gdscript
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript')
-rw-r--r--modules/gdscript/gd_functions.cpp5
-rw-r--r--modules/gdscript/gd_parser.cpp22
-rw-r--r--modules/gdscript/gd_script.cpp64
3 files changed, 55 insertions, 36 deletions
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp
index e015ddb65e..9b7d8eeac4 100644
--- a/modules/gdscript/gd_functions.cpp
+++ b/modules/gdscript/gd_functions.cpp
@@ -1355,9 +1355,12 @@ MethodInfo GDFunctions::get_info(Function p_func) {
return mi;
} break;
case TYPE_OF: {
+
MethodInfo mi("typeof",PropertyInfo(Variant::NIL,"what"));
mi.return_val.type=Variant::INT;
- };
+ return mi;
+
+ } break;
case TEXT_STR: {
MethodInfo mi("str",PropertyInfo(Variant::NIL,"what"),PropertyInfo(Variant::NIL,"..."));
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp
index 4c6b6ff2dd..b6e8478846 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -283,13 +283,23 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
return NULL;
}
tokenizer->advance();
- if (tokenizer->get_token()!=GDTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type()!=Variant::STRING) {
- _set_error("Expected string constant as 'preload' argument.");
+
+ String path;
+ bool valid = false;
+ Node *subexpr = _parse_and_reduce_expression(p_parent, p_static);
+ if (subexpr) {
+ if (subexpr->type == Node::TYPE_CONSTANT) {
+ ConstantNode *cn = static_cast<ConstantNode*>(subexpr);
+ if (cn->value.get_type() == Variant::STRING) {
+ valid = true;
+ path = (String) cn->value;
+ }
+ }
+ }
+ if (!valid) {
+ _set_error("expected string constant as 'preload' argument.");
return NULL;
}
-
-
- String path = tokenizer->get_token_constant();
if (!path.is_abs_path() && base_path!="")
path=base_path+"/"+path;
path = path.replace("///","//").simplify_path();
@@ -322,8 +332,6 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
}
}
- tokenizer->advance();
-
if (tokenizer->get_token()!=GDTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ')' after 'preload' path");
return NULL;
diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp
index 62c5eb735a..1b2ed670ad 100644
--- a/modules/gdscript/gd_script.cpp
+++ b/modules/gdscript/gd_script.cpp
@@ -2456,6 +2456,7 @@ void GDInstance::get_method_list(List<MethodInfo> *p_list) const {
MethodInfo mi;
mi.name=E->key();
+ mi.flags|=METHOD_FLAG_FROM_SCRIPT;
for(int i=0;i<E->get().get_argument_count();i++)
mi.arguments.push_back(PropertyInfo(Variant::NIL,"arg"+itos(i)));
p_list->push_back(mi);
@@ -2677,40 +2678,47 @@ void GDScriptLanguage::frame() {
void GDScriptLanguage::get_reserved_words(List<String> *p_words) const {
static const char *_reserved_words[]={
- "break",
- "class",
- "continue",
- "const",
- "else",
- "elif",
- "enum",
- "extends" ,
- "onready",
- "for" ,
- "func" ,
- "if" ,
- "in" ,
- "null" ,
- "not" ,
- "return" ,
- "self" ,
- "while" ,
- "true" ,
- "false" ,
- "tool",
- "var",
- "setget",
- "pass",
+ // operators
"and",
+ "in",
+ "not",
"or",
- "export",
+ // types and values
+ "false",
+ "float",
+ "int",
+ "null",
+ "PI",
+ "self",
+ "true",
+ // functions
"assert",
"breakpoint",
+ "class",
+ "extends",
+ "func",
+ "preload",
+ "setget",
+ "signal",
+ "tool",
"yield",
+ // var
+ "const",
+ "enum",
+ "export",
+ "onready",
"static",
- "float",
- "int",
- "signal",
+ "var",
+ // control flow
+ "break",
+ "continue",
+ "if",
+ "elif",
+ "else",
+ "for",
+ "pass",
+ "return",
+ "while",
0};